Skip to content

Commit

Permalink
UI fixes for restoring from snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronPlave committed Sep 26, 2023
1 parent 6efe859 commit da50f53
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/components/plan/PlanForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@
activePlanSnapshotId={$planSnapshotId}
{planSnapshot}
on:click={() => setQueryParam(SearchParameters.SNAPSHOT_ID, `${planSnapshot.snapshot_id}`)}
on:restore={() => effects.restorePlanSnapshot(planSnapshot, user)}
/>
{/each}
</CardList>
Expand Down
8 changes: 6 additions & 2 deletions src/utilities/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3264,8 +3264,12 @@ const effects = {
const { confirm } = await showRestorePlanSnapshotModal(snapshot, get(activityDirectives).length);

if (confirm) {
const data = await reqHasura(gql.DELETE_PLAN_SNAPSHOT, { snapshot_id: snapshot.snapshot_id }, user);
if (data.deletePlanSnapshot != null) {
const data = await reqHasura(
gql.RESTORE_PLAN_SNAPSHOT,
{ plan_id: snapshot.plan_id, snapshot_id: snapshot.snapshot_id },
user,
);
if (data.restore_from_snapshot != null) {
showSuccessToast('Plan Snapshot Restored Successfully');

goto(`${base}/plans/${snapshot.plan_id}`);
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,7 @@ const gql = {
RESTORE_PLAN_SNAPSHOT: `#graphql
mutation RestorePlanSnapshot($plan_id: Int!, $snapshot_id: Int!) {
restore_from_snapshot(args: { _plan_id: $plan_id, _snapshot_id: $snapshot_id }) {
plan_id
snapshot_id
}
}
`,
Expand Down

0 comments on commit da50f53

Please sign in to comment.