on master help sign in
ux: keyfile button gives helpful feedback
commitfe8db0a548f884560da8030e65b566afeb670993 authortomholford <tomholford@users.noreply.github.com> dateWed 23 Feb 2022, 12:49 (5 years ago) parent0b34ca9
2 files changed+34−10
src/components/L2/Window/HeaderPane.scss+5 src/views/UrbitOS/Home.tsx+29−10
src/components/L2/Window/HeaderPane.scss+5
@@ -33,6 +33,11 @@
3333 padding: 8px 16px;
3434 font-family: $default-font;
3535
36+ &.keyfile-unavailable {
37+ height: unset;
38+ background-color: rgba(0, 0, 0, 0.6);
39+ }
40+
3641 &:hover {
3742 opacity: 0.8;
3843 }
src/views/UrbitOS/Home.tsx+29−10
@@ -16,6 +16,7 @@ import CopiableWithTooltip from 'components/copiable/CopiableWithTooltip';
1616import './UrbitOS.scss';
1717import Modal from 'components/L2/Modal';
1818import { useRollerStore } from 'store/rollerStore';
19+import WithTooltip from 'components/WithTooltip';
1920
2021export default function UrbitOSHome() {
2122 const { point } = useRollerStore();
@@ -42,22 +43,40 @@ export default function UrbitOSHome() {
4243 names,
4344 ]);
4445
45− const { code, download } = useSingleKeyfileGenerator({});
46+ const { available, code, download, generating } = useSingleKeyfileGenerator(
47+ {}
48+ );
49+ const keyfileAvailable = available && !generating;
50+
51+ const headerButton = () => {
52+ if (!hasSetNetworkKeys) {
53+ return null;
54+ }
55+
56+ if (generating) {
57+ return <Box className="header-button keyfile">Generating...</Box>;
58+ }
59+
60+ return keyfileAvailable ? (
61+ <Button className="header-button keyfile" onClick={download}>
62+ <KeyfileIcon />
63+ Download Keyfile
64+ </Button>
65+ ) : (
66+ <WithTooltip content="Either the key was derived non-deterministically, or try Login > Use Legacy Compatibility">
67+ <Box className="header-button keyfile-unavailable">
68+ Keyfile Unavailable
69+ </Box>
70+ </WithTooltip>
71+ );
72+ };
4673
4774 return (
4875 <Window className="os-home">
4976 <HeaderPane>
5077 <Row className="header-row">
5178 <h5>OS</h5>
52− {hasSetNetworkKeys && (
53− <Button
54− className="header-button keyfile"
55− disabled={!hasSetNetworkKeys}
56− onClick={download}>
57− <KeyfileIcon />
58− Download Keyfile
59− </Button>
60− )}
79+ {headerButton()}
6180 </Row>
6281 </HeaderPane>
6382 <BodyPane>