diff --git a/packages/ui/src/components/NotificationToast.svelte b/packages/ui/src/components/NotificationToast.svelte new file mode 100644 index 0000000000..aba306a501 --- /dev/null +++ b/packages/ui/src/components/NotificationToast.svelte @@ -0,0 +1,112 @@ + + + + +
+
+
+ {#if icon} +
+ +
+ {/if} + {title} +
+ {#if onClose !== undefined} +
+ +
+ +
+ + {#if $$slots.buttons} +
+ +
+ {/if} +
+ + diff --git a/packages/ui/src/index.ts b/packages/ui/src/index.ts index feab0dc87b..9ba0b1a78d 100644 --- a/packages/ui/src/index.ts +++ b/packages/ui/src/index.ts @@ -140,6 +140,7 @@ export { default as NavItem } from './components/NavItem.svelte' export { default as NavGroup } from './components/NavGroup.svelte' export { default as Modal } from './components/Modal.svelte' export { default as AccordionItem } from './components/AccordionItem.svelte' +export { default as NotificationToast } from './components/NotificationToast.svelte' export { default as IconAdd } from './components/icons/Add.svelte' export { default as IconCircleAdd } from './components/icons/CircleAdd.svelte' diff --git a/plugins/tracker-resources/src/components/issues/IssueNotification.svelte b/plugins/tracker-resources/src/components/issues/IssueNotification.svelte index 84682fb04f..69672f6812 100644 --- a/plugins/tracker-resources/src/components/issues/IssueNotification.svelte +++ b/plugins/tracker-resources/src/components/issues/IssueNotification.svelte @@ -2,20 +2,8 @@ import { getMetadata } from '@hcengineering/platform' import presentation, { copyTextToClipboard, createQuery } from '@hcengineering/presentation' import { Issue, IssueStatus } from '@hcengineering/tracker' - import { - AnySvelteComponent, - Button, - Icon, - IconCheckCircle, - IconClose, - IconInfo, - Notification, - NotificationSeverity, - navigate, - parseLocation - } from '@hcengineering/ui' + import { Button, Notification, navigate, parseLocation, NotificationToast } from '@hcengineering/ui' import view from '@hcengineering/view' - import { fade } from 'svelte/transition' import { statusStore } from '@hcengineering/view-resources' import tracker from '../../plugin' @@ -27,10 +15,10 @@ const issueQuery = createQuery() - let issue: Issue | undefined - let status: IssueStatus | undefined + let issue: Issue | undefined = undefined + let status: IssueStatus | undefined = undefined - const { title, subTitle, severity, params } = notification + const { subTitle, params } = notification $: issueQuery.query( tracker.class.Issue, @@ -45,30 +33,7 @@ status = $statusStore.byId.get(issue.status) } - const getIcon = (): AnySvelteComponent | undefined => { - switch (severity) { - case NotificationSeverity.Success: - return IconCheckCircle - case NotificationSeverity.Error: - case NotificationSeverity.Info: - case NotificationSeverity.Warning: - return IconInfo - } - } - - const getIconColor = () => { - switch (severity) { - case NotificationSeverity.Success: - return '#34db80' - case NotificationSeverity.Error: - return '#eb5757' - case NotificationSeverity.Info: - return '#93caf3' - case NotificationSeverity.Warning: - return '#f2994a' - } - } - const handleIssueOpened = () => { + function handleIssueOpened (): void { if (params?.issueUrl) { const url = new URL(params?.issueUrl) const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin @@ -80,67 +45,34 @@ onRemove() } - const handleCopyUrl = () => { - if (issue) { - copyTextToClipboard(params?.issueUrl) + + function handleCopyUrl (): void { + if (issue === undefined) { + void copyTextToClipboard(params?.issueUrl) } } - $: icon = getIcon() -
-
-
- {#if icon} -
+ + +
+ {#if status === undefined && issue} + {/if} - {title} + {#if issue} + + {/if} + + {subTitle} + + + {params?.subTitlePostfix} +
-
+ -
- {#if status && issue} - - {/if} - {#if issue} - - {/if} - - {subTitle} - - - {params?.subTitlePostfix} - -
-
+
-
- - + +