Skip to content

Commit bb14301

Browse files
committed
simplify neurons table
1 parent d8489e8 commit bb14301

File tree

2 files changed

+78
-20
lines changed

2 files changed

+78
-20
lines changed

frontend/src/lib/components/staking/ProjectsTable.svelte

Lines changed: 77 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import { selectableUniversesStore } from "$lib/derived/selectable-universes.derived";
1515
import { loadIcpSwapTickers } from "$lib/services/icp-swap.services";
1616
import { failedActionableSnsesStore } from "$lib/stores/actionable-sns-proposals.store";
17+
import { ENABLE_NEW_TABLES } from "$lib/stores/feature-flags.store";
1718
import { hideZeroNeuronsStore } from "$lib/stores/hide-zero-neurons.store";
1819
import { i18n } from "$lib/stores/i18n";
1920
import { neuronsStore } from "$lib/stores/neurons.store";
@@ -43,51 +44,36 @@
4344
title: $i18n.staking.nervous_systems,
4445
cellComponent: ProjectTitleCell,
4546
alignment: "left",
46-
templateColumns: ["minmax(min-content, max-content)"],
47+
templateColumns: ["2fr"],
4748
comparator: $authSignedInStore ? compareByProject : undefined,
4849
},
49-
{
50-
title: "",
51-
alignment: "left",
52-
templateColumns: ["1fr"],
53-
},
5450
{
5551
id: "stake",
5652
title: $i18n.neuron_detail.stake,
5753
cellComponent: ProjectStakeCell,
5854
alignment: "right",
59-
templateColumns: ["max-content"],
60-
comparator: $authSignedInStore ? compareByStake : undefined,
61-
},
62-
{
63-
title: "",
64-
alignment: "left",
6555
templateColumns: ["1fr"],
56+
comparator: $authSignedInStore ? compareByStake : undefined,
6657
},
6758
{
6859
title: $i18n.neuron_detail.maturity_title,
6960
cellComponent: ProjectMaturityCell,
7061
alignment: "right",
71-
templateColumns: ["max-content"],
72-
},
73-
{
74-
title: "",
75-
alignment: "left",
7662
templateColumns: ["1fr"],
7763
},
7864
{
7965
id: "neurons",
8066
title: $i18n.neurons.title,
8167
cellComponent: ProjectNeuronsCell,
8268
alignment: "right",
83-
templateColumns: ["max-content"],
69+
templateColumns: ["1fr"],
8470
comparator: $authSignedInStore ? compareByNeuron : undefined,
8571
},
8672
{
8773
title: "",
8874
cellComponent: ProjectActionsCell,
8975
alignment: "right",
90-
templateColumns: ["max-content"],
76+
templateColumns: ["1fr"],
9177
},
9278
];
9379
@@ -132,6 +118,16 @@
132118
(!("stakeInUsd" in project) || isNullish(project.stakeInUsd))
133119
);
134120
121+
let nnsNeurons: TableProject[] = [];
122+
$: nnsNeurons = sortedTableProjects.filter(
123+
(project) => project.universeId === OWN_CANISTER_ID_TEXT
124+
);
125+
126+
let snsNeurons: TableProject[] = [];
127+
$: snsNeurons = sortedTableProjects.filter(
128+
(project) => project.universeId !== OWN_CANISTER_ID_TEXT
129+
);
130+
135131
const dispatcher = createEventDispatcher();
136132
137133
const handleAction = ({
@@ -154,7 +150,68 @@
154150
</UsdValueBanner>
155151
{/if}
156152

157-
{#if !$authSignedInStore}
153+
{#if $ENABLE_NEW_TABLES}
154+
{#if !$authSignedInStore}
155+
<ResponsiveTable
156+
tableData={nnsNeurons}
157+
{columns}
158+
on:nnsAction={handleAction}
159+
/>
160+
161+
<ResponsiveTable
162+
tableData={snsNeurons}
163+
{columns}
164+
on:nnsAction={handleAction}
165+
/>
166+
{:else}
167+
<ResponsiveTable
168+
tableData={nnsNeurons}
169+
{columns}
170+
on:nnsAction={handleAction}
171+
bind:order={$projectsTableOrderStore}
172+
displayTableSettings
173+
>
174+
<svelte:fragment slot="settings-popover">
175+
<HideZeroNeuronsToggle />
176+
<Separator spacing="none" />
177+
</svelte:fragment>
178+
179+
<div
180+
slot="last-row"
181+
class="last-row"
182+
class:hidden={!shouldHideProjectsWithoutNeurons}
183+
>
184+
{#if shouldHideProjectsWithoutNeurons}
185+
<div class="show-all-button-container">
186+
{$i18n.staking.hide_no_neurons_table_hint}
187+
<button
188+
data-tid="show-all-button"
189+
class="ghost show-all"
190+
on:click={showAll}
191+
>
192+
{$i18n.staking.show_all}</button
193+
>
194+
</div>
195+
{/if}
196+
</div>
197+
</ResponsiveTable>
198+
199+
{#if snsNeurons.length > 0}
200+
<ResponsiveTable
201+
tableData={snsNeurons}
202+
{columns}
203+
on:nnsAction={handleAction}
204+
bind:order={$projectsTableOrderStore}
205+
displayTableSettings
206+
>
207+
<svelte:fragment slot="settings-popover">
208+
<HideZeroNeuronsToggle />
209+
<Separator spacing="none" />
210+
</svelte:fragment>
211+
</ResponsiveTable>
212+
{/if}
213+
{/if}
214+
{:else if !$authSignedInStore}
158215
<ResponsiveTable
159216
tableData={sortedTableProjects}
160217
{columns}

frontend/src/lib/types/responsive-table.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ export interface ResponsiveTableRowData {
1111
export type ColumnAlignment = "left" | "right";
1212
export type TemplateItem =
1313
| "1fr"
14+
| "2fr"
1415
| "max-content"
1516
| "minmax(max-content, 1fr)"
1617
| "minmax(min-content, max-content)";

0 commit comments

Comments
 (0)