Skip to content

Commit

Permalink
frontend: ActionsNotifier: Adjust keys for snackbars
Browse files Browse the repository at this point in the history
This change adds a unique refKey for error states, separate from success
states, and creates a unique key for every snackbar. This addresses a
regression where failure notifications would not appear in the UI.

Fixes: #2655

Signed-off-by: Evangelos Skopelitis <[email protected]>

change
  • Loading branch information
skoeva committed Dec 13, 2024
1 parent b1e62cf commit f3a50cb
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 f3a50cb

Please sign in to comment.