-
Notifications
You must be signed in to change notification settings - Fork 366
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
refactor: [M3-6492, M3-6315] - React Query - Linode Detail - Backups #9079
Merged
bnussman-akamai
merged 18 commits into
linode:develop
from
bnussman-akamai:M3-6492-react-query-linode-backups
May 8, 2023
Merged
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
5d1d35a
initial refactor
bnussman 6c442b2
only enable query if we need it
bnussman 81968a9
update e2e tests
bnussman 9c26025
improve the UX of `RestoreToLinodeDrawer.tsx`
bnussman c329a5b
simplify error logic for backups schedule
bnussman 395e302
minor improvements and add unit testing
bnussman 8d495cb
fix typo
bnussman 403dd4e
Merge branch 'develop' into M3-6492-react-query-linode-backups
bnussman 5b2bbe7
add some more testing
bnussman ef2aed1
clean up styles and break things out into components
bnussman 8d9e716
re-add some styles and clean up
bnussman 45147de
break up `LinodeBackups.tsx` into components
bnussman 93ce6a4
adding unit tests for `<ScheduleSettings />`
bnussman 3a0685e
small test improvement
bnussman 961101c
fix faling test
bnussman 4928ea5
more basic testing
bnussman 99d9e2a
Merge branch 'develop' into M3-6492-react-query-linode-backups
bnussman 13bd318
run `tss-react` migation on backups related files
bnussman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/manager/src/features/linodes/LinodesDetail/LinodeBackup/CancelBackupsDialog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import * as React from 'react'; | ||
import { useSnackbar } from 'notistack'; | ||
import { resetEventsPolling } from 'src/eventsPolling'; | ||
import { useLinodeBackupsCancelMutation } from 'src/queries/linodes/backups'; | ||
import { sendBackupsDisabledEvent } from 'src/utilities/ga'; | ||
import Typography from 'src/components/core/Typography'; | ||
import { ConfirmationDialog } from 'src/components/ConfirmationDialog/ConfirmationDialog'; | ||
import ActionsPanel from 'src/components/ActionsPanel/ActionsPanel'; | ||
import Button from 'src/components/Button/Button'; | ||
|
||
interface Props { | ||
isOpen: boolean; | ||
onClose: () => void; | ||
linodeId: number; | ||
} | ||
|
||
export const CancelBackupsDialog = (props: Props) => { | ||
const { isOpen, onClose, linodeId } = props; | ||
const { enqueueSnackbar } = useSnackbar(); | ||
|
||
const { | ||
mutateAsync: cancelBackups, | ||
error, | ||
isLoading, | ||
} = useLinodeBackupsCancelMutation(linodeId); | ||
|
||
const onCancelBackups = async () => { | ||
await cancelBackups(); | ||
enqueueSnackbar('Backups are being canceled for this Linode', { | ||
variant: 'info', | ||
}); | ||
onClose(); | ||
resetEventsPolling(); | ||
sendBackupsDisabledEvent(); | ||
}; | ||
|
||
return ( | ||
<ConfirmationDialog | ||
open={isOpen} | ||
onClose={onClose} | ||
title="Confirm Cancellation" | ||
error={error?.[0].reason} | ||
actions={ | ||
<ActionsPanel style={{ padding: 0 }}> | ||
<Button | ||
buttonType="secondary" | ||
onClick={onClose} | ||
data-qa-cancel-cancel | ||
> | ||
Close | ||
</Button> | ||
<Button | ||
buttonType="primary" | ||
onClick={onCancelBackups} | ||
loading={isLoading} | ||
data-qa-confirm-cancel | ||
> | ||
Cancel Backups | ||
</Button> | ||
</ActionsPanel> | ||
} | ||
> | ||
<Typography> | ||
Canceling backups associated with this Linode will delete all existing | ||
backups. Are you sure? | ||
</Typography> | ||
<Typography style={{ marginTop: 12 }}> | ||
<strong>Note: </strong> | ||
Once backups for this Linode have been canceled, you cannot re-enable | ||
them for 24 hours. | ||
</Typography> | ||
</ConfirmationDialog> | ||
); | ||
}; |
50 changes: 50 additions & 0 deletions
50
packages/manager/src/features/linodes/LinodesDetail/LinodeBackup/CaptureSnapshot.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import * as React from 'react'; | ||
import { renderWithTheme } from 'src/utilities/testHelpers'; | ||
import { rest, server } from 'src/mocks/testServer'; | ||
import { linodeFactory } from 'src/factories/linodes'; | ||
import { CaptureSnapshot } from './CaptureSnapshot'; | ||
import userEvent from '@testing-library/user-event'; | ||
|
||
describe('CaptureSnapshot', () => { | ||
it('renders heading and copy', async () => { | ||
server.use( | ||
rest.get('*/linode/instances/1', (req, res, ctx) => { | ||
return res( | ||
ctx.json(linodeFactory.build({ id: 1, backups: { enabled: true } })) | ||
); | ||
}) | ||
); | ||
|
||
const { getByText } = renderWithTheme( | ||
<CaptureSnapshot linodeId={1} isReadOnly={false} /> | ||
); | ||
|
||
getByText('Manual Snapshot'); | ||
getByText( | ||
/You can make a manual backup of your Linode by taking a snapshot./ | ||
); | ||
}); | ||
it('a confirmation dialog should open when you attempt to take a snapshot', async () => { | ||
server.use( | ||
rest.get('*/linode/instances/1', (req, res, ctx) => { | ||
return res( | ||
ctx.json(linodeFactory.build({ id: 1, backups: { enabled: true } })) | ||
); | ||
}) | ||
); | ||
|
||
const { getByLabelText, getByText } = renderWithTheme( | ||
<CaptureSnapshot linodeId={1} isReadOnly={false} /> | ||
); | ||
|
||
userEvent.type(getByLabelText('Name Snapshot'), 'my-linode-snapshot'); | ||
|
||
userEvent.click(getByText('Take Snapshot')); | ||
|
||
expect( | ||
getByText( | ||
/Taking a snapshot will back up your Linode in its current state, overriding your previous snapshot. Are you sure?/ | ||
) | ||
).toBeVisible(); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor: Did we want to do
handleCancelBackups
?