Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: CP-9166 add tooltip and disabled button #47

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/localization/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@
"The secret key can be assigned by the Fireblocks workspace admin": "The secret key can be assigned by the Fireblocks workspace admin",
"The transaction has been reverted": "The transaction has been reverted",
"The transaction timed out": "The transaction timed out",
"There are invalid fields in the form": "There are invalid fields in the form",
"There is no search result.": "There is no search result.",
"There was a problem with the transfer": "There was a problem with the transfer",
"These are the addresses derived from your Keystone device": "These are the addresses derived from your Keystone device",
Expand Down
41 changes: 26 additions & 15 deletions src/pages/Networks/AddNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
Scrollbars,
ScrollbarsRef,
Stack,
Tooltip,
Typography,
styled,
toast,
Expand Down Expand Up @@ -68,6 +69,9 @@ export const AddNetwork = () => {
);

useEffect(() => {
if (Object.keys(pageHistoryData).length) {
setShowErrors(true);
}
setNetwork({ ...defaultNetworkValues, ...pageHistoryData });
}, [defaultNetworkValues, pageHistoryData]);

Expand Down Expand Up @@ -147,25 +151,32 @@ export const AddNetwork = () => {
size="large"
fullWidth
onClick={history.goBack}
sx={{ px: 0 }}
>
{t('Cancel')}
</Button>
<Button
color="primary"
data-testid="add-network-save"
size="large"
fullWidth
disabled={isSaving}
isLoading={isSaving}
onClick={() => {
setShowErrors(true);
if (isFormValid) {
handleSave();
}
}}
<Tooltip
title={!isFormValid && t('There are invalid fields in the form')}
sx={{ boxSizing: 'border-box', width: '100%' }}
>
{t('Save')}
</Button>
<Button
color="primary"
data-testid="add-network-save"
size="large"
fullWidth
disabled={!isFormValid || isSaving}
isLoading={isSaving}
onClick={() => {
setShowErrors(true);
if (isFormValid) {
handleSave();
}
}}
sx={{ px: 0 }}
>
{t('Save')}
</Button>
</Tooltip>
</Stack>
</Stack>
);
Expand Down
Loading