From 145c77460ebbe94c66d826dce557bacabd60a25a Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Wed, 1 Dec 2021 16:42:39 -0300 Subject: [PATCH 01/22] [DDW-796] Refactor and voting phases --- .../voting-info/CurrentPhase.messages.js | 10 +++ .../{CurrentFund.scss => CurrentPhase.scss} | 22 +++-- .../{CurrentFund.js => FundResults.js} | 44 +++++----- ...nd.messages.js => FundResults.messages.js} | 11 +-- .../voting/voting-info/RegisterToVote.js | 6 +- .../voting/voting-info/RegisterToVote.scss | 7 -- .../voting/voting-info/UpcomingFund.js | 80 +++++++++++++++++++ .../voting-info/UpcomingFund.messages.js | 15 ++++ .../voting/voting-info/VotingInfo.js | 11 ++- .../voting/voting-info/VotingInfo.scss | 6 +- .../voting/voting-info/VotingOpen.js | 73 +++++++++++++++++ .../voting/voting-info/VotingOpen.messages.js | 15 ++++ source/renderer/app/config/votingConfig.js | 19 ++--- .../voting/VotingRegistrationPage.js | 4 +- source/renderer/app/stores/VotingStore.js | 36 +++++---- source/renderer/app/utils/formatters.js | 33 ++++---- storybook/stories/voting/Voting.stories.js | 1 - 17 files changed, 293 insertions(+), 100 deletions(-) create mode 100644 source/renderer/app/components/voting/voting-info/CurrentPhase.messages.js rename source/renderer/app/components/voting/voting-info/{CurrentFund.scss => CurrentPhase.scss} (73%) rename source/renderer/app/components/voting/voting-info/{CurrentFund.js => FundResults.js} (58%) rename source/renderer/app/components/voting/voting-info/{CurrentFund.messages.js => FundResults.messages.js} (64%) create mode 100644 source/renderer/app/components/voting/voting-info/UpcomingFund.js create mode 100644 source/renderer/app/components/voting/voting-info/UpcomingFund.messages.js create mode 100644 source/renderer/app/components/voting/voting-info/VotingOpen.js create mode 100644 source/renderer/app/components/voting/voting-info/VotingOpen.messages.js diff --git a/source/renderer/app/components/voting/voting-info/CurrentPhase.messages.js b/source/renderer/app/components/voting/voting-info/CurrentPhase.messages.js new file mode 100644 index 0000000000..00dab7ebd9 --- /dev/null +++ b/source/renderer/app/components/voting/voting-info/CurrentPhase.messages.js @@ -0,0 +1,10 @@ +// @flow +import { defineMessages } from 'react-intl'; + +export const messages = defineMessages({ + currentFundName: { + id: 'voting.currentPhase.fundName', + defaultMessage: '!!!Fund{currentVotingFundNumber}', + description: 'Current fund name', + }, +}); diff --git a/source/renderer/app/components/voting/voting-info/CurrentFund.scss b/source/renderer/app/components/voting/voting-info/CurrentPhase.scss similarity index 73% rename from source/renderer/app/components/voting/voting-info/CurrentFund.scss rename to source/renderer/app/components/voting/voting-info/CurrentPhase.scss index 731691c221..5f21f39cd3 100644 --- a/source/renderer/app/components/voting/voting-info/CurrentFund.scss +++ b/source/renderer/app/components/voting/voting-info/CurrentPhase.scss @@ -1,13 +1,12 @@ @import '../votingConfig'; -.component { +.root { @extend %regularText; align-items: start; background-color: var(--theme-button-flat-background-color); border-radius: 5px; display: flex; flex-direction: column; - height: 175px; padding: 20px; width: 271px; @@ -16,23 +15,32 @@ font-family: var(--font-bold); font-size: 18px; line-height: 1.33; + margin-bottom: 11px; } - .endDateBlock { + .block { align-items: start; display: flex; flex-direction: column; - margin-bottom: 20px; - margin-top: 11px; - .endDateText { + .label { color: var(--theme-button-flat-text-color); display: block; } - .endDate { + .value { color: var(--theme-button-flat-text-color); font-family: var(--font-medium); } + + & + .block { + margin-top: 11px; + } + } + + .rectangle { + background-color: var(--theme-voting-separator-color); + height: 1px; + opacity: 0.15; } } diff --git a/source/renderer/app/components/voting/voting-info/CurrentFund.js b/source/renderer/app/components/voting/voting-info/FundResults.js similarity index 58% rename from source/renderer/app/components/voting/voting-info/CurrentFund.js rename to source/renderer/app/components/voting/voting-info/FundResults.js index c0053a628b..770d5577a9 100644 --- a/source/renderer/app/components/voting/voting-info/CurrentFund.js +++ b/source/renderer/app/components/voting/voting-info/FundResults.js @@ -2,7 +2,7 @@ import React from 'react'; import { injectIntl } from 'react-intl'; import { - VOTING_REGISTRATION_CAST_END_DATE, + VOTING_CAST_END_DATE, CURRENT_VOTING_FUND_NUMBER, } from '../../../config/votingConfig'; import { @@ -12,8 +12,8 @@ import { import type { Locale } from '../../../../../common/types/locales.types'; import { ExternalLinkButton } from '../../widgets/ExternalLinkButton'; import type { Intl } from '../../../types/i18nTypes'; -import styles from './CurrentFund.scss'; -import { messages } from './CurrentFund.messages'; +import styles from './CurrentPhase.scss'; +import { messages } from './FundResults.messages'; type Props = { currentLocale: Locale, @@ -23,38 +23,38 @@ type Props = { intl: Intl, }; -function CurrentFund({ +function FundResults({ currentLocale, currentDateFormat, currentTimeFormat, onExternalLinkClick, intl, }: Props) { - const currentFundEndDate = formattedDateTime( - VOTING_REGISTRATION_CAST_END_DATE, - { - currentLocale, - ...mapToLongDateTimeFormat({ - currentLocale, - currentDateFormat, - currentTimeFormat, - }), - } - ); + const mappedFormats = mapToLongDateTimeFormat({ + currentLocale, + currentDateFormat, + currentTimeFormat, + }); + + const endDate = formattedDateTime(VOTING_CAST_END_DATE, { + currentLocale, + currentDateFormat: mappedFormats.currentDateFormat, + currentTimeFormat: mappedFormats.currentTimeFormat, + }); return ( -
+

- {intl.formatMessage(messages.name, { + {intl.formatMessage(messages.currentFundName, { currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, })}

-
- - {intl.formatMessage(messages.headingForEndDate)} +
+ + {intl.formatMessage(messages.date)} - {currentFundEndDate} + {endDate}
{castEndDate} -
+
{intl.formatMessage(messages.stepsTitle)} diff --git a/source/renderer/app/components/voting/voting-info/RegisterToVote.scss b/source/renderer/app/components/voting/voting-info/RegisterToVote.scss index b8bed5157f..dbdd57b02f 100644 --- a/source/renderer/app/components/voting/voting-info/RegisterToVote.scss +++ b/source/renderer/app/components/voting/voting-info/RegisterToVote.scss @@ -22,13 +22,6 @@ font-family: var(--font-medium); } - .separator { - background-color: var(--theme-voting-separator-color); - height: 1px; - margin: 20px 0; - width: 100%; - } - .stepsTitle { font-family: var(--font-medium); } diff --git a/source/renderer/app/components/voting/voting-info/UpcomingFund.js b/source/renderer/app/components/voting/voting-info/UpcomingFund.js new file mode 100644 index 0000000000..b16cc6dda1 --- /dev/null +++ b/source/renderer/app/components/voting/voting-info/UpcomingFund.js @@ -0,0 +1,80 @@ +// @flow +import React from 'react'; +import { injectIntl } from 'react-intl'; +import { + CURRENT_VOTING_FUND_NUMBER, + VOTING_SNAPSHOT_DATE, + VOTING_CAST_START_DATE, + VOTING_CAST_END_DATE, +} from '../../../config/votingConfig'; +import { + formattedDateTime, + mapToLongDateTimeFormat, +} from '../../../utils/formatters'; +import type { Locale } from '../../../../../common/types/locales.types'; +import type { Intl } from '../../../types/i18nTypes'; +import styles from './CurrentPhase.scss'; +import { messages } from './UpcomingFund.messages'; +import { messages as votingMessages } from './CurrentPhase.messages'; + +type Props = { + currentLocale: Locale, + currentDateFormat: string, + currentTimeFormat: string, + intl: Intl, +}; + +function UpcomingFund({ + currentLocale, + currentDateFormat, + currentTimeFormat, + intl, +}: Props) { + const mappedFormats = mapToLongDateTimeFormat({ + currentLocale, + currentDateFormat, + currentTimeFormat, + }); + + const upcomingFundSnapshotDate = formattedDateTime(VOTING_SNAPSHOT_DATE, { + currentLocale, + currentDateFormat: mappedFormats.currentDateFormat, + currentTimeFormat: mappedFormats.currentTimeFormat, + }); + + const upcomingFundStartDate = formattedDateTime(VOTING_CAST_START_DATE, { + currentLocale, + currentDateFormat: mappedFormats.currentDateFormat, + }); + + const upcomingFundEndDate = formattedDateTime(VOTING_CAST_END_DATE, { + currentLocale, + currentDateFormat: mappedFormats.currentDateFormat, + }); + + return ( +
+

+ {intl.formatMessage(votingMessages.currentFundName, { + currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, + })} +

+
+ + {intl.formatMessage(messages.snapshotDateLabel)} + + {upcomingFundSnapshotDate} +
+
+ + {intl.formatMessage(messages.votingDateLabel)} + + + {upcomingFundStartDate} – {upcomingFundEndDate} + +
+
+ ); +} + +export default injectIntl(UpcomingFund); diff --git a/source/renderer/app/components/voting/voting-info/UpcomingFund.messages.js b/source/renderer/app/components/voting/voting-info/UpcomingFund.messages.js new file mode 100644 index 0000000000..20860dff29 --- /dev/null +++ b/source/renderer/app/components/voting/voting-info/UpcomingFund.messages.js @@ -0,0 +1,15 @@ +// @flow +import { defineMessages } from 'react-intl'; + +export const messages = defineMessages({ + snapshotDateLabel: { + id: 'voting.upcomingFund.snapshotDateLabel', + defaultMessage: '!!!Snapshot date:', + description: 'Snapshot date label', + }, + votingDateLabel: { + id: 'voting.upcomingFund.votingDateLabel', + defaultMessage: '!!!Next voting period:', + description: 'Next voting date label', + }, +}); diff --git a/source/renderer/app/components/voting/voting-info/VotingInfo.js b/source/renderer/app/components/voting/voting-info/VotingInfo.js index 43f317cf58..2132a63587 100644 --- a/source/renderer/app/components/voting/voting-info/VotingInfo.js +++ b/source/renderer/app/components/voting/voting-info/VotingInfo.js @@ -5,10 +5,16 @@ import { intlShape } from 'react-intl'; import BorderedBox from '../../widgets/BorderedBox'; import type { Locale } from '../../../../../common/types/locales.types'; import styles from './VotingInfo.scss'; -import CurrentFund from './CurrentFund'; +import UpcomingFund from './UpcomingFund'; +import VotingOpen from './VotingOpen'; import Headline from './Headline'; import AppStore from './AppStore'; import RegisterToVote from './RegisterToVote'; +import { + VOTING_SNAPSHOT_DATE, + VOTING_CAST_START_DATE, + VOTING_CAST_END_DATE, +} from '../../../config/votingConfig'; type Props = { currentLocale: Locale, @@ -40,11 +46,10 @@ export default class VotingInfo extends Component {
-
+

+ {intl.formatMessage(votingMessages.currentFundName, { + currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, + })} +

+
+ + {intl.formatMessage(messages.periodLabel)} + + + {startDate} – {endDate} + +
+
+
+ + {intl.formatMessage(messages.instruction)} + +
+
+ ); +} + +export default injectIntl(VotingOpen); diff --git a/source/renderer/app/components/voting/voting-info/VotingOpen.messages.js b/source/renderer/app/components/voting/voting-info/VotingOpen.messages.js new file mode 100644 index 0000000000..5b9090482a --- /dev/null +++ b/source/renderer/app/components/voting/voting-info/VotingOpen.messages.js @@ -0,0 +1,15 @@ +// @flow +import { defineMessages } from 'react-intl'; + +export const messages = defineMessages({ + periodLabel: { + id: 'voting.votingOpen.periodLabel', + defaultMessage: '!!!Voting period is open:', + description: 'Voting period label', + }, + instruction: { + id: 'voting.votingOpen.instruction', + defaultMessage: '!!!Use mobile app to vote', + description: 'Voting instruction', + }, +}); diff --git a/source/renderer/app/config/votingConfig.js b/source/renderer/app/config/votingConfig.js index 6dcc3203f4..2ab15ff4ea 100644 --- a/source/renderer/app/config/votingConfig.js +++ b/source/renderer/app/config/votingConfig.js @@ -2,22 +2,17 @@ const { isDev } = global.environment; export const IS_VOTING_REGISTRATION_AVAILABLE = true; -export const CURRENT_VOTING_FUND_NUMBER = 6; +export const CURRENT_VOTING_FUND_NUMBER = 7; export const NEXT_VOTING_FUND_NUMBER = CURRENT_VOTING_FUND_NUMBER + 1; export const VOTING_REGISTRATION_MIN_WALLET_FUNDS = 500; // 500 ADA | unit: ADA export const VOTING_REGISTRATION_FEE_CALCULATION_AMOUNT = 1; // 1 ADA | unit: ADA export const VOTING_REGISTRATION_PIN_CODE_LENGTH = 4; export const VOTING_REGISTRATION_MIN_TRANSACTION_CONFIRMATIONS = isDev ? 2 : 10; export const VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL = 1000; // 1 second | unit: milliseconds -export const VOTING_REGISTRATION_END_DATE = new Date('Jan 6, 2022, 11:00 UTC'); -export const VOTING_REGISTRATION_END_CHECK_INTERVAL = 3000; // 3 seconds | unit: milliseconds -export const VOTING_REGISTRATION_CAST_START_DATE = new Date( - 'Oct 7, 2021, 11:00 UTC' -); -export const VOTING_REGISTRATION_CAST_END_DATE = new Date( - 'Oct 21, 2021, 11:00 UTC' -); -export const VOTING_REGISTRATION_NEW_START_DATE = new Date( - 'Nov 11, 2021, 11:00 UTC' -); +export const VOTING_PHASE_CHECK_INTERVAL = 3000; // 3 seconds | unit: milliseconds +export const VOTING_SNAPSHOT_DATE = new Date('Jan 6, 2022, 11:00 UTC'); +export const VOTING_CAST_START_DATE = new Date('Jan 13, 2022, 11:00 UTC'); +export const VOTING_CAST_END_DATE = new Date('Jan 27, 2022, 11:00 UTC'); +export const VOTING_RESULTS_DATE = new Date('Feb 3, 2022'); +export const VOTING_NEW_SNAPSHOT_DATE = new Date('Apr 7, 2022, 11:00 UTC'); export const VOTING_REWARD = 1040000; // 1,040,000 USD | Unit: dollar diff --git a/source/renderer/app/containers/voting/VotingRegistrationPage.js b/source/renderer/app/containers/voting/VotingRegistrationPage.js index e8a6a31a18..a0c205ded0 100644 --- a/source/renderer/app/containers/voting/VotingRegistrationPage.js +++ b/source/renderer/app/containers/voting/VotingRegistrationPage.js @@ -28,9 +28,8 @@ export default class VotingRegistrationPage extends Component { }; getInnerContent = (isVotingRegistrationDialogOpen: boolean) => { - const { app, networkStatus, wallets, voting, profile } = this.props.stores; + const { app, networkStatus, wallets, profile } = this.props.stores; const { isSynced, syncPercentage } = networkStatus; - const { isRegistrationEnded } = voting; const { openExternalLink } = app; if ( @@ -61,7 +60,6 @@ export default class VotingRegistrationPage extends Component { currentLocale={currentLocale} currentDateFormat={currentDateFormat} currentTimeFormat={currentTimeFormat} - isRegistrationEnded={isRegistrationEnded} onRegisterToVoteClick={() => this.props.actions.dialogs.open.trigger({ dialog: VotingRegistrationDialog, diff --git a/source/renderer/app/stores/VotingStore.js b/source/renderer/app/stores/VotingStore.js index e4bc3bc0df..7d167fdff5 100644 --- a/source/renderer/app/stores/VotingStore.js +++ b/source/renderer/app/stores/VotingStore.js @@ -11,11 +11,14 @@ import { import { formattedArrayBufferToHexString } from '../utils/formatters'; import walletUtils from '../utils/walletUtils'; import { + // VOTING_SNAPSHOT_DATE, + // VOTING_CAST_START_DATE, + // VOTING_CAST_END_DATE, + // VOTING_RESULTS_DATE, + VOTING_PHASE_CHECK_INTERVAL, VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL, VOTING_REGISTRATION_MIN_TRANSACTION_CONFIRMATIONS, NEXT_VOTING_FUND_NUMBER, - VOTING_REGISTRATION_END_DATE, - VOTING_REGISTRATION_END_CHECK_INTERVAL, } from '../config/votingConfig'; import { votingPDFGenerator } from '../utils/votingPDFGenerator'; import { i18nContext } from '../utils/i18nContext'; @@ -38,6 +41,8 @@ export type VotingDataType = { absoluteSlotNumber: number, }; +export type VotingPhase = 'Snapshot' | 'Voting' | 'Tallying' | 'Results'; + export default class VotingStore extends Store { @observable registrationStep: number = 1; @observable selectedWalletId: ?string = null; @@ -48,10 +53,10 @@ export default class VotingStore extends Store { @observable votingRegistrationKey: ?VotingRegistrationKeyType = null; @observable qrCode: ?string = null; @observable isConfirmationDialogOpen: boolean = false; - @observable isRegistrationEnded: boolean = false; + @observable votingPhase: VotingPhase = 'Snapshot'; transactionPollingInterval: ?IntervalID = null; - registrationEndCheckInterval: ?IntervalID = null; + votingPhaseInterval: ?IntervalID = null; setup() { const { voting: votingActions } = this.actions; @@ -66,7 +71,7 @@ export default class VotingStore extends Store { votingActions.resetRegistration.listen(this._resetRegistration); votingActions.showConfirmationDialog.listen(this._showConfirmationDialog); votingActions.closeConfirmationDialog.listen(this._closeConfirmationDialog); - this._initializeRegistrationEndCheckInterval(); + this._initializeVotingPhaseInterval(); } // REQUESTS @@ -127,8 +132,7 @@ export default class VotingStore extends Store { this.signMetadataRequest.reset(); if (this.transactionPollingInterval) clearInterval(this.transactionPollingInterval); - if (this.registrationEndCheckInterval) - clearInterval(this.registrationEndCheckInterval); + if (this.votingPhaseInterval) clearInterval(this.votingPhaseInterval); }; @action _startTransactionPolling = () => { @@ -139,12 +143,14 @@ export default class VotingStore extends Store { }, VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL); }; - @action _initializeRegistrationEndCheckInterval = () => { - if (this.registrationEndCheckInterval) - clearInterval(this.registrationEndCheckInterval); - this.registrationEndCheckInterval = setInterval(() => { - this._checkVotingRegistrationEnd(); - }, VOTING_REGISTRATION_END_CHECK_INTERVAL); + @action _initializeVotingPhaseInterval = () => { + if (this.votingPhaseInterval) { + clearInterval(this.votingPhaseInterval); + } + + this.votingPhaseInterval = setInterval(() => { + this._checkVotingPhase(); + }, VOTING_PHASE_CHECK_INTERVAL); }; @action _setVotingRegistrationKey = (value: VotingRegistrationKeyType) => { @@ -433,8 +439,8 @@ export default class VotingStore extends Store { } }; - @action _checkVotingRegistrationEnd = () => { - this.isRegistrationEnded = new Date() >= VOTING_REGISTRATION_END_DATE; + @action _checkVotingPhase = () => { + this.votingPhase = 'Snapshot'; }; _generateVotingRegistrationKey = async () => { diff --git a/source/renderer/app/utils/formatters.js b/source/renderer/app/utils/formatters.js index 2a422a748e..31bea3cb4c 100644 --- a/source/renderer/app/utils/formatters.js +++ b/source/renderer/app/utils/formatters.js @@ -287,26 +287,29 @@ export const formattedSize = (size: string): string => { return formattedResult; }; +type CurrentFormats = { + currentLocale: Locale, + currentDateFormat: string, + currentTimeFormat?: string, +}; + export const formattedDateTime = ( dateTime: Date, - { - currentLocale, - currentDateFormat, - currentTimeFormat, - }: { - currentLocale: Locale, - currentDateFormat: string, - currentTimeFormat: string, - } + { currentLocale, currentDateFormat, currentTimeFormat }: CurrentFormats ) => { moment.locale(momentLocales[currentLocale]); const dateTimeMoment = moment(dateTime); const dateFormatted = dateTimeMoment.format(currentDateFormat); - const timeFormatted = dateTimeMoment.format(currentTimeFormat); - const dateTimeSeparator = DATE_TIME_SEPARATOR_MAP[currentDateFormat]; - return `${dateFormatted}${dateTimeSeparator}${timeFormatted}`; + if (currentTimeFormat) { + const timeFormatted = dateTimeMoment.format(currentTimeFormat); + const dateTimeSeparator = DATE_TIME_SEPARATOR_MAP[currentDateFormat]; + + return `${dateFormatted}${dateTimeSeparator}${timeFormatted}`; + } + + return dateFormatted; }; export const getMultiplierFromDecimalPlaces = (decimalPlaces: number) => @@ -316,11 +319,7 @@ export const mapToLongDateTimeFormat = ({ currentLocale, currentDateFormat, currentTimeFormat, -}: { - currentLocale: Locale, - currentDateFormat: string, - currentTimeFormat: string, -}) => { +}: CurrentFormats) => { const mappedDateFormat = currentLocale === LOCALES.english ? DATE_ENGLISH_LL_MAP_OPTIONS[currentDateFormat] diff --git a/storybook/stories/voting/Voting.stories.js b/storybook/stories/voting/Voting.stories.js index f01d3238ae..b71c23d959 100644 --- a/storybook/stories/voting/Voting.stories.js +++ b/storybook/stories/voting/Voting.stories.js @@ -177,7 +177,6 @@ storiesOf('Voting|Voting Info', module) currentLocale={LANGUAGE_OPTIONS[0].value} currentDateFormat={DATE_ENGLISH_OPTIONS[0].value} currentTimeFormat={TIME_OPTIONS[0].value} - isRegistrationEnded={boolean('isRegistrationEnded', false)} onRegisterToVoteClick={action('onRegisterToVoteClick')} onExternalLinkClick={action('onExternalLinkClick')} /> From d770712cb8495a374f2785b04508dc88717a4f65 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Thu, 2 Dec 2021 15:10:55 -0300 Subject: [PATCH 02/22] [DDW-796] Remove closed voting logic --- .../components/voting/VotingUnavailable.js | 56 +++---------------- source/renderer/app/config/votingConfig.js | 1 - .../voting/VotingRegistrationPage.js | 11 +--- 3 files changed, 11 insertions(+), 57 deletions(-) diff --git a/source/renderer/app/components/voting/VotingUnavailable.js b/source/renderer/app/components/voting/VotingUnavailable.js index 98dbb343b4..78dcf7e7fa 100644 --- a/source/renderer/app/components/voting/VotingUnavailable.js +++ b/source/renderer/app/components/voting/VotingUnavailable.js @@ -77,55 +77,17 @@ export default class VotingUnavailable extends Component { onExternalLinkClick, } = this.props; - const heading = intl.formatMessage(messages.heading); - const paragraph1 = intl.formatMessage(messages.paragraph1, { - currentFundNumber: CURRENT_VOTING_FUND_NUMBER, - nextVotingFundNumber: NEXT_VOTING_FUND_NUMBER, - }); - const link1 = ( - - onExternalLinkClick(intl.formatMessage(messages.link1Url)) - } - /> - ); - const link2 = ( - - onExternalLinkClick(intl.formatMessage(messages.link2Url)) - } - /> - ); - return (
- {isVotingRegistrationAvailable ? ( - <> - -
- -
- - ) : ( - <> -

{heading}

-

{paragraph1}

- - - )} + +
+ +
); } diff --git a/source/renderer/app/config/votingConfig.js b/source/renderer/app/config/votingConfig.js index 2ab15ff4ea..560656a266 100644 --- a/source/renderer/app/config/votingConfig.js +++ b/source/renderer/app/config/votingConfig.js @@ -1,7 +1,6 @@ // @flow const { isDev } = global.environment; -export const IS_VOTING_REGISTRATION_AVAILABLE = true; export const CURRENT_VOTING_FUND_NUMBER = 7; export const NEXT_VOTING_FUND_NUMBER = CURRENT_VOTING_FUND_NUMBER + 1; export const VOTING_REGISTRATION_MIN_WALLET_FUNDS = 500; // 500 ADA | unit: ADA diff --git a/source/renderer/app/containers/voting/VotingRegistrationPage.js b/source/renderer/app/containers/voting/VotingRegistrationPage.js index a0c205ded0..b441b018c8 100644 --- a/source/renderer/app/containers/voting/VotingRegistrationPage.js +++ b/source/renderer/app/containers/voting/VotingRegistrationPage.js @@ -2,10 +2,7 @@ import React, { Component } from 'react'; import { observer, inject } from 'mobx-react'; import Layout from '../MainLayout'; -import { - IS_VOTING_REGISTRATION_AVAILABLE, - VOTING_REGISTRATION_MIN_WALLET_FUNDS, -} from '../../config/votingConfig'; +import { VOTING_REGISTRATION_MIN_WALLET_FUNDS } from '../../config/votingConfig'; import VerticalFlexContainer from '../../components/layout/VerticalFlexContainer'; import VotingInfo from '../../components/voting/voting-info/VotingInfo'; import VotingNoWallets from '../../components/voting/VotingNoWallets'; @@ -32,14 +29,10 @@ export default class VotingRegistrationPage extends Component { const { isSynced, syncPercentage } = networkStatus; const { openExternalLink } = app; - if ( - !IS_VOTING_REGISTRATION_AVAILABLE || - (!isSynced && !isVotingRegistrationDialogOpen) - ) { + if (!isSynced && !isVotingRegistrationDialogOpen) { return ( ); From cd26d6a30b17cc19ce282fdc92c1ef8551dc6a9c Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Thu, 2 Dec 2021 17:22:11 -0300 Subject: [PATCH 03/22] [DDW-796] Exclude js/ts files from nix-build glob --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index b3e42e3d38..b43c8bb717 100755 --- a/.gitignore +++ b/.gitignore @@ -86,6 +86,10 @@ mainnet-genesis-dryrun-with-stakeholders.json # nix-build results result* +!result*.js +!result*.jsx +!result*.ts +!result*.tsx # Npm package-lock.json From 0376de677920a9d551f2f03c056ac24297bda21c Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Thu, 2 Dec 2021 17:27:21 -0300 Subject: [PATCH 04/22] [DDW-796] Fund phase logic --- source/renderer/app/config/votingConfig.js | 2 +- source/renderer/app/stores/VotingStore.js | 53 +++++++++++++++------- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/source/renderer/app/config/votingConfig.js b/source/renderer/app/config/votingConfig.js index 560656a266..ff3464abd0 100644 --- a/source/renderer/app/config/votingConfig.js +++ b/source/renderer/app/config/votingConfig.js @@ -8,7 +8,7 @@ export const VOTING_REGISTRATION_FEE_CALCULATION_AMOUNT = 1; // 1 ADA | unit: AD export const VOTING_REGISTRATION_PIN_CODE_LENGTH = 4; export const VOTING_REGISTRATION_MIN_TRANSACTION_CONFIRMATIONS = isDev ? 2 : 10; export const VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL = 1000; // 1 second | unit: milliseconds -export const VOTING_PHASE_CHECK_INTERVAL = 3000; // 3 seconds | unit: milliseconds +export const VOTING_PHASE_CHECK_INTERVAL = 60000; // 60 seconds | unit: milliseconds export const VOTING_SNAPSHOT_DATE = new Date('Jan 6, 2022, 11:00 UTC'); export const VOTING_CAST_START_DATE = new Date('Jan 13, 2022, 11:00 UTC'); export const VOTING_CAST_END_DATE = new Date('Jan 27, 2022, 11:00 UTC'); diff --git a/source/renderer/app/stores/VotingStore.js b/source/renderer/app/stores/VotingStore.js index 7d167fdff5..51be56b2ae 100644 --- a/source/renderer/app/stores/VotingStore.js +++ b/source/renderer/app/stores/VotingStore.js @@ -11,10 +11,10 @@ import { import { formattedArrayBufferToHexString } from '../utils/formatters'; import walletUtils from '../utils/walletUtils'; import { - // VOTING_SNAPSHOT_DATE, - // VOTING_CAST_START_DATE, - // VOTING_CAST_END_DATE, - // VOTING_RESULTS_DATE, + VOTING_SNAPSHOT_DATE, + VOTING_CAST_START_DATE, + VOTING_CAST_END_DATE, + VOTING_RESULTS_DATE, VOTING_PHASE_CHECK_INTERVAL, VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL, VOTING_REGISTRATION_MIN_TRANSACTION_CONFIRMATIONS, @@ -41,7 +41,13 @@ export type VotingDataType = { absoluteSlotNumber: number, }; -export type VotingPhase = 'Snapshot' | 'Voting' | 'Tallying' | 'Results'; +export type FundPhase = 'snapshot' | 'voting' | 'tallying' | 'results'; +export const FundPhases: EnumMap = { + SNAPSHOT: 'snapshot', + VOTING: 'voting', + TALLYING: 'tallying', + RESULTS: 'results', +}; export default class VotingStore extends Store { @observable registrationStep: number = 1; @@ -53,10 +59,10 @@ export default class VotingStore extends Store { @observable votingRegistrationKey: ?VotingRegistrationKeyType = null; @observable qrCode: ?string = null; @observable isConfirmationDialogOpen: boolean = false; - @observable votingPhase: VotingPhase = 'Snapshot'; + @observable fundPhase: FundPhase = FundPhases.SNAPSHOT; transactionPollingInterval: ?IntervalID = null; - votingPhaseInterval: ?IntervalID = null; + fundPhaseInterval: ?IntervalID = null; setup() { const { voting: votingActions } = this.actions; @@ -71,7 +77,7 @@ export default class VotingStore extends Store { votingActions.resetRegistration.listen(this._resetRegistration); votingActions.showConfirmationDialog.listen(this._showConfirmationDialog); votingActions.closeConfirmationDialog.listen(this._closeConfirmationDialog); - this._initializeVotingPhaseInterval(); + this._initializeFundPhaseInterval(); } // REQUESTS @@ -130,9 +136,12 @@ export default class VotingStore extends Store { this.getWalletPublicKeyRequest.reset(); this.createVotingRegistrationTransactionRequest.reset(); this.signMetadataRequest.reset(); - if (this.transactionPollingInterval) + if (this.transactionPollingInterval) { clearInterval(this.transactionPollingInterval); - if (this.votingPhaseInterval) clearInterval(this.votingPhaseInterval); + } + if (this.fundPhaseInterval) { + clearInterval(this.fundPhaseInterval); + } }; @action _startTransactionPolling = () => { @@ -143,13 +152,13 @@ export default class VotingStore extends Store { }, VOTING_REGISTRATION_TRANSACTION_POLLING_INTERVAL); }; - @action _initializeVotingPhaseInterval = () => { - if (this.votingPhaseInterval) { - clearInterval(this.votingPhaseInterval); + @action _initializeFundPhaseInterval = () => { + if (this.fundPhaseInterval) { + clearInterval(this.fundPhaseInterval); } - this.votingPhaseInterval = setInterval(() => { - this._checkVotingPhase(); + this.fundPhaseInterval = setInterval(() => { + this._checkFundPhase(new Date()); }, VOTING_PHASE_CHECK_INTERVAL); }; @@ -439,8 +448,18 @@ export default class VotingStore extends Store { } }; - @action _checkVotingPhase = () => { - this.votingPhase = 'Snapshot'; + @action _checkFundPhase = (now: Date) => { + const phaseValidation = { + [FundPhases.SNAPSHOT]: now < VOTING_CAST_START_DATE, + [FundPhases.VOTING]: + now >= VOTING_CAST_START_DATE && now <= VOTING_CAST_END_DATE, + [FundPhases.TALLYING]: + now > VOTING_CAST_END_DATE && now < VOTING_RESULTS_DATE, + [FundPhases.RESULTS]: now >= VOTING_RESULTS_DATE, + }; + this.fundPhase = + Object.values(FundPhases).find((phase) => phaseValidation[phase]) || + FundPhases.SNAPSHOT; }; _generateVotingRegistrationKey = async () => { From 6d12ff3c131010792e88bedf47fcec8976399744 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Thu, 2 Dec 2021 17:42:53 -0300 Subject: [PATCH 05/22] [DDW-796] Fund phase components --- .../voting/voting-info/CurrentPhase.scss | 6 +- .../{FundResults.js => ResultsPhase.js} | 25 ++- ...s.messages.js => ResultsPhase.messages.js} | 8 +- .../{UpcomingFund.js => SnapshotPhase.js} | 10 +- ....messages.js => SnapshotPhase.messages.js} | 4 +- .../voting/voting-info/TallyingPhase.js | 71 +++++++ .../voting-info/TallyingPhase.messages.js | 15 ++ .../voting/voting-info/VotingInfo.js | 106 +++++----- .../{VotingOpen.js => VotingPhase.js} | 12 +- ...en.messages.js => VotingPhase.messages.js} | 8 +- .../voting/VotingRegistrationPage.js | 3 +- .../app/i18n/locales/defaultMessages.json | 196 ++++++++++++++---- source/renderer/app/i18n/locales/en-US.json | 14 +- source/renderer/app/i18n/locales/ja-JP.json | 14 +- source/renderer/app/stores/VotingStore.js | 1 - 15 files changed, 349 insertions(+), 144 deletions(-) rename source/renderer/app/components/voting/voting-info/{FundResults.js => ResultsPhase.js} (70%) rename source/renderer/app/components/voting/voting-info/{FundResults.messages.js => ResultsPhase.messages.js} (74%) rename source/renderer/app/components/voting/voting-info/{UpcomingFund.js => SnapshotPhase.js} (89%) rename source/renderer/app/components/voting/voting-info/{UpcomingFund.messages.js => SnapshotPhase.messages.js} (76%) create mode 100644 source/renderer/app/components/voting/voting-info/TallyingPhase.js create mode 100644 source/renderer/app/components/voting/voting-info/TallyingPhase.messages.js rename source/renderer/app/components/voting/voting-info/{VotingOpen.js => VotingPhase.js} (84%) rename source/renderer/app/components/voting/voting-info/{VotingOpen.messages.js => VotingPhase.messages.js} (64%) diff --git a/source/renderer/app/components/voting/voting-info/CurrentPhase.scss b/source/renderer/app/components/voting/voting-info/CurrentPhase.scss index 5f21f39cd3..741df095ef 100644 --- a/source/renderer/app/components/voting/voting-info/CurrentPhase.scss +++ b/source/renderer/app/components/voting/voting-info/CurrentPhase.scss @@ -38,9 +38,7 @@ } } - .rectangle { - background-color: var(--theme-voting-separator-color); - height: 1px; - opacity: 0.15; + .resultsButton { + margin-top: 28px; } } diff --git a/source/renderer/app/components/voting/voting-info/FundResults.js b/source/renderer/app/components/voting/voting-info/ResultsPhase.js similarity index 70% rename from source/renderer/app/components/voting/voting-info/FundResults.js rename to source/renderer/app/components/voting/voting-info/ResultsPhase.js index 770d5577a9..c452eaf039 100644 --- a/source/renderer/app/components/voting/voting-info/FundResults.js +++ b/source/renderer/app/components/voting/voting-info/ResultsPhase.js @@ -13,7 +13,8 @@ import type { Locale } from '../../../../../common/types/locales.types'; import { ExternalLinkButton } from '../../widgets/ExternalLinkButton'; import type { Intl } from '../../../types/i18nTypes'; import styles from './CurrentPhase.scss'; -import { messages } from './FundResults.messages'; +import { messages } from './ResultsPhase.messages'; +import { messages as currentPhaseMessages } from './CurrentPhase.messages'; type Props = { currentLocale: Locale, @@ -23,7 +24,7 @@ type Props = { intl: Intl, }; -function FundResults({ +function ResultsPhase({ currentLocale, currentDateFormat, currentTimeFormat, @@ -45,26 +46,28 @@ function FundResults({ return (

- {intl.formatMessage(messages.currentFundName, { + {intl.formatMessage(currentPhaseMessages.currentFundName, { currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, })}

- {intl.formatMessage(messages.date)} + {intl.formatMessage(messages.endDateLabel)} {endDate}
- - onExternalLinkClick(intl.formatMessage(messages.viewResultsLinkURL)) - } - /> +
+ + onExternalLinkClick(intl.formatMessage(messages.viewResultsLinkURL)) + } + /> +
); } -export default injectIntl(FundResults); +export default injectIntl(ResultsPhase); diff --git a/source/renderer/app/components/voting/voting-info/FundResults.messages.js b/source/renderer/app/components/voting/voting-info/ResultsPhase.messages.js similarity index 74% rename from source/renderer/app/components/voting/voting-info/FundResults.messages.js rename to source/renderer/app/components/voting/voting-info/ResultsPhase.messages.js index afe01a8b02..dfa5b68ef6 100644 --- a/source/renderer/app/components/voting/voting-info/FundResults.messages.js +++ b/source/renderer/app/components/voting/voting-info/ResultsPhase.messages.js @@ -2,18 +2,18 @@ import { defineMessages } from 'react-intl'; export const messages = defineMessages({ - headingForEndDate: { - id: 'voting.fundResults.headingForEndDate', + endDateLabel: { + id: 'voting.resultsPhase.endDateLabel', defaultMessage: '!!!End of voting:', description: 'Headline for end date', }, viewResultsLinkLabel: { - id: 'voting.fundResults.viewResultsLinkLabel', + id: 'voting.resultsPhase.viewResultsLinkLabel', defaultMessage: '!!!View results', description: 'View resuls link label for Fund{currentVotingFundNumber}', }, viewResultsLinkURL: { - id: 'voting.fundResults.viewResultsLinkURL', + id: 'voting.resultsPhase.viewResultsLinkURL', defaultMessage: 'https://cardano.ideascale.com/a/pages/results', description: 'View results from Fund{currentVotingFundNumber}', }, diff --git a/source/renderer/app/components/voting/voting-info/UpcomingFund.js b/source/renderer/app/components/voting/voting-info/SnapshotPhase.js similarity index 89% rename from source/renderer/app/components/voting/voting-info/UpcomingFund.js rename to source/renderer/app/components/voting/voting-info/SnapshotPhase.js index b16cc6dda1..3a9c3b4bdf 100644 --- a/source/renderer/app/components/voting/voting-info/UpcomingFund.js +++ b/source/renderer/app/components/voting/voting-info/SnapshotPhase.js @@ -14,8 +14,8 @@ import { import type { Locale } from '../../../../../common/types/locales.types'; import type { Intl } from '../../../types/i18nTypes'; import styles from './CurrentPhase.scss'; -import { messages } from './UpcomingFund.messages'; -import { messages as votingMessages } from './CurrentPhase.messages'; +import { messages } from './SnapshotPhase.messages'; +import { messages as currentPhase } from './CurrentPhase.messages'; type Props = { currentLocale: Locale, @@ -24,7 +24,7 @@ type Props = { intl: Intl, }; -function UpcomingFund({ +function SnapshotPhase({ currentLocale, currentDateFormat, currentTimeFormat, @@ -55,7 +55,7 @@ function UpcomingFund({ return (

- {intl.formatMessage(votingMessages.currentFundName, { + {intl.formatMessage(currentPhase.currentFundName, { currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, })}

@@ -77,4 +77,4 @@ function UpcomingFund({ ); } -export default injectIntl(UpcomingFund); +export default injectIntl(SnapshotPhase); diff --git a/source/renderer/app/components/voting/voting-info/UpcomingFund.messages.js b/source/renderer/app/components/voting/voting-info/SnapshotPhase.messages.js similarity index 76% rename from source/renderer/app/components/voting/voting-info/UpcomingFund.messages.js rename to source/renderer/app/components/voting/voting-info/SnapshotPhase.messages.js index 20860dff29..4eee34d671 100644 --- a/source/renderer/app/components/voting/voting-info/UpcomingFund.messages.js +++ b/source/renderer/app/components/voting/voting-info/SnapshotPhase.messages.js @@ -3,12 +3,12 @@ import { defineMessages } from 'react-intl'; export const messages = defineMessages({ snapshotDateLabel: { - id: 'voting.upcomingFund.snapshotDateLabel', + id: 'voting.snapshotPhase.snapshotDateLabel', defaultMessage: '!!!Snapshot date:', description: 'Snapshot date label', }, votingDateLabel: { - id: 'voting.upcomingFund.votingDateLabel', + id: 'voting.snapshotPhase.votingDateLabel', defaultMessage: '!!!Next voting period:', description: 'Next voting date label', }, diff --git a/source/renderer/app/components/voting/voting-info/TallyingPhase.js b/source/renderer/app/components/voting/voting-info/TallyingPhase.js new file mode 100644 index 0000000000..5b01c6eba4 --- /dev/null +++ b/source/renderer/app/components/voting/voting-info/TallyingPhase.js @@ -0,0 +1,71 @@ +// @flow +import React from 'react'; +import { injectIntl } from 'react-intl'; +import { + CURRENT_VOTING_FUND_NUMBER, + VOTING_RESULTS_DATE, + VOTING_CAST_END_DATE, +} from '../../../config/votingConfig'; +import { + formattedDateTime, + mapToLongDateTimeFormat, +} from '../../../utils/formatters'; +import type { Locale } from '../../../../../common/types/locales.types'; +import type { Intl } from '../../../types/i18nTypes'; +import styles from './CurrentPhase.scss'; +import { messages } from './TallyingPhase.messages'; +import { messages as currentPhaseMessages } from './CurrentPhase.messages'; + +type Props = { + currentLocale: Locale, + currentDateFormat: string, + currentTimeFormat: string, + intl: Intl, +}; + +function TallyingPhase({ + currentLocale, + currentDateFormat, + currentTimeFormat, + intl, +}: Props) { + const mappedFormats = mapToLongDateTimeFormat({ + currentLocale, + currentDateFormat, + currentTimeFormat, + }); + + const endDated = formattedDateTime(VOTING_CAST_END_DATE, { + currentLocale, + currentDateFormat: mappedFormats.currentDateFormat, + }); + + const resultsDate = formattedDateTime(VOTING_RESULTS_DATE, { + currentLocale, + currentDateFormat: mappedFormats.currentDateFormat, + }); + + return ( +
+

+ {intl.formatMessage(currentPhaseMessages.currentFundName, { + currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, + })} +

+
+ + {intl.formatMessage(messages.endDateLabel)} + + {endDated} +
+
+ + {intl.formatMessage(messages.resultsLabel)} + + {resultsDate} +
+
+ ); +} + +export default injectIntl(TallyingPhase); diff --git a/source/renderer/app/components/voting/voting-info/TallyingPhase.messages.js b/source/renderer/app/components/voting/voting-info/TallyingPhase.messages.js new file mode 100644 index 0000000000..445edbb8fc --- /dev/null +++ b/source/renderer/app/components/voting/voting-info/TallyingPhase.messages.js @@ -0,0 +1,15 @@ +// @flow +import { defineMessages } from 'react-intl'; + +export const messages = defineMessages({ + endDateLabel: { + id: 'voting.tallyingPhase.endDateLabel', + defaultMessage: '!!!Voting ended:', + description: 'Voting end date label', + }, + resultsLabel: { + id: 'voting.tallyingPhase.resultsLabel', + defaultMessage: '!!!Check back for results:', + description: 'Results date label', + }, +}); diff --git a/source/renderer/app/components/voting/voting-info/VotingInfo.js b/source/renderer/app/components/voting/voting-info/VotingInfo.js index 2132a63587..2976683bba 100644 --- a/source/renderer/app/components/voting/voting-info/VotingInfo.js +++ b/source/renderer/app/components/voting/voting-info/VotingInfo.js @@ -1,74 +1,76 @@ // @flow -import React, { Component } from 'react'; +import React from 'react'; import { observer } from 'mobx-react'; -import { intlShape } from 'react-intl'; +import { injectIntl } from 'react-intl'; import BorderedBox from '../../widgets/BorderedBox'; import type { Locale } from '../../../../../common/types/locales.types'; import styles from './VotingInfo.scss'; -import UpcomingFund from './UpcomingFund'; -import VotingOpen from './VotingOpen'; +import ResultsPhase from './ResultsPhase'; +import SnapshotPhase from './SnapshotPhase'; +import VotingPhase from './VotingPhase'; +import TallyingPhase from './TallyingPhase'; import Headline from './Headline'; import AppStore from './AppStore'; import RegisterToVote from './RegisterToVote'; -import { - VOTING_SNAPSHOT_DATE, - VOTING_CAST_START_DATE, - VOTING_CAST_END_DATE, -} from '../../../config/votingConfig'; +import { FundPhase, FundPhases } from '../../../stores/VotingStore'; type Props = { currentLocale: Locale, currentDateFormat: string, currentTimeFormat: string, + fundPhase: FundPhase, onRegisterToVoteClick: Function, onExternalLinkClick: Function, }; -@observer -export default class VotingInfo extends Component { - static contextTypes = { - intl: intlShape.isRequired, - }; +const phaseToComponentMap = { + [FundPhases.SNAPSHOT]: SnapshotPhase, + [FundPhases.VOTING]: VotingPhase, + [FundPhases.TALLYING]: TallyingPhase, + [FundPhases.RESULTS]: ResultsPhase, +}; - render() { - const { - currentLocale, - currentDateFormat, - currentTimeFormat, - onRegisterToVoteClick, - onExternalLinkClick, - } = this.props; +const VotingInfo = ({ + currentLocale, + currentDateFormat, + currentTimeFormat, + fundPhase, + onRegisterToVoteClick, + onExternalLinkClick, +}: Props) => { + const PhaseComponent = phaseToComponentMap[fundPhase || FundPhases.SNAPSHOT]; - return ( -
- - -
-
-
- -
- -
-
-
- + + +
+
+
+ +
+
- -
- ); - } -} +
+ +
+
+ +
+ ); +}; + +export default injectIntl(observer(VotingInfo)); diff --git a/source/renderer/app/components/voting/voting-info/VotingOpen.js b/source/renderer/app/components/voting/voting-info/VotingPhase.js similarity index 84% rename from source/renderer/app/components/voting/voting-info/VotingOpen.js rename to source/renderer/app/components/voting/voting-info/VotingPhase.js index f2952525a9..dfd83cf4e8 100644 --- a/source/renderer/app/components/voting/voting-info/VotingOpen.js +++ b/source/renderer/app/components/voting/voting-info/VotingPhase.js @@ -13,8 +13,8 @@ import { import type { Locale } from '../../../../../common/types/locales.types'; import type { Intl } from '../../../types/i18nTypes'; import styles from './CurrentPhase.scss'; -import { messages } from './VotingOpen.messages'; -import { messages as votingMessages } from './CurrentPhase.messages'; +import { messages } from './VotingPhase.messages'; +import { messages as currentPhase } from './CurrentPhase.messages'; type Props = { currentLocale: Locale, @@ -23,7 +23,7 @@ type Props = { intl: Intl, }; -function VotingOpen({ +function VotingPhase({ currentLocale, currentDateFormat, currentTimeFormat, @@ -48,13 +48,13 @@ function VotingOpen({ return (

- {intl.formatMessage(votingMessages.currentFundName, { + {intl.formatMessage(currentPhase.currentFundName, { currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, })}

- {intl.formatMessage(messages.periodLabel)} + {intl.formatMessage(messages.dateLabel)} {startDate} – {endDate} @@ -70,4 +70,4 @@ function VotingOpen({ ); } -export default injectIntl(VotingOpen); +export default injectIntl(VotingPhase); diff --git a/source/renderer/app/components/voting/voting-info/VotingOpen.messages.js b/source/renderer/app/components/voting/voting-info/VotingPhase.messages.js similarity index 64% rename from source/renderer/app/components/voting/voting-info/VotingOpen.messages.js rename to source/renderer/app/components/voting/voting-info/VotingPhase.messages.js index 5b9090482a..be2242fc39 100644 --- a/source/renderer/app/components/voting/voting-info/VotingOpen.messages.js +++ b/source/renderer/app/components/voting/voting-info/VotingPhase.messages.js @@ -2,13 +2,13 @@ import { defineMessages } from 'react-intl'; export const messages = defineMessages({ - periodLabel: { - id: 'voting.votingOpen.periodLabel', + dateLabel: { + id: 'voting.votingOpenPhase.dateLabel', defaultMessage: '!!!Voting period is open:', - description: 'Voting period label', + description: 'Voting date label', }, instruction: { - id: 'voting.votingOpen.instruction', + id: 'voting.votingOpenPhase.instruction', defaultMessage: '!!!Use mobile app to vote', description: 'Voting instruction', }, diff --git a/source/renderer/app/containers/voting/VotingRegistrationPage.js b/source/renderer/app/containers/voting/VotingRegistrationPage.js index b441b018c8..bd4562137a 100644 --- a/source/renderer/app/containers/voting/VotingRegistrationPage.js +++ b/source/renderer/app/containers/voting/VotingRegistrationPage.js @@ -25,7 +25,7 @@ export default class VotingRegistrationPage extends Component { }; getInnerContent = (isVotingRegistrationDialogOpen: boolean) => { - const { app, networkStatus, wallets, profile } = this.props.stores; + const { app, networkStatus, wallets, profile, voting } = this.props.stores; const { isSynced, syncPercentage } = networkStatus; const { openExternalLink } = app; @@ -50,6 +50,7 @@ export default class VotingRegistrationPage extends Component { const { currentTimeFormat, currentDateFormat, currentLocale } = profile; return ( Date: Thu, 2 Dec 2021 17:56:35 -0300 Subject: [PATCH 06/22] [DDW-796] Fix lint issues --- .../components/voting/VotingUnavailable.js | 100 +++-------------- .../app/i18n/locales/defaultMessages.json | 103 ------------------ source/renderer/app/i18n/locales/en-US.json | 7 -- source/renderer/app/i18n/locales/ja-JP.json | 7 -- 4 files changed, 18 insertions(+), 199 deletions(-) diff --git a/source/renderer/app/components/voting/VotingUnavailable.js b/source/renderer/app/components/voting/VotingUnavailable.js index 78dcf7e7fa..ab28eef1a6 100644 --- a/source/renderer/app/components/voting/VotingUnavailable.js +++ b/source/renderer/app/components/voting/VotingUnavailable.js @@ -1,94 +1,30 @@ // @flow -import React, { Component } from 'react'; +import React from 'react'; import { observer } from 'mobx-react'; -import { - defineMessages, - intlShape, - FormattedMessage, - FormattedHTMLMessage, -} from 'react-intl'; +import { FormattedHTMLMessage } from 'react-intl'; import BigNumber from 'bignumber.js'; -import { Link } from 'react-polymorph/lib/components/Link'; import globalMessages from '../../i18n/global-messages'; import LoadingSpinner from '../widgets/LoadingSpinner'; -import { - CURRENT_VOTING_FUND_NUMBER, - NEXT_VOTING_FUND_NUMBER, -} from '../../config/votingConfig'; import styles from './VotingUnavailable.scss'; -const messages = defineMessages({ - heading: { - id: 'voting.unavailable.heading', - defaultMessage: '!!!Project Catalyst voting registration', - description: 'Headline for the "Voting unavailable" screen', - }, - paragraph1: { - id: 'voting.unavailable.paragraph1', - defaultMessage: - '!!!Project Catalyst Fund{currentVotingFundNumber} has now ended. Fund{nextVotingFundNumber} is currently in preparation, voting registration is not available yet.', - description: 'First paragraph on the "Voting unavailable" screen', - }, - paragraph2: { - id: 'voting.unavailable.paragraph2', - defaultMessage: - '!!!Join our {link1} and {link2} Telegram channels for the latest updates (English language only).', - description: 'Second paragraph on the "Voting unavailable" screen', - }, - link1Text: { - id: 'voting.unavailable.link1Text', - defaultMessage: '!!!Catalyst Announcements', - description: 'First link text on the "Voting unavailable" screen', - }, - link2Text: { - id: 'voting.unavailable.link2Text', - defaultMessage: '!!!Project Catalyst Chat', - description: 'Second link text on the "Voting unavailable" screen', - }, - link1Url: { - id: 'voting.unavailable.link1Url', - defaultMessage: '!!!https://t.me/cardanocatalyst', - description: 'First link URL on the "Voting unavailable" screen', - }, - link2Url: { - id: 'voting.unavailable.link2Url', - defaultMessage: '!!!https://t.me/ProjectCatalystChat', - description: 'Second link URL on the "Voting unavailable" screen', - }, -}); - type Props = { syncPercentage: number, - isVotingRegistrationAvailable: boolean, - onExternalLinkClick: Function, }; -@observer -export default class VotingUnavailable extends Component { - static contextTypes = { - intl: intlShape.isRequired, - }; - - render() { - const { intl } = this.context; - const { - syncPercentage, - isVotingRegistrationAvailable, - onExternalLinkClick, - } = this.props; - - return ( -
- -
- -
+const VotingUnavailable = ({ syncPercentage }: Props) => { + return ( +
+ +
+
- ); - } -} +
+ ); +}; + +export default observer(VotingUnavailable); diff --git a/source/renderer/app/i18n/locales/defaultMessages.json b/source/renderer/app/i18n/locales/defaultMessages.json index d79dfe37fb..1ec39dee31 100644 --- a/source/renderer/app/i18n/locales/defaultMessages.json +++ b/source/renderer/app/i18n/locales/defaultMessages.json @@ -9107,109 +9107,6 @@ ], "path": "source/renderer/app/components/voting/VotingNoWallets.json" }, - { - "descriptors": [ - { - "defaultMessage": "!!!Project Catalyst voting registration", - "description": "Headline for the \"Voting unavailable\" screen", - "end": { - "column": 3, - "line": 25 - }, - "file": "source/renderer/app/components/voting/VotingUnavailable.js", - "id": "voting.unavailable.heading", - "start": { - "column": 11, - "line": 21 - } - }, - { - "defaultMessage": "!!!Project Catalyst Fund{currentVotingFundNumber} has now ended. Fund{nextVotingFundNumber} is currently in preparation, voting registration is not available yet.", - "description": "First paragraph on the \"Voting unavailable\" screen", - "end": { - "column": 3, - "line": 31 - }, - "file": "source/renderer/app/components/voting/VotingUnavailable.js", - "id": "voting.unavailable.paragraph1", - "start": { - "column": 14, - "line": 26 - } - }, - { - "defaultMessage": "!!!Join our {link1} and {link2} Telegram channels for the latest updates (English language only).", - "description": "Second paragraph on the \"Voting unavailable\" screen", - "end": { - "column": 3, - "line": 37 - }, - "file": "source/renderer/app/components/voting/VotingUnavailable.js", - "id": "voting.unavailable.paragraph2", - "start": { - "column": 14, - "line": 32 - } - }, - { - "defaultMessage": "!!!Catalyst Announcements", - "description": "First link text on the \"Voting unavailable\" screen", - "end": { - "column": 3, - "line": 42 - }, - "file": "source/renderer/app/components/voting/VotingUnavailable.js", - "id": "voting.unavailable.link1Text", - "start": { - "column": 13, - "line": 38 - } - }, - { - "defaultMessage": "!!!Project Catalyst Chat", - "description": "Second link text on the \"Voting unavailable\" screen", - "end": { - "column": 3, - "line": 47 - }, - "file": "source/renderer/app/components/voting/VotingUnavailable.js", - "id": "voting.unavailable.link2Text", - "start": { - "column": 13, - "line": 43 - } - }, - { - "defaultMessage": "!!!https://t.me/cardanocatalyst", - "description": "First link URL on the \"Voting unavailable\" screen", - "end": { - "column": 3, - "line": 52 - }, - "file": "source/renderer/app/components/voting/VotingUnavailable.js", - "id": "voting.unavailable.link1Url", - "start": { - "column": 12, - "line": 48 - } - }, - { - "defaultMessage": "!!!https://t.me/ProjectCatalystChat", - "description": "Second link URL on the \"Voting unavailable\" screen", - "end": { - "column": 3, - "line": 57 - }, - "file": "source/renderer/app/components/voting/VotingUnavailable.js", - "id": "voting.unavailable.link2Url", - "start": { - "column": 12, - "line": 53 - } - } - ], - "path": "source/renderer/app/components/voting/VotingUnavailable.json" - }, { "descriptors": [ { diff --git a/source/renderer/app/i18n/locales/en-US.json b/source/renderer/app/i18n/locales/en-US.json index a82afeb6f2..9de05ee48c 100755 --- a/source/renderer/app/i18n/locales/en-US.json +++ b/source/renderer/app/i18n/locales/en-US.json @@ -658,13 +658,6 @@ "voting.snapshotPhase.votingDateLabel": "Next voting period:", "voting.tallyingPhase.endDateLabel": "Voting ended:", "voting.tallyingPhase.resultsLabel": "Check back for results:", - "voting.unavailable.heading": "Project Catalyst voting registration", - "voting.unavailable.link1Text": "Catalyst Announcements", - "voting.unavailable.link1Url": "https://t.me/cardanocatalyst", - "voting.unavailable.link2Text": "Project Catalyst Chat", - "voting.unavailable.link2Url": "https://t.me/ProjectCatalystChat", - "voting.unavailable.paragraph1": "Project Catalyst Fund{currentVotingFundNumber} has now ended. Fund{nextVotingFundNumber} is currently in preparation, voting registration is not available yet.", - "voting.unavailable.paragraph2": "Join our {link1} and {link2} Telegram channels for the latest updates (English language only).", "voting.votingOpenPhase.dateLabel": "Voting period is open:", "voting.votingOpenPhase.instruction": "Use mobile app to vote", "voting.votingRegistration.chooseWallet.step.continueButtonLabel": "Continue", diff --git a/source/renderer/app/i18n/locales/ja-JP.json b/source/renderer/app/i18n/locales/ja-JP.json index 12c46463d7..166f4551f5 100755 --- a/source/renderer/app/i18n/locales/ja-JP.json +++ b/source/renderer/app/i18n/locales/ja-JP.json @@ -658,13 +658,6 @@ "voting.snapshotPhase.votingDateLabel": "!!!Next voting period:", "voting.tallyingPhase.endDateLabel": "!!!Voting ended:", "voting.tallyingPhase.resultsLabel": "!!!Check back for results:", - "voting.unavailable.heading": "Project Catalyst有権者登録", - "voting.unavailable.link1Text": "Catalyst案内", - "voting.unavailable.link1Url": "https://t.me/cardanocatalyst", - "voting.unavailable.link2Text": "Project Catalyst Chat", - "voting.unavailable.link2Url": "https://t.me/ProjectCatalystChat", - "voting.unavailable.paragraph1": "Project Catalyst Fund{currentVotingFundNumber}は終了しました。現在Fund{nextVotingFundNumber}は準備中です。有権者登録の開始までしばらくお待ちください。", - "voting.unavailable.paragraph2": "!最新情報は、{link1}やTelegramの{link2}でチェックしてください(英語のみ)。", "voting.votingOpenPhase.dateLabel": "!!!Voting period is open:", "voting.votingOpenPhase.instruction": "!!!Use mobile app to vote", "voting.votingRegistration.chooseWallet.step.continueButtonLabel": "続ける", From c39e24f6dc66a89c67e59aca33813b2117821324 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Fri, 3 Dec 2021 10:02:51 -0300 Subject: [PATCH 07/22] [DDW-796] Fix flow issues --- .../renderer/app/components/voting/voting-info/VotingInfo.js | 3 ++- source/renderer/app/stores/VotingStore.js | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/source/renderer/app/components/voting/voting-info/VotingInfo.js b/source/renderer/app/components/voting/voting-info/VotingInfo.js index 2976683bba..de01c4cc97 100644 --- a/source/renderer/app/components/voting/voting-info/VotingInfo.js +++ b/source/renderer/app/components/voting/voting-info/VotingInfo.js @@ -12,7 +12,8 @@ import TallyingPhase from './TallyingPhase'; import Headline from './Headline'; import AppStore from './AppStore'; import RegisterToVote from './RegisterToVote'; -import { FundPhase, FundPhases } from '../../../stores/VotingStore'; +import { FundPhases } from '../../../stores/VotingStore'; +import type { FundPhase } from '../../../stores/VotingStore'; type Props = { currentLocale: Locale, diff --git a/source/renderer/app/stores/VotingStore.js b/source/renderer/app/stores/VotingStore.js index ee40c3da86..9b6d873ff6 100644 --- a/source/renderer/app/stores/VotingStore.js +++ b/source/renderer/app/stores/VotingStore.js @@ -457,8 +457,9 @@ export default class VotingStore extends Store { [FundPhases.RESULTS]: now >= VOTING_RESULTS_DATE, }; this.fundPhase = - Object.values(FundPhases).find((phase) => phaseValidation[phase]) || - FundPhases.SNAPSHOT; + Object.keys(FundPhases) + .map((phase) => FundPhases[phase]) + .find((phase) => phaseValidation[phase]) || FundPhases.SNAPSHOT; }; _generateVotingRegistrationKey = async () => { From 1a722817f4ae5edcb1aaf2c43a0f4bc49b778c0e Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Fri, 3 Dec 2021 16:11:40 -0300 Subject: [PATCH 08/22] [DDW-796] Style fix --- .../app/components/voting/voting-info/CurrentPhase.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/renderer/app/components/voting/voting-info/CurrentPhase.scss b/source/renderer/app/components/voting/voting-info/CurrentPhase.scss index 741df095ef..1d90208480 100644 --- a/source/renderer/app/components/voting/voting-info/CurrentPhase.scss +++ b/source/renderer/app/components/voting/voting-info/CurrentPhase.scss @@ -39,6 +39,6 @@ } .resultsButton { - margin-top: 28px; + margin-top: 20px; } } From 1432543d106a2bf10d279c016404f1922c611649 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Fri, 3 Dec 2021 16:12:11 -0300 Subject: [PATCH 09/22] [DDW-796] Add observer --- .../renderer/app/components/voting/voting-info/ResultsPhase.js | 3 ++- .../app/components/voting/voting-info/SnapshotPhase.js | 3 ++- .../app/components/voting/voting-info/TallyingPhase.js | 3 ++- .../renderer/app/components/voting/voting-info/VotingPhase.js | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/renderer/app/components/voting/voting-info/ResultsPhase.js b/source/renderer/app/components/voting/voting-info/ResultsPhase.js index c452eaf039..1a9c839302 100644 --- a/source/renderer/app/components/voting/voting-info/ResultsPhase.js +++ b/source/renderer/app/components/voting/voting-info/ResultsPhase.js @@ -1,5 +1,6 @@ // @flow import React from 'react'; +import { observer } from 'mobx-react'; import { injectIntl } from 'react-intl'; import { VOTING_CAST_END_DATE, @@ -70,4 +71,4 @@ function ResultsPhase({ ); } -export default injectIntl(ResultsPhase); +export default injectIntl(observer(ResultsPhase)); diff --git a/source/renderer/app/components/voting/voting-info/SnapshotPhase.js b/source/renderer/app/components/voting/voting-info/SnapshotPhase.js index 3a9c3b4bdf..343dc6f1df 100644 --- a/source/renderer/app/components/voting/voting-info/SnapshotPhase.js +++ b/source/renderer/app/components/voting/voting-info/SnapshotPhase.js @@ -1,5 +1,6 @@ // @flow import React from 'react'; +import { observer } from 'mobx-react'; import { injectIntl } from 'react-intl'; import { CURRENT_VOTING_FUND_NUMBER, @@ -77,4 +78,4 @@ function SnapshotPhase({ ); } -export default injectIntl(SnapshotPhase); +export default injectIntl(observer(SnapshotPhase)); diff --git a/source/renderer/app/components/voting/voting-info/TallyingPhase.js b/source/renderer/app/components/voting/voting-info/TallyingPhase.js index 5b01c6eba4..d3b8d2f8cf 100644 --- a/source/renderer/app/components/voting/voting-info/TallyingPhase.js +++ b/source/renderer/app/components/voting/voting-info/TallyingPhase.js @@ -1,5 +1,6 @@ // @flow import React from 'react'; +import { observer } from 'mobx-react'; import { injectIntl } from 'react-intl'; import { CURRENT_VOTING_FUND_NUMBER, @@ -68,4 +69,4 @@ function TallyingPhase({ ); } -export default injectIntl(TallyingPhase); +export default injectIntl(observer(TallyingPhase)); diff --git a/source/renderer/app/components/voting/voting-info/VotingPhase.js b/source/renderer/app/components/voting/voting-info/VotingPhase.js index dfd83cf4e8..01138b635c 100644 --- a/source/renderer/app/components/voting/voting-info/VotingPhase.js +++ b/source/renderer/app/components/voting/voting-info/VotingPhase.js @@ -1,5 +1,6 @@ // @flow import React from 'react'; +import { observer } from 'mobx-react'; import { injectIntl } from 'react-intl'; import { CURRENT_VOTING_FUND_NUMBER, @@ -70,4 +71,4 @@ function VotingPhase({ ); } -export default injectIntl(VotingPhase); +export default injectIntl(observer(VotingPhase)); From dc9e1c71a1ca7bbb097ff767d936a40a1e35767b Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Fri, 3 Dec 2021 16:12:30 -0300 Subject: [PATCH 10/22] [DDW-796] Remove unused --- .../renderer/app/components/voting/voting-info/VotingInfo.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/renderer/app/components/voting/voting-info/VotingInfo.js b/source/renderer/app/components/voting/voting-info/VotingInfo.js index de01c4cc97..f3311858a1 100644 --- a/source/renderer/app/components/voting/voting-info/VotingInfo.js +++ b/source/renderer/app/components/voting/voting-info/VotingInfo.js @@ -1,7 +1,6 @@ // @flow import React from 'react'; import { observer } from 'mobx-react'; -import { injectIntl } from 'react-intl'; import BorderedBox from '../../widgets/BorderedBox'; import type { Locale } from '../../../../../common/types/locales.types'; import styles from './VotingInfo.scss'; @@ -74,4 +73,4 @@ const VotingInfo = ({ ); }; -export default injectIntl(observer(VotingInfo)); +export default observer(VotingInfo); From 81192f59c470e90b9e6c731c5e0c8f0738a1acd3 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Fri, 3 Dec 2021 16:12:54 -0300 Subject: [PATCH 11/22] [DDW-796] Lazy validation --- source/renderer/app/stores/VotingStore.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/source/renderer/app/stores/VotingStore.js b/source/renderer/app/stores/VotingStore.js index 9b6d873ff6..727b4ba978 100644 --- a/source/renderer/app/stores/VotingStore.js +++ b/source/renderer/app/stores/VotingStore.js @@ -449,17 +449,17 @@ export default class VotingStore extends Store { @action _checkFundPhase = (now: Date) => { const phaseValidation = { - [FundPhases.SNAPSHOT]: now < VOTING_CAST_START_DATE, - [FundPhases.VOTING]: - now >= VOTING_CAST_START_DATE && now <= VOTING_CAST_END_DATE, - [FundPhases.TALLYING]: - now > VOTING_CAST_END_DATE && now < VOTING_RESULTS_DATE, - [FundPhases.RESULTS]: now >= VOTING_RESULTS_DATE, + [FundPhases.SNAPSHOT]: (date: Date) => date < VOTING_CAST_START_DATE, + [FundPhases.VOTING]: (date: Date) => + now >= VOTING_CAST_START_DATE && date < VOTING_CAST_END_DATE, + [FundPhases.TALLYING]: (date: Date) => + now >= VOTING_CAST_END_DATE && date < VOTING_RESULTS_DATE, + [FundPhases.RESULTS]: (date: Date) => date >= VOTING_RESULTS_DATE, }; this.fundPhase = Object.keys(FundPhases) - .map((phase) => FundPhases[phase]) - .find((phase) => phaseValidation[phase]) || FundPhases.SNAPSHOT; + .map((key) => FundPhases[key]) + .find((phase) => phaseValidation[phase](now)) || FundPhases.SNAPSHOT; }; _generateVotingRegistrationKey = async () => { From bcaf13808ad477cee518a10516ab0dd53680bc50 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Mon, 6 Dec 2021 09:49:52 -0300 Subject: [PATCH 12/22] [DDW-796] Update text --- .../app/components/voting/voting-info/SnapshotPhase.js | 10 +++++----- .../voting/voting-info/TallyingPhase.messages.js | 2 +- .../voting/voting-info/VotingPhase.messages.js | 2 +- source/renderer/app/i18n/locales/defaultMessages.json | 4 ++-- source/renderer/app/i18n/locales/en-US.json | 4 ++-- source/renderer/app/i18n/locales/ja-JP.json | 6 +++--- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/source/renderer/app/components/voting/voting-info/SnapshotPhase.js b/source/renderer/app/components/voting/voting-info/SnapshotPhase.js index 343dc6f1df..b9bc0a1bd4 100644 --- a/source/renderer/app/components/voting/voting-info/SnapshotPhase.js +++ b/source/renderer/app/components/voting/voting-info/SnapshotPhase.js @@ -37,18 +37,18 @@ function SnapshotPhase({ currentTimeFormat, }); - const upcomingFundSnapshotDate = formattedDateTime(VOTING_SNAPSHOT_DATE, { + const snapshotDate = formattedDateTime(VOTING_SNAPSHOT_DATE, { currentLocale, currentDateFormat: mappedFormats.currentDateFormat, currentTimeFormat: mappedFormats.currentTimeFormat, }); - const upcomingFundStartDate = formattedDateTime(VOTING_CAST_START_DATE, { + const startDate = formattedDateTime(VOTING_CAST_START_DATE, { currentLocale, currentDateFormat: mappedFormats.currentDateFormat, }); - const upcomingFundEndDate = formattedDateTime(VOTING_CAST_END_DATE, { + const endDate = formattedDateTime(VOTING_CAST_END_DATE, { currentLocale, currentDateFormat: mappedFormats.currentDateFormat, }); @@ -64,14 +64,14 @@ function SnapshotPhase({ {intl.formatMessage(messages.snapshotDateLabel)} - {upcomingFundSnapshotDate} + {snapshotDate}
{intl.formatMessage(messages.votingDateLabel)} - {upcomingFundStartDate} – {upcomingFundEndDate} + {startDate} – {endDate}
diff --git a/source/renderer/app/components/voting/voting-info/TallyingPhase.messages.js b/source/renderer/app/components/voting/voting-info/TallyingPhase.messages.js index 445edbb8fc..64830d7959 100644 --- a/source/renderer/app/components/voting/voting-info/TallyingPhase.messages.js +++ b/source/renderer/app/components/voting/voting-info/TallyingPhase.messages.js @@ -9,7 +9,7 @@ export const messages = defineMessages({ }, resultsLabel: { id: 'voting.tallyingPhase.resultsLabel', - defaultMessage: '!!!Check back for results:', + defaultMessage: '!!!Check back for results on:', description: 'Results date label', }, }); diff --git a/source/renderer/app/components/voting/voting-info/VotingPhase.messages.js b/source/renderer/app/components/voting/voting-info/VotingPhase.messages.js index be2242fc39..49fe8c6fdd 100644 --- a/source/renderer/app/components/voting/voting-info/VotingPhase.messages.js +++ b/source/renderer/app/components/voting/voting-info/VotingPhase.messages.js @@ -4,7 +4,7 @@ import { defineMessages } from 'react-intl'; export const messages = defineMessages({ dateLabel: { id: 'voting.votingOpenPhase.dateLabel', - defaultMessage: '!!!Voting period is open:', + defaultMessage: '!!!Voting period open between:', description: 'Voting date label', }, instruction: { diff --git a/source/renderer/app/i18n/locales/defaultMessages.json b/source/renderer/app/i18n/locales/defaultMessages.json index 1ec39dee31..41a26820ab 100644 --- a/source/renderer/app/i18n/locales/defaultMessages.json +++ b/source/renderer/app/i18n/locales/defaultMessages.json @@ -8271,7 +8271,7 @@ } }, { - "defaultMessage": "!!!Check back for results:", + "defaultMessage": "!!!Check back for results on:", "description": "Results date label", "end": { "column": 3, @@ -8290,7 +8290,7 @@ { "descriptors": [ { - "defaultMessage": "!!!Voting period is open:", + "defaultMessage": "!!!Voting period open between:", "description": "Voting date label", "end": { "column": 3, diff --git a/source/renderer/app/i18n/locales/en-US.json b/source/renderer/app/i18n/locales/en-US.json index 9de05ee48c..2f6204776d 100755 --- a/source/renderer/app/i18n/locales/en-US.json +++ b/source/renderer/app/i18n/locales/en-US.json @@ -657,8 +657,8 @@ "voting.snapshotPhase.snapshotDateLabel": "Snapshot date:", "voting.snapshotPhase.votingDateLabel": "Next voting period:", "voting.tallyingPhase.endDateLabel": "Voting ended:", - "voting.tallyingPhase.resultsLabel": "Check back for results:", - "voting.votingOpenPhase.dateLabel": "Voting period is open:", + "voting.tallyingPhase.resultsLabel": "Check back for results on:", + "voting.votingOpenPhase.dateLabel": "Voting period open between:", "voting.votingOpenPhase.instruction": "Use mobile app to vote", "voting.votingRegistration.chooseWallet.step.continueButtonLabel": "Continue", "voting.votingRegistration.chooseWallet.step.description": "You can only use one wallet when registering. To maximize rewards and voting power, choose the wallet with the largest balance.", diff --git a/source/renderer/app/i18n/locales/ja-JP.json b/source/renderer/app/i18n/locales/ja-JP.json index 166f4551f5..8f6b3c8d0e 100755 --- a/source/renderer/app/i18n/locales/ja-JP.json +++ b/source/renderer/app/i18n/locales/ja-JP.json @@ -654,11 +654,11 @@ "voting.resultsPhase.endDateLabel": "投票締め切り:", "voting.resultsPhase.viewResultsLinkLabel": "結果を見る", "voting.resultsPhase.viewResultsLinkURL": "https://cardano.ideascale.com/a/pages/results", - "voting.snapshotPhase.snapshotDateLabel": "!!!Snapshot date:", + "voting.snapshotPhase.snapshotDateLabel": "スナップショット日:", "voting.snapshotPhase.votingDateLabel": "!!!Next voting period:", "voting.tallyingPhase.endDateLabel": "!!!Voting ended:", - "voting.tallyingPhase.resultsLabel": "!!!Check back for results:", - "voting.votingOpenPhase.dateLabel": "!!!Voting period is open:", + "voting.tallyingPhase.resultsLabel": "!!!Check back for results on:", + "voting.votingOpenPhase.dateLabel": "!!!Voting period open between:", "voting.votingOpenPhase.instruction": "!!!Use mobile app to vote", "voting.votingRegistration.chooseWallet.step.continueButtonLabel": "続ける", "voting.votingRegistration.chooseWallet.step.description": "投票に使用できるウォレットは1つだけです。報酬と議決権を最大にするには、残高の一番大きなウォレットを選択してください。", From b065f492e8de62bfea8bddd1424267c149edb6ba Mon Sep 17 00:00:00 2001 From: Renan Ferreira Date: Fri, 3 Dec 2021 16:53:36 -0300 Subject: [PATCH 13/22] [DDW-858] Fix eslint warnings --- .../app/components/staking/delegation-center/WalletRow.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/source/renderer/app/components/staking/delegation-center/WalletRow.js b/source/renderer/app/components/staking/delegation-center/WalletRow.js index 4e732a3acf..98927a2cd3 100644 --- a/source/renderer/app/components/staking/delegation-center/WalletRow.js +++ b/source/renderer/app/components/staking/delegation-center/WalletRow.js @@ -82,22 +82,16 @@ const messages = defineMessages({ type Props = { wallet: Wallet, delegatedStakePool?: ?StakePool, - numberOfStakePools: number, numberOfRankedStakePools: number, onDelegate: Function, onUndelegate: Function, getStakePoolById: Function, nextEpochNumber: number, futureEpochNumber: number, - onSelect?: Function, - selectedPoolId?: ?number, - isListActive?: boolean, currentTheme: string, onOpenExternalLink: Function, showWithSelectButton?: boolean, containerClassName: string, - setListActive?: Function, - listName?: string, }; type WalletRowState = { From b30e1fc7e28e9514ec69eab2533c10a20ee59e29 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Mon, 6 Dec 2021 11:02:23 -0300 Subject: [PATCH 14/22] [DDW-796] Add jp translations --- source/renderer/app/i18n/locales/ja-JP.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/source/renderer/app/i18n/locales/ja-JP.json b/source/renderer/app/i18n/locales/ja-JP.json index 8f6b3c8d0e..a73361dc39 100755 --- a/source/renderer/app/i18n/locales/ja-JP.json +++ b/source/renderer/app/i18n/locales/ja-JP.json @@ -637,7 +637,7 @@ "voting.catalystFooterLinks.community": "コミュニティチャット", "voting.catalystFooterLinks.newsletter": "ニュースレター", "voting.catalystFooterLinks.projects": "プロジェクト", - "voting.currentPhase.fundName": "!!!Fund{currentVotingFundNumber}", + "voting.currentPhase.fundName": "Fund{currentVotingFundNumber}", "voting.info.androidAppButtonUrl": "https://play.google.com/store/apps/details?id=io.iohk.vitvoting", "voting.info.appleAppButtonUrl": "https://apps.apple.com/in/app/catalyst-voting/id1517473397", "voting.info.learnMoreLinkLabel": "もっと知る", @@ -655,11 +655,11 @@ "voting.resultsPhase.viewResultsLinkLabel": "結果を見る", "voting.resultsPhase.viewResultsLinkURL": "https://cardano.ideascale.com/a/pages/results", "voting.snapshotPhase.snapshotDateLabel": "スナップショット日:", - "voting.snapshotPhase.votingDateLabel": "!!!Next voting period:", - "voting.tallyingPhase.endDateLabel": "!!!Voting ended:", - "voting.tallyingPhase.resultsLabel": "!!!Check back for results on:", - "voting.votingOpenPhase.dateLabel": "!!!Voting period open between:", - "voting.votingOpenPhase.instruction": "!!!Use mobile app to vote", + "voting.snapshotPhase.votingDateLabel": "次回投票期間:", + "voting.tallyingPhase.endDateLabel": "投票締め切り:", + "voting.tallyingPhase.resultsLabel": "結果発表:", + "voting.votingOpenPhase.dateLabel": "投票期間:", + "voting.votingOpenPhase.instruction": "モバイルアプリから投票してください", "voting.votingRegistration.chooseWallet.step.continueButtonLabel": "続ける", "voting.votingRegistration.chooseWallet.step.description": "投票に使用できるウォレットは1つだけです。報酬と議決権を最大にするには、残高の一番大きなウォレットを選択してください。", "voting.votingRegistration.chooseWallet.step.errorLegacyWallet": "このウォレットはByronレガシーウォレットであるため、有権者登録に使用できません。", From 454c7e130fff64f81b5749bebfea87f692188bd1 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Mon, 6 Dec 2021 14:27:45 -0300 Subject: [PATCH 15/22] [DDW-796] Enable voting in all env for testing only --- source/renderer/app/stores/SidebarStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/renderer/app/stores/SidebarStore.js b/source/renderer/app/stores/SidebarStore.js index 74dc0116e0..95f1c6dd4b 100644 --- a/source/renderer/app/stores/SidebarStore.js +++ b/source/renderer/app/stores/SidebarStore.js @@ -81,7 +81,7 @@ export default class SidebarStore extends Store { [categories.STAKING_DELEGATION_COUNTDOWN.name]: false, [categories.STAKING.name]: true, [categories.SETTINGS.name]: true, - [categories.VOTING.name]: isMainnet || isDev, + [categories.VOTING.name]: true, [categories.NETWORK_INFO.name]: isFlight, }; From 754d5e41d9cb6c895c85d6402c539a5f471000a2 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Mon, 6 Dec 2021 15:29:44 -0300 Subject: [PATCH 16/22] [DDW-796] Add function for external link --- source/renderer/app/components/voting/voting-info/VotingInfo.js | 1 + 1 file changed, 1 insertion(+) diff --git a/source/renderer/app/components/voting/voting-info/VotingInfo.js b/source/renderer/app/components/voting/voting-info/VotingInfo.js index f3311858a1..6d10bcc0ec 100644 --- a/source/renderer/app/components/voting/voting-info/VotingInfo.js +++ b/source/renderer/app/components/voting/voting-info/VotingInfo.js @@ -51,6 +51,7 @@ const VotingInfo = ({ currentLocale={currentLocale} currentDateFormat={currentDateFormat} currentTimeFormat={currentTimeFormat} + onExternalLinkClick={onExternalLinkClick} />
Date: Mon, 6 Dec 2021 17:27:53 -0300 Subject: [PATCH 17/22] [DDW-796] Review changes --- .../components/voting/VotingUnavailable.js | 4 +- .../voting/voting-info/RegisterToVote.js | 10 ++- .../voting-info/RegisterToVote.messages.js | 5 -- .../voting/voting-info/ResultsPhase.js | 8 +- .../voting-info/ResultsPhase.messages.js | 4 +- .../voting/voting-info/SnapshotPhase.js | 6 +- .../voting/voting-info/TallyingPhase.js | 6 +- ...ase.messages.js => VotingInfo.messages.js} | 6 +- .../voting/voting-info/VotingInfo.scss | 2 +- .../voting/voting-info/VotingPhase.js | 11 +-- .../app/i18n/locales/defaultMessages.json | 76 ++++++++----------- source/renderer/app/i18n/locales/en-US.json | 3 +- source/renderer/app/i18n/locales/ja-JP.json | 3 +- 13 files changed, 63 insertions(+), 81 deletions(-) rename source/renderer/app/components/voting/voting-info/{CurrentPhase.messages.js => VotingInfo.messages.js} (55%) diff --git a/source/renderer/app/components/voting/VotingUnavailable.js b/source/renderer/app/components/voting/VotingUnavailable.js index ab28eef1a6..7cc3c63392 100644 --- a/source/renderer/app/components/voting/VotingUnavailable.js +++ b/source/renderer/app/components/voting/VotingUnavailable.js @@ -2,10 +2,10 @@ import React from 'react'; import { observer } from 'mobx-react'; import { FormattedHTMLMessage } from 'react-intl'; -import BigNumber from 'bignumber.js'; import globalMessages from '../../i18n/global-messages'; import LoadingSpinner from '../widgets/LoadingSpinner'; import styles from './VotingUnavailable.scss'; +import { formattedNumber } from '../../utils/formatters'; type Props = { syncPercentage: number, @@ -19,7 +19,7 @@ const VotingUnavailable = ({ syncPercentage }: Props) => {
diff --git a/source/renderer/app/components/voting/voting-info/RegisterToVote.js b/source/renderer/app/components/voting/voting-info/RegisterToVote.js index 69ce604984..d0109c2cf4 100644 --- a/source/renderer/app/components/voting/voting-info/RegisterToVote.js +++ b/source/renderer/app/components/voting/voting-info/RegisterToVote.js @@ -13,8 +13,10 @@ import { } from '../../../utils/formatters'; import type { Locale } from '../../../../../common/types/locales.types'; import type { Intl } from '../../../types/i18nTypes'; -import styles from './RegisterToVote.scss'; import { messages } from './RegisterToVote.messages'; +import { messages as votingMessages } from './VotingInfo.messages'; +import styles from './RegisterToVote.scss'; +import votingStyles from './VotingInfo.scss'; type Props = { currentLocale: Locale, @@ -46,15 +48,15 @@ function RegisterToVote({ return (
- {intl.formatMessage(messages.name, { - nextVotingFundNumber: NEXT_VOTING_FUND_NUMBER, + {intl.formatMessage(votingMessages.fundName, { + votingFundNumber: NEXT_VOTING_FUND_NUMBER, })} {intl.formatMessage(messages.dateLabel)} {castEndDate} -
+
{intl.formatMessage(messages.stepsTitle)} diff --git a/source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js b/source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js index 0583a97544..bd46ec2849 100644 --- a/source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js +++ b/source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js @@ -2,11 +2,6 @@ import { defineMessages } from 'react-intl'; export const messages = defineMessages({ - name: { - id: 'voting.registerToVote.name', - defaultMessage: '!!!Fund{nextVotingFundNumber}', - description: 'Regiter to fund name', - }, dateLabel: { id: 'voting.registerToVote.dateLabel', defaultMessage: '!!!Snapshot date:', diff --git a/source/renderer/app/components/voting/voting-info/ResultsPhase.js b/source/renderer/app/components/voting/voting-info/ResultsPhase.js index 1a9c839302..23a73778ae 100644 --- a/source/renderer/app/components/voting/voting-info/ResultsPhase.js +++ b/source/renderer/app/components/voting/voting-info/ResultsPhase.js @@ -13,9 +13,9 @@ import { import type { Locale } from '../../../../../common/types/locales.types'; import { ExternalLinkButton } from '../../widgets/ExternalLinkButton'; import type { Intl } from '../../../types/i18nTypes'; -import styles from './CurrentPhase.scss'; import { messages } from './ResultsPhase.messages'; -import { messages as currentPhaseMessages } from './CurrentPhase.messages'; +import { messages as votingMessages } from './VotingInfo.messages'; +import styles from './CurrentPhase.scss'; type Props = { currentLocale: Locale, @@ -47,8 +47,8 @@ function ResultsPhase({ return (

- {intl.formatMessage(currentPhaseMessages.currentFundName, { - currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, + {intl.formatMessage(votingMessages.fundName, { + votingFundNumber: CURRENT_VOTING_FUND_NUMBER, })}

diff --git a/source/renderer/app/components/voting/voting-info/ResultsPhase.messages.js b/source/renderer/app/components/voting/voting-info/ResultsPhase.messages.js index dfa5b68ef6..bf72163c2c 100644 --- a/source/renderer/app/components/voting/voting-info/ResultsPhase.messages.js +++ b/source/renderer/app/components/voting/voting-info/ResultsPhase.messages.js @@ -10,11 +10,11 @@ export const messages = defineMessages({ viewResultsLinkLabel: { id: 'voting.resultsPhase.viewResultsLinkLabel', defaultMessage: '!!!View results', - description: 'View resuls link label for Fund{currentVotingFundNumber}', + description: 'View results link label', }, viewResultsLinkURL: { id: 'voting.resultsPhase.viewResultsLinkURL', defaultMessage: 'https://cardano.ideascale.com/a/pages/results', - description: 'View results from Fund{currentVotingFundNumber}', + description: 'View results link', }, }); diff --git a/source/renderer/app/components/voting/voting-info/SnapshotPhase.js b/source/renderer/app/components/voting/voting-info/SnapshotPhase.js index b9bc0a1bd4..d10fb7f961 100644 --- a/source/renderer/app/components/voting/voting-info/SnapshotPhase.js +++ b/source/renderer/app/components/voting/voting-info/SnapshotPhase.js @@ -16,7 +16,7 @@ import type { Locale } from '../../../../../common/types/locales.types'; import type { Intl } from '../../../types/i18nTypes'; import styles from './CurrentPhase.scss'; import { messages } from './SnapshotPhase.messages'; -import { messages as currentPhase } from './CurrentPhase.messages'; +import { messages as votingMessages } from './VotingInfo.messages'; type Props = { currentLocale: Locale, @@ -56,8 +56,8 @@ function SnapshotPhase({ return (

- {intl.formatMessage(currentPhase.currentFundName, { - currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, + {intl.formatMessage(votingMessages.fundName, { + votingFundNumber: CURRENT_VOTING_FUND_NUMBER, })}

diff --git a/source/renderer/app/components/voting/voting-info/TallyingPhase.js b/source/renderer/app/components/voting/voting-info/TallyingPhase.js index d3b8d2f8cf..ac9dcdda63 100644 --- a/source/renderer/app/components/voting/voting-info/TallyingPhase.js +++ b/source/renderer/app/components/voting/voting-info/TallyingPhase.js @@ -15,7 +15,7 @@ import type { Locale } from '../../../../../common/types/locales.types'; import type { Intl } from '../../../types/i18nTypes'; import styles from './CurrentPhase.scss'; import { messages } from './TallyingPhase.messages'; -import { messages as currentPhaseMessages } from './CurrentPhase.messages'; +import { messages as votingMessages } from './VotingInfo.messages'; type Props = { currentLocale: Locale, @@ -49,8 +49,8 @@ function TallyingPhase({ return (

- {intl.formatMessage(currentPhaseMessages.currentFundName, { - currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, + {intl.formatMessage(votingMessages.fundName, { + votingFundNumber: CURRENT_VOTING_FUND_NUMBER, })}

diff --git a/source/renderer/app/components/voting/voting-info/CurrentPhase.messages.js b/source/renderer/app/components/voting/voting-info/VotingInfo.messages.js similarity index 55% rename from source/renderer/app/components/voting/voting-info/CurrentPhase.messages.js rename to source/renderer/app/components/voting/voting-info/VotingInfo.messages.js index 00dab7ebd9..68d1f55e54 100644 --- a/source/renderer/app/components/voting/voting-info/CurrentPhase.messages.js +++ b/source/renderer/app/components/voting/voting-info/VotingInfo.messages.js @@ -2,9 +2,9 @@ import { defineMessages } from 'react-intl'; export const messages = defineMessages({ - currentFundName: { - id: 'voting.currentPhase.fundName', - defaultMessage: '!!!Fund{currentVotingFundNumber}', + fundName: { + id: 'voting.fundName', + defaultMessage: '!!!Fund{votingFundNumber}', description: 'Current fund name', }, }); diff --git a/source/renderer/app/components/voting/voting-info/VotingInfo.scss b/source/renderer/app/components/voting/voting-info/VotingInfo.scss index 6bfded8591..72ddf75471 100644 --- a/source/renderer/app/components/voting/voting-info/VotingInfo.scss +++ b/source/renderer/app/components/voting/voting-info/VotingInfo.scss @@ -4,7 +4,7 @@ flex: 1 0 0; padding: 20px; - hr { + .separator { border: 1px solid var(--theme-voting-separator-color); border-bottom-width: 0; margin: 20px 0; diff --git a/source/renderer/app/components/voting/voting-info/VotingPhase.js b/source/renderer/app/components/voting/voting-info/VotingPhase.js index 01138b635c..64f4d875a2 100644 --- a/source/renderer/app/components/voting/voting-info/VotingPhase.js +++ b/source/renderer/app/components/voting/voting-info/VotingPhase.js @@ -13,9 +13,10 @@ import { } from '../../../utils/formatters'; import type { Locale } from '../../../../../common/types/locales.types'; import type { Intl } from '../../../types/i18nTypes'; -import styles from './CurrentPhase.scss'; import { messages } from './VotingPhase.messages'; -import { messages as currentPhase } from './CurrentPhase.messages'; +import { messages as votingMessages } from './VotingInfo.messages'; +import styles from './CurrentPhase.scss'; +import votingStyles from './VotingInfo.scss'; type Props = { currentLocale: Locale, @@ -49,8 +50,8 @@ function VotingPhase({ return (

- {intl.formatMessage(currentPhase.currentFundName, { - currentVotingFundNumber: CURRENT_VOTING_FUND_NUMBER, + {intl.formatMessage(votingMessages.fundName, { + votingFundNumber: CURRENT_VOTING_FUND_NUMBER, })}

@@ -61,7 +62,7 @@ function VotingPhase({ {startDate} – {endDate}
-
+
{intl.formatMessage(messages.instruction)} diff --git a/source/renderer/app/i18n/locales/defaultMessages.json b/source/renderer/app/i18n/locales/defaultMessages.json index 41a26820ab..6dde82ee1d 100644 --- a/source/renderer/app/i18n/locales/defaultMessages.json +++ b/source/renderer/app/i18n/locales/defaultMessages.json @@ -7991,25 +7991,6 @@ ], "path": "source/renderer/app/components/voting/voting-info/AppStore.messages.json" }, - { - "descriptors": [ - { - "defaultMessage": "!!!Fund{currentVotingFundNumber}", - "description": "Current fund name", - "end": { - "column": 3, - "line": 9 - }, - "file": "source/renderer/app/components/voting/voting-info/CurrentPhase.messages.js", - "id": "voting.currentPhase.fundName", - "start": { - "column": 19, - "line": 5 - } - } - ], - "path": "source/renderer/app/components/voting/voting-info/CurrentPhase.messages.json" - }, { "descriptors": [ { @@ -8087,32 +8068,18 @@ }, { "descriptors": [ - { - "defaultMessage": "!!!Fund{nextVotingFundNumber}", - "description": "Regiter to fund name", - "end": { - "column": 3, - "line": 9 - }, - "file": "source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js", - "id": "voting.registerToVote.name", - "start": { - "column": 8, - "line": 5 - } - }, { "defaultMessage": "!!!Snapshot date:", "description": "Voting info snapshot date label", "end": { "column": 3, - "line": 14 + "line": 9 }, "file": "source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js", "id": "voting.registerToVote.dateLabel", "start": { "column": 13, - "line": 10 + "line": 5 } }, { @@ -8120,13 +8087,13 @@ "description": "Steps to follow title", "end": { "column": 3, - "line": 19 + "line": 14 }, "file": "source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js", "id": "voting.registerToVote.stepsTitle", "start": { "column": 14, - "line": 15 + "line": 10 } }, { @@ -8134,13 +8101,13 @@ "description": "First step to follow in order to vote", "end": { "column": 3, - "line": 24 + "line": 19 }, "file": "source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js", "id": "voting.registerToVote.step1CheckBoxLabel", "start": { "column": 22, - "line": 20 + "line": 15 } }, { @@ -8148,13 +8115,13 @@ "description": "Second step to follow in order to vote", "end": { "column": 3, - "line": 30 + "line": 25 }, "file": "source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js", "id": "voting.registerToVote.step2CheckBoxLabel", "start": { "column": 22, - "line": 25 + "line": 20 } }, { @@ -8162,13 +8129,13 @@ "description": "Button Label for voting registration steps", "end": { "column": 3, - "line": 35 + "line": 30 }, "file": "source/renderer/app/components/voting/voting-info/RegisterToVote.messages.js", "id": "voting.registerToVote.registerToVoteButtonLabel", "start": { "column": 15, - "line": 31 + "line": 26 } } ], @@ -8192,7 +8159,7 @@ }, { "defaultMessage": "!!!View results", - "description": "View resuls link label for Fund{currentVotingFundNumber}", + "description": "View results link label", "end": { "column": 3, "line": 14 @@ -8206,7 +8173,7 @@ }, { "defaultMessage": "https://cardano.ideascale.com/a/pages/results", - "description": "View results from Fund{currentVotingFundNumber}", + "description": "View results link", "end": { "column": 3, "line": 19 @@ -8287,6 +8254,25 @@ ], "path": "source/renderer/app/components/voting/voting-info/TallyingPhase.messages.json" }, + { + "descriptors": [ + { + "defaultMessage": "!!!Fund{votingFundNumber}", + "description": "Current fund name", + "end": { + "column": 3, + "line": 9 + }, + "file": "source/renderer/app/components/voting/voting-info/VotingInfo.messages.js", + "id": "voting.fundName", + "start": { + "column": 12, + "line": 5 + } + } + ], + "path": "source/renderer/app/components/voting/voting-info/VotingInfo.messages.json" + }, { "descriptors": [ { diff --git a/source/renderer/app/i18n/locales/en-US.json b/source/renderer/app/i18n/locales/en-US.json index 2f6204776d..525b0e7ffd 100755 --- a/source/renderer/app/i18n/locales/en-US.json +++ b/source/renderer/app/i18n/locales/en-US.json @@ -637,7 +637,7 @@ "voting.catalystFooterLinks.community": "Community Chat", "voting.catalystFooterLinks.newsletter": "Newsletter", "voting.catalystFooterLinks.projects": "Projects", - "voting.currentPhase.fundName": "Fund{currentVotingFundNumber}", + "voting.fundName": "Fund{votingFundNumber}", "voting.info.androidAppButtonUrl": "https://play.google.com/store/apps/details?id=io.iohk.vitvoting", "voting.info.appleAppButtonUrl": "https://apps.apple.com/in/app/catalyst-voting/id1517473397", "voting.info.learnMoreLinkLabel": "Learn more", @@ -646,7 +646,6 @@ "voting.info.noWallets.headLine": "Voting registration for Fund{nextVotingFundNumber} is not available as you currently do not have any Shelley-compatible wallets.", "voting.info.noWallets.instructions": "Create a new wallet and transfer a minimum of {minVotingFunds} ADA (or restore an existing wallet with funds), then return here to register for voting.", "voting.registerToVote.dateLabel": "Snapshot date:", - "voting.registerToVote.name": "Fund{nextVotingFundNumber}", "voting.registerToVote.registerToVoteButtonLabel": "Register to vote", "voting.registerToVote.step1CheckBoxLabel": "Download the Catalyst Voting app on your smartphone", "voting.registerToVote.step2CheckBoxLabel": "Ensure that you register and hold the necessary 500 ADA at the time of the snapshot.", diff --git a/source/renderer/app/i18n/locales/ja-JP.json b/source/renderer/app/i18n/locales/ja-JP.json index a73361dc39..5376f37759 100755 --- a/source/renderer/app/i18n/locales/ja-JP.json +++ b/source/renderer/app/i18n/locales/ja-JP.json @@ -637,7 +637,7 @@ "voting.catalystFooterLinks.community": "コミュニティチャット", "voting.catalystFooterLinks.newsletter": "ニュースレター", "voting.catalystFooterLinks.projects": "プロジェクト", - "voting.currentPhase.fundName": "Fund{currentVotingFundNumber}", + "voting.fundName": "Fund{votingFundNumber}", "voting.info.androidAppButtonUrl": "https://play.google.com/store/apps/details?id=io.iohk.vitvoting", "voting.info.appleAppButtonUrl": "https://apps.apple.com/in/app/catalyst-voting/id1517473397", "voting.info.learnMoreLinkLabel": "もっと知る", @@ -646,7 +646,6 @@ "voting.info.noWallets.headLine": "現在Shelley対応のウォレットがないため、Fund{nextVotingFundNumber}の有権者登録はできません。", "voting.info.noWallets.instructions": "ウォレットを作成し、そこに{minVotingFunds} ADA以上を移してから(または既存の資金入りウォレットを復元してから)、改めてここで有権者登録を行ってください。", "voting.registerToVote.dateLabel": "スナップショット日:", - "voting.registerToVote.name": "Fund{nextVotingFundNumber}", "voting.registerToVote.registerToVoteButtonLabel": "有権者登録をする", "voting.registerToVote.step1CheckBoxLabel": "スマートフォンにCatalyst Votingアプリをダウンロードします", "voting.registerToVote.step2CheckBoxLabel": "スナップショット実施の時点で、登録を済ませ、500ADAを保有していてください", From 3d6948fe034ce6d1c7c5cb0399fa23e64a77f386 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Tue, 7 Dec 2021 14:21:49 -0300 Subject: [PATCH 18/22] [DDW-796] VotingStore unit test --- .../renderer/app/stores/VotingStore.spec.js | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 source/renderer/app/stores/VotingStore.spec.js diff --git a/source/renderer/app/stores/VotingStore.spec.js b/source/renderer/app/stores/VotingStore.spec.js new file mode 100644 index 0000000000..b97ad1a085 --- /dev/null +++ b/source/renderer/app/stores/VotingStore.spec.js @@ -0,0 +1,40 @@ +// @flow +import type { Api } from '../api/index'; +import type { ActionsMap } from '../actions/index'; +import VotingStore, { FundPhases } from './VotingStore'; +import { + VOTING_CAST_END_DATE, + VOTING_CAST_START_DATE, + VOTING_RESULTS_DATE, + VOTING_SNAPSHOT_DATE, +} from '../config/votingConfig'; + +describe('VotingStore', () => { + const api: Api = ({ + ada: jest.fn(), + }: any); + + const actions: ActionsMap = (jest.fn(): any); + + const cases = [ + [new Date(VOTING_SNAPSHOT_DATE.getTime() - 60000), FundPhases.SNAPSHOT], + [VOTING_SNAPSHOT_DATE, FundPhases.SNAPSHOT], + [new Date(VOTING_CAST_START_DATE.getTime() - 60000), FundPhases.SNAPSHOT], + [VOTING_CAST_START_DATE, FundPhases.VOTING], + [new Date(VOTING_CAST_END_DATE.getTime() - 60000), FundPhases.VOTING], + [VOTING_CAST_END_DATE, FundPhases.TALLYING], + [new Date(VOTING_RESULTS_DATE.getTime() - 60000), FundPhases.TALLYING], + [VOTING_RESULTS_DATE, FundPhases.RESULTS], + ]; + + test.each(cases)( + `should have correct fund phase for date %s - %s phase`, + (date, expected) => { + const votingStore = new VotingStore(api, actions); + + votingStore._checkFundPhase(date); + + expect(votingStore.fundPhase).toEqual(expected); + } + ); +}); From a9bf930dc1f0193765fe49785184b67e5a646d7b Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Tue, 7 Dec 2021 14:52:13 -0300 Subject: [PATCH 19/22] [DDW-796] Update story --- storybook/stories/voting/Voting.stories.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/storybook/stories/voting/Voting.stories.js b/storybook/stories/voting/Voting.stories.js index b71c23d959..2618a07531 100644 --- a/storybook/stories/voting/Voting.stories.js +++ b/storybook/stories/voting/Voting.stories.js @@ -2,7 +2,7 @@ import React from 'react'; import { storiesOf } from '@storybook/react'; import { action } from '@storybook/addon-actions'; -import { withKnobs, boolean, number } from '@storybook/addon-knobs'; +import { withKnobs, boolean, number, select } from '@storybook/addon-knobs'; import BigNumber from 'bignumber.js'; import StoryDecorator from '../_support/StoryDecorator'; import StoryProvider from '../_support/StoryProvider'; @@ -12,6 +12,7 @@ import VotingRegistrationStepsConfirm from '../../../source/renderer/app/compone import VotingRegistrationStepsEnterPinCode from '../../../source/renderer/app/components/voting/voting-registration-wizard-steps/VotingRegistrationStepsEnterPinCode'; import VotingRegistrationStepsQrCode from '../../../source/renderer/app/components/voting/voting-registration-wizard-steps/VotingRegistrationStepsQrCode'; import VotingInfo from '../../../source/renderer/app/components/voting/voting-info/VotingInfo'; +import { FundPhases } from '../../../source/renderer/app/stores/VotingStore'; import { VotingFooterLinks } from '../../../source/renderer/app/components/voting/VotingFooterLinks'; import { LANGUAGE_OPTIONS, @@ -174,6 +175,12 @@ storiesOf('Voting|Voting Info', module) .add('Voting Info', () => ( Date: Tue, 7 Dec 2021 16:17:11 -0300 Subject: [PATCH 20/22] [DDW-796] Test only --- source/renderer/app/App.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/renderer/app/App.js b/source/renderer/app/App.js index 211f523247..6e993ebaca 100755 --- a/source/renderer/app/App.js +++ b/source/renderer/app/App.js @@ -1,6 +1,7 @@ // @flow import React, { Component, Fragment } from 'react'; import { Provider, observer } from 'mobx-react'; +import { spy } from 'mobx'; import { ThemeProvider } from 'react-polymorph/lib/components/ThemeProvider'; import { SimpleSkins } from 'react-polymorph/lib/skins/simple'; import { SimpleDefaults } from 'react-polymorph/lib/themes/simple'; @@ -28,6 +29,9 @@ export default class App extends Component<{ history: Object, }> { componentDidMount() { + spy((event) => { + console.log(event); + }); // Loads app's global environment variables into AppStore via ipc this.props.actions.app.initAppEnvironment.trigger(); } From ad1734a59fdd63161999b128794058e67caf16c7 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Wed, 8 Dec 2021 11:40:56 -0300 Subject: [PATCH 21/22] Revert "[DDW-796] Test only" This reverts commit 3140b6514b7eb8a15dcc85e19e727c69a7f9122d. --- source/renderer/app/App.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/source/renderer/app/App.js b/source/renderer/app/App.js index 6e993ebaca..211f523247 100755 --- a/source/renderer/app/App.js +++ b/source/renderer/app/App.js @@ -1,7 +1,6 @@ // @flow import React, { Component, Fragment } from 'react'; import { Provider, observer } from 'mobx-react'; -import { spy } from 'mobx'; import { ThemeProvider } from 'react-polymorph/lib/components/ThemeProvider'; import { SimpleSkins } from 'react-polymorph/lib/skins/simple'; import { SimpleDefaults } from 'react-polymorph/lib/themes/simple'; @@ -29,9 +28,6 @@ export default class App extends Component<{ history: Object, }> { componentDidMount() { - spy((event) => { - console.log(event); - }); // Loads app's global environment variables into AppStore via ipc this.props.actions.app.initAppEnvironment.trigger(); } From 83034294b6147159385689c2c369e4cae94e6145 Mon Sep 17 00:00:00 2001 From: Lucas Araujo Date: Wed, 8 Dec 2021 11:45:11 -0300 Subject: [PATCH 22/22] Revert "[DDW-796] Enable voting in all env for testing only" This reverts commit 454c7e130fff64f81b5749bebfea87f692188bd1. --- source/renderer/app/stores/SidebarStore.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/renderer/app/stores/SidebarStore.js b/source/renderer/app/stores/SidebarStore.js index 95f1c6dd4b..74dc0116e0 100644 --- a/source/renderer/app/stores/SidebarStore.js +++ b/source/renderer/app/stores/SidebarStore.js @@ -81,7 +81,7 @@ export default class SidebarStore extends Store { [categories.STAKING_DELEGATION_COUNTDOWN.name]: false, [categories.STAKING.name]: true, [categories.SETTINGS.name]: true, - [categories.VOTING.name]: true, + [categories.VOTING.name]: isMainnet || isDev, [categories.NETWORK_INFO.name]: isFlight, };