Skip to content

Commit

Permalink
Rewrite oracle redirect dialog to disclosure
Browse files Browse the repository at this point in the history
  • Loading branch information
aidenaio committed Apr 5, 2023
1 parent 1ddfa99 commit f2ec015
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 26 deletions.
20 changes: 13 additions & 7 deletions renderer/pages/oracles/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ export default function ViewVotingPage() {
})
}, [onCloseCampaignDisclosure, redirect, successToast, t])

const redirectDisclosure = useDisclosure()
const [redirectUrl, setRedirectUrl] = React.useState()

return (
<>
<Layout syncing={syncing} offline={offline}>
Expand Down Expand Up @@ -343,7 +346,8 @@ export default function ViewVotingPage() {
>
<Linkify
onClick={(url) => {
send('FOLLOW_LINK', {url})
setRedirectUrl(url)
redirectDisclosure.onOpen()
}}
>
{desc}
Expand Down Expand Up @@ -1105,20 +1109,22 @@ export default function ViewVotingPage() {
/>
)}

<Dialog
isOpen={eitherIdleState('redirecting')}
onClose={() => send('CANCEL')}
>
<Dialog {...redirectDisclosure}>
<DialogHeader>{t('Leaving Idena')}</DialogHeader>
<DialogBody>
<Text>{t(`You're about to leave Idena.`)}</Text>
<Text>{t(`Are you sure?`)}</Text>
</DialogBody>
<DialogFooter>
<SecondaryButton onClick={() => send('CANCEL')}>
<SecondaryButton onClick={redirectDisclosure.onClose}>
{t('Cancel')}
</SecondaryButton>
<PrimaryButton onClick={() => send('CONTINUE')}>
<PrimaryButton
onClick={() => {
global.openExternal(redirectUrl)
redirectDisclosure.onClose()
}}
>
{t('Continue')}
</PrimaryButton>
</DialogFooter>
Expand Down
20 changes: 1 addition & 19 deletions renderer/screens/oracles/machines.js
Original file line number Diff line number Diff line change
Expand Up @@ -1091,25 +1091,8 @@ export const createViewVotingMachine = (id, epoch, address) =>
CANCEL: 'hist',
},
},
redirecting: {
entry: [
assign({
redirectUrl: (_, {url}) => url,
}),
log(),
],
on: {
CONTINUE: {
target: 'hist',
actions: [
({redirectUrl}) => global.openExternal(redirectUrl),
],
},
CANCEL: 'hist',
},
},
hist: {
type: 'hist',
type: 'history',
},
},
on: {
Expand Down Expand Up @@ -1140,7 +1123,6 @@ export const createViewVotingMachine = (id, epoch, address) =>
},
REVIEW_PROLONG_VOTING: 'prolong',
REVIEW_FINISH_VOTING: 'finish',
FOLLOW_LINK: '.redirecting',
},
},
review: {
Expand Down

0 comments on commit f2ec015

Please sign in to comment.