fix resume also has dialog

This commit is contained in:
Damodar Lohani committed 2023-03-26 14:25:01 +05:45
1 parent 4072de0264
commit c2c50a59e0
3 files changed
+31 -26

No files matched your search

@@ -14,14 +14,14 @@
import { base } from '$app/paths';
import { page } from '$app/stores';
import { Submit, trackEvent, trackError } from '$lib/actions/analytics';
import PauseProject from './pauseProject.svelte';
import PauseProject from './toggleProject.svelte';
let name: string = null;
let showDelete = false;
let updating = false;
const endpoint = sdk.forConsole.client.config.endpoint;
const projectId = $page.params.project;
let showPause = false;
let showToggle = false;
onMount(async () => {
name ??= $project.name;
@@ -47,8 +47,8 @@
}
async function toggleProject() {
if (!$project.paused && !showPause) {
showPause = true;
if (!showToggle) {
showToggle = true;
return;
}
updating = true;
@@ -78,7 +78,7 @@
});
trackError(error, Submit.ProjectUpdateName);
} finally {
showPause = false;
showToggle = false;
}
}
@@ -215,4 +215,4 @@
</Container>
<Delete bind:showDelete />
<PauseProject handlePause={toggleProject} bind:show={showPause} />
<PauseProject paused={$project.paused} handleToggle={toggleProject} bind:show={showToggle} />
@@ -1,20 +0,0 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { project } from '../store';
export let show = false;
export let handlePause;
</script>
<Modal warning={true} bind:show onSubmit={handlePause}>
<svelte:fragment slot="header">Pause Project</svelte:fragment>
<p class="text" data-private>
Are you sure you want to pause <b>{$project.name}</b>? While paused, you will not be able to
make API requests.
</p>
<svelte:fragment slot="footer">
<Button text on:click={() => (show = false)}>Cancel</Button>
<Button secondary submit>Pause my project</Button>
</svelte:fragment>
</Modal>
@@ -0,0 +1,25 @@
<script lang="ts">
import { Modal } from '$lib/components';
import { Button } from '$lib/elements/forms';
import { project } from '../store';
export let show = false;
export let paused: boolean;
export let handleToggle;
</script>
<Modal warning={true} bind:show onSubmit={handleToggle}>
<svelte:fragment slot="header">{paused ? ' Resume' : 'Pause'} Project</svelte:fragment>
<p class="text" data-private>
{#if paused}
Your project will be up-and-running again soon.
{:else}
Are you sure you want to pause <b>{$project.name}</b>? While paused, you will not be
able to make API requests.
{/if}
</p>
<svelte:fragment slot="footer">
<Button text on:click={() => (show = false)}>Cancel</Button>
<Button secondary submit>{paused ? 'Resume' : 'Pause'} my project</Button>
</svelte:fragment>
</Modal>