mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-12 15:53:46 -04:00
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: peaklabs-dev <122374094+peaklabs-dev@users.noreply.github.com> Co-authored-by: Aditya Tripathi <aditya@climactic.co>
26 lines
1.1 KiB
JavaScript
26 lines
1.1 KiB
JavaScript
// The dashboard callout "{n} resources need a security update now." stays dismissed until a resource that was not
|
|
// dismissed needs an update now. localStorage (one key per team) keeps the dismissed resource UUIDs; the page removes
|
|
// them when no resource needs an update now (`reset`), so the next one shows the callout again.
|
|
function dismissedSet(stored) {
|
|
try {
|
|
const parsed = JSON.parse(stored ?? 'null');
|
|
return Array.isArray(parsed) ? new Set(parsed.map(String)) : null;
|
|
} catch {
|
|
return null;
|
|
}
|
|
}
|
|
|
|
export function securityCallout(current, stored) {
|
|
const dismissed = dismissedSet(stored);
|
|
if (current.length === 0) {
|
|
return { visible: false, reset: dismissed !== null };
|
|
}
|
|
|
|
return { visible: dismissed === null || current.some((uuid) => !dismissed.has(String(uuid))), reset: false };
|
|
}
|
|
|
|
// The value to store when the callout is dismissed: the current resources and the ones dismissed before.
|
|
export function dismissSecurityCallout(current, stored) {
|
|
return JSON.stringify([...new Set([...(dismissedSet(stored) ?? []), ...current.map(String)])]);
|
|
}
|