-
Notifications
You must be signed in to change notification settings - Fork 204
feat(app): create DeleteRecordsModal #21856
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e68bf59
feat(app): create DeleteRecordsModal
ncdiehl11 13476a2
refactor DeleteRecordsModal variant to defined type
ncdiehl11 2e715a1
wire up modal in RecentProtocolRuns for smoke testing
ncdiehl11 5ff2c40
refactor RecentProtocolRuns
ncdiehl11 2d0c00a
use design tokens in CSS module
ncdiehl11 2e49b8d
move logic for DeleteRecordsModal content to IIF inside component
ncdiehl11 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 hidden or 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
50 changes: 50 additions & 0 deletions
50
app/src/organisms/Desktop/Devices/DeleteRecordsModal/__tests__/DeleteRecordsModal.test.tsx
This file contains hidden or 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 { screen } from '@testing-library/react' | ||
| import { describe, it, vi } from 'vitest' | ||
|
|
||
| import { renderWithProviders } from '/app/__testing-utils__' | ||
| import { i18n } from '/app/i18n' | ||
|
|
||
| import { DeleteRecordsModal } from '..' | ||
|
|
||
| const render = ( | ||
| type: React.ComponentProps<typeof DeleteRecordsModal>['type'] | ||
| ) => | ||
| renderWithProviders( | ||
| <DeleteRecordsModal type={type} onClose={vi.fn()} onConfirm={vi.fn()} />, | ||
| { i18nInstance: i18n } | ||
| ) | ||
|
|
||
| describe('DeleteRecordsModal', () => { | ||
| it('renders allRuns copy', () => { | ||
| render('allRuns') | ||
| screen.getByText('Delete all protocol run records?') | ||
| screen.getByText( | ||
| 'Deleting all protocol run records will permanently remove them from the robot, along with all associated files. This action cannot be undone.' | ||
| ) | ||
| screen.getByText( | ||
| 'We recommend downloading all protocol files before proceeding.' | ||
| ) | ||
| }) | ||
|
|
||
| it('renders selectedRuns copy', () => { | ||
| render('selectedRuns') | ||
| screen.getByText('Delete selected protocol run records?') | ||
| screen.getByText( | ||
| 'Deleting the selected protocol run records will permanently remove them from the robot, along with all associated files. This action cannot be undone.' | ||
| ) | ||
| screen.getByText( | ||
| 'We recommend downloading all protocol files before proceeding.' | ||
| ) | ||
| }) | ||
|
|
||
| it('renders allLogs copy', () => { | ||
| render('allLogs') | ||
| screen.getByText('Delete all logs?') | ||
| screen.getByText( | ||
| 'Deleting all logs will permanently remove them from the robot. This action cannot be undone.' | ||
| ) | ||
| screen.getByText( | ||
| 'We recommend downloading all log files before proceeding.' | ||
| ) | ||
| }) | ||
| }) |
19 changes: 19 additions & 0 deletions
19
app/src/organisms/Desktop/Devices/DeleteRecordsModal/deleterecordsmodal.module.css
This file contains hidden or 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,19 @@ | ||
| .button_row { | ||
| display: flex; | ||
| height: 100%; | ||
| align-items: center; | ||
| justify-content: flex-end; | ||
| gap: var(--spacing-8); | ||
| } | ||
|
|
||
| .description { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--spacing-8); | ||
| } | ||
|
|
||
| .modal_content { | ||
| display: flex; | ||
| flex-direction: column; | ||
| gap: var(--spacing-24); | ||
| } |
80 changes: 80 additions & 0 deletions
80
app/src/organisms/Desktop/Devices/DeleteRecordsModal/index.tsx
This file contains hidden or 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,80 @@ | ||
| import { useTranslation } from 'react-i18next' | ||
|
|
||
| import { | ||
| AlertPrimaryButton, | ||
| Modal, | ||
| SecondaryButton, | ||
| StyledText, | ||
| } from '@opentrons/components' | ||
|
|
||
| import styles from './deleterecordsmodal.module.css' | ||
|
|
||
| import type { DeleteRecordsType } from './types' | ||
|
|
||
| interface DeleteRecordsModalProps { | ||
| onClose: () => void | ||
| onConfirm: () => void | ||
| type: DeleteRecordsType | ||
| } | ||
|
|
||
| export function DeleteRecordsModal( | ||
| props: DeleteRecordsModalProps | ||
| ): JSX.Element { | ||
| const { onClose, onConfirm, type } = props | ||
| const { t } = useTranslation(['device_details', 'shared']) | ||
| const { title, description, recommendation } = ((): { | ||
| title: string | ||
| description: string | ||
| recommendation: string | ||
| } => { | ||
| switch (type) { | ||
| case 'allRuns': | ||
| return { | ||
| title: t('device_details:delete_all_run_records'), | ||
| description: t('device_details:delete_all_run_records_description'), | ||
| recommendation: t( | ||
| 'device_details:delete_all_run_records_recommendation' | ||
| ), | ||
| } | ||
| case 'selectedRuns': | ||
| return { | ||
| title: t('device_details:delete_selected_run_records'), | ||
| description: t( | ||
| 'device_details:delete_selected_run_records_description' | ||
| ), | ||
| recommendation: t( | ||
| 'device_details:delete_selected_run_records_recommendation' | ||
| ), | ||
| } | ||
| case 'allLogs': | ||
| return { | ||
| title: t('device_details:delete_all_logs'), | ||
| description: t('device_details:delete_all_logs_description'), | ||
| recommendation: t('device_details:delete_all_logs_recommendation'), | ||
| } | ||
| } | ||
| })() | ||
|
|
||
| return ( | ||
| <Modal type="warning" title={title} onClose={onClose}> | ||
| <div className={styles.modal_content}> | ||
| <div className={styles.description}> | ||
| <StyledText desktopStyle="bodyDefaultRegular"> | ||
| {description} | ||
| </StyledText> | ||
| <StyledText desktopStyle="bodyDefaultRegular"> | ||
| {recommendation} | ||
| </StyledText> | ||
| </div> | ||
| <div className={styles.button_row}> | ||
| <SecondaryButton onClick={onClose}> | ||
| {t('shared:cancel')} | ||
| </SecondaryButton> | ||
| <AlertPrimaryButton onClick={onConfirm}> | ||
| {t('delete_all')} | ||
| </AlertPrimaryButton> | ||
| </div> | ||
| </div> | ||
| </Modal> | ||
| ) | ||
| } |
This file contains hidden or 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 @@ | ||
| export type DeleteRecordsType = 'allRuns' | 'selectedRuns' | 'allLogs' | ||
5 changes: 0 additions & 5 deletions
5
app/src/organisms/Desktop/Devices/HistoricalProtocolRun.module.css
This file was deleted.
Oops, something went wrong.
188 changes: 0 additions & 188 deletions
188
app/src/organisms/Desktop/Devices/RecentProtocolRuns.tsx
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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
Oops, something went wrong.
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.
nit
defining this in the modal component?
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.
I can do that, but I moved the hook that also uses this type to its own file, so I thought it might be better to have a
types.tsfile