Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: change node url for proposal (#5956)
* refactor: refactor menuitem * feat: change node url * enhancement: improve error message * enhancement: add node icon * enhancement: make selected proposal reactive * fix: fix tests * enhancement: add success translations * fix: allow overflow on edit proposal popup --------- Co-authored-by: Matthew Maxwell <44885822+maxwellmattryan@users.noreply.github.com> Co-authored-by: Nicole O'Brien <nicole.obrien@iota.org>
- Loading branch information
1 parent
63869b9
commit 1c5a03c
Showing
21 changed files
with
251 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 76 additions & 3 deletions
79
packages/shared/components/atoms/buttons/ProposalDetailsButton.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,83 @@ | ||
<script lang="ts"> | ||
import { Modal, ProposalDetailsMenu, MeatballMenuButton } from 'shared/components' | ||
import { onMount } from 'svelte' | ||
import { Modal, MenuItem, MeatballMenuButton } from 'shared/components' | ||
import { Icon } from '@auxiliary/icon' | ||
import { openPopup } from '@auxiliary/popup/actions' | ||
import { handleError } from '@core/error/handlers' | ||
import { isVotingForSelectedProposal } from '@contexts/governance/utils' | ||
import { participationOverviewForSelectedAccount } from '@contexts/governance/stores' | ||
import { localize } from '@core/i18n' | ||
import { selectedAccount } from '@core/account/stores' | ||
// TODO: https://github.com/iotaledger/firefly/issues/5801 | ||
import features from '../../../../desktop/features/features' | ||
import { PopupId } from '@auxiliary/popup' | ||
import { IProposal } from '@contexts/governance' | ||
let modal: Modal | ||
export let proposal: IProposal | ||
export let modal: Modal = undefined | ||
let isVotingForProposal: boolean | ||
let isBusy = true // starts in a busy state because data needs to be fetched before displaying selectable options | ||
$: isTransferring = $selectedAccount?.isTransferring | ||
$: isTransferring, $participationOverviewForSelectedAccount, void updateIsVoting() // vote/stop vote changes the isTransferring value. Relying on this requires less updates than relying on proposalsState | ||
$: isBusy = isVotingForProposal === undefined | ||
$: buttons = [ | ||
{ | ||
icon: Icon.Node, | ||
title: localize('actions.changeNode'), | ||
onClick: onChangeNodeClick, | ||
}, | ||
{ | ||
icon: Icon.Delete, | ||
title: isBusy ? localize('views.governance.details.fetching') : localize('actions.removeProposal'), | ||
onClick: onRemoveProposalClick, | ||
variant: 'error', | ||
isLoading: isBusy, | ||
disabled: !features.governance.removeProposals.enabled || isVotingForProposal, | ||
enableTooltipVisible: isVotingForProposal !== undefined, | ||
tooltip: localize('tooltips.governance.removeProposalWarning'), | ||
}, | ||
] | ||
function onChangeNodeClick(): void { | ||
openPopup({ | ||
id: PopupId.AddProposal, | ||
props: { | ||
initialEventId: proposal.id, | ||
initialNodeUrl: proposal.nodeUrl, | ||
}, | ||
overflow: true, | ||
}) | ||
modal.close() | ||
} | ||
function onRemoveProposalClick(): void { | ||
openPopup({ | ||
id: PopupId.RemoveProposal, | ||
}) | ||
modal.close() | ||
} | ||
function updateIsVoting(): void { | ||
try { | ||
isVotingForProposal = isVotingForSelectedProposal() | ||
} catch (err) { | ||
handleError(err) | ||
} | ||
} | ||
onMount(() => void updateIsVoting()) | ||
</script> | ||
|
||
<div class="max-h-7 max-w-9 flex-none flex-initial overflow-visible relative"> | ||
<MeatballMenuButton onClick={modal?.toggle} /> | ||
<ProposalDetailsMenu bind:modal position={{ right: '0' }} classes="mt-1.5" /> | ||
<Modal bind:this={modal} position={{ right: '0' }} classes="mt-1.5"> | ||
<div class="flex flex-col"> | ||
{#each buttons as button} | ||
<MenuItem {...button} /> | ||
{/each} | ||
</div> | ||
</Modal> | ||
</div> |
78 changes: 0 additions & 78 deletions
78
packages/shared/components/modals/ProposalDetailsMenu.svelte
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.