From d9fac2dddbed04561406babc814d0d66f79ccb86 Mon Sep 17 00:00:00 2001 From: Denis Maslennikov <41147528+disant1@users.noreply.github.com> Date: Tue, 6 Dec 2022 15:29:06 +0700 Subject: [PATCH] TSK-458: Create of sub-issue not show Issue created notification (#2419) Signed-off-by: Denis Maslennikov --- packages/ui/src/utils.ts | 23 ++++++++++++++++ .../src/components/CreateIssue.svelte | 26 +++++-------------- .../issues/edit/CreateSubIssue.svelte | 9 ++++++- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/packages/ui/src/utils.ts b/packages/ui/src/utils.ts index 522b046654..66998dbe0f 100644 --- a/packages/ui/src/utils.ts +++ b/packages/ui/src/utils.ts @@ -13,8 +13,11 @@ // limitations under the License. // +import { generateId } from '@hcengineering/core' import type { Metadata } from '@hcengineering/platform' import { setMetadata } from '@hcengineering/platform' +import { Notification, notificationsStore, NotificationPosition, NotificationSeverity } from '.' +import { AnyComponent, AnySvelteComponent } from './types' export function setMetadataLocalStorage (id: Metadata, value: T | null): void { if (value != null) { @@ -47,3 +50,23 @@ export function checkMobile (): boolean { export function floorFractionDigits (n: number | string, amount: number): number { return Number(Number(n).toFixed(amount)) } + +export function addNotification ( + title: string, + subTitle: string, + component: AnyComponent | AnySvelteComponent, + params?: { [key: string]: any } +): void { + const notification: Notification = { + id: generateId(), + title, + subTitle, + severity: NotificationSeverity.Success, + position: NotificationPosition.BottomRight, + component, + closeTimeout: 10000, + params + } + + notificationsStore.addNotification(notification) +} diff --git a/plugins/tracker-resources/src/components/CreateIssue.svelte b/plugins/tracker-resources/src/components/CreateIssue.svelte index 9257604c4f..ccb981f828 100644 --- a/plugins/tracker-resources/src/components/CreateIssue.svelte +++ b/plugins/tracker-resources/src/components/CreateIssue.svelte @@ -44,6 +44,7 @@ } from '@hcengineering/tracker' import { ActionIcon, + addNotification, Button, Component, DatePresenter, @@ -54,11 +55,7 @@ Menu, setMetadataLocalStorage, showPopup, - Spinner, - NotificationPosition, - NotificationSeverity, - Notification, - notificationsStore + Spinner } from '@hcengineering/ui' import view from '@hcengineering/view' import { ObjectBox } from '@hcengineering/view-resources' @@ -518,21 +515,10 @@ } } - const notification: Notification = { - id: generateId(), - title: tracker.string.IssueCreated, - subTitle: getTitle(object.title), - severity: NotificationSeverity.Success, - position: NotificationPosition.BottomRight, - component: IssueNotification, - closeTimeout: 10000, - params: { - issueId: objectId, - subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase() - } - } - - notificationsStore.addNotification(notification) + addNotification(tracker.string.IssueCreated, getTitle(object.title), IssueNotification, { + issueId: objectId, + subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase() + }) objectId = generateId() resetObject() diff --git a/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte b/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte index e2dcdca16d..cd34a176d2 100644 --- a/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte +++ b/plugins/tracker-resources/src/components/issues/edit/CreateSubIssue.svelte @@ -18,13 +18,15 @@ import presentation, { getClient, KeyedAttribute } from '@hcengineering/presentation' import { StyledTextArea } from '@hcengineering/text-editor' import { IssueStatus, IssuePriority, Issue, Team, calcRank } from '@hcengineering/tracker' - import { Button, Component, EditBox } from '@hcengineering/ui' + import { addNotification, Button, Component, EditBox } from '@hcengineering/ui' import tags, { TagElement, TagReference } from '@hcengineering/tags' import tracker from '../../../plugin' import AssigneeEditor from '../AssigneeEditor.svelte' import StatusEditor from '../StatusEditor.svelte' import PriorityEditor from '../PriorityEditor.svelte' import EstimationEditor from '../timereport/EstimationEditor.svelte' + import IssueNotification from '../IssueNotification.svelte' + import { translate } from '@hcengineering/platform' export let parentIssue: Issue export let issueStatuses: WithLookup[] @@ -123,6 +125,11 @@ tag: label.tag }) } + + addNotification(tracker.string.IssueCreated, getTitle(newIssue.title), IssueNotification, { + issueId: objectId, + subTitlePostfix: (await translate(tracker.string.Created, { value: 1 })).toLowerCase() + }) } finally { resetToDefaults() loading = false