Skip to content

Commit

Permalink
Add initial support for deleting plan snapshots though backend may no…
Browse files Browse the repository at this point in the history
…t yet support this
  • Loading branch information
AaronPlave committed Sep 26, 2023
1 parent da50f53 commit 078a122
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/components/menus/MenuDivider.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<hr class="menu-divider" />

<style>
hr.menu-divider {
opacity: 0.3;
width: 90%;
}
</style>
5 changes: 3 additions & 2 deletions src/components/menus/PlanMenu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import { featurePermissions } from '../../utilities/permissions';
import Menu from '../menus/Menu.svelte';
import MenuItem from '../menus/MenuItem.svelte';
import MenuDivider from './MenuDivider.svelte';
export let plan: Plan;
export let user: User | null;
Expand Down Expand Up @@ -66,7 +67,7 @@
<div class="column-name">View merge requests</div>
</MenuItem>
{#if plan.parent_plan !== null}
<hr class="menu-divider" />
<MenuDivider />
<MenuItem
on:click={createMergePlanBranchRequest}
use={[
Expand All @@ -85,7 +86,7 @@
<div class="column-name">Open parent plan</div>
</MenuItem>
{/if}
<hr class="menu-divider" />
<MenuDivider />
<MenuItem on:click={createPlanSnapshot}>
<div class="column-name">Take Snapshot</div>
</MenuItem>
Expand Down
1 change: 1 addition & 0 deletions src/components/plan/PlanForm.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@
{planSnapshot}
on:click={() => setQueryParam(SearchParameters.SNAPSHOT_ID, `${planSnapshot.snapshot_id}`)}
on:restore={() => effects.restorePlanSnapshot(planSnapshot, user)}
on:delete={() => effects.deletePlanSnapshot(planSnapshot, user)}
/>
{/each}
</CardList>
Expand Down
4 changes: 3 additions & 1 deletion src/components/plan/PlanSnapshot.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import type { PlanSnapshot } from '../../types/plan-snapshot';
import { getSimulationProgress, getSimulationStatus } from '../../utilities/simulation';
import Menu from '../menus/Menu.svelte';
import MenuDivider from '../menus/MenuDivider.svelte';
import MenuItem from '../menus/MenuItem.svelte';
import Card from '../ui/Card.svelte';
import StatusBadge from '../ui/StatusBadge.svelte';
Expand Down Expand Up @@ -39,6 +40,8 @@
<Menu bind:this={menu}>
<MenuItem on:click={() => dispatch('click')}>Preview</MenuItem>
<MenuItem on:click={() => dispatch('restore')}>Restore</MenuItem>
<MenuDivider />
<MenuItem disabled on:click={() => dispatch('delete')}>Delete</MenuItem>
</Menu>
</button>
</div>
Expand All @@ -51,7 +54,6 @@
--aerie-menu-item-template-columns: auto;
--aerie-menu-item-line-height: 1rem;
--aerie-menu-item-font-size: 12px;
/* --aerie-menu-item-padding: 4px; */
align-items: center;
display: flex;
gap: 8px;
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ const gql = {

DELETE_PLAN_SNAPSHOT: `#graphql
mutation DeletePlanSnapshot($snapshot_id: Int!) {
deletePlanSnapshot: delete_plan_snapshot(snapshot_id: $snapshot_id) {
deletePlanSnapshot: delete_plan_snapshot_by_pk(snapshot_id: $snapshot_id) {

This comment has been minimized.

Copy link
@duranb

duranb Sep 26, 2023

Collaborator

do you mind updating the permissions util file to check this specific query as well?

snapshot_id
}
}
Expand Down

0 comments on commit 078a122

Please sign in to comment.