|
8 | 8 | import ResponsiveTable from "$lib/components/ui/ResponsiveTable.svelte";
|
9 | 9 | import Separator from "$lib/components/ui/Separator.svelte";
|
10 | 10 | import UsdValueBanner from "$lib/components/ui/UsdValueBanner.svelte";
|
11 |
| - import { OWN_CANISTER_ID_TEXT } from "$lib/constants/canister-ids.constants"; |
| 11 | + import { |
| 12 | + abandonedProjectsCanisterId, |
| 13 | + OWN_CANISTER_ID_TEXT, |
| 14 | + } from "$lib/constants/canister-ids.constants"; |
12 | 15 | import { authSignedInStore } from "$lib/derived/auth.derived";
|
13 | 16 | import { icpSwapUsdPricesStore } from "$lib/derived/icp-swap.derived";
|
14 | 17 | import { selectableUniversesStore } from "$lib/derived/selectable-universes.derived";
|
15 | 18 | import { loadIcpSwapTickers } from "$lib/services/icp-swap.services";
|
16 | 19 | import { failedActionableSnsesStore } from "$lib/stores/actionable-sns-proposals.store";
|
| 20 | + import { ENABLE_NEW_TABLES } from "$lib/stores/feature-flags.store"; |
17 | 21 | import { hideZeroNeuronsStore } from "$lib/stores/hide-zero-neurons.store";
|
18 | 22 | import { i18n } from "$lib/stores/i18n";
|
19 | 23 | import { neuronsStore } from "$lib/stores/neurons.store";
|
|
29 | 33 | sortTableProjects,
|
30 | 34 | } from "$lib/utils/staking.utils";
|
31 | 35 | import { IconNeuronsPage } from "@dfinity/gix-components";
|
32 |
| - import { TokenAmountV2, isNullish } from "@dfinity/utils"; |
| 36 | + import { isNullish, TokenAmountV2 } from "@dfinity/utils"; |
33 | 37 | import { createEventDispatcher } from "svelte";
|
34 | 38 |
|
35 | 39 | $: if ($authSignedInStore) {
|
36 | 40 | loadIcpSwapTickers();
|
37 | 41 | }
|
38 |
| -
|
39 |
| - let columns: ProjectsTableColumn[] = []; |
40 |
| - $: columns = [ |
41 |
| - { |
42 |
| - id: "title", |
43 |
| - title: $i18n.staking.nervous_systems, |
44 |
| - cellComponent: ProjectTitleCell, |
45 |
| - alignment: "left", |
46 |
| - templateColumns: ["minmax(min-content, max-content)"], |
47 |
| - comparator: $authSignedInStore ? compareByProject : undefined, |
48 |
| - }, |
49 |
| - { |
50 |
| - title: "", |
51 |
| - alignment: "left", |
52 |
| - templateColumns: ["1fr"], |
53 |
| - }, |
| 42 | + let commonColumns: ProjectsTableColumn[] = []; |
| 43 | + $: commonColumns = [ |
54 | 44 | {
|
55 | 45 | id: "stake",
|
56 | 46 | title: $i18n.neuron_detail.stake,
|
57 | 47 | cellComponent: ProjectStakeCell,
|
58 | 48 | alignment: "right",
|
59 |
| - templateColumns: ["max-content"], |
60 |
| - comparator: $authSignedInStore ? compareByStake : undefined, |
61 |
| - }, |
62 |
| - { |
63 |
| - title: "", |
64 |
| - alignment: "left", |
65 | 49 | templateColumns: ["1fr"],
|
| 50 | + comparator: $authSignedInStore ? compareByStake : undefined, |
66 | 51 | },
|
67 | 52 | {
|
68 | 53 | title: $i18n.neuron_detail.maturity_title,
|
69 | 54 | cellComponent: ProjectMaturityCell,
|
70 | 55 | alignment: "right",
|
71 |
| - templateColumns: ["max-content"], |
72 |
| - }, |
73 |
| - { |
74 |
| - title: "", |
75 |
| - alignment: "left", |
76 | 56 | templateColumns: ["1fr"],
|
77 | 57 | },
|
78 | 58 | {
|
79 | 59 | id: "neurons",
|
80 | 60 | title: $i18n.neurons.title,
|
81 | 61 | cellComponent: ProjectNeuronsCell,
|
82 | 62 | alignment: "right",
|
83 |
| - templateColumns: ["max-content"], |
| 63 | + templateColumns: ["1fr"], |
84 | 64 | comparator: $authSignedInStore ? compareByNeuron : undefined,
|
85 | 65 | },
|
86 | 66 | {
|
87 | 67 | title: "",
|
88 | 68 | cellComponent: ProjectActionsCell,
|
89 | 69 | alignment: "right",
|
90 |
| - templateColumns: ["max-content"], |
| 70 | + templateColumns: ["1fr"], |
| 71 | + }, |
| 72 | + ]; |
| 73 | +
|
| 74 | + let columns: ProjectsTableColumn[] = []; |
| 75 | + $: columns = [ |
| 76 | + { |
| 77 | + id: "title", |
| 78 | + title: $i18n.staking.nervous_systems, |
| 79 | + cellComponent: ProjectTitleCell, |
| 80 | + alignment: "left", |
| 81 | + templateColumns: ["2fr"], |
| 82 | + comparator: $authSignedInStore ? compareByProject : undefined, |
| 83 | + }, |
| 84 | + ...commonColumns, |
| 85 | + ]; |
| 86 | +
|
| 87 | + let nnsColumns: ProjectsTableColumn[] = []; |
| 88 | + $: nnsColumns = [ |
| 89 | + { |
| 90 | + id: "title", |
| 91 | + title: $i18n.staking.nervous_systems_nns, |
| 92 | + cellComponent: ProjectTitleCell, |
| 93 | + alignment: "left", |
| 94 | + templateColumns: ["2fr"], |
| 95 | + comparator: $authSignedInStore ? compareByProject : undefined, |
| 96 | + }, |
| 97 | + ...commonColumns, |
| 98 | + ]; |
| 99 | +
|
| 100 | + let snsColumns: ProjectsTableColumn[] = []; |
| 101 | + $: snsColumns = [ |
| 102 | + { |
| 103 | + id: "title", |
| 104 | + title: $i18n.staking.nervous_systems_sns, |
| 105 | + cellComponent: ProjectTitleCell, |
| 106 | + alignment: "left", |
| 107 | + templateColumns: ["2fr"], |
| 108 | + comparator: $authSignedInStore ? compareByProject : undefined, |
| 109 | + }, |
| 110 | + ...commonColumns, |
| 111 | + ]; |
| 112 | +
|
| 113 | + let sunsettedSnsColumns: ProjectsTableColumn[] = []; |
| 114 | + $: sunsettedSnsColumns = [ |
| 115 | + { |
| 116 | + id: "title", |
| 117 | + title: $i18n.staking.nervous_systems_sns_sunset, |
| 118 | + cellComponent: ProjectTitleCell, |
| 119 | + alignment: "left", |
| 120 | + templateColumns: ["2fr"], |
| 121 | + }, |
| 122 | + { |
| 123 | + title: "", |
| 124 | + alignment: "left", |
| 125 | + templateColumns: ["1fr"], |
91 | 126 | },
|
92 | 127 | ];
|
93 | 128 |
|
|
132 | 167 | (!("stakeInUsd" in project) || isNullish(project.stakeInUsd))
|
133 | 168 | );
|
134 | 169 |
|
| 170 | + let nnsNeurons: TableProject[] = []; |
| 171 | + $: nnsNeurons = sortedTableProjects.filter( |
| 172 | + (project) => project.universeId === OWN_CANISTER_ID_TEXT |
| 173 | + ); |
| 174 | +
|
| 175 | + let snsNeurons: TableProject[] = []; |
| 176 | + $: snsNeurons = sortedTableProjects |
| 177 | + .filter((p) => p.universeId !== OWN_CANISTER_ID_TEXT) |
| 178 | + .filter((p) => !abandonedProjectsCanisterId.includes(p.universeId)); |
| 179 | +
|
| 180 | + let sunsetSns: TableProject[] = []; |
| 181 | + $: sunsetSns = sortedTableProjects.filter((p) => |
| 182 | + abandonedProjectsCanisterId.includes(p.universeId) |
| 183 | + ); |
| 184 | +
|
135 | 185 | const dispatcher = createEventDispatcher();
|
136 | 186 |
|
137 | 187 | const handleAction = ({
|
|
154 | 204 | </UsdValueBanner>
|
155 | 205 | {/if}
|
156 | 206 |
|
157 |
| - {#if !$authSignedInStore} |
| 207 | + {#if $ENABLE_NEW_TABLES} |
| 208 | + {#if !$authSignedInStore} |
| 209 | + <ResponsiveTable |
| 210 | + tableData={nnsNeurons} |
| 211 | + columns={nnsColumns} |
| 212 | + on:nnsAction={handleAction} |
| 213 | + /> |
| 214 | + |
| 215 | + <ResponsiveTable |
| 216 | + tableData={snsNeurons} |
| 217 | + columns={snsColumns} |
| 218 | + on:nnsAction={handleAction} |
| 219 | + /> |
| 220 | + |
| 221 | + {#if sunsetSns.length > 0} |
| 222 | + <ResponsiveTable tableData={sunsetSns} columns={sunsettedSnsColumns} /> |
| 223 | + {/if} |
| 224 | + {:else} |
| 225 | + <ResponsiveTable |
| 226 | + tableData={nnsNeurons} |
| 227 | + columns={nnsColumns} |
| 228 | + on:nnsAction={handleAction} |
| 229 | + bind:order={$projectsTableOrderStore} |
| 230 | + displayTableSettings |
| 231 | + > |
| 232 | + <svelte:fragment slot="settings-popover"> |
| 233 | + <HideZeroNeuronsToggle /> |
| 234 | + <Separator spacing="none" /> |
| 235 | + </svelte:fragment> |
| 236 | + |
| 237 | + <div |
| 238 | + slot="last-row" |
| 239 | + class="last-row" |
| 240 | + class:hidden={!shouldHideProjectsWithoutNeurons} |
| 241 | + > |
| 242 | + {#if shouldHideProjectsWithoutNeurons} |
| 243 | + <div class="show-all-button-container"> |
| 244 | + {$i18n.staking.hide_no_neurons_table_hint} |
| 245 | + <button |
| 246 | + data-tid="show-all-button" |
| 247 | + class="ghost show-all" |
| 248 | + on:click={showAll} |
| 249 | + > |
| 250 | + {$i18n.staking.show_all}</button |
| 251 | + > |
| 252 | + </div> |
| 253 | + {/if} |
| 254 | + </div> |
| 255 | + </ResponsiveTable> |
| 256 | + |
| 257 | + {#if snsNeurons.length > 0} |
| 258 | + <ResponsiveTable |
| 259 | + tableData={snsNeurons} |
| 260 | + columns={snsColumns} |
| 261 | + on:nnsAction={handleAction} |
| 262 | + bind:order={$projectsTableOrderStore} |
| 263 | + displayTableSettings |
| 264 | + > |
| 265 | + <svelte:fragment slot="settings-popover"> |
| 266 | + <HideZeroNeuronsToggle /> |
| 267 | + <Separator spacing="none" /> |
| 268 | + </svelte:fragment> |
| 269 | + </ResponsiveTable> |
| 270 | + {/if} |
| 271 | + |
| 272 | + {#if $hideZeroNeuronsStore !== "hide" && sunsetSns.length > 0} |
| 273 | + <ResponsiveTable tableData={sunsetSns} columns={sunsettedSnsColumns} /> |
| 274 | + {/if} |
| 275 | + {/if} |
| 276 | + {:else if !$authSignedInStore} |
158 | 277 | <ResponsiveTable
|
159 | 278 | tableData={sortedTableProjects}
|
160 | 279 | {columns}
|
|
0 commit comments