Skip to content

Commit

Permalink
feat: Open Subtree section if highlighted is active or if it is the o…
Browse files Browse the repository at this point in the history
…nly section when PT opened
  • Loading branch information
Thomas Junk committed Nov 28, 2023
1 parent f5b416d commit 2e61f41
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/lib/singleview/SingleView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@
<Collapsible
header="Product tree"
onOpen={() => {
appStore.setProductTreeSectionVisible();
appStore.setProductTreeOpen();
}}
open={$appStore.ui.isProductTreeVisible}
onClose={() => {
appStore.setProductTreeSectionInVisible();
appStore.resetSelectedProduct();
appStore.setProductTreeClosed();
}}
>
<ProductTree />
Expand Down
44 changes: 40 additions & 4 deletions src/lib/singleview/producttree/ProductTree.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,62 @@

{#if $appStore.doc?.productTree.branches}
{#each $appStore.doc?.productTree.branches as branch}
<Collapsible header="Branches" open={$appStore.ui.isProductTreeVisible}>
<Collapsible
header="Branches"
open={$appStore.ui.isProductTreeVisible ||
($appStore.ui.isProductTreeOpen &&
!(
$appStore.doc?.productTree.relationships &&
$appStore.doc?.productTree.product_groups &&
$appStore.doc?.productTree.full_product_names
))}
>
<Branch {branch} />
</Collapsible>
{/each}
{/if}

{#if $appStore.doc?.productTree.relationships}
<Collapsible header="Relationships" open={$appStore.ui.isProductTreeVisible}>
<Collapsible
header="Relationships"
open={$appStore.ui.isProductTreeVisible ||
($appStore.ui.isProductTreeOpen &&
!(
$appStore.doc?.productTree.branches &&
$appStore.doc?.productTree.product_groups &&
$appStore.doc?.productTree.full_product_names
))}
>
<Relationships relationships={$appStore.doc?.productTree.relationships} />
</Collapsible>
{/if}

{#if $appStore.doc?.productTree.product_groups}
<Collapsible header="Product groups" open={$appStore.ui.isProductTreeVisible}>
<Collapsible
header="Product groups"
open={$appStore.ui.isProductTreeVisible ||
($appStore.ui.isProductTreeOpen &&
!(
$appStore.doc?.productTree.branches &&
$appStore.doc?.productTree.relationships &&
$appStore.doc?.productTree.full_product_names
))}
>
<ProductGroups productGroups={$appStore.doc?.productTree.product_groups} />
</Collapsible>
{/if}

{#if $appStore.doc?.productTree.full_product_names}
<Collapsible header="Full Product Names" open={$appStore.ui.isProductTreeVisible}>
<Collapsible
header="Full Product Names"
open={$appStore.ui.isProductTreeVisible ||
($appStore.ui.isProductTreeOpen &&
!(
$appStore.doc?.productTree.branches &&
$appStore.doc?.productTree.relationships &&
$appStore.doc?.productTree.product_groups
))}
>
<ProductNames productNames={$appStore.doc?.productTree.full_product_names} />
</Collapsible>
{/if}
14 changes: 14 additions & 0 deletions src/lib/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type AppStore = {
isRevisionHistoryVisible: boolean;
isVulnerabilitiesOverviewVisible: boolean;
isVulnerabilitiesSectionVisible: boolean;
isProductTreeOpen: boolean;
isProductTreeVisible: boolean;
isFeedSectionOpen: boolean;
lastFeed: string;
Expand Down Expand Up @@ -62,6 +63,7 @@ const generateInitialState = (): AppStore => {
isRevisionHistoryVisible: false,
isVulnerabilitiesOverviewVisible: true,
isVulnerabilitiesSectionVisible: false,
isProductTreeOpen: false,
isProductTreeVisible: false,
isFeedSectionOpen: false,
lastFeed: "",
Expand Down Expand Up @@ -257,6 +259,18 @@ function createStore() {
return settings;
});
},
setProductTreeOpen: () => {
update((settings) => {
settings.ui.isProductTreeOpen = true;
return settings;
});
},
setProductTreeClosed: () => {
update((settings) => {
settings.ui.isProductTreeOpen = false;
return settings;
});
},
setProductTreeSectionVisible: () => {
update((settings) => {
settings.ui.isProductTreeVisible = true;
Expand Down

0 comments on commit 2e61f41

Please sign in to comment.