Skip to content

Commit

Permalink
Merge pull request #2674 from headlamp-k8s/fix-notifications
Browse files Browse the repository at this point in the history
frontend: ActionsNotifier: Adjust keys for snackbars
  • Loading branch information
joaquimrocha authored Dec 20, 2024
2 parents d325b5b + f3a50cb commit b3f862f
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions frontend/src/components/common/ActionsNotifier.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,20 @@ function PureActionsNotifier({ dispatch, clusterActions }: PureActionsNotifierPr
}

const prevKey = snackbarRefs.current[clusterAction.id];
const uniqueKey = clusterAction.key || clusterAction.id;
const uniqueKey = `${clusterAction.key || clusterAction.id}-${Date.now()}`;

if (prevKey && prevKey !== uniqueKey) {
closeSnackbar(prevKey);
}

if (clusterAction.message) {
// Check for completed actions
// Check for success or error states
const refKey =
clusterAction.state === 'complete' ? `${clusterAction.id}-complete` : clusterAction.id;
clusterAction.state === 'complete'
? `${clusterAction.id}-complete`
: clusterAction.state === 'error'
? `${clusterAction.id}-error`
: clusterAction.id;

if (!snackbarRefs.current[refKey]) {
snackbarRefs.current[refKey] = uniqueKey;
Expand Down

0 comments on commit b3f862f

Please sign in to comment.