Skip to content

Commit

Permalink
feat: add support for proposals with pending results
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Dec 14, 2024
1 parent 53248a8 commit cacab7b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 10 deletions.
18 changes: 17 additions & 1 deletion apps/ui/src/components/ProposalResults.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,27 @@ const otherResultsSummary = computed(() => {
}
);
});
const isFinalizing = computed(() => {
return (
!props.proposal.completed &&
['passed', 'executed', 'rejected'].includes(props.proposal.state)
);
});
</script>

<template>
<div v-if="isFinalizing" class="mb-1 border rounded-lg px-3 py-2.5">
<div class="flex items-center gap-2 text-skin-link">
<IH-exclamation-circle class="shrink-0" />
Finalizing results
</div>
Please allow few minutes while final results are being calculated.
</div>
<div
v-if="!!props.proposal.privacy && !props.proposal.completed && withDetails"
v-else-if="
!!props.proposal.privacy && !props.proposal.completed && withDetails
"
>
<div class="mb-1">
All votes are encrypted and will be decrypted only after the voting period
Expand Down
26 changes: 18 additions & 8 deletions apps/ui/src/components/ProposalVoteChoice.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { getChoiceText } from '@/helpers/utils';
import { Proposal, Vote } from '@/types';
withDefaults(
const props = withDefaults(
defineProps<{
proposal: Proposal;
vote: Vote;
Expand All @@ -12,16 +12,26 @@ withDefaults(
showReason: true
}
);
const isClosed = computed(() => {
return ['passed', 'executed', 'rejected'].includes(props.proposal.state);
});
</script>

<template>
<div
v-if="!!proposal.privacy && !proposal.completed"
class="flex gap-1 items-center"
>
<span class="text-skin-heading leading-[22px]">Encrypted choice</span>
<IH-lock-closed class="size-[16px] shrink-0" />
</div>
<template v-if="!!proposal.privacy && !proposal.completed">
<div v-if="isClosed" class="flex flex-col items-start">
<div class="flex gap-1 items-center">
<div class="text-skin-heading leading-[22px]">Decrypting choice</div>
<IH-lock-closed class="size-[16px] shrink-0" />
</div>
<div class="text-[17px] text-skin-text">Please wait ...</div>
</div>
<div v-else class="flex gap-1 items-center">
<span class="text-skin-heading leading-[22px]">Encrypted choice</span>
<IH-lock-closed class="size-[16px] shrink-0" />
</div>
</template>
<div v-else class="flex flex-col max-w-full truncate items-start">
<UiTooltip
v-if="proposal.type !== 'basic'"
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/networks/offchain/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ function formatProposal(proposal: ApiProposal, networkId: NetworkID): Proposal {
state,
cancelled: false,
vetoed: false,
completed: proposal.state === 'closed',
completed: proposal.state === 'closed' && proposal.scores_state === 'final',
space: {
id: proposal.space.id,
name: proposal.space.name,
Expand Down
1 change: 1 addition & 0 deletions apps/ui/src/networks/offchain/api/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ const PROPOSAL_FRAGMENT = gql`
labels
scores
scores_total
scores_state
state
strategies {
name
Expand Down
1 change: 1 addition & 0 deletions apps/ui/src/networks/offchain/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ export type ApiProposal = {
labels: string[];
scores: number[];
scores_total: number;
scores_state: 'invalid' | 'pending' | 'final';
state: 'active' | 'pending' | 'closed';
strategies: { network: string; params: Record<string, any>; name: string }[];
created: number;
Expand Down

0 comments on commit cacab7b

Please sign in to comment.