-
Notifications
You must be signed in to change notification settings - Fork 894
fix: stop SSHKeysPage from flaking #10553
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 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9bdda94
refactor: reorganize SSHKeysPage
Parkreiner 0e1caf2
refactor: update render behavior for GlobalSnackbar
Parkreiner bc9b5af
fix: remove redundant error handling
Parkreiner 3f491e1
docs: Clean up wording on docs
Parkreiner c619d34
fix: remove temp error handling tests
Parkreiner 8083591
fix: remove local error alert
Parkreiner 7dabbe3
fix: remove error logging hacks
Parkreiner 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import { type FC, useCallback, useState } from "react"; | ||
import { type FC, useState } from "react"; | ||
import { useCustomEvent } from "hooks/events"; | ||
import type { CustomEventListener } from "utils/events"; | ||
import { EnterpriseSnackbar } from "./EnterpriseSnackbar"; | ||
import { ErrorIcon } from "../Icons/ErrorIcon"; | ||
import { Typography } from "../Typography/Typography"; | ||
|
@@ -29,54 +28,10 @@ export const GlobalSnackbar: FC = () => { | |
const [open, setOpen] = useState<boolean>(false); | ||
const [notification, setNotification] = useState<NotificationMsg>(); | ||
|
||
const handleNotification = useCallback<CustomEventListener<NotificationMsg>>( | ||
(event) => { | ||
setNotification(event.detail); | ||
setOpen(true); | ||
}, | ||
[], | ||
); | ||
|
||
useCustomEvent(SnackbarEventType, handleNotification); | ||
|
||
const renderAdditionalMessage = (msg: AdditionalMessage, idx: number) => { | ||
if (isNotificationText(msg)) { | ||
return ( | ||
<Typography | ||
key={idx} | ||
gutterBottom | ||
variant="body2" | ||
css={styles.messageSubtitle} | ||
> | ||
{msg} | ||
</Typography> | ||
); | ||
} else if (isNotificationTextPrefixed(msg)) { | ||
return ( | ||
<Typography | ||
key={idx} | ||
gutterBottom | ||
variant="body2" | ||
css={styles.messageSubtitle} | ||
> | ||
<strong>{msg.prefix}:</strong> {msg.text} | ||
</Typography> | ||
); | ||
} else if (isNotificationList(msg)) { | ||
return ( | ||
<ul css={styles.list} key={idx}> | ||
{msg.map((item, idx) => ( | ||
<li key={idx}> | ||
<Typography variant="body2" css={styles.messageSubtitle}> | ||
{item} | ||
</Typography> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
} | ||
return null; | ||
}; | ||
useCustomEvent<NotificationMsg>(SnackbarEventType, (event) => { | ||
setNotification(event.detail); | ||
setOpen(true); | ||
}); | ||
|
||
if (!notification) { | ||
return null; | ||
|
@@ -87,26 +42,27 @@ export const GlobalSnackbar: FC = () => { | |
key={notification.msg} | ||
open={open} | ||
variant={variantFromMsgType(notification.msgType)} | ||
onClose={() => setOpen(false)} | ||
autoHideDuration={notification.msgType === MsgType.Error ? 22000 : 6000} | ||
anchorOrigin={{ vertical: "bottom", horizontal: "right" }} | ||
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. All the prop changes here are just moving the single-line prop definitions so they're grouped together 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. it's the little things ✨ |
||
message={ | ||
<div css={styles.messageWrapper}> | ||
{notification.msgType === MsgType.Error && ( | ||
<ErrorIcon css={styles.errorIcon} /> | ||
)} | ||
|
||
<div css={styles.message}> | ||
<Typography variant="body1" css={styles.messageTitle}> | ||
{notification.msg} | ||
</Typography> | ||
|
||
{notification.additionalMsgs && | ||
notification.additionalMsgs.map(renderAdditionalMessage)} | ||
notification.additionalMsgs.map((msg, index) => ( | ||
<AdditionalMessageDisplay key={index} message={msg} /> | ||
))} | ||
</div> | ||
</div> | ||
} | ||
onClose={() => setOpen(false)} | ||
autoHideDuration={notification.msgType === MsgType.Error ? 22000 : 6000} | ||
anchorOrigin={{ | ||
vertical: "bottom", | ||
horizontal: "right", | ||
}} | ||
/> | ||
); | ||
}; | ||
|
@@ -133,3 +89,37 @@ const styles = { | |
marginRight: theme.spacing(2), | ||
}), | ||
} satisfies Record<string, Interpolation<Theme>>; | ||
|
||
function AdditionalMessageDisplay({ message }: { message: AdditionalMessage }) { | ||
if (isNotificationText(message)) { | ||
return ( | ||
<Typography gutterBottom variant="body2" css={styles.messageSubtitle}> | ||
{message} | ||
</Typography> | ||
); | ||
} | ||
|
||
if (isNotificationTextPrefixed(message)) { | ||
return ( | ||
<Typography gutterBottom variant="body2" css={styles.messageSubtitle}> | ||
<strong>{message.prefix}:</strong> {message.text} | ||
</Typography> | ||
); | ||
} | ||
|
||
if (isNotificationList(message)) { | ||
return ( | ||
<ul css={styles.list}> | ||
{message.map((item, idx) => ( | ||
<li key={idx}> | ||
<Typography variant="body2" css={styles.messageSubtitle}> | ||
{item} | ||
</Typography> | ||
</li> | ||
))} | ||
</ul> | ||
); | ||
} | ||
|
||
return null; | ||
} |
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
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
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
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
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
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
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.
This got removed in favor of making it a separate component at the bottom of the file