Skip to content

Commit

Permalink
add token enable to admin screen (#5974)
Browse files Browse the repository at this point in the history
  • Loading branch information
julianjelfs authored Jul 1, 2024
1 parent abb40be commit b89c76b
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 2 deletions.
36 changes: 36 additions & 0 deletions frontend/app/src/components/home/admin/OperatorFunctions.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,14 @@
let currentFees: Record<"ICP" | "CHAT", Fees>;
let originalFees: Record<"ICP" | "CHAT", DiamondMembershipFees>;
let feesTab: "ICP" | "CHAT" = "ICP";
let tokenLedger = "";
let tokenEnabled = true;
$: groupUpgradeConcurrencyInvalid = isNaN(parseInt(groupUpgradeConcurrency, 0));
$: communityUpgradeConcurrencyInvalid = isNaN(parseInt(communityUpgradeConcurrency, 0));
$: userUpgradeConcurrencyInvalid = isNaN(parseInt(userUpgradeConcurrency, 0));
$: exchangeIdInvalid = isNaN(parseInt(exchangeId, 0));
$: tokenLedgerValid = tokenLedger.length > 0;
onMount(() => {
client.diamondMembershipFees().then((fees) => {
Expand Down Expand Up @@ -265,6 +268,26 @@
});
}
}
function setTokenEnabled(): void {
error = undefined;
addBusy(6);
client
.setTokenEnabled(tokenLedger, tokenEnabled)
.then((success) => {
if (success) {
toastStore.showSuccessToast(
i18nKey(`Token enabled set successfully: ${tokenLedger}, ${tokenEnabled}`),
);
} else {
error = i18nKey(`Failed to set token enabled: ${tokenLedger}, ${tokenEnabled}`);
toastStore.showFailureToast(error);
}
})
.finally(() => {
removeBusy(6);
});
}
</script>

<div class="operator">
Expand Down Expand Up @@ -452,6 +475,19 @@
on:click={updateMarketMakerConfig}>Apply</Button>
</section>

<section class="operator-function">
<div class="title">Set token enabled</div>
<ButtonGroup align="fill">
<Input invalid={!tokenLedgerValid} bind:value={tokenLedger} />
<Toggle small id="token-enabled" bind:checked={tokenEnabled} />
<Button
tiny
disabled={busy.has(6) || !tokenLedgerValid}
loading={busy.has(6)}
on:click={setTokenEnabled}>Apply</Button>
</ButtonGroup>
</section>

<section class="operator-function">
<ButtonGroup align="fill">
<h4>Pause event loop</h4>
Expand Down
14 changes: 12 additions & 2 deletions frontend/app/src/components/home/profile/Accounts.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,11 @@
<tr class:hidden={token.zero && !showZeroBalance}>
<td width="99%">
<div class="token">
<img class="icon" src={token.logo} />
<img
alt={token.name}
class:disabled={!token.enabled}
class="icon"
src={token.logo} />
<div>
{token.symbol}
</div>
Expand Down Expand Up @@ -200,7 +204,9 @@
slot="icon" />
<div slot="text">
<Translatable
resourceKey={i18nKey("cryptoAccount.swap")} />
resourceKey={i18nKey(
"cryptoAccount.swap",
)} />
</div>
</MenuItem>
{/if}
Expand Down Expand Up @@ -324,6 +330,10 @@
border-radius: 50%;
background-repeat: no-repeat;
background-position: top;
&.disabled {
filter: grayscale(1);
}
}
}
</style>

0 comments on commit b89c76b

Please sign in to comment.