mirror of
https://github.com/rcourtman/Pulse.git
synced 2026-09-24 04:07:16 +00:00
Polish: Consistent notifications in Settings modals
This commit is contained in:
@@ -189,7 +189,7 @@ export const APITokenManager: Component<APITokenManagerProps> = (props) => {
|
||||
setTokensLoaded(true);
|
||||
} catch (err) {
|
||||
logger.error('Failed to load API tokens', err);
|
||||
showError('Failed to load API tokens');
|
||||
notificationStore.error('Failed to load API tokens');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -259,11 +259,11 @@ export const APITokenManager: Component<APITokenManagerProps> = (props) => {
|
||||
source: 'security',
|
||||
note: 'Copy this token now. You can reopen this dialog from Security → API tokens while this page stays open.',
|
||||
});
|
||||
showSuccess('New API token generated. Copy it below while it is still visible.');
|
||||
notificationStore.success('New API token generated. Copy it below while it is still visible.');
|
||||
props.onTokensChanged?.();
|
||||
} catch (err) {
|
||||
logger.error('Failed to generate API token', err);
|
||||
showError('Failed to generate API token');
|
||||
notificationStore.error('Failed to generate API token');
|
||||
} finally {
|
||||
setIsGenerating(false);
|
||||
}
|
||||
@@ -327,7 +327,7 @@ export const APITokenManager: Component<APITokenManagerProps> = (props) => {
|
||||
try {
|
||||
await SecurityAPI.deleteToken(record.id);
|
||||
setTokens((prev) => prev.filter((token) => token.id !== record.id));
|
||||
showSuccess('Token revoked', revokeMessage);
|
||||
notificationStore.success('Token revoked', revokeMessage);
|
||||
props.onTokensChanged?.();
|
||||
if (affectedDockerHostIds.length > 0) {
|
||||
markDockerHostsTokenRevoked(record.id, affectedDockerHostIds);
|
||||
@@ -343,7 +343,7 @@ export const APITokenManager: Component<APITokenManagerProps> = (props) => {
|
||||
}
|
||||
} catch (err) {
|
||||
logger.error('Failed to revoke API token', err);
|
||||
showError('Failed to revoke API token');
|
||||
notificationStore.error('Failed to revoke API token');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, createSignal, Show } from 'solid-js';
|
||||
import { Portal } from 'solid-js/web';
|
||||
import { showSuccess, showError } from '@/utils/toast';
|
||||
import { notificationStore } from '@/stores/notifications';
|
||||
import { SectionHeader } from '@/components/shared/SectionHeader';
|
||||
import { formField, labelClass, controlClass, formHelpText } from '@/components/shared/Form';
|
||||
|
||||
@@ -75,7 +75,7 @@ export const ChangePasswordModal: Component<ChangePasswordModalProps> = (props)
|
||||
throw new Error(text || 'Failed to change password');
|
||||
}
|
||||
|
||||
showSuccess('Password changed successfully. Please log in with your new password.');
|
||||
notificationStore.success('Password changed successfully. Please log in with your new password.');
|
||||
|
||||
// Clear form
|
||||
setCurrentPassword('');
|
||||
@@ -92,7 +92,7 @@ export const ChangePasswordModal: Component<ChangePasswordModalProps> = (props)
|
||||
} catch (err) {
|
||||
const errorMessage = err instanceof Error ? err.message : 'Failed to change password';
|
||||
setError(errorMessage);
|
||||
showError(errorMessage);
|
||||
notificationStore.error(errorMessage);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export const ProLicensePanel: Component = () => {
|
||||
const nextStatus = await LicenseAPI.getStatus();
|
||||
setStatus(nextStatus);
|
||||
} catch (err) {
|
||||
showError(err instanceof Error ? err.message : 'Failed to load license status');
|
||||
notificationStore.error(err instanceof Error ? err.message : 'Failed to load license status');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
@@ -108,17 +108,17 @@ export const ProLicensePanel: Component = () => {
|
||||
const handleActivate = async () => {
|
||||
const trimmedKey = licenseKey().trim();
|
||||
if (!trimmedKey) {
|
||||
showError('License key is required');
|
||||
notificationStore.error('License key is required');
|
||||
return;
|
||||
}
|
||||
setActivating(true);
|
||||
try {
|
||||
const result = await LicenseAPI.activateLicense(trimmedKey);
|
||||
if (!result.success) {
|
||||
showError(result.message || 'Failed to activate license');
|
||||
notificationStore.error(result.message || 'Failed to activate license');
|
||||
return;
|
||||
}
|
||||
showSuccess(result.message || 'License activated');
|
||||
notificationStore.success(result.message || 'License activated');
|
||||
setLicenseKey('');
|
||||
if (result.status) {
|
||||
setStatus(result.status);
|
||||
@@ -126,7 +126,7 @@ export const ProLicensePanel: Component = () => {
|
||||
await loadStatus();
|
||||
}
|
||||
} catch (err) {
|
||||
showError(err instanceof Error ? err.message : 'Failed to activate license');
|
||||
notificationStore.error(err instanceof Error ? err.message : 'Failed to activate license');
|
||||
} finally {
|
||||
setActivating(false);
|
||||
}
|
||||
@@ -139,10 +139,10 @@ export const ProLicensePanel: Component = () => {
|
||||
setClearing(true);
|
||||
try {
|
||||
const result = await LicenseAPI.clearLicense();
|
||||
showSuccess(result.message || 'License cleared');
|
||||
notificationStore.success(result.message || 'License cleared');
|
||||
await loadStatus();
|
||||
} catch (err) {
|
||||
showError(err instanceof Error ? err.message : 'Failed to clear license');
|
||||
notificationStore.error(err instanceof Error ? err.message : 'Failed to clear license');
|
||||
} finally {
|
||||
setClearing(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user