Skip to content

Commit

Permalink
Update notifications
Browse files Browse the repository at this point in the history
Fix typo, fix error notification, remove notification
of missing visual entity on delete, #776.
  • Loading branch information
skodapetr committed Nov 8, 2024
1 parent c338629 commit 39a289b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ export function deleteFromVisualModelAction(
// Delete the visual entity.
const visualEntity = visualModel.getVisualEntityForRepresented(identifier);
if (visualEntity === null) {
notifications.error("Entity is not part of the visual model.");
console.log("Missing visual entity.", { identifier, visualModel });
// The entity is not part of the visual model and thus should not be visible.
// We ignore the operation but only show an error.
console.error("Missing visual entity.", { identifier, visualModel });
return;
}
const entitiesToRemove = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {logger} from "./logging";
*/
const translations: Record<string, string | Function> = {
"notification.icon-error": "Error icon",
"notification.icon-sucess": "Check icon",
"notification.icon-success": "Check icon",
//
"header.package.label": (name:string) => `Package: ${name}`,
"header.package.missing": "Package of unknown name",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const useNotificationService = (): UseNotificationServiceType => {

const writer: UseNotificationServiceWriterType = {
success: (label: string) => notificationService.addSuccess(label),
error: (label: string) => notificationService.addSuccess(label),
error: (label: string) => notificationService.addError(label),
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const ERROR_MESSAGE_TTL_MS = 5000;
const MESSAGE_UPDATE_INTERVAL_MS = 1000;

/**
* The sirvice register an interval to remove older notifications.
* The service register an interval to remove older notifications.
* Every write operation creates new array in order to be easily used with React.
*/
class DefaultNotificationService implements NotificationService {
Expand All @@ -71,7 +71,7 @@ class DefaultNotificationService implements NotificationService {
return;
}
this.notifications = nextNotifications;
this.notifiListeners();
this.notifyListeners();
}

addSuccess(label: string) {
Expand All @@ -80,10 +80,10 @@ class DefaultNotificationService implements NotificationService {
type: NotificationType.Success,
timeToLive: Date.now() + SUCCESS_MESSAGE_TTL_MS,
}];
this.notifiListeners();
this.notifyListeners();
}

private notifiListeners() {
private notifyListeners() {
this.listeners.forEach(listener => listener(this));
}

Expand All @@ -93,7 +93,7 @@ class DefaultNotificationService implements NotificationService {
type: NotificationType.Error,
timeToLive: Date.now() + ERROR_MESSAGE_TTL_MS,
}];
this.notifiListeners();
this.notifyListeners();
}

addListener(listener: EventChangeListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const IconSuccess = () => (
<svg className="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z" />
</svg>
<span className="sr-only">{t("notification.icon-sucess")}</span>
<span className="sr-only">{t("notification.icon-success")}</span>
</div>
);

Expand All @@ -60,7 +60,7 @@ const IconSuccess = () => (
const IconError = () => (
<div className="inline-flex items-center justify-center flex-shrink-0 w-8 h-8 text-red-500 bg-red-100 rounded-lg dark:bg-red-800 dark:text-red-200">
<svg className="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z" />
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 11.793a1 1 0 1 1-1.414 1.414L10 11.414l-2.293 2.293a1 1 0 0 1-1.414-1.414L8.586 10 6.293 7.707a1 1 0 0 1 1.414-1.414L10 8.586l2.293-2.293a1 1 0 0 1 1.414 1.414L11.414 10l2.293 2.293Z"/>
</svg>
<span className="sr-only">{t("notification.icon-error")}</span>
</div>
Expand Down

0 comments on commit 39a289b

Please sign in to comment.