@gooddata/sdk-ui-dashboard 11.43.0-alpha.5 → 11.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm/__version.d.ts +1 -1
- package/esm/__version.d.ts.map +1 -1
- package/esm/__version.js +1 -1
- package/esm/index.d.ts +2 -2
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +2 -2
- package/esm/presentation/automations/{_staging/alerting → alerting}/AlertingManagementDialog.d.ts +1 -1
- package/esm/presentation/automations/alerting/AlertingManagementDialog.d.ts.map +1 -0
- package/esm/presentation/automations/{_staging/alerting → alerting}/AlertingManagementDialog.js +1 -1
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogContentBasic.d.ts.map +1 -0
- package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogContentBasic.js +8 -9
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogContentEnhanced.d.ts.map +1 -0
- package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogContentEnhanced.js +17 -29
- package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogNew.d.ts +1 -1
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogNew.d.ts.map +1 -0
- package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogNew.js +9 -28
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/Alert.d.ts.map +1 -0
- package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/components/Alert.js +15 -18
- package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/components/AlertDropdown.d.ts +1 -1
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/AlertDropdown.d.ts.map +1 -0
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/AlertsList.d.ts.map +1 -0
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/DeleteAlertConfirmDialog.d.ts.map +1 -1
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/DeleteAlertConfirmDialog.js +2 -2
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.d.ts.map +1 -0
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.js +31 -0
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.test.d.ts +2 -0
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.test.d.ts.map +1 -0
- package/esm/presentation/automations/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.test.js +39 -0
- package/esm/presentation/automations/alerting/hooks/useAlertingDialogAccessibility.d.ts.map +1 -0
- package/esm/presentation/automations/alerting/hooks/useAlertingDialogAccessibility.js +11 -0
- package/esm/presentation/automations/connectors/AlertingConnector.d.ts +6 -3
- package/esm/presentation/automations/connectors/AlertingConnector.d.ts.map +1 -1
- package/esm/presentation/automations/connectors/AlertingConnector.js +75 -12
- package/esm/presentation/automations/connectors/AlertingConnector.test.d.ts +2 -0
- package/esm/presentation/automations/connectors/AlertingConnector.test.d.ts.map +1 -0
- package/esm/presentation/automations/connectors/AlertingConnector.test.js +152 -0
- package/esm/presentation/automations/connectors/DefaultAlertingManagementDialogConnected.d.ts +11 -0
- package/esm/presentation/automations/connectors/DefaultAlertingManagementDialogConnected.d.ts.map +1 -0
- package/esm/presentation/automations/connectors/DefaultAlertingManagementDialogConnected.js +20 -0
- package/esm/presentation/automations/connectors/hooks/useBuildAlertingManagementDialogContext.d.ts +3 -0
- package/esm/presentation/automations/connectors/hooks/useBuildAlertingManagementDialogContext.d.ts.map +1 -0
- package/esm/presentation/automations/connectors/hooks/useBuildAlertingManagementDialogContext.js +131 -0
- package/esm/presentation/automations/connectors/hooks/useBuildAutomationsContext.d.ts.map +1 -1
- package/esm/presentation/automations/connectors/hooks/useBuildAutomationsContext.js +4 -1
- package/esm/presentation/automations/connectors/hooks/useBuildAutomationsContext.test.js +2 -0
- package/esm/presentation/automations/contexts/AlertingManagementDialogContext.d.ts +27 -0
- package/esm/presentation/automations/contexts/AlertingManagementDialogContext.d.ts.map +1 -0
- package/esm/presentation/automations/contexts/AlertingManagementDialogContext.js +11 -0
- package/esm/presentation/automations/contexts/AutomationsContext.d.ts +1 -0
- package/esm/presentation/automations/contexts/AutomationsContext.d.ts.map +1 -1
- package/esm/presentation/automations/shared/automationFilters/components/AutomationDateFilter.test.js +1 -0
- package/esm/presentation/dashboard/DashboardHeader/AlertingDialogProvider.d.ts.map +1 -1
- package/esm/presentation/dashboard/DashboardHeader/AlertingDialogProvider.js +3 -17
- package/esm/presentation/dashboard/components/DashboardRenderer.js +1 -1
- package/esm/presentation/widget/insight/configuration/InsightAlertConfig/AlertsList.js +1 -1
- package/esm/presentation/widget/insight/configuration/InsightAlerts.d.ts.map +1 -1
- package/esm/presentation/widget/insight/configuration/InsightAlerts.js +8 -1
- package/esm/presentation/widget/insight/configuration/InsightAlertsNew.d.ts.map +1 -1
- package/esm/presentation/widget/insight/configuration/InsightAlertsNew.test.d.ts +2 -0
- package/esm/presentation/widget/insight/configuration/InsightAlertsNew.test.d.ts.map +1 -0
- package/esm/presentation/widget/insight/configuration/InsightAlertsNew.test.js +124 -0
- package/esm/sdk-ui-dashboard.d.ts +6 -1
- package/package.json +20 -20
- package/esm/presentation/automations/_staging/alerting/AlertingManagementDialog.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogContentBasic.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogContentEnhanced.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogNew.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/components/Alert.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/components/AlertDropdown.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/components/AlertsList.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/components/DeleteAlertConfirmDialog.d.ts +0 -11
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/components/DeleteAlertConfirmDialog.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/components/DeleteAlertConfirmDialog.js +0 -38
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.js +0 -50
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/hooks/useAlertValidation.d.ts +0 -7
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/hooks/useAlertValidation.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/DefaultAlertingManagementDialog/hooks/useAlertValidation.js +0 -30
- package/esm/presentation/automations/_staging/alerting/hooks/useAlertingDialogAccessibility.d.ts.map +0 -1
- package/esm/presentation/automations/_staging/alerting/hooks/useAlertingDialogAccessibility.js +0 -12
- /package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogContentBasic.d.ts +0 -0
- /package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogContentEnhanced.d.ts +0 -0
- /package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/components/Alert.d.ts +0 -0
- /package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/components/AlertDropdown.js +0 -0
- /package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/components/AlertsList.d.ts +0 -0
- /package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/components/AlertsList.js +0 -0
- /package/esm/presentation/automations/{_staging/alerting → alerting}/DefaultAlertingManagementDialog/components/PauseAlertRunner.d.ts +0 -0
- /package/esm/presentation/automations/{_staging/alerting → alerting}/hooks/useAlertingDialogAccessibility.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PauseAlertRunner.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/automations/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.tsx"],"names":[],"mappings":"AAIA,OAAO,EACH,KAAK,yBAAyB,EAC9B,KAAK,mCAAmC,EAC3C,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,gBAAgB,EAAgB,MAAM,kBAAkB,CAAC;AAIvE,UAAU,sBAAsB;IAC5B,KAAK,EAAE,yBAAyB,GAAG,IAAI,CAAC;IACxC,KAAK,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,CACR,KAAK,EAAE,yBAAyB,GAAG,mCAAmC,EACtE,KAAK,EAAE,OAAO,KACb,IAAI,CAAC;IACV,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,gBAAgB,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC/D;AAED,wBAAgB,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,EAAE,sBAAsB,QA4B5F"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// (C) 2022-2026 GoodData Corporation
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
import { convertError } from "@gooddata/sdk-ui";
|
|
4
|
+
import { useAlertingManagementDialogContext } from "../../../contexts/AlertingManagementDialogContext.js";
|
|
5
|
+
export function PauseAlertRunner({ alert, pause, onSuccess, onError }) {
|
|
6
|
+
const { pauseAlert, resumeAlert } = useAlertingManagementDialogContext();
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (!alert) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
if (pause) {
|
|
12
|
+
const alertToPause = {
|
|
13
|
+
...alert,
|
|
14
|
+
alert: { ...alert.alert, trigger: { ...alert.alert?.trigger, state: "PAUSED" } },
|
|
15
|
+
};
|
|
16
|
+
pauseAlert(alertToPause)
|
|
17
|
+
.then((updatedAlert) => onSuccess?.(updatedAlert, true))
|
|
18
|
+
.catch((err) => onError?.(convertError(err), true));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
const alertToResume = {
|
|
22
|
+
...alert,
|
|
23
|
+
alert: { ...alert.alert, trigger: { ...alert.alert?.trigger, state: "ACTIVE" } },
|
|
24
|
+
};
|
|
25
|
+
resumeAlert(alertToResume)
|
|
26
|
+
.then((updatedAlert) => onSuccess?.(updatedAlert, false))
|
|
27
|
+
.catch((err) => onError?.(convertError(err), false));
|
|
28
|
+
}
|
|
29
|
+
}, [alert, onError, onSuccess, pause, pauseAlert, resumeAlert]);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PauseAlertRunner.test.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/automations/alerting/DefaultAlertingManagementDialog/components/PauseAlertRunner.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// (C) 2026 GoodData Corporation
|
|
3
|
+
import { render, waitFor } from "@testing-library/react";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
const fixtures = vi.hoisted(() => {
|
|
6
|
+
return {
|
|
7
|
+
pauseAlert: vi.fn(),
|
|
8
|
+
resumeAlert: vi.fn(),
|
|
9
|
+
};
|
|
10
|
+
});
|
|
11
|
+
vi.mock("../../../contexts/AlertingManagementDialogContext.js", () => ({
|
|
12
|
+
useAlertingManagementDialogContext: () => ({
|
|
13
|
+
pauseAlert: fixtures.pauseAlert,
|
|
14
|
+
resumeAlert: fixtures.resumeAlert,
|
|
15
|
+
}),
|
|
16
|
+
}));
|
|
17
|
+
import { PauseAlertRunner } from "./PauseAlertRunner.js";
|
|
18
|
+
describe("PauseAlertRunner", () => {
|
|
19
|
+
it("passes the updated paused alert returned by the context to onSuccess", async () => {
|
|
20
|
+
const originalAlert = { id: "alert-1", alert: { trigger: { state: "ACTIVE" } } };
|
|
21
|
+
const updatedAlert = { id: "alert-1", alert: { trigger: { state: "PAUSED" } } };
|
|
22
|
+
fixtures.pauseAlert.mockResolvedValueOnce(updatedAlert);
|
|
23
|
+
const onSuccess = vi.fn();
|
|
24
|
+
render(_jsx(PauseAlertRunner, { alert: originalAlert, pause: true, onSuccess: onSuccess }));
|
|
25
|
+
await waitFor(() => {
|
|
26
|
+
expect(onSuccess).toHaveBeenCalledWith(updatedAlert, true);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it("passes the updated resumed alert returned by the context to onSuccess", async () => {
|
|
30
|
+
const originalAlert = { id: "alert-1", alert: { trigger: { state: "PAUSED" } } };
|
|
31
|
+
const updatedAlert = { id: "alert-1", alert: { trigger: { state: "ACTIVE" } } };
|
|
32
|
+
fixtures.resumeAlert.mockResolvedValueOnce(updatedAlert);
|
|
33
|
+
const onSuccess = vi.fn();
|
|
34
|
+
render(_jsx(PauseAlertRunner, { alert: originalAlert, pause: false, onSuccess: onSuccess }));
|
|
35
|
+
await waitFor(() => {
|
|
36
|
+
expect(onSuccess).toHaveBeenCalledWith(updatedAlert, false);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAlertingDialogAccessibility.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/alerting/hooks/useAlertingDialogAccessibility.ts"],"names":[],"mappings":"AAOA,eAAO,MAAM,8BAA8B;;CAW1C,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// (C) 2025-2026 GoodData Corporation
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { DEFAULT_MENU_BUTTON_ID } from "../../../../_staging/accessibility/elementId.js";
|
|
4
|
+
import { useAlertingManagementDialogContext } from "../../contexts/AlertingManagementDialogContext.js";
|
|
5
|
+
export const useAlertingDialogAccessibility = () => {
|
|
6
|
+
const { alertingDialogReturnFocusTo } = useAlertingManagementDialogContext();
|
|
7
|
+
const returnFocusTo = useMemo(() => alertingDialogReturnFocusTo || DEFAULT_MENU_BUTTON_ID, [alertingDialogReturnFocusTo]);
|
|
8
|
+
return {
|
|
9
|
+
returnFocusTo,
|
|
10
|
+
};
|
|
11
|
+
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type ReactElement, type ReactNode } from "react";
|
|
2
2
|
/**
|
|
3
3
|
* Provides AutomationsContext to its children, built from dashboard Redux state.
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Wraps the alerting dialog subtree (both the create/edit and management dialogs reach
|
|
5
|
+
* AutomationsContext through this provider).
|
|
6
6
|
*
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
@@ -11,7 +11,7 @@ export declare function AlertingAutomationsProvider({ children }: {
|
|
|
11
11
|
}): ReactElement;
|
|
12
12
|
/**
|
|
13
13
|
* Connector component that reads from the dashboard Redux store and wires up
|
|
14
|
-
* the alerting dialog tree via context providers.
|
|
14
|
+
* the alerting dialog tree (create/edit and management) via context providers.
|
|
15
15
|
*
|
|
16
16
|
* This is the primary bridge between dashboard store state and the alerting
|
|
17
17
|
* dialog tree. One transitive exception remains: useAutomationAlertParameters
|
|
@@ -21,6 +21,9 @@ export declare function AlertingAutomationsProvider({ children }: {
|
|
|
21
21
|
* (see the GDP-3167 note there) and is tracked for a Phase 3 move behind this
|
|
22
22
|
* connector.
|
|
23
23
|
*
|
|
24
|
+
* AutomationsContext is provided by AlertingAutomationsProvider, which wraps this
|
|
25
|
+
* connector (see AlertingDialogProvider).
|
|
26
|
+
*
|
|
24
27
|
* @internal
|
|
25
28
|
*/
|
|
26
29
|
export declare function AlertingConnector(): ReactElement | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AlertingConnector.d.ts","sourceRoot":"","sources":["../../../../src/presentation/automations/connectors/AlertingConnector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"AlertingConnector.d.ts","sourceRoot":"","sources":["../../../../src/presentation/automations/connectors/AlertingConnector.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAe,MAAM,OAAO,CAAC;AA4BvE;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,SAAS,CAAA;CAAE,GAAG,YAAY,CAG/F;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,IAAI,YAAY,GAAG,IAAI,CAMvD"}
|
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
// (C) 2026 GoodData Corporation
|
|
3
|
+
import { useCallback } from "react";
|
|
2
4
|
import { isWidget } from "@gooddata/sdk-model";
|
|
5
|
+
import { buildAutomationUrl, navigate, useWorkspaceStrict } from "@gooddata/sdk-ui";
|
|
6
|
+
import { useDashboardSelector } from "../../../model/react/DashboardStoreProvider.js";
|
|
3
7
|
import { useDashboardAlerts } from "../../../model/react/useDashboardAlerting/useDashboardAlerts.js";
|
|
4
8
|
import { useWorkspaceUsers } from "../../../model/react/useWorkspaceUsers.js";
|
|
9
|
+
import { selectEnableAutomationManagement, selectExternalRecipient, selectIsEmbedded, selectSettings, } from "../../../model/store/config/configSelectors.js";
|
|
10
|
+
import { selectDashboardId } from "../../../model/store/meta/metaSelectors.js";
|
|
5
11
|
import { AlertingDialog } from "../alerting/AlertingDialog.js";
|
|
12
|
+
import { AlertingManagementDialog } from "../alerting/AlertingManagementDialog.js";
|
|
6
13
|
import { AlertingDialogContextProvider } from "../contexts/AlertingDialogContext.js";
|
|
14
|
+
import { AlertingManagementDialogContextProvider } from "../contexts/AlertingManagementDialogContext.js";
|
|
7
15
|
import { AutomationsContextProvider } from "../contexts/AutomationsContext.js";
|
|
8
16
|
import { useBuildAlertingDialogContext } from "./hooks/useBuildAlertingDialogContext.js";
|
|
17
|
+
import { useBuildAlertingManagementDialogContext } from "./hooks/useBuildAlertingManagementDialogContext.js";
|
|
9
18
|
import { useBuildAutomationsContext } from "./hooks/useBuildAutomationsContext.js";
|
|
10
19
|
/**
|
|
11
20
|
* Provides AutomationsContext to its children, built from dashboard Redux state.
|
|
12
|
-
*
|
|
13
|
-
*
|
|
21
|
+
* Wraps the alerting dialog subtree (both the create/edit and management dialogs reach
|
|
22
|
+
* AutomationsContext through this provider).
|
|
14
23
|
*
|
|
15
24
|
* @internal
|
|
16
25
|
*/
|
|
@@ -20,7 +29,7 @@ export function AlertingAutomationsProvider({ children }) {
|
|
|
20
29
|
}
|
|
21
30
|
/**
|
|
22
31
|
* Connector component that reads from the dashboard Redux store and wires up
|
|
23
|
-
* the alerting dialog tree via context providers.
|
|
32
|
+
* the alerting dialog tree (create/edit and management) via context providers.
|
|
24
33
|
*
|
|
25
34
|
* This is the primary bridge between dashboard store state and the alerting
|
|
26
35
|
* dialog tree. One transitive exception remains: useAutomationAlertParameters
|
|
@@ -30,6 +39,9 @@ export function AlertingAutomationsProvider({ children }) {
|
|
|
30
39
|
* (see the GDP-3167 note there) and is tracked for a Phase 3 move behind this
|
|
31
40
|
* connector.
|
|
32
41
|
*
|
|
42
|
+
* AutomationsContext is provided by AlertingAutomationsProvider, which wraps this
|
|
43
|
+
* connector (see AlertingDialogProvider).
|
|
44
|
+
*
|
|
33
45
|
* @internal
|
|
34
46
|
*/
|
|
35
47
|
export function AlertingConnector() {
|
|
@@ -40,25 +52,76 @@ export function AlertingConnector() {
|
|
|
40
52
|
return _jsx(AlertingConnectorInitialized, { ...alerts });
|
|
41
53
|
}
|
|
42
54
|
function AlertingConnectorInitialized(alerts) {
|
|
43
|
-
|
|
55
|
+
const { isAlertDialogOpen, isAlertManagementDialogOpen } = alerts;
|
|
56
|
+
// Defer store reads and user loading until at least one dialog is open.
|
|
57
|
+
if (!isAlertDialogOpen && !isAlertManagementDialogOpen) {
|
|
44
58
|
return null;
|
|
45
59
|
}
|
|
46
60
|
return _jsx(AlertingConnectorWithData, { alerts: alerts });
|
|
47
61
|
}
|
|
48
62
|
function AlertingConnectorWithData({ alerts }) {
|
|
49
|
-
const {
|
|
63
|
+
const {
|
|
64
|
+
// Shared Local State
|
|
65
|
+
alertToEdit,
|
|
66
|
+
// Data
|
|
67
|
+
automations, automationsError, automationsLoading, notificationChannels,
|
|
68
|
+
// Single Alert Dialog
|
|
69
|
+
isAlertDialogOpen, onAlertingCancel, onAlertingCreateSuccess, onAlertingCreateError, onAlertingSaveSuccess, onAlertingSaveError,
|
|
70
|
+
// Management / List Dialog
|
|
71
|
+
isAlertManagementDialogOpen, onAlertingManagementClose, onAlertingManagementAdd, onAlertingManagementEdit, onAlertingManagementDeleteSuccess, onAlertingManagementDeleteError, onAlertingManagementPauseSuccess, onAlertingManagementPauseError, widget, insight, } = alerts;
|
|
72
|
+
const workspace = useWorkspaceStrict();
|
|
73
|
+
const enableAutomationManagement = useDashboardSelector(selectEnableAutomationManagement);
|
|
74
|
+
const dashboardId = useDashboardSelector(selectDashboardId);
|
|
75
|
+
const isEmbedded = useDashboardSelector(selectIsEmbedded);
|
|
76
|
+
const externalRecipientOverride = useDashboardSelector(selectExternalRecipient);
|
|
77
|
+
const settings = useDashboardSelector(selectSettings);
|
|
78
|
+
const useHostRoute = Boolean(settings?.enableShellApplication) && Boolean(settings?.enableShellApplication_dashboards);
|
|
79
|
+
// Cross-dashboard edit routing lives in the connector (which may read router + store).
|
|
80
|
+
// The management dialog only invokes this injected callback.
|
|
81
|
+
const handleManagementEdit = useCallback((alert) => {
|
|
82
|
+
const targetDashboardId = alert.dashboard?.id;
|
|
83
|
+
if (enableAutomationManagement && targetDashboardId && targetDashboardId !== dashboardId) {
|
|
84
|
+
navigate(buildAutomationUrl({
|
|
85
|
+
workspaceId: workspace,
|
|
86
|
+
dashboardId: targetDashboardId,
|
|
87
|
+
automationId: alert.id,
|
|
88
|
+
isEmbedded,
|
|
89
|
+
useHostRoute,
|
|
90
|
+
queryParams: externalRecipientOverride
|
|
91
|
+
? { recipient: externalRecipientOverride }
|
|
92
|
+
: undefined,
|
|
93
|
+
}));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
onAlertingManagementEdit(alert);
|
|
97
|
+
}, [
|
|
98
|
+
onAlertingManagementEdit,
|
|
99
|
+
enableAutomationManagement,
|
|
100
|
+
dashboardId,
|
|
101
|
+
workspace,
|
|
102
|
+
isEmbedded,
|
|
103
|
+
useHostRoute,
|
|
104
|
+
externalRecipientOverride,
|
|
105
|
+
]);
|
|
50
106
|
const insightWidget = isWidget(widget) ? widget : undefined;
|
|
51
107
|
const alertingCtx = useBuildAlertingDialogContext({
|
|
52
108
|
mode: alertToEdit ? "edit" : "create",
|
|
53
109
|
widget: insightWidget,
|
|
54
110
|
insight,
|
|
55
111
|
});
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
112
|
+
const managementCtx = useBuildAlertingManagementDialogContext();
|
|
113
|
+
const isManagementLoading = automationsLoading;
|
|
114
|
+
return (_jsx(AlertingDialogContextProvider, { value: alertingCtx, children: _jsxs(AlertingManagementDialogContextProvider, { value: managementCtx, children: [isAlertManagementDialogOpen ? (
|
|
115
|
+
// TODO(GDP-3167 phase3): automations, notificationChannels, and alertDataError
|
|
116
|
+
// are still prop-threaded here because DefaultAlertingManagementDialog reads
|
|
117
|
+
// them from props, not from AutomationsContext. Once all dialog fields are
|
|
118
|
+
// migrated to read from context, remove these props and the corresponding prop types.
|
|
119
|
+
_jsx(AlertingManagementDialog, { automations: automations, notificationChannels: notificationChannels, alertDataError: automationsError, isLoadingAlertingData: isManagementLoading, onAdd: onAlertingManagementAdd, onEdit: handleManagementEdit, onClose: onAlertingManagementClose, onDeleteSuccess: onAlertingManagementDeleteSuccess, onDeleteError: onAlertingManagementDeleteError, onPauseSuccess: onAlertingManagementPauseSuccess, onPauseError: onAlertingManagementPauseError })) : null, isAlertDialogOpen ? (
|
|
120
|
+
// TODO(GDP-3167 phase3): notificationChannels, users, usersError, and isLoading
|
|
121
|
+
// are still prop-threaded here because DefaultAlertingDialog reads them from props,
|
|
122
|
+
// not from AutomationsContext. Once all dialog fields are migrated to read from
|
|
123
|
+
// context, remove these props and the corresponding prop types.
|
|
124
|
+
_jsx(AlertingDialogWithUsers, { alertToEdit: alertToEdit, notificationChannels: notificationChannels, widget: insightWidget, insight: insight, isLoading: automationsLoading, onCancel: onAlertingCancel, onError: onAlertingCreateError, onSuccess: onAlertingCreateSuccess, onSaveError: onAlertingSaveError, onSaveSuccess: onAlertingSaveSuccess, onDeleteSuccess: onAlertingManagementDeleteSuccess, onDeleteError: onAlertingManagementDeleteError })) : null] }) }));
|
|
62
125
|
}
|
|
63
126
|
/**
|
|
64
127
|
* Loads workspace users only while the create/edit dialog is mounted. Keeping the
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AlertingConnector.test.d.ts","sourceRoot":"","sources":["../../../../src/presentation/automations/connectors/AlertingConnector.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// (C) 2026 GoodData Corporation
|
|
3
|
+
import { render } from "@testing-library/react";
|
|
4
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
+
const fixtures = vi.hoisted(() => {
|
|
6
|
+
const buildAutomationUrl = vi.fn(() => "/target-url");
|
|
7
|
+
const navigate = vi.fn();
|
|
8
|
+
const onAlertingManagementEdit = vi.fn();
|
|
9
|
+
let managementDialogProps;
|
|
10
|
+
return {
|
|
11
|
+
buildAutomationUrl,
|
|
12
|
+
navigate,
|
|
13
|
+
onAlertingManagementEdit,
|
|
14
|
+
get managementDialogProps() {
|
|
15
|
+
return managementDialogProps;
|
|
16
|
+
},
|
|
17
|
+
set managementDialogProps(value) {
|
|
18
|
+
managementDialogProps = value;
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
vi.mock("@gooddata/sdk-ui", () => ({
|
|
23
|
+
buildAutomationUrl: fixtures.buildAutomationUrl,
|
|
24
|
+
navigate: fixtures.navigate,
|
|
25
|
+
useWorkspaceStrict: () => "workspace-id",
|
|
26
|
+
}));
|
|
27
|
+
vi.mock("../../../model/react/DashboardStoreProvider.js", () => ({
|
|
28
|
+
useDashboardSelector: vi.fn((selector) => selector()),
|
|
29
|
+
}));
|
|
30
|
+
vi.mock("../../../model/react/useDashboardAlerting/useDashboardAlerts.js", () => ({
|
|
31
|
+
useDashboardAlerts: () => ({
|
|
32
|
+
isInitialized: true,
|
|
33
|
+
isAlertDialogOpen: false,
|
|
34
|
+
isAlertManagementDialogOpen: true,
|
|
35
|
+
alertToEdit: undefined,
|
|
36
|
+
automations: [],
|
|
37
|
+
automationsError: undefined,
|
|
38
|
+
automationsLoading: false,
|
|
39
|
+
notificationChannels: [],
|
|
40
|
+
onAlertingCancel: vi.fn(),
|
|
41
|
+
onAlertingCreateSuccess: vi.fn(),
|
|
42
|
+
onAlertingCreateError: vi.fn(),
|
|
43
|
+
onAlertingSaveSuccess: vi.fn(),
|
|
44
|
+
onAlertingSaveError: vi.fn(),
|
|
45
|
+
onAlertingManagementClose: vi.fn(),
|
|
46
|
+
onAlertingManagementAdd: vi.fn(),
|
|
47
|
+
onAlertingManagementEdit: fixtures.onAlertingManagementEdit,
|
|
48
|
+
onAlertingManagementDeleteSuccess: vi.fn(),
|
|
49
|
+
onAlertingManagementDeleteError: vi.fn(),
|
|
50
|
+
onAlertingManagementPauseSuccess: vi.fn(),
|
|
51
|
+
onAlertingManagementPauseError: vi.fn(),
|
|
52
|
+
widget: undefined,
|
|
53
|
+
insight: undefined,
|
|
54
|
+
}),
|
|
55
|
+
}));
|
|
56
|
+
vi.mock("../../../model/react/useWorkspaceUsers.js", () => ({
|
|
57
|
+
useWorkspaceUsers: () => ({ users: [], status: "success", usersError: undefined }),
|
|
58
|
+
}));
|
|
59
|
+
vi.mock("../../../model/store/config/configSelectors.js", () => ({
|
|
60
|
+
selectEnableAutomationManagement: () => true,
|
|
61
|
+
selectExternalRecipient: () => "recipient@example.com",
|
|
62
|
+
selectIsEmbedded: () => false,
|
|
63
|
+
selectSettings: () => ({
|
|
64
|
+
enableShellApplication: true,
|
|
65
|
+
enableShellApplication_dashboards: true,
|
|
66
|
+
}),
|
|
67
|
+
}));
|
|
68
|
+
vi.mock("../../../model/store/meta/metaSelectors.js", () => ({
|
|
69
|
+
selectDashboardId: () => "current-dashboard",
|
|
70
|
+
}));
|
|
71
|
+
vi.mock("../alerting/AlertingDialog.js", () => ({
|
|
72
|
+
AlertingDialog: () => null,
|
|
73
|
+
}));
|
|
74
|
+
vi.mock("../alerting/AlertingManagementDialog.js", () => ({
|
|
75
|
+
AlertingManagementDialog: (props) => {
|
|
76
|
+
fixtures.managementDialogProps = props;
|
|
77
|
+
return null;
|
|
78
|
+
},
|
|
79
|
+
}));
|
|
80
|
+
vi.mock("../contexts/AlertingDialogContext.js", () => ({
|
|
81
|
+
AlertingDialogContextProvider: ({ children }) => children,
|
|
82
|
+
}));
|
|
83
|
+
vi.mock("../contexts/AlertingManagementDialogContext.js", () => ({
|
|
84
|
+
AlertingManagementDialogContextProvider: ({ children }) => children,
|
|
85
|
+
}));
|
|
86
|
+
vi.mock("../contexts/AutomationsContext.js", () => ({
|
|
87
|
+
AutomationsContextProvider: ({ children }) => children,
|
|
88
|
+
}));
|
|
89
|
+
vi.mock("./hooks/useBuildAlertingDialogContext.js", () => ({
|
|
90
|
+
useBuildAlertingDialogContext: () => ({}),
|
|
91
|
+
}));
|
|
92
|
+
vi.mock("./hooks/useBuildAlertingManagementDialogContext.js", () => ({
|
|
93
|
+
useBuildAlertingManagementDialogContext: () => ({
|
|
94
|
+
dashboardId: "current-dashboard",
|
|
95
|
+
isEmbedded: false,
|
|
96
|
+
canManageWorkspace: true,
|
|
97
|
+
currentUser: { login: "user" },
|
|
98
|
+
dashboardTitle: "Current Dashboard",
|
|
99
|
+
isAlertDialogOpen: false,
|
|
100
|
+
managementDialogContext: {},
|
|
101
|
+
enableAccessibilityMode: false,
|
|
102
|
+
getWidgetByRef: () => undefined,
|
|
103
|
+
getInsightByWidgetRef: () => undefined,
|
|
104
|
+
pauseAlert: vi.fn(),
|
|
105
|
+
resumeAlert: vi.fn(),
|
|
106
|
+
}),
|
|
107
|
+
}));
|
|
108
|
+
vi.mock("./hooks/useBuildAutomationsContext.js", () => ({
|
|
109
|
+
useBuildAutomationsContext: () => ({}),
|
|
110
|
+
}));
|
|
111
|
+
import { AlertingConnector } from "./AlertingConnector.js";
|
|
112
|
+
describe("AlertingConnector", () => {
|
|
113
|
+
beforeEach(() => {
|
|
114
|
+
fixtures.buildAutomationUrl.mockClear();
|
|
115
|
+
fixtures.navigate.mockClear();
|
|
116
|
+
fixtures.onAlertingManagementEdit.mockClear();
|
|
117
|
+
fixtures.managementDialogProps = undefined;
|
|
118
|
+
});
|
|
119
|
+
it("uses host routes when editing an alert on another dashboard in shell mode", () => {
|
|
120
|
+
render(_jsx(AlertingConnector, {}));
|
|
121
|
+
const onEdit = fixtures.managementDialogProps?.["onEdit"];
|
|
122
|
+
expect(onEdit).toBeDefined();
|
|
123
|
+
onEdit?.({
|
|
124
|
+
id: "alert-1",
|
|
125
|
+
dashboard: { id: "other-dashboard" },
|
|
126
|
+
});
|
|
127
|
+
expect(fixtures.buildAutomationUrl).toHaveBeenCalledWith({
|
|
128
|
+
workspaceId: "workspace-id",
|
|
129
|
+
dashboardId: "other-dashboard",
|
|
130
|
+
automationId: "alert-1",
|
|
131
|
+
isEmbedded: false,
|
|
132
|
+
useHostRoute: true,
|
|
133
|
+
queryParams: { recipient: "recipient@example.com" },
|
|
134
|
+
});
|
|
135
|
+
expect(fixtures.navigate).toHaveBeenCalledWith("/target-url");
|
|
136
|
+
expect(fixtures.onAlertingManagementEdit).not.toHaveBeenCalled();
|
|
137
|
+
});
|
|
138
|
+
it("falls back to local edit when the target dashboard id is missing", () => {
|
|
139
|
+
render(_jsx(AlertingConnector, {}));
|
|
140
|
+
const onEdit = fixtures.managementDialogProps?.["onEdit"];
|
|
141
|
+
onEdit?.({
|
|
142
|
+
id: "alert-2",
|
|
143
|
+
dashboard: undefined,
|
|
144
|
+
});
|
|
145
|
+
expect(fixtures.navigate).not.toHaveBeenCalled();
|
|
146
|
+
expect(fixtures.buildAutomationUrl).not.toHaveBeenCalled();
|
|
147
|
+
expect(fixtures.onAlertingManagementEdit).toHaveBeenCalledWith({
|
|
148
|
+
id: "alert-2",
|
|
149
|
+
dashboard: undefined,
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type IAlertingManagementDialogProps } from "../alerting/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Self-contained version of DefaultAlertingManagementDialogNew that builds the required
|
|
4
|
+
* AutomationsContext and AlertingManagementDialogContext internally from the dashboard
|
|
5
|
+
* Redux store. Use this export when mounting the management dialog outside of
|
|
6
|
+
* AlertingConnector (e.g. embedding scenarios, storybooks, or custom dashboard shells).
|
|
7
|
+
*
|
|
8
|
+
* @alpha
|
|
9
|
+
*/
|
|
10
|
+
export declare function DefaultAlertingManagementDialogNew(props: IAlertingManagementDialogProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=DefaultAlertingManagementDialogConnected.d.ts.map
|
package/esm/presentation/automations/connectors/DefaultAlertingManagementDialogConnected.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DefaultAlertingManagementDialogConnected.d.ts","sourceRoot":"","sources":["../../../../src/presentation/automations/connectors/DefaultAlertingManagementDialogConnected.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,8BAA8B,EAAE,MAAM,sBAAsB,CAAC;AAO3E;;;;;;;GAOG;AACH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,8BAA8B,2CAWvF"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// (C) 2026 GoodData Corporation
|
|
3
|
+
import { DefaultAlertingManagementDialogNew as DefaultAlertingManagementDialogNewInner } from "../alerting/DefaultAlertingManagementDialog/DefaultAlertingManagementDialogNew.js";
|
|
4
|
+
import { AlertingManagementDialogContextProvider } from "../contexts/AlertingManagementDialogContext.js";
|
|
5
|
+
import { AutomationsContextProvider } from "../contexts/AutomationsContext.js";
|
|
6
|
+
import { useBuildAlertingManagementDialogContext } from "./hooks/useBuildAlertingManagementDialogContext.js";
|
|
7
|
+
import { useBuildAutomationsContext } from "./hooks/useBuildAutomationsContext.js";
|
|
8
|
+
/**
|
|
9
|
+
* Self-contained version of DefaultAlertingManagementDialogNew that builds the required
|
|
10
|
+
* AutomationsContext and AlertingManagementDialogContext internally from the dashboard
|
|
11
|
+
* Redux store. Use this export when mounting the management dialog outside of
|
|
12
|
+
* AlertingConnector (e.g. embedding scenarios, storybooks, or custom dashboard shells).
|
|
13
|
+
*
|
|
14
|
+
* @alpha
|
|
15
|
+
*/
|
|
16
|
+
export function DefaultAlertingManagementDialogNew(props) {
|
|
17
|
+
const automationsCtx = useBuildAutomationsContext();
|
|
18
|
+
const managementCtx = useBuildAlertingManagementDialogContext();
|
|
19
|
+
return (_jsx(AutomationsContextProvider, { value: automationsCtx, children: _jsx(AlertingManagementDialogContextProvider, { value: managementCtx, children: _jsx(DefaultAlertingManagementDialogNewInner, { ...props }) }) }));
|
|
20
|
+
}
|
package/esm/presentation/automations/connectors/hooks/useBuildAlertingManagementDialogContext.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { IAlertingManagementDialogContextValue } from "../../contexts/AlertingManagementDialogContext.js";
|
|
2
|
+
export declare function useBuildAlertingManagementDialogContext(): IAlertingManagementDialogContextValue;
|
|
3
|
+
//# sourceMappingURL=useBuildAlertingManagementDialogContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBuildAlertingManagementDialogContext.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/connectors/hooks/useBuildAlertingManagementDialogContext.ts"],"names":[],"mappings":"AAgCA,OAAO,KAAK,EAAE,qCAAqC,EAAE,MAAM,mDAAmD,CAAC;AAI/G,wBAAgB,uCAAuC,IAAI,qCAAqC,CA2I/F"}
|
package/esm/presentation/automations/connectors/hooks/useBuildAlertingManagementDialogContext.js
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
// (C) 2026 GoodData Corporation
|
|
2
|
+
import { useCallback, useMemo, useRef } from "react";
|
|
3
|
+
import { isInsightWidget, isWidget, } from "@gooddata/sdk-model";
|
|
4
|
+
import { saveAlert } from "../../../../model/commands/alerts.js";
|
|
5
|
+
import { useDashboardSelector } from "../../../../model/react/DashboardStoreProvider.js";
|
|
6
|
+
import { useDashboardCommandProcessing } from "../../../../model/react/useDashboardCommandProcessing.js";
|
|
7
|
+
import { selectEnableAccessibilityMode, selectIsEmbedded, } from "../../../../model/store/config/configSelectors.js";
|
|
8
|
+
import { selectInsightsMap } from "../../../../model/store/insights/insightsSelectors.js";
|
|
9
|
+
import { selectDashboardId, selectDashboardTitle } from "../../../../model/store/meta/metaSelectors.js";
|
|
10
|
+
import { selectCanManageWorkspace } from "../../../../model/store/permissions/permissionsSelectors.js";
|
|
11
|
+
import { selectWidgetsMap } from "../../../../model/store/tabs/layout/layoutSelectors.js";
|
|
12
|
+
import { selectAlertingDialogReturnFocusTo, selectAutomationsInvalidationId, selectIsAlertingDialogOpen, selectIsAlertingManagementDialogContext, } from "../../../../model/store/ui/uiSelectors.js";
|
|
13
|
+
import { selectCurrentUser } from "../../../../model/store/user/userSelectors.js";
|
|
14
|
+
import { sanitizeAutomationForSave } from "./sanitizeAutomationForSave.js";
|
|
15
|
+
export function useBuildAlertingManagementDialogContext() {
|
|
16
|
+
const currentUser = useDashboardSelector(selectCurrentUser);
|
|
17
|
+
const dashboardId = useDashboardSelector(selectDashboardId);
|
|
18
|
+
const dashboardTitle = useDashboardSelector(selectDashboardTitle);
|
|
19
|
+
const canManageWorkspace = useDashboardSelector(selectCanManageWorkspace);
|
|
20
|
+
const isAlertDialogOpen = useDashboardSelector(selectIsAlertingDialogOpen);
|
|
21
|
+
const alertingDialogReturnFocusTo = useDashboardSelector(selectAlertingDialogReturnFocusTo);
|
|
22
|
+
const managementDialogContext = useDashboardSelector(selectIsAlertingManagementDialogContext);
|
|
23
|
+
const automationsInvalidationId = useDashboardSelector(selectAutomationsInvalidationId);
|
|
24
|
+
const isEmbedded = useDashboardSelector(selectIsEmbedded);
|
|
25
|
+
const enableAccessibilityMode = useDashboardSelector(selectEnableAccessibilityMode);
|
|
26
|
+
const widgetsMap = useDashboardSelector(selectWidgetsMap);
|
|
27
|
+
const insightsMap = useDashboardSelector(selectInsightsMap);
|
|
28
|
+
// Look widgets up through the ObjRefMap (same as selectWidgetByRef) so an
|
|
29
|
+
// identifier-vs-URI ref mismatch between the stored alert and the dashboard
|
|
30
|
+
// widget is bridged. A plain areObjRefsEqual scan would miss those.
|
|
31
|
+
const getWidgetByRef = useCallback((ref) => {
|
|
32
|
+
if (!ref) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
const found = widgetsMap.get(ref);
|
|
36
|
+
return isWidget(found) ? found : undefined;
|
|
37
|
+
}, [widgetsMap]);
|
|
38
|
+
const getInsightByWidgetRef = useCallback((ref) => {
|
|
39
|
+
if (!ref) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const widget = widgetsMap.get(ref);
|
|
43
|
+
if (!isInsightWidget(widget)) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return insightsMap.get(widget.insight) ?? undefined;
|
|
47
|
+
}, [widgetsMap, insightsMap]);
|
|
48
|
+
const pauseResolveRef = useRef(null);
|
|
49
|
+
const pauseRejectRef = useRef(null);
|
|
50
|
+
const resumeResolveRef = useRef(null);
|
|
51
|
+
const resumeRejectRef = useRef(null);
|
|
52
|
+
const pauseCommandProcessing = useDashboardCommandProcessing({
|
|
53
|
+
commandCreator: saveAlert,
|
|
54
|
+
errorEvent: "GDC.DASH/EVT.COMMAND.FAILED",
|
|
55
|
+
successEvent: "GDC.DASH/EVT.ALERT.SAVED",
|
|
56
|
+
onSuccess: (event) => {
|
|
57
|
+
pauseResolveRef.current?.(event.payload.alert);
|
|
58
|
+
pauseResolveRef.current = null;
|
|
59
|
+
pauseRejectRef.current = null;
|
|
60
|
+
},
|
|
61
|
+
onError: (event) => {
|
|
62
|
+
pauseRejectRef.current?.(event.payload.error);
|
|
63
|
+
pauseResolveRef.current = null;
|
|
64
|
+
pauseRejectRef.current = null;
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
const resumeCommandProcessing = useDashboardCommandProcessing({
|
|
68
|
+
commandCreator: saveAlert,
|
|
69
|
+
errorEvent: "GDC.DASH/EVT.COMMAND.FAILED",
|
|
70
|
+
successEvent: "GDC.DASH/EVT.ALERT.SAVED",
|
|
71
|
+
onSuccess: (event) => {
|
|
72
|
+
resumeResolveRef.current?.(event.payload.alert);
|
|
73
|
+
resumeResolveRef.current = null;
|
|
74
|
+
resumeRejectRef.current = null;
|
|
75
|
+
},
|
|
76
|
+
onError: (event) => {
|
|
77
|
+
resumeRejectRef.current?.(event.payload.error);
|
|
78
|
+
resumeResolveRef.current = null;
|
|
79
|
+
resumeRejectRef.current = null;
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
const pauseCommandProcessingRef = useRef(pauseCommandProcessing);
|
|
83
|
+
pauseCommandProcessingRef.current = pauseCommandProcessing;
|
|
84
|
+
const resumeCommandProcessingRef = useRef(resumeCommandProcessing);
|
|
85
|
+
resumeCommandProcessingRef.current = resumeCommandProcessing;
|
|
86
|
+
const pauseAlert = useCallback((alert) => {
|
|
87
|
+
return new Promise((resolve, reject) => {
|
|
88
|
+
pauseResolveRef.current = resolve;
|
|
89
|
+
pauseRejectRef.current = reject;
|
|
90
|
+
pauseCommandProcessingRef.current.run(sanitizeAutomationForSave(alert));
|
|
91
|
+
});
|
|
92
|
+
}, []);
|
|
93
|
+
const resumeAlert = useCallback((alert) => {
|
|
94
|
+
return new Promise((resolve, reject) => {
|
|
95
|
+
resumeResolveRef.current = resolve;
|
|
96
|
+
resumeRejectRef.current = reject;
|
|
97
|
+
resumeCommandProcessingRef.current.run(sanitizeAutomationForSave(alert));
|
|
98
|
+
});
|
|
99
|
+
}, []);
|
|
100
|
+
return useMemo(() => ({
|
|
101
|
+
currentUser,
|
|
102
|
+
dashboardId,
|
|
103
|
+
dashboardTitle,
|
|
104
|
+
canManageWorkspace,
|
|
105
|
+
isAlertDialogOpen,
|
|
106
|
+
alertingDialogReturnFocusTo,
|
|
107
|
+
managementDialogContext,
|
|
108
|
+
automationsInvalidationId,
|
|
109
|
+
isEmbedded,
|
|
110
|
+
enableAccessibilityMode,
|
|
111
|
+
getWidgetByRef,
|
|
112
|
+
getInsightByWidgetRef,
|
|
113
|
+
pauseAlert,
|
|
114
|
+
resumeAlert,
|
|
115
|
+
}), [
|
|
116
|
+
currentUser,
|
|
117
|
+
dashboardId,
|
|
118
|
+
dashboardTitle,
|
|
119
|
+
canManageWorkspace,
|
|
120
|
+
isAlertDialogOpen,
|
|
121
|
+
alertingDialogReturnFocusTo,
|
|
122
|
+
managementDialogContext,
|
|
123
|
+
automationsInvalidationId,
|
|
124
|
+
isEmbedded,
|
|
125
|
+
enableAccessibilityMode,
|
|
126
|
+
getWidgetByRef,
|
|
127
|
+
getInsightByWidgetRef,
|
|
128
|
+
pauseAlert,
|
|
129
|
+
resumeAlert,
|
|
130
|
+
]);
|
|
131
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBuildAutomationsContext.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/connectors/hooks/useBuildAutomationsContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useBuildAutomationsContext.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/connectors/hooks/useBuildAutomationsContext.ts"],"names":[],"mappings":"AA0EA,OAAO,KAAK,EACR,wBAAwB,EAE3B,MAAM,sCAAsC,CAAC;AAI9C,wBAAgB,0BAA0B,IAAI,wBAAwB,CA+LrE"}
|