@gooddata/sdk-ui-dashboard 11.50.0-alpha.2 → 11.50.0-alpha.4

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.
Files changed (73) hide show
  1. package/NOTICE +3 -3
  2. package/esm/__version.d.ts +1 -1
  3. package/esm/__version.js +1 -1
  4. package/esm/_staging/dateFilterConfig/dateFilterConfigConverters.d.ts +1 -9
  5. package/esm/_staging/dateFilterConfig/dateFilterConfigConverters.d.ts.map +1 -1
  6. package/esm/_staging/dateFilterConfig/dateFilterConfigConverters.js +3 -88
  7. package/esm/_staging/dateFilterConfig/dateFilterOptionMapping.d.ts +1 -33
  8. package/esm/_staging/dateFilterConfig/dateFilterOptionMapping.d.ts.map +1 -1
  9. package/esm/_staging/dateFilterConfig/dateFilterOptionMapping.js +3 -260
  10. package/esm/_staging/dateFilterConfig/defaultConfig.d.ts +1 -11
  11. package/esm/_staging/dateFilterConfig/defaultConfig.d.ts.map +1 -1
  12. package/esm/_staging/dateFilterConfig/defaultConfig.js +3 -436
  13. package/esm/model/commandHandlers/scheduledEmail/initializeAutomationsHandler.d.ts.map +1 -1
  14. package/esm/model/commandHandlers/scheduledEmail/initializeAutomationsHandler.js +5 -10
  15. package/esm/model/store/config/configSelectors.d.ts +1 -17
  16. package/esm/model/store/config/configSelectors.d.ts.map +1 -1
  17. package/esm/model/store/config/configSelectors.js +9 -40
  18. package/esm/presentation/automations/alerting/DefaultAlertingDialog/DefaultAlertingDialog.d.ts +2 -3
  19. package/esm/presentation/automations/alerting/DefaultAlertingDialog/DefaultAlertingDialog.d.ts.map +1 -1
  20. package/esm/presentation/automations/alerting/DefaultAlertingDialog/DefaultAlertingDialog.js +3 -12
  21. package/esm/presentation/automations/alerting/DefaultAlertingDialog/hooks/useAlertFilters.d.ts +6 -4
  22. package/esm/presentation/automations/alerting/DefaultAlertingDialog/hooks/useAlertFilters.d.ts.map +1 -1
  23. package/esm/presentation/automations/alerting/DefaultAlertingDialog/hooks/useAlertFilters.js +6 -4
  24. package/esm/presentation/automations/alerting/DefaultAlertingDialog/hooks/useAlertSelectedValues.d.ts +5 -5
  25. package/esm/presentation/automations/alerting/DefaultAlertingDialog/hooks/useAlertSelectedValues.js +5 -5
  26. package/esm/presentation/automations/alerting/DefaultAlertingDialog/hooks/useAlertSupportedMetrics.d.ts +5 -5
  27. package/esm/presentation/automations/alerting/DefaultAlertingDialog/hooks/useAlertSupportedMetrics.js +5 -5
  28. package/esm/presentation/automations/connectors/AlertingConnector.d.ts +5 -7
  29. package/esm/presentation/automations/connectors/AlertingConnector.d.ts.map +1 -1
  30. package/esm/presentation/automations/connectors/AlertingConnector.js +5 -7
  31. package/esm/presentation/automations/connectors/ScheduledEmailConnector.d.ts +4 -4
  32. package/esm/presentation/automations/connectors/ScheduledEmailConnector.js +4 -4
  33. package/esm/presentation/automations/contexts/AlertingDialogContext.d.ts +3 -3
  34. package/esm/presentation/automations/contexts/ScheduledEmailDialogContext.d.ts +4 -2
  35. package/esm/presentation/automations/contexts/ScheduledEmailDialogContext.d.ts.map +1 -1
  36. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useEditScheduledEmail.d.ts +2 -2
  37. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useEditScheduledEmail.d.ts.map +1 -1
  38. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useEditScheduledEmail.js +10 -190
  39. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailEffectiveFilters.d.ts +8 -10
  40. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailEffectiveFilters.d.ts.map +1 -1
  41. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailEffectiveFilters.js +8 -10
  42. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailExportSettings.d.ts +3 -11
  43. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailExportSettings.d.ts.map +1 -1
  44. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailExportSettings.js +21 -3
  45. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFilters.d.ts +34 -0
  46. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFilters.d.ts.map +1 -0
  47. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFilters.js +194 -0
  48. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFormState.d.ts +6 -9
  49. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFormState.d.ts.map +1 -1
  50. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFormState.js +11 -10
  51. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.d.ts +1 -9
  52. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.d.ts.map +1 -1
  53. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.js +3 -88
  54. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.d.ts +1 -33
  55. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.d.ts.map +1 -1
  56. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.js +3 -260
  57. package/esm/presentation/automations/shared/dateFilterConfig/defaultConfig.d.ts +1 -11
  58. package/esm/presentation/automations/shared/dateFilterConfig/defaultConfig.d.ts.map +1 -1
  59. package/esm/presentation/automations/shared/dateFilterConfig/defaultConfig.js +3 -436
  60. package/esm/presentation/dashboardList/DashboardList.d.ts.map +1 -1
  61. package/esm/presentation/dashboardList/DashboardList.js +6 -0
  62. package/esm/presentation/filterBar/filterBar/DefaultDashboardFilterGroup.d.ts.map +1 -1
  63. package/esm/presentation/filterBar/filterBar/DefaultDashboardFilterGroup.js +1 -15
  64. package/esm/presentation/widget/common/InsightDropdown.d.ts.map +1 -1
  65. package/esm/presentation/widget/common/InsightDropdown.js +14 -0
  66. package/esm/presentation/widget/common/configuration/ConfigurationBubble.d.ts.map +1 -1
  67. package/esm/presentation/widget/common/configuration/ConfigurationBubble.js +2 -0
  68. package/esm/presentation/widget/insightMenu/DefaultDashboardInsightMenu/DashboardInsightMenu/DashboardInsightMenuBubble.d.ts.map +1 -1
  69. package/esm/presentation/widget/insightMenu/DefaultDashboardInsightMenu/DashboardInsightMenu/DashboardInsightMenuBubble.js +1 -1
  70. package/esm/sdk-ui-dashboard.d.ts +2 -3
  71. package/package.json +21 -21
  72. package/styles/css/main.css +4 -1
  73. package/styles/css/main.css.map +1 -1
@@ -4,17 +4,15 @@ import { useScheduledEmailDialogContext } from "../../../contexts/ScheduledEmail
4
4
  import { shouldStoreExportParameters } from "../../../shared/automationFilters/automationParameters.js";
5
5
  import { getAppliedDashboardFilters, getAppliedWidgetFilters, getVisibleFiltersByFilters, getVisibleFiltersByFiltersByTab, } from "../../../shared/automationFilters/utils.js";
6
6
  /**
7
- * Derives the effective-filters cluster consumed early by `useScheduledEmailFormState` (draft init) and
8
- * `useScheduledEmailExportSettings`, and later still by the (still-in-parent) filters handlers.
7
+ * Derives the filter sets a scheduled export actually runs with: the widget and dashboard filters left
8
+ * after hidden filters are removed, their visible-filter counterparts for display, and the per-tab
9
+ * variants used by multi-tab dashboards.
9
10
  *
10
- * Filters slice A of 2. Reads `hiddenFilters`/`commonDateFilterId`/`exportParametersByTab` from
11
- * {@link useScheduledEmailDialogContext} internally, same as the parent (`useEditScheduledEmail`) does
12
- * today. `isWidget` is re-derived internally (`!!widget && !!insight`) — if the parent still needs it for
13
- * the filters handlers, it keeps its own copy, a harmless identical re-derivation (mirrors the sibling
14
- * hooks).
15
- *
16
- * Slice B (`useScheduledEmailFilters`, next PR) will own the four filters handlers, which run after
17
- * `formState` (they need `setEditedAutomation`); this derivation cluster runs before it, hence the split.
11
+ * This has to run before the draft exists, because `useScheduledEmailFormState` and
12
+ * `useScheduledEmailExportSettings` consume these values while initializing it. The handlers that
13
+ * *change* filters live in {@link useScheduledEmailFilters} and necessarily run later — they write
14
+ * through the draft's setter. That ordering is why reading and writing filters are two hooks rather
15
+ * than one.
18
16
  *
19
17
  * @internal
20
18
  */
@@ -1,27 +1,18 @@
1
- import { type Dispatch, type RefObject, type SetStateAction } from "react";
1
+ import { type Dispatch, type SetStateAction } from "react";
2
2
  import { type DashboardAttachmentType, type FilterContextItem, type IAutomationMetadataObjectDefinition, type IDashboardExportParameter, type IExportDefinitionVisualizationObjectSettings, type IFilter, type IInsight, type IWidget, type WidgetAttachmentType } from "@gooddata/sdk-model";
3
3
  export interface IUseScheduledEmailExportSettingsProps {
4
4
  editedAutomation: IAutomationMetadataObjectDefinition;
5
5
  setEditedAutomation: Dispatch<SetStateAction<IAutomationMetadataObjectDefinition>>;
6
6
  insight?: IInsight;
7
7
  widget?: IWidget;
8
- dashboardId?: string;
9
- dashboardTitle: string;
10
8
  storeFilters?: boolean;
11
9
  effectiveDashboardFilters: FilterContextItem[] | undefined;
12
10
  effectiveDashboardFiltersByTab: Record<string, FilterContextItem[]> | undefined;
13
11
  effectiveWidgetFilters: IFilter[];
14
12
  effectiveWidgetFiltersWithInsight: IFilter[];
15
13
  defaultPdfPageSize?: IExportDefinitionVisualizationObjectSettings["pageSize"];
16
- resolvedDefaultCsvDelimiter: string;
17
- /**
18
- * Holds the wire outside the automation so it survives a rebuild from zero export definitions —
19
- * with no definitions `setExportParametersByTab` has nowhere to store it. Owned by the parent
20
- * (`useEditScheduledEmail`); read here (never written) at attachment-change time.
21
- */
22
- latestParametersWireRef: RefObject<Record<string, IDashboardExportParameter[]> | undefined>;
23
14
  }
24
- export declare function useScheduledEmailExportSettings({ editedAutomation, setEditedAutomation, insight, widget, dashboardId, dashboardTitle, storeFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, defaultPdfPageSize, resolvedDefaultCsvDelimiter, latestParametersWireRef }: IUseScheduledEmailExportSettingsProps): {
15
+ export declare function useScheduledEmailExportSettings({ editedAutomation, setEditedAutomation, insight, widget, storeFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, defaultPdfPageSize }: IUseScheduledEmailExportSettingsProps): {
25
16
  selectedAttachments: ("CSV" | "CSV_RAW" | "HTML" | "PDF" | "PDF_SLIDES" | "PDF_TABULAR" | "PNG" | "PPTX" | "XLSX")[];
26
17
  isDashboardExportSelected: boolean;
27
18
  isCsvExportSelected: boolean;
@@ -53,5 +44,6 @@ export declare function useScheduledEmailExportSettings({ editedAutomation, setE
53
44
  onCsvSettingsChange: (settings: IExportDefinitionVisualizationObjectSettings) => void;
54
45
  onCsvRawSettingsChange: (settings: IExportDefinitionVisualizationObjectSettings) => void;
55
46
  onSlidesTemplateIdChange: (templateId: string | undefined, format: "PDF" | "PDF_SLIDES" | "PPTX") => void;
47
+ setParametersWire: (wire: Record<string, IDashboardExportParameter[]> | undefined) => void;
56
48
  };
57
49
  //# sourceMappingURL=useScheduledEmailExportSettings.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScheduledEmailExportSettings.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailExportSettings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,SAAS,EAAE,KAAK,cAAc,EAAwB,MAAM,OAAO,CAAC;AAIjG,OAAO,EACH,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,mCAAmC,EACxC,KAAK,yBAAyB,EAC9B,KAAK,4CAA4C,EACjD,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,oBAAoB,EAG5B,MAAM,qBAAqB,CAAC;AAQ7B,MAAM,WAAW,qCAAqC;IAClD,gBAAgB,EAAE,mCAAmC,CAAC;IACtD,mBAAmB,EAAE,QAAQ,CAAC,cAAc,CAAC,mCAAmC,CAAC,CAAC,CAAC;IACnF,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,yBAAyB,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAC3D,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,GAAG,SAAS,CAAC;IAChF,sBAAsB,EAAE,OAAO,EAAE,CAAC;IAClC,iCAAiC,EAAE,OAAO,EAAE,CAAC;IAC7C,kBAAkB,CAAC,EAAE,4CAA4C,CAAC,UAAU,CAAC,CAAC;IAC9E,2BAA2B,EAAE,MAAM,CAAC;IACpC;;;;OAIG;IACH,uBAAuB,EAAE,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,yBAAyB,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC;CAC/F;AAED,wBAAgB,+BAA+B,CAAC,EAC5C,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,MAAM,EACN,WAAW,EACX,cAAc,EACd,YAAY,EACZ,yBAAyB,EACzB,8BAA8B,EAC9B,sBAAsB,EACtB,iCAAiC,EACjC,kBAAkB,EAClB,2BAA2B,EAC3B,uBAAuB,EAC1B,EAAE,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8UvC"}
1
+ {"version":3,"file":"useScheduledEmailExportSettings.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailExportSettings.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAgC,MAAM,OAAO,CAAC;AAIzF,OAAO,EAEH,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,mCAAmC,EACxC,KAAK,yBAAyB,EAC9B,KAAK,4CAA4C,EACjD,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,oBAAoB,EAG5B,MAAM,qBAAqB,CAAC;AAc7B,MAAM,WAAW,qCAAqC;IAClD,gBAAgB,EAAE,mCAAmC,CAAC;IACtD,mBAAmB,EAAE,QAAQ,CAAC,cAAc,CAAC,mCAAmC,CAAC,CAAC,CAAC;IACnF,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,yBAAyB,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAC3D,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,GAAG,SAAS,CAAC;IAChF,sBAAsB,EAAE,OAAO,EAAE,CAAC;IAClC,iCAAiC,EAAE,OAAO,EAAE,CAAC;IAC7C,kBAAkB,CAAC,EAAE,4CAA4C,CAAC,UAAU,CAAC,CAAC;CACjF;AAED,wBAAgB,+BAA+B,CAAC,EAC5C,gBAAgB,EAChB,mBAAmB,EACnB,OAAO,EACP,MAAM,EACN,YAAY,EACZ,yBAAyB,EACzB,8BAA8B,EAC9B,sBAAsB,EACtB,iCAAiC,EACjC,kBAAkB,EACrB,EAAE,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsWvC"}
@@ -1,9 +1,26 @@
1
1
  // (C) 2019-2026 GoodData Corporation
2
- import { useCallback, useMemo } from "react";
2
+ import { useCallback, useMemo, useRef } from "react";
3
3
  import { invariant } from "ts-invariant";
4
- import { isExportDefinitionDashboardRequestPayload, isExportDefinitionVisualizationObjectRequestPayload, } from "@gooddata/sdk-model";
4
+ import { DEFAULT_CSV_DELIMITER, isExportDefinitionDashboardRequestPayload, isExportDefinitionVisualizationObjectRequestPayload, } from "@gooddata/sdk-model";
5
+ import { getAutomationExportParametersByTab, setExportParametersByTab, } from "../../../../../_staging/automation/index.js";
6
+ import { useAutomationsContext } from "../../../contexts/AutomationsContext.js";
7
+ import { useScheduledEmailDialogContext } from "../../../contexts/ScheduledEmailDialogContext.js";
5
8
  import { newDashboardExportDefinitionMetadataObjectDefinition, newWidgetExportDefinitionMetadataObjectDefinition, withRebuiltExportDefinitions, } from "../utils/exportDefinitions.js";
6
- export function useScheduledEmailExportSettings({ editedAutomation, setEditedAutomation, insight, widget, dashboardId, dashboardTitle, storeFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, defaultPdfPageSize, resolvedDefaultCsvDelimiter, latestParametersWireRef, }) {
9
+ export function useScheduledEmailExportSettings({ editedAutomation, setEditedAutomation, insight, widget, storeFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, defaultPdfPageSize, }) {
10
+ const { settings } = useAutomationsContext();
11
+ const { dashboardId, dashboardTitle } = useScheduledEmailDialogContext();
12
+ const resolvedDefaultCsvDelimiter = settings?.exportCsvCustomDelimiter ?? DEFAULT_CSV_DELIMITER;
13
+ // Holds the wire outside the automation so it survives a rebuild from zero export definitions —
14
+ // with no definitions `setExportParametersByTab` has nowhere to store it.
15
+ // Seeded from the stored wire.
16
+ const latestParametersWireRef = useRef(getAutomationExportParametersByTab(editedAutomation));
17
+ // The user-edit path into `content.parametersByTab`: re-encoded wire in, every export definition
18
+ // patched. Handed to `useAutomationExportParameters`, which owns when to call it. Definition
19
+ // rebuilds preserve the wire separately via `withRebuiltExportDefinitions`.
20
+ const setParametersWire = useCallback((wire) => {
21
+ latestParametersWireRef.current = wire;
22
+ setEditedAutomation((automation) => setExportParametersByTab(automation, wire));
23
+ }, [setEditedAutomation]);
7
24
  // Re-derived locally (not passed as a prop) so that `invariant(isWidget, ...)` below narrows
8
25
  // `widget`/`insight` via TS's aliased-condition control-flow analysis — this requires the boolean
9
26
  // to be declared from those exact variables in this same scope, same as in the parent.
@@ -237,5 +254,6 @@ export function useScheduledEmailExportSettings({ editedAutomation, setEditedAut
237
254
  onCsvSettingsChange,
238
255
  onCsvRawSettingsChange,
239
256
  onSlidesTemplateIdChange,
257
+ setParametersWire,
240
258
  };
241
259
  }
@@ -0,0 +1,34 @@
1
+ import { type Dispatch, type SetStateAction } from "react";
2
+ import { type FilterContextItem, type IAutomationMetadataObjectDefinition, type IAutomationVisibleFilter, type IInsight, type IWidget } from "@gooddata/sdk-model";
3
+ import type { IAutomationFiltersTab } from "../../../../../model/store/filtering/types.js";
4
+ export interface IUseScheduledEmailFiltersProps {
5
+ setEditedAutomation: Dispatch<SetStateAction<IAutomationMetadataObjectDefinition>>;
6
+ widget?: IWidget;
7
+ insight?: IInsight;
8
+ setEditedAutomationFilters: (filters: FilterContextItem[]) => void;
9
+ setEditedAutomationFiltersByTab?: (filters: Record<string, FilterContextItem[]>) => void;
10
+ availableFiltersAsVisibleFilters?: IAutomationVisibleFilter[] | undefined;
11
+ availableFiltersAsVisibleFiltersByTab?: Record<string, IAutomationVisibleFilter[]>;
12
+ filtersDataByTab?: IAutomationFiltersTab[] | undefined;
13
+ storeFilters?: boolean;
14
+ setStoreFilters: (storeFilters: boolean) => void;
15
+ filtersForNewAutomation: FilterContextItem[];
16
+ }
17
+ /**
18
+ * Owns the scheduled-email dialog's filter changes. Each handler updates the edited filter state and
19
+ * mirrors the result into the draft — rewriting the filters on its export definitions along with the
20
+ * `metadata.visibleFilters`/`visibleFiltersByTab` used to render them back to the user.
21
+ *
22
+ * Runs after `useScheduledEmailFormState`, because every handler writes through `setEditedAutomation`.
23
+ * The filter sets these handlers start from are derived earlier, in
24
+ * {@link useScheduledEmailEffectiveFilters}.
25
+ *
26
+ * @internal
27
+ */
28
+ export declare function useScheduledEmailFilters({ setEditedAutomation, widget, insight, setEditedAutomationFilters, setEditedAutomationFiltersByTab, availableFiltersAsVisibleFilters, availableFiltersAsVisibleFiltersByTab, filtersDataByTab, storeFilters, setStoreFilters, filtersForNewAutomation }: IUseScheduledEmailFiltersProps): {
29
+ onFiltersChange: (filters: FilterContextItem[], storeFiltersParam?: boolean | undefined) => void;
30
+ onFiltersByTabChange: (newFiltersByTab: Record<string, FilterContextItem[]>, storeFiltersParam?: boolean | undefined) => void;
31
+ onApplyCurrentFilters: () => void;
32
+ onStoreFiltersChange: (value: boolean, filters?: FilterContextItem[] | undefined, filtersByTabParam?: Record<string, FilterContextItem[]> | undefined) => void;
33
+ };
34
+ //# sourceMappingURL=useScheduledEmailFilters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScheduledEmailFilters.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFilters.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,cAAc,EAAe,MAAM,OAAO,CAAC;AAExE,OAAO,EACH,KAAK,iBAAiB,EACtB,KAAK,mCAAmC,EACxC,KAAK,wBAAwB,EAC7B,KAAK,QAAQ,EACb,KAAK,OAAO,EAIf,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AAU3F,MAAM,WAAW,8BAA8B;IAC3C,mBAAmB,EAAE,QAAQ,CAAC,cAAc,CAAC,mCAAmC,CAAC,CAAC,CAAC;IACnF,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,0BAA0B,EAAE,CAAC,OAAO,EAAE,iBAAiB,EAAE,KAAK,IAAI,CAAC;IACnE,+BAA+B,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,KAAK,IAAI,CAAC;IACzF,gCAAgC,CAAC,EAAE,wBAAwB,EAAE,GAAG,SAAS,CAAC;IAC1E,qCAAqC,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,EAAE,CAAC,CAAC;IACnF,gBAAgB,CAAC,EAAE,qBAAqB,EAAE,GAAG,SAAS,CAAC;IACvD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,EAAE,CAAC,YAAY,EAAE,OAAO,KAAK,IAAI,CAAC;IACjD,uBAAuB,EAAE,iBAAiB,EAAE,CAAC;CAChD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,EACrC,mBAAmB,EACnB,MAAM,EACN,OAAO,EACP,0BAA0B,EAC1B,+BAA+B,EAC/B,gCAAgC,EAChC,qCAAqC,EACrC,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,uBAAuB,EAC1B,EAAE,8BAA8B;;;;;EAqPhC"}
@@ -0,0 +1,194 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { useCallback } from "react";
3
+ import { isExportDefinitionDashboardRequestPayload, isExportDefinitionVisualizationObjectRequestPayload, isInsightWidget, } from "@gooddata/sdk-model";
4
+ import { useScheduledEmailDialogContext } from "../../../contexts/ScheduledEmailDialogContext.js";
5
+ import { getDefaultSelectedFiltersFromFiltersByTab } from "../../../shared/automationFilters/useAutomationFiltersSelect.js";
6
+ import { getAppliedDashboardFilters, getAppliedWidgetFilters, getVisibleFiltersByFilters, getVisibleFiltersByFiltersByTab, } from "../../../shared/automationFilters/utils.js";
7
+ /**
8
+ * Owns the scheduled-email dialog's filter changes. Each handler updates the edited filter state and
9
+ * mirrors the result into the draft — rewriting the filters on its export definitions along with the
10
+ * `metadata.visibleFilters`/`visibleFiltersByTab` used to render them back to the user.
11
+ *
12
+ * Runs after `useScheduledEmailFormState`, because every handler writes through `setEditedAutomation`.
13
+ * The filter sets these handlers start from are derived earlier, in
14
+ * {@link useScheduledEmailEffectiveFilters}.
15
+ *
16
+ * @internal
17
+ */
18
+ export function useScheduledEmailFilters({ setEditedAutomation, widget, insight, setEditedAutomationFilters, setEditedAutomationFiltersByTab, availableFiltersAsVisibleFilters, availableFiltersAsVisibleFiltersByTab, filtersDataByTab, storeFilters, setStoreFilters, filtersForNewAutomation, }) {
19
+ const { hiddenFilters: dashboardHiddenFilters, commonDateFilterId } = useScheduledEmailDialogContext();
20
+ // Re-derived locally (not passed as a prop) so that the `if (isWidget)` branch below narrows
21
+ // `widget`/`insight` via TS's aliased-condition control-flow analysis — this requires the boolean
22
+ // to be declared from those exact variables in this same scope, same as in the parent.
23
+ const isWidget = !!widget && !!insight;
24
+ const onFiltersChange = useCallback((filters, storeFiltersParam) => {
25
+ setEditedAutomationFilters(filters);
26
+ const shouldStoreFilters = storeFiltersParam ?? storeFilters;
27
+ if (isWidget) {
28
+ if (!isInsightWidget(widget)) {
29
+ return;
30
+ }
31
+ setEditedAutomation((s) => {
32
+ const appliedDashboardFilters = getAppliedDashboardFilters(filters, dashboardHiddenFilters, true);
33
+ const appliedWidgetFiltersWithInsight = getAppliedWidgetFilters(filters, dashboardHiddenFilters, widget, insight, commonDateFilterId, true);
34
+ const appliedWidgetFiltersWithoutInsight = getAppliedWidgetFilters(filters, dashboardHiddenFilters, widget, insight, commonDateFilterId, false);
35
+ const visibleFilters = getVisibleFiltersByFilters(filters, availableFiltersAsVisibleFilters, true);
36
+ return {
37
+ ...s,
38
+ exportDefinitions: s.exportDefinitions?.map((exportDefinition) => {
39
+ if (isExportDefinitionVisualizationObjectRequestPayload(exportDefinition.requestPayload)) {
40
+ const format = exportDefinition.requestPayload.format;
41
+ const shouldUseWidgetFiltersWithInsight = format === "CSV";
42
+ const shouldUseWidgetFiltersWithoutInsight = format === "CSV_RAW";
43
+ const appliedFilters = shouldUseWidgetFiltersWithInsight
44
+ ? appliedWidgetFiltersWithInsight
45
+ : shouldUseWidgetFiltersWithoutInsight
46
+ ? appliedWidgetFiltersWithoutInsight
47
+ : appliedDashboardFilters;
48
+ return {
49
+ ...exportDefinition,
50
+ requestPayload: {
51
+ ...exportDefinition.requestPayload,
52
+ content: {
53
+ ...exportDefinition.requestPayload.content,
54
+ filters: appliedFilters,
55
+ },
56
+ },
57
+ };
58
+ }
59
+ else {
60
+ return exportDefinition;
61
+ }
62
+ }),
63
+ metadata: {
64
+ ...s.metadata,
65
+ visibleFilters,
66
+ },
67
+ };
68
+ });
69
+ }
70
+ else {
71
+ setEditedAutomation((s) => {
72
+ const appliedFilters = getAppliedDashboardFilters(filters, dashboardHiddenFilters, shouldStoreFilters);
73
+ const visibleFilters = getVisibleFiltersByFilters(filters, availableFiltersAsVisibleFilters, shouldStoreFilters);
74
+ return {
75
+ ...s,
76
+ exportDefinitions: s.exportDefinitions?.map((exportDefinition) => {
77
+ if (isExportDefinitionDashboardRequestPayload(exportDefinition.requestPayload)) {
78
+ return {
79
+ ...exportDefinition,
80
+ requestPayload: {
81
+ ...exportDefinition.requestPayload,
82
+ content: {
83
+ ...exportDefinition.requestPayload.content,
84
+ filters: appliedFilters,
85
+ },
86
+ },
87
+ };
88
+ }
89
+ else {
90
+ return exportDefinition;
91
+ }
92
+ }),
93
+ metadata: {
94
+ ...s.metadata,
95
+ visibleFilters,
96
+ },
97
+ };
98
+ });
99
+ }
100
+ }, [
101
+ setEditedAutomationFilters,
102
+ setEditedAutomation,
103
+ dashboardHiddenFilters,
104
+ availableFiltersAsVisibleFilters,
105
+ storeFilters,
106
+ widget,
107
+ insight,
108
+ isWidget,
109
+ commonDateFilterId,
110
+ ]);
111
+ // Callback for per-tab filter changes - updates state AND syncs to export definitions
112
+ const onFiltersByTabChange = useCallback((newFiltersByTab, storeFiltersParam) => {
113
+ // Update the editedFiltersByTab state
114
+ setEditedAutomationFiltersByTab?.(newFiltersByTab);
115
+ const shouldStoreFilters = storeFiltersParam ?? storeFilters;
116
+ const newEffectiveFiltersByTab = shouldStoreFilters
117
+ ? Object.entries(newFiltersByTab).reduce((acc, [tabId, filters]) => {
118
+ const tabHiddenFilters = filtersDataByTab?.find((tab) => tab.tabId === tabId)?.hiddenFilters ?? [];
119
+ const appliedFilters = getAppliedDashboardFilters(filters ?? [], tabHiddenFilters, true);
120
+ if (appliedFilters) {
121
+ acc[tabId] = appliedFilters;
122
+ }
123
+ return acc;
124
+ }, {})
125
+ : undefined;
126
+ const newVisibleFiltersByTab = getVisibleFiltersByFiltersByTab(newFiltersByTab, availableFiltersAsVisibleFiltersByTab, shouldStoreFilters);
127
+ // Sync to export definitions AND metadata
128
+ setEditedAutomation((s) => ({
129
+ ...s,
130
+ exportDefinitions: s.exportDefinitions?.map((exportDefinition) => {
131
+ if (isExportDefinitionDashboardRequestPayload(exportDefinition.requestPayload)) {
132
+ return {
133
+ ...exportDefinition,
134
+ requestPayload: {
135
+ ...exportDefinition.requestPayload,
136
+ content: {
137
+ ...exportDefinition.requestPayload.content,
138
+ filtersByTab: newEffectiveFiltersByTab,
139
+ },
140
+ },
141
+ };
142
+ }
143
+ return exportDefinition;
144
+ }),
145
+ metadata: {
146
+ ...s.metadata,
147
+ visibleFiltersByTab: newVisibleFiltersByTab,
148
+ },
149
+ }));
150
+ }, [
151
+ setEditedAutomationFiltersByTab,
152
+ storeFilters,
153
+ setEditedAutomation,
154
+ availableFiltersAsVisibleFiltersByTab,
155
+ filtersDataByTab,
156
+ ]);
157
+ const onApplyCurrentFilters = useCallback(() => {
158
+ // Widget schedules should never use per-tab filters, only dashboard schedules can have tabs
159
+ const filtersByTabForNewAutomation = widget
160
+ ? undefined
161
+ : getDefaultSelectedFiltersFromFiltersByTab(filtersDataByTab);
162
+ if (filtersByTabForNewAutomation) {
163
+ onFiltersByTabChange(filtersByTabForNewAutomation);
164
+ }
165
+ else {
166
+ onFiltersChange(filtersForNewAutomation ?? [], widget ? true : storeFilters);
167
+ }
168
+ }, [
169
+ filtersForNewAutomation,
170
+ storeFilters,
171
+ onFiltersChange,
172
+ onFiltersByTabChange,
173
+ widget,
174
+ filtersDataByTab,
175
+ ]);
176
+ const onStoreFiltersChange = useCallback((value, filters, filtersByTabParam) => {
177
+ setStoreFilters(value);
178
+ // If filtersByTab is provided, use onFiltersByTabChange, otherwise use onFiltersChange
179
+ if (filtersByTabParam) {
180
+ // Trigger filtersByTab change which handles the sync
181
+ onFiltersByTabChange(filtersByTabParam, value);
182
+ }
183
+ if (filters) {
184
+ // Use regular filters change
185
+ onFiltersChange(filters, value);
186
+ }
187
+ }, [onFiltersChange, onFiltersByTabChange, setStoreFilters]);
188
+ return {
189
+ onFiltersChange,
190
+ onFiltersByTabChange,
191
+ onApplyCurrentFilters,
192
+ onStoreFiltersChange,
193
+ };
194
+ }
@@ -16,7 +16,6 @@ export interface IUseScheduledEmailFormStateProps {
16
16
  effectiveVisibleDashboardFiltersByTab: Record<string, IAutomationVisibleFilter[]> | undefined;
17
17
  parametersByTabForNewAutomation: Record<string, IDashboardExportParameter[]> | undefined;
18
18
  defaultPdfPageSize?: IExportDefinitionVisualizationObjectSettings["pageSize"];
19
- targetTabId?: string;
20
19
  }
21
20
  /**
22
21
  * Owns the scheduled-email dialog's `editedAutomation` draft (initialized either from
@@ -24,17 +23,14 @@ export interface IUseScheduledEmailFormStateProps {
24
23
  * baseline, the derived defaults (`defaultRecipient`, `defaultUser`), and the form's field/message
25
24
  * change handlers and their validity UI state.
26
25
  *
27
- * `timezone` (already part 1) and `currentUser` are read from {@link useAutomationsContext};
28
- * `dashboardId`/`dashboardTitle` from {@link useScheduledEmailDialogContext}. The effective-filters
29
- * derivations, `parametersByTabForNewAutomation`, `defaultPdfPageSize`, and `targetTabId` stay owned
30
- * by the parent (`useEditScheduledEmail`) — shared with other consumers — and are passed in as params.
31
- *
32
- * Part 2 of 2 (mirrors the alerting `useAlertFormState` part 2): completes the hook by folding in the
33
- * draft init that part 1 left in the parent.
26
+ * Values only this hook needs — `timezone` and `currentUser` from {@link useAutomationsContext},
27
+ * `dashboardId`/`dashboardTitle`/`widgetLocalIdToTabIdMap` from {@link useScheduledEmailDialogContext} —
28
+ * are read here directly. The effective-filters derivations, `parametersByTabForNewAutomation`, and
29
+ * `defaultPdfPageSize` arrive as params instead, because the parent shares them with other consumers.
34
30
  *
35
31
  * @internal
36
32
  */
37
- export declare function useScheduledEmailFormState({ scheduledExportToEdit, widget, insight, notificationChannels, users, externalRecipientOverride, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, effectiveVisibleWidgetFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveVisibleDashboardFilters, effectiveVisibleDashboardFiltersByTab, parametersByTabForNewAutomation, defaultPdfPageSize, targetTabId }: IUseScheduledEmailFormStateProps): {
33
+ export declare function useScheduledEmailFormState({ scheduledExportToEdit, widget, insight, notificationChannels, users, externalRecipientOverride, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, effectiveVisibleWidgetFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveVisibleDashboardFilters, effectiveVisibleDashboardFiltersByTab, parametersByTabForNewAutomation, defaultPdfPageSize }: IUseScheduledEmailFormStateProps): {
38
34
  editedAutomation: IAutomationMetadataObjectDefinition;
39
35
  setEditedAutomation: import("react").Dispatch<import("react").SetStateAction<IAutomationMetadataObjectDefinition>>;
40
36
  originalAutomation: IAutomationMetadataObjectDefinition;
@@ -51,5 +47,6 @@ export declare function useScheduledEmailFormState({ scheduledExportToEdit, widg
51
47
  isTitleValid: boolean;
52
48
  isSubjectValid: boolean;
53
49
  isOnMessageValid: boolean;
50
+ startDate: Date;
54
51
  };
55
52
  //# sourceMappingURL=useScheduledEmailFormState.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useScheduledEmailFormState.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFormState.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAE9B,KAAK,mCAAmC,EACxC,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,4CAA4C,EACjD,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EACvC,KAAK,OAAO,EACZ,KAAK,cAAc,EACtB,MAAM,qBAAqB,CAAC;AAiB7B,MAAM,WAAW,gCAAgC;IAC7C,qBAAqB,CAAC,EAAE,yBAAyB,CAAC;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,oBAAoB,EAAE,8BAA8B,EAAE,GAAG,kCAAkC,EAAE,CAAC;IAC9F,iFAAiF;IACjF,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,sBAAsB,EAAE,OAAO,EAAE,CAAC;IAClC,iCAAiC,EAAE,OAAO,EAAE,CAAC;IAC7C,6BAA6B,EAAE,wBAAwB,EAAE,GAAG,SAAS,CAAC;IACtE,yBAAyB,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAC3D,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,GAAG,SAAS,CAAC;IAChF,gCAAgC,EAAE,wBAAwB,EAAE,GAAG,SAAS,CAAC;IACzE,qCAAqC,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,EAAE,CAAC,GAAG,SAAS,CAAC;IAC9F,+BAA+B,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,EAAE,CAAC,GAAG,SAAS,CAAC;IACzF,kBAAkB,CAAC,EAAE,4CAA4C,CAAC,UAAU,CAAC,CAAC;IAC9E,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,0BAA0B,CAAC,EACvC,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,KAAK,EACL,yBAAyB,EACzB,sBAAsB,EACtB,iCAAiC,EACjC,6BAA6B,EAC7B,yBAAyB,EACzB,8BAA8B,EAC9B,gCAAgC,EAChC,qCAAqC,EACrC,+BAA+B,EAC/B,kBAAkB,EAClB,WAAW,EACd,EAAE,gCAAgC;;;;;;;;;;;;;;;;;EAwIlC"}
1
+ {"version":3,"file":"useScheduledEmailFormState.d.ts","sourceRoot":"","sources":["../../../../../../src/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFormState.ts"],"names":[],"mappings":"AAIA,OAAO,EAEH,KAAK,iBAAiB,EACtB,KAAK,yBAAyB,EAE9B,KAAK,mCAAmC,EACxC,KAAK,oBAAoB,EACzB,KAAK,wBAAwB,EAC7B,KAAK,yBAAyB,EAC9B,KAAK,4CAA4C,EACjD,KAAK,OAAO,EACZ,KAAK,QAAQ,EACb,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EACvC,KAAK,OAAO,EACZ,KAAK,cAAc,EACtB,MAAM,qBAAqB,CAAC;AAqB7B,MAAM,WAAW,gCAAgC;IAC7C,qBAAqB,CAAC,EAAE,yBAAyB,CAAC;IAClD,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,QAAQ,CAAC;IACnB,oBAAoB,EAAE,8BAA8B,EAAE,GAAG,kCAAkC,EAAE,CAAC;IAC9F,iFAAiF;IACjF,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,sBAAsB,EAAE,OAAO,EAAE,CAAC;IAClC,iCAAiC,EAAE,OAAO,EAAE,CAAC;IAC7C,6BAA6B,EAAE,wBAAwB,EAAE,GAAG,SAAS,CAAC;IACtE,yBAAyB,EAAE,iBAAiB,EAAE,GAAG,SAAS,CAAC;IAC3D,8BAA8B,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,CAAC,GAAG,SAAS,CAAC;IAChF,gCAAgC,EAAE,wBAAwB,EAAE,GAAG,SAAS,CAAC;IACzE,qCAAqC,EAAE,MAAM,CAAC,MAAM,EAAE,wBAAwB,EAAE,CAAC,GAAG,SAAS,CAAC;IAC9F,+BAA+B,EAAE,MAAM,CAAC,MAAM,EAAE,yBAAyB,EAAE,CAAC,GAAG,SAAS,CAAC;IACzF,kBAAkB,CAAC,EAAE,4CAA4C,CAAC,UAAU,CAAC,CAAC;CACjF;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,0BAA0B,CAAC,EACvC,qBAAqB,EACrB,MAAM,EACN,OAAO,EACP,oBAAoB,EACpB,KAAK,EACL,yBAAyB,EACzB,sBAAsB,EACtB,iCAAiC,EACjC,6BAA6B,EAC7B,yBAAyB,EACzB,8BAA8B,EAC9B,gCAAgC,EAChC,qCAAqC,EACrC,+BAA+B,EAC/B,kBAAkB,EACrB,EAAE,gCAAgC;;;;;;;;;;;;;;;;;;EAqJlC"}
@@ -4,7 +4,7 @@ import { setExportParametersByTab } from "../../../../../_staging/automation/ind
4
4
  import { useAutomationsContext } from "../../../contexts/AutomationsContext.js";
5
5
  import { useScheduledEmailDialogContext } from "../../../contexts/ScheduledEmailDialogContext.js";
6
6
  import { convertCurrentUserToAutomationRecipient, convertCurrentUserToWorkspaceUser, convertExternalRecipientToAutomationRecipient, } from "../../../shared/utils/automationUtils.js";
7
- import { toModifiedISOStringToTimezone, toNormalizedFirstRunAndCron } from "../../utils/date.js";
7
+ import { toModifiedISOStringToTimezone, toNormalizedFirstRunAndCron, toNormalizedStartDate, } from "../../utils/date.js";
8
8
  import { getUserTimezone } from "../../utils/timezone.js";
9
9
  import { newDashboardExportDefinitionMetadataObjectDefinition, newWidgetExportDefinitionMetadataObjectDefinition, } from "../utils/exportDefinitions.js";
10
10
  /**
@@ -13,20 +13,19 @@ import { newDashboardExportDefinitionMetadataObjectDefinition, newWidgetExportDe
13
13
  * baseline, the derived defaults (`defaultRecipient`, `defaultUser`), and the form's field/message
14
14
  * change handlers and their validity UI state.
15
15
  *
16
- * `timezone` (already part 1) and `currentUser` are read from {@link useAutomationsContext};
17
- * `dashboardId`/`dashboardTitle` from {@link useScheduledEmailDialogContext}. The effective-filters
18
- * derivations, `parametersByTabForNewAutomation`, `defaultPdfPageSize`, and `targetTabId` stay owned
19
- * by the parent (`useEditScheduledEmail`) — shared with other consumers — and are passed in as params.
20
- *
21
- * Part 2 of 2 (mirrors the alerting `useAlertFormState` part 2): completes the hook by folding in the
22
- * draft init that part 1 left in the parent.
16
+ * Values only this hook needs — `timezone` and `currentUser` from {@link useAutomationsContext},
17
+ * `dashboardId`/`dashboardTitle`/`widgetLocalIdToTabIdMap` from {@link useScheduledEmailDialogContext} —
18
+ * are read here directly. The effective-filters derivations, `parametersByTabForNewAutomation`, and
19
+ * `defaultPdfPageSize` arrive as params instead, because the parent shares them with other consumers.
23
20
  *
24
21
  * @internal
25
22
  */
26
- export function useScheduledEmailFormState({ scheduledExportToEdit, widget, insight, notificationChannels, users, externalRecipientOverride, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, effectiveVisibleWidgetFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveVisibleDashboardFilters, effectiveVisibleDashboardFiltersByTab, parametersByTabForNewAutomation, defaultPdfPageSize, targetTabId, }) {
23
+ export function useScheduledEmailFormState({ scheduledExportToEdit, widget, insight, notificationChannels, users, externalRecipientOverride, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, effectiveVisibleWidgetFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveVisibleDashboardFilters, effectiveVisibleDashboardFiltersByTab, parametersByTabForNewAutomation, defaultPdfPageSize, }) {
27
24
  const { timezone, currentUser } = useAutomationsContext();
28
- const { dashboardId, dashboardTitle } = useScheduledEmailDialogContext();
25
+ const { dashboardId, dashboardTitle, widgetLocalIdToTabIdMap: widgetTabMap, } = useScheduledEmailDialogContext();
29
26
  const isWidget = !!widget && !!insight;
27
+ // Determine target tab ID if widget is present
28
+ const targetTabId = widget?.localIdentifier ? widgetTabMap[widget.localIdentifier] : undefined;
30
29
  const defaultUser = convertCurrentUserToWorkspaceUser(users ?? [], currentUser);
31
30
  const defaultRecipient = externalRecipientOverride
32
31
  ? convertExternalRecipientToAutomationRecipient(externalRecipientOverride)
@@ -65,6 +64,7 @@ export function useScheduledEmailFormState({ scheduledExportToEdit, widget, insi
65
64
  parametersByTab: parametersByTabForNewAutomation,
66
65
  }));
67
66
  const [originalAutomation] = useState(editedAutomation);
67
+ const startDate = toNormalizedStartDate(editedAutomation.schedule?.firstRun, editedAutomation.schedule?.timezone);
68
68
  const [isCronValid, setIsCronValid] = useState(true);
69
69
  const [isTitleValid, setIsTitleValid] = useState(true);
70
70
  const [isSubjectValid, setIsSubjectValid] = useState(true);
@@ -139,6 +139,7 @@ export function useScheduledEmailFormState({ scheduledExportToEdit, widget, insi
139
139
  isTitleValid,
140
140
  isSubjectValid,
141
141
  isOnMessageValid,
142
+ startDate,
142
143
  };
143
144
  }
144
145
  function newAutomationMetadataObjectDefinition({ timezone, dashboardId, notificationChannel, title, insight, widget, recipient, dashboardFilters, filtersByTab, widgetFilters, widgetFiltersWithInsight, visibleFiltersMetadata, visibleFiltersByTab, defaultPdfPageSize, evaluationMode, targetTabId, parametersByTab, }) {
@@ -1,10 +1,2 @@
1
- import { type IDateFilterConfig } from "@gooddata/sdk-model";
2
- import { type IDateFilterOptionsByType } from "@gooddata/sdk-ui-filters";
3
- /**
4
- * Converts date filter config - as stored on the backend - into the date filter options that are aimed for
5
- * consumption by the actual date filtering view components.
6
- *
7
- * @param config - date filter config from backend
8
- */
9
- export declare function convertDateFilterConfigToDateFilterOptions(config: IDateFilterConfig): IDateFilterOptionsByType;
1
+ export { convertDateFilterConfigToDateFilterOptions } from "@gooddata/sdk-ui-filters";
10
2
  //# sourceMappingURL=dateFilterConfigConverters.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateFilterConfigConverters.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.ts"],"names":[],"mappings":"AAKA,OAAO,EAIH,KAAK,iBAAiB,EAIzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAGH,KAAK,wBAAwB,EAIhC,MAAM,0BAA0B,CAAC;AAKlC;;;;;GAKG;AACH,wBAAgB,0CAA0C,CACtD,MAAM,EAAE,iBAAiB,GAC1B,wBAAwB,CAgB1B"}
1
+ {"version":3,"file":"dateFilterConfigConverters.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,0CAA0C,EAAE,MAAM,0BAA0B,CAAC"}
@@ -1,89 +1,4 @@
1
1
  // (C) 2019-2026 GoodData Corporation
2
- import { endOfDay, format, startOfDay, subMonths } from "date-fns";
3
- import { groupBy, isEmpty, max, min } from "lodash-es";
4
- // TODO: this import was coming from internal/esm and was wrecking tests
5
- const PLATFORM_DATE_FORMAT = "yyyy-MM-dd HH:mm";
6
- /**
7
- * Converts date filter config - as stored on the backend - into the date filter options that are aimed for
8
- * consumption by the actual date filtering view components.
9
- *
10
- * @param config - date filter config from backend
11
- */
12
- export function convertDateFilterConfigToDateFilterOptions(config) {
13
- const allTime = convertAllTime(config.allTime);
14
- const emptyValues = convertEmptyValues(config.emptyValues);
15
- const absoluteForm = convertAbsoluteForm(config.absoluteForm);
16
- const relativeForm = convertRelativeForm(config.relativeForm);
17
- const absolutePreset = convertAbsolutePresets(config.absolutePresets);
18
- const relativePreset = convertRelativePresets(config.relativePresets);
19
- return removeEmptyKeysFromDateFilterOptions({
20
- allTime,
21
- emptyValues,
22
- absoluteForm,
23
- absolutePreset,
24
- relativeForm,
25
- relativePreset,
26
- });
27
- }
28
- function convertAllTime(filter) {
29
- return (filter && {
30
- ...filter,
31
- type: "allTime",
32
- });
33
- }
34
- function convertEmptyValues(filter) {
35
- return (filter && {
36
- ...filter,
37
- type: "emptyValues",
38
- });
39
- }
40
- function convertAbsoluteForm(filter) {
41
- return (filter && {
42
- ...filter,
43
- from: format(startOfDay(subMonths(new Date(), 1)), PLATFORM_DATE_FORMAT),
44
- to: format(endOfDay(new Date()), PLATFORM_DATE_FORMAT),
45
- type: "absoluteForm",
46
- });
47
- }
48
- function convertRelativeForm(filter) {
49
- return (filter && {
50
- from: undefined,
51
- // we order the granularities anyway, this lets the user to config the default
52
- granularity: filter.availableGranularities[0],
53
- localIdentifier: filter.localIdentifier,
54
- name: filter.name,
55
- to: undefined,
56
- type: "relativeForm",
57
- visible: filter.visible,
58
- });
59
- }
60
- function convertAbsolutePresets(filters) {
61
- return filters?.map((preset) => sanitizeDateFilterOption({
62
- ...preset,
63
- type: "absolutePreset",
64
- }));
65
- }
66
- function convertRelativePresets(filters) {
67
- return (filters &&
68
- groupBy(filters.map((preset) => sanitizeDateFilterOption({
69
- ...preset,
70
- type: "relativePreset",
71
- })), (preset) => preset.granularity));
72
- }
73
- function removeEmptyKeysFromDateFilterOptions({ absoluteForm, absolutePreset, allTime, emptyValues, relativeForm, relativePreset, }) {
74
- return {
75
- ...(allTime && { allTime }),
76
- ...(emptyValues && { emptyValues }),
77
- ...(absoluteForm && { absoluteForm }),
78
- ...(!isEmpty(absolutePreset) && { absolutePreset }),
79
- ...(relativeForm && { relativeForm }),
80
- ...(!isEmpty(relativePreset) && { relativePreset }),
81
- };
82
- }
83
- function sanitizeDateFilterOption(option) {
84
- return {
85
- ...option,
86
- from: min([option.from, option.to]),
87
- to: max([option.from, option.to]),
88
- };
89
- }
2
+ /* oxlint-disable no-barrel-files/no-barrel-files */
3
+ // Moved to sdk-ui-filters (shared with the CF date picker); re-exported for existing import sites.
4
+ export { convertDateFilterConfigToDateFilterOptions } from "@gooddata/sdk-ui-filters";
@@ -1,34 +1,2 @@
1
- import { type IDashboardDateFilter } from "@gooddata/sdk-model";
2
- import { type DateFilterOption, type IDateFilterOptionsByType } from "@gooddata/sdk-ui-filters";
3
- interface IDateFilterOptionInfo {
4
- dateFilterOption: DateFilterOption;
5
- excludeCurrentPeriod: boolean;
6
- }
7
- /**
8
- * Tries to match a preset or a form with the provided value. Prioritizes the provided option if possible.
9
- *
10
- * @remarks
11
- * This is to handle cases when user picked a form and filled values that match an existing preset.
12
- * In those cases we want to show the form as picked even though a preset would otherwise be preferred.
13
- *
14
- * @param dateFilter - value to match against
15
- * @param availableOptions - date options available
16
- * @param preferredOptionId - id of the option that should be matched first if possible
17
- */
18
- export declare function matchDateFilterToDateFilterOptionWithPreference(dateFilter: IDashboardDateFilter | undefined, availableOptions: IDateFilterOptionsByType, preferredOptionId: string | undefined): IDateFilterOptionInfo;
19
- /**
20
- * Tries to match a preset or a form with the provided value. Prioritizes presets over forms.
21
- * @param dateFilterValue - value to match against
22
- * @param availableOptions - date options available
23
- */
24
- export declare function matchDateFilterToDateFilterOption(dateFilter: IDashboardDateFilter | undefined, availableOptions: IDateFilterOptionsByType): IDateFilterOptionInfo;
25
- /**
26
- * Flattens the provided date filter options. The flattening maintains a stable, predefined order in which
27
- * the options should be rendered by the date filter component.
28
- *
29
- * @param dateFilterOptions - available options to flatten
30
- */
31
- export declare function flattenDateFilterOptions(dateFilterOptions: IDateFilterOptionsByType): DateFilterOption[];
32
- export declare function findDateFilterOptionByValue(dateFilter: IDashboardDateFilter, dateFilterOptions: IDateFilterOptionsByType): DateFilterOption | undefined;
33
- export {};
1
+ export { findDateFilterOptionByValue, flattenDateFilterOptions, matchDateFilterToDateFilterOption, matchDateFilterToDateFilterOptionWithPreference, } from "@gooddata/sdk-ui-filters";
34
2
  //# sourceMappingURL=dateFilterOptionMapping.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"dateFilterOptionMapping.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.ts"],"names":[],"mappings":"AAIA,OAAO,EAKH,KAAK,oBAAoB,EAM5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACH,KAAK,gBAAgB,EACrB,KAAK,wBAAwB,EAKhC,MAAM,0BAA0B,CAAC;AAUlC,UAAU,qBAAqB;IAC3B,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,oBAAoB,EAAE,OAAO,CAAC;CACjC;AAaD;;;;;;;;;;GAUG;AACH,wBAAgB,+CAA+C,CAC3D,UAAU,EAAE,oBAAoB,GAAG,SAAS,EAC5C,gBAAgB,EAAE,wBAAwB,EAC1C,iBAAiB,EAAE,MAAM,GAAG,SAAS,GACtC,qBAAqB,CAmBvB;AAED;;;;GAIG;AACH,wBAAgB,iCAAiC,CAC7C,UAAU,EAAE,oBAAoB,GAAG,SAAS,EAC5C,gBAAgB,EAAE,wBAAwB,GAC3C,qBAAqB,CAqEvB;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,iBAAiB,EAAE,wBAAwB,GAAG,gBAAgB,EAAE,CAmBxG;AAsDD,wBAAgB,2BAA2B,CACvC,UAAU,EAAE,oBAAoB,EAChC,iBAAiB,EAAE,wBAAwB,gCAG9C"}
1
+ {"version":3,"file":"dateFilterOptionMapping.d.ts","sourceRoot":"","sources":["../../../../../src/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,2BAA2B,EAC3B,wBAAwB,EACxB,iCAAiC,EACjC,+CAA+C,GAClD,MAAM,0BAA0B,CAAC"}