-
Notifications
You must be signed in to change notification settings - Fork 0
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
6913 lock version conflict mitigation #986
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
2288a79
bugfix mishandling cancelText Prop
ttoomey e7096f4
implement cross-tab version sync/refresh
ttoomey 6a631e9
6913
ttoomey 09c4cd4
6913-cross-tab-sync
ttoomey 152c6d3
cleanups
ttoomey 7e863d3
language
ttoomey 69d2b7d
simplify
ttoomey 65b9293
Merge branch 'release-144' into 6913-cross-tab-sync
gigxz 5808a54
Update LocalVersionCoordinationPrompt style
gigxz 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import { Meta, StoryObj } from '@storybook/react'; | ||
import SnackbarAlert from './SnackbarAlert'; | ||
|
||
const meta: Meta<typeof SnackbarAlert> = { | ||
component: SnackbarAlert, | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
// Add controls for commonly adjusted props | ||
argTypes: { | ||
open: { | ||
control: 'boolean', | ||
description: 'Controls the visibility of the snackbar', | ||
}, | ||
title: { | ||
control: 'text', | ||
description: 'Optional title text for the alert', | ||
}, | ||
children: { | ||
control: 'text', | ||
description: 'Main content of the alert', | ||
}, | ||
alertProps: { | ||
control: 'object', | ||
description: 'Props passed to the underlying MUI Alert component', | ||
}, | ||
}, | ||
}; | ||
|
||
export default meta; | ||
|
||
type Story = StoryObj<typeof SnackbarAlert>; | ||
|
||
// Basic success message | ||
export const Success: Story = { | ||
args: { | ||
open: true, | ||
onClose: () => console.info('Close clicked'), | ||
children: 'Operation completed successfully', | ||
alertProps: { | ||
severity: 'success', | ||
}, | ||
}, | ||
}; | ||
|
||
// Error message with title | ||
export const Error: Story = { | ||
args: { | ||
open: true, | ||
onClose: () => console.log('Close clicked'), | ||
title: 'Error', | ||
children: 'Something went wrong. Please try again.', | ||
alertProps: { | ||
severity: 'error', | ||
}, | ||
}, | ||
}; | ||
|
||
// Example with no title | ||
export const NoTitle: Story = { | ||
args: { | ||
open: true, | ||
onClose: () => console.log('Close clicked'), | ||
children: 'Simple notification without a title', | ||
alertProps: { | ||
severity: 'success', | ||
}, | ||
}, | ||
}; | ||
|
||
// Example with longer content | ||
export const LongContent: Story = { | ||
args: { | ||
open: true, | ||
onClose: () => console.log('Close clicked'), | ||
title: 'System Notification', | ||
children: `This is a longer notification message that demonstrates how the SnackbarAlert | ||
component handles multiple lines of text. It might contain important information that | ||
needs more space to be properly communicated to the user.`, | ||
alertProps: { | ||
severity: 'info', | ||
sx: { height: '100%' }, | ||
}, | ||
}, | ||
}; |
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,40 @@ | ||
import { Alert, AlertProps, AlertTitle, Snackbar } from '@mui/material'; | ||
|
||
import { ReactNode } from 'react'; | ||
|
||
interface Props { | ||
open: boolean; | ||
onClose: VoidFunction; | ||
children?: ReactNode; | ||
alertProps?: AlertProps; | ||
title?: string; | ||
} | ||
const SnackbarAlert: React.FC<Props> = ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ideally we'd use this in the existing Apollo Alert but refactoring that felt like a bit too much scope creep for this branch |
||
open, | ||
onClose, | ||
children, | ||
alertProps, | ||
title, | ||
}) => { | ||
return ( | ||
<Snackbar | ||
TransitionProps={{ appear: false }} // disabled transition since it looks a bit junky | ||
open={open} | ||
onClose={onClose} | ||
anchorOrigin={{ vertical: 'top', horizontal: 'center' }} | ||
sx={({ shadows }) => ({ | ||
boxShadow: shadows[6], | ||
borderRadius: 2, // matches Alert | ||
'.MuiAlertTitle-root': { fontWeight: 600 }, | ||
marginTop: '100px', | ||
})} | ||
> | ||
<Alert onClose={onClose} {...alertProps}> | ||
{title && <AlertTitle sx={{ mb: 0 }}>{title}</AlertTitle>} | ||
{children} | ||
</Alert> | ||
</Snackbar> | ||
); | ||
}; | ||
|
||
export default SnackbarAlert; |
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
44 changes: 44 additions & 0 deletions
44
src/modules/client/components/ClientForceRefetchButton.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,44 @@ | ||
import { LoadingButton } from '@mui/lab'; | ||
import { ButtonProps } from '@mui/material'; | ||
import React, { useCallback, useRef } from 'react'; | ||
|
||
import { useGetClientLazyQuery } from '@/types/gqlTypes'; | ||
|
||
interface Props extends Omit<ButtonProps, 'onClick'> { | ||
clientId: string; | ||
children: string; | ||
onClick: VoidFunction | undefined; | ||
} | ||
|
||
// before on-click, refetch the client to ensure we have the latest values | ||
const ClientForceRefetchButton: React.FC<Props> = ({ | ||
clientId, | ||
children, | ||
onClick, | ||
...buttonProps | ||
}) => { | ||
const activeRequestClientId = useRef<string | null>(null); | ||
|
||
const [getClient, { loading, error }] = useGetClientLazyQuery({ | ||
fetchPolicy: 'network-only', | ||
}); | ||
if (error) throw error; | ||
|
||
const handleClick = useCallback(() => { | ||
activeRequestClientId.current = clientId; | ||
getClient({ variables: { id: clientId } }).then(() => { | ||
// Only trigger onClick if the clientId hasn't changed | ||
if (onClick && activeRequestClientId.current === clientId) { | ||
onClick?.(); | ||
} | ||
}); | ||
}, [clientId, getClient, onClick]); | ||
|
||
return ( | ||
<LoadingButton loading={loading} onClick={handleClick} {...buttonProps}> | ||
{children} | ||
</LoadingButton> | ||
); | ||
}; | ||
|
||
export default ClientForceRefetchButton; |
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
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.
looks like a bug where cancelText was not displayed