@gooddata/sdk-ui-dashboard 11.50.0-alpha.1 → 11.50.0-alpha.3

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 (48) hide show
  1. package/NOTICE +216 -203
  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/store/config/configSelectors.d.ts.map +1 -1
  14. package/esm/model/store/config/configSelectors.js +2 -9
  15. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useEditScheduledEmail.d.ts +4 -4
  16. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useEditScheduledEmail.d.ts.map +1 -1
  17. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useEditScheduledEmail.js +50 -359
  18. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailEffectiveFilters.d.ts +38 -0
  19. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailEffectiveFilters.d.ts.map +1 -0
  20. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailEffectiveFilters.js +61 -0
  21. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFilters.d.ts +35 -0
  22. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFilters.d.ts.map +1 -0
  23. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFilters.js +195 -0
  24. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFormState.d.ts +55 -0
  25. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFormState.d.ts.map +1 -0
  26. package/esm/presentation/automations/scheduledEmail/DefaultScheduledEmailDialog/hooks/useScheduledEmailFormState.js +203 -0
  27. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.d.ts +1 -9
  28. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.d.ts.map +1 -1
  29. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterConfigConverters.js +3 -88
  30. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.d.ts +1 -33
  31. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.d.ts.map +1 -1
  32. package/esm/presentation/automations/shared/dateFilterConfig/dateFilterOptionMapping.js +3 -260
  33. package/esm/presentation/automations/shared/dateFilterConfig/defaultConfig.d.ts +1 -11
  34. package/esm/presentation/automations/shared/dateFilterConfig/defaultConfig.d.ts.map +1 -1
  35. package/esm/presentation/automations/shared/dateFilterConfig/defaultConfig.js +3 -436
  36. package/esm/presentation/dashboardList/DashboardList.d.ts.map +1 -1
  37. package/esm/presentation/dashboardList/DashboardList.js +6 -0
  38. package/esm/presentation/filterBar/filterBar/DefaultFilterBarContainer.d.ts.map +1 -1
  39. package/esm/presentation/filterBar/filterBar/DefaultFilterBarContainer.js +11 -5
  40. package/esm/presentation/widget/common/InsightDropdown.d.ts.map +1 -1
  41. package/esm/presentation/widget/common/InsightDropdown.js +14 -0
  42. package/esm/presentation/widget/common/configuration/ConfigurationBubble.d.ts.map +1 -1
  43. package/esm/presentation/widget/common/configuration/ConfigurationBubble.js +2 -0
  44. package/esm/presentation/widget/insightMenu/DefaultDashboardInsightMenu/DashboardInsightMenu/DashboardInsightMenuBubble.d.ts.map +1 -1
  45. package/esm/presentation/widget/insightMenu/DefaultDashboardInsightMenu/DashboardInsightMenu/DashboardInsightMenuBubble.js +1 -1
  46. package/esm/tsdoc-metadata.json +1 -1
  47. package/package.json +21 -21
  48. package/styles/css/main.css +1 -1
@@ -0,0 +1,195 @@
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 four scheduled-email filters handlers: they update the edited filters state and sync the
9
+ * result into the draft's export definitions and `metadata.visibleFilters`/`visibleFiltersByTab`.
10
+ *
11
+ * Filters slice B of 2. Runs after `useScheduledEmailFormState` because the handlers need
12
+ * `setEditedAutomation`; the derivation cluster in {@link useScheduledEmailEffectiveFilters} (slice A)
13
+ * has to run before it, which is why the two are separate hooks. Reads
14
+ * `hiddenFilters`/`commonDateFilterId` from {@link useScheduledEmailDialogContext} internally, same as
15
+ * slice A and as the parent (`useEditScheduledEmail`) did before.
16
+ *
17
+ * @internal
18
+ */
19
+ export function useScheduledEmailFilters({ setEditedAutomation, widget, insight, setEditedAutomationFilters, setEditedAutomationFiltersByTab, availableFiltersAsVisibleFilters, availableFiltersAsVisibleFiltersByTab, filtersDataByTab, storeFilters, setStoreFilters, filtersForNewAutomation, }) {
20
+ const { hiddenFilters: dashboardHiddenFilters, commonDateFilterId } = useScheduledEmailDialogContext();
21
+ // Re-derived locally (not passed as a prop) so that the `if (isWidget)` branch below narrows
22
+ // `widget`/`insight` via TS's aliased-condition control-flow analysis — this requires the boolean
23
+ // to be declared from those exact variables in this same scope, same as in the parent.
24
+ const isWidget = !!widget && !!insight;
25
+ const onFiltersChange = useCallback((filters, storeFiltersParam) => {
26
+ setEditedAutomationFilters(filters);
27
+ const shouldStoreFilters = storeFiltersParam ?? storeFilters;
28
+ if (isWidget) {
29
+ if (!isInsightWidget(widget)) {
30
+ return;
31
+ }
32
+ setEditedAutomation((s) => {
33
+ const appliedDashboardFilters = getAppliedDashboardFilters(filters, dashboardHiddenFilters, true);
34
+ const appliedWidgetFiltersWithInsight = getAppliedWidgetFilters(filters, dashboardHiddenFilters, widget, insight, commonDateFilterId, true);
35
+ const appliedWidgetFiltersWithoutInsight = getAppliedWidgetFilters(filters, dashboardHiddenFilters, widget, insight, commonDateFilterId, false);
36
+ const visibleFilters = getVisibleFiltersByFilters(filters, availableFiltersAsVisibleFilters, true);
37
+ return {
38
+ ...s,
39
+ exportDefinitions: s.exportDefinitions?.map((exportDefinition) => {
40
+ if (isExportDefinitionVisualizationObjectRequestPayload(exportDefinition.requestPayload)) {
41
+ const format = exportDefinition.requestPayload.format;
42
+ const shouldUseWidgetFiltersWithInsight = format === "CSV";
43
+ const shouldUseWidgetFiltersWithoutInsight = format === "CSV_RAW";
44
+ const appliedFilters = shouldUseWidgetFiltersWithInsight
45
+ ? appliedWidgetFiltersWithInsight
46
+ : shouldUseWidgetFiltersWithoutInsight
47
+ ? appliedWidgetFiltersWithoutInsight
48
+ : appliedDashboardFilters;
49
+ return {
50
+ ...exportDefinition,
51
+ requestPayload: {
52
+ ...exportDefinition.requestPayload,
53
+ content: {
54
+ ...exportDefinition.requestPayload.content,
55
+ filters: appliedFilters,
56
+ },
57
+ },
58
+ };
59
+ }
60
+ else {
61
+ return exportDefinition;
62
+ }
63
+ }),
64
+ metadata: {
65
+ ...s.metadata,
66
+ visibleFilters,
67
+ },
68
+ };
69
+ });
70
+ }
71
+ else {
72
+ setEditedAutomation((s) => {
73
+ const appliedFilters = getAppliedDashboardFilters(filters, dashboardHiddenFilters, shouldStoreFilters);
74
+ const visibleFilters = getVisibleFiltersByFilters(filters, availableFiltersAsVisibleFilters, shouldStoreFilters);
75
+ return {
76
+ ...s,
77
+ exportDefinitions: s.exportDefinitions?.map((exportDefinition) => {
78
+ if (isExportDefinitionDashboardRequestPayload(exportDefinition.requestPayload)) {
79
+ return {
80
+ ...exportDefinition,
81
+ requestPayload: {
82
+ ...exportDefinition.requestPayload,
83
+ content: {
84
+ ...exportDefinition.requestPayload.content,
85
+ filters: appliedFilters,
86
+ },
87
+ },
88
+ };
89
+ }
90
+ else {
91
+ return exportDefinition;
92
+ }
93
+ }),
94
+ metadata: {
95
+ ...s.metadata,
96
+ visibleFilters,
97
+ },
98
+ };
99
+ });
100
+ }
101
+ }, [
102
+ setEditedAutomationFilters,
103
+ setEditedAutomation,
104
+ dashboardHiddenFilters,
105
+ availableFiltersAsVisibleFilters,
106
+ storeFilters,
107
+ widget,
108
+ insight,
109
+ isWidget,
110
+ commonDateFilterId,
111
+ ]);
112
+ // Callback for per-tab filter changes - updates state AND syncs to export definitions
113
+ const onFiltersByTabChange = useCallback((newFiltersByTab, storeFiltersParam) => {
114
+ // Update the editedFiltersByTab state
115
+ setEditedAutomationFiltersByTab?.(newFiltersByTab);
116
+ const shouldStoreFilters = storeFiltersParam ?? storeFilters;
117
+ const newEffectiveFiltersByTab = shouldStoreFilters
118
+ ? Object.entries(newFiltersByTab).reduce((acc, [tabId, filters]) => {
119
+ const tabHiddenFilters = filtersDataByTab?.find((tab) => tab.tabId === tabId)?.hiddenFilters ?? [];
120
+ const appliedFilters = getAppliedDashboardFilters(filters ?? [], tabHiddenFilters, true);
121
+ if (appliedFilters) {
122
+ acc[tabId] = appliedFilters;
123
+ }
124
+ return acc;
125
+ }, {})
126
+ : undefined;
127
+ const newVisibleFiltersByTab = getVisibleFiltersByFiltersByTab(newFiltersByTab, availableFiltersAsVisibleFiltersByTab, shouldStoreFilters);
128
+ // Sync to export definitions AND metadata
129
+ setEditedAutomation((s) => ({
130
+ ...s,
131
+ exportDefinitions: s.exportDefinitions?.map((exportDefinition) => {
132
+ if (isExportDefinitionDashboardRequestPayload(exportDefinition.requestPayload)) {
133
+ return {
134
+ ...exportDefinition,
135
+ requestPayload: {
136
+ ...exportDefinition.requestPayload,
137
+ content: {
138
+ ...exportDefinition.requestPayload.content,
139
+ filtersByTab: newEffectiveFiltersByTab,
140
+ },
141
+ },
142
+ };
143
+ }
144
+ return exportDefinition;
145
+ }),
146
+ metadata: {
147
+ ...s.metadata,
148
+ visibleFiltersByTab: newVisibleFiltersByTab,
149
+ },
150
+ }));
151
+ }, [
152
+ setEditedAutomationFiltersByTab,
153
+ storeFilters,
154
+ setEditedAutomation,
155
+ availableFiltersAsVisibleFiltersByTab,
156
+ filtersDataByTab,
157
+ ]);
158
+ const onApplyCurrentFilters = useCallback(() => {
159
+ // Widget schedules should never use per-tab filters, only dashboard schedules can have tabs
160
+ const filtersByTabForNewAutomation = widget
161
+ ? undefined
162
+ : getDefaultSelectedFiltersFromFiltersByTab(filtersDataByTab);
163
+ if (filtersByTabForNewAutomation) {
164
+ onFiltersByTabChange(filtersByTabForNewAutomation);
165
+ }
166
+ else {
167
+ onFiltersChange(filtersForNewAutomation ?? [], widget ? true : storeFilters);
168
+ }
169
+ }, [
170
+ filtersForNewAutomation,
171
+ storeFilters,
172
+ onFiltersChange,
173
+ onFiltersByTabChange,
174
+ widget,
175
+ filtersDataByTab,
176
+ ]);
177
+ const onStoreFiltersChange = useCallback((value, filters, filtersByTabParam) => {
178
+ setStoreFilters(value);
179
+ // If filtersByTab is provided, use onFiltersByTabChange, otherwise use onFiltersChange
180
+ if (filtersByTabParam) {
181
+ // Trigger filtersByTab change which handles the sync
182
+ onFiltersByTabChange(filtersByTabParam, value);
183
+ }
184
+ if (filters) {
185
+ // Use regular filters change
186
+ onFiltersChange(filters, value);
187
+ }
188
+ }, [onFiltersChange, onFiltersByTabChange, setStoreFilters]);
189
+ return {
190
+ onFiltersChange,
191
+ onFiltersByTabChange,
192
+ onApplyCurrentFilters,
193
+ onStoreFiltersChange,
194
+ };
195
+ }
@@ -0,0 +1,55 @@
1
+ import { type FilterContextItem, type IAutomationMetadataObject, type IAutomationMetadataObjectDefinition, type IAutomationRecipient, type IAutomationVisibleFilter, type IDashboardExportParameter, type IExportDefinitionVisualizationObjectSettings, type IFilter, type IInsight, type INotificationChannelIdentifier, type INotificationChannelMetadataObject, type IWidget, type IWorkspaceUser } from "@gooddata/sdk-model";
2
+ export interface IUseScheduledEmailFormStateProps {
3
+ scheduledExportToEdit?: IAutomationMetadataObject;
4
+ widget?: IWidget;
5
+ insight?: IInsight;
6
+ notificationChannels: INotificationChannelIdentifier[] | INotificationChannelMetadataObject[];
7
+ /** Workspace users, lazy-loaded in the connector and passed via dialog props. */
8
+ users: IWorkspaceUser[];
9
+ externalRecipientOverride?: string;
10
+ effectiveWidgetFilters: IFilter[];
11
+ effectiveWidgetFiltersWithInsight: IFilter[];
12
+ effectiveVisibleWidgetFilters: IAutomationVisibleFilter[] | undefined;
13
+ effectiveDashboardFilters: FilterContextItem[] | undefined;
14
+ effectiveDashboardFiltersByTab: Record<string, FilterContextItem[]> | undefined;
15
+ effectiveVisibleDashboardFilters: IAutomationVisibleFilter[] | undefined;
16
+ effectiveVisibleDashboardFiltersByTab: Record<string, IAutomationVisibleFilter[]> | undefined;
17
+ parametersByTabForNewAutomation: Record<string, IDashboardExportParameter[]> | undefined;
18
+ defaultPdfPageSize?: IExportDefinitionVisualizationObjectSettings["pageSize"];
19
+ targetTabId?: string;
20
+ }
21
+ /**
22
+ * Owns the scheduled-email dialog's `editedAutomation` draft (initialized either from
23
+ * `scheduledExportToEdit` or via `newAutomationMetadataObjectDefinition`), its `originalAutomation`
24
+ * baseline, the derived defaults (`defaultRecipient`, `defaultUser`), and the form's field/message
25
+ * change handlers and their validity UI state.
26
+ *
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.
34
+ *
35
+ * @internal
36
+ */
37
+ export declare function useScheduledEmailFormState({ scheduledExportToEdit, widget, insight, notificationChannels, users, externalRecipientOverride, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, effectiveVisibleWidgetFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveVisibleDashboardFilters, effectiveVisibleDashboardFiltersByTab, parametersByTabForNewAutomation, defaultPdfPageSize, targetTabId }: IUseScheduledEmailFormStateProps): {
38
+ editedAutomation: IAutomationMetadataObjectDefinition;
39
+ setEditedAutomation: import("react").Dispatch<import("react").SetStateAction<IAutomationMetadataObjectDefinition>>;
40
+ originalAutomation: IAutomationMetadataObjectDefinition;
41
+ defaultRecipient: IAutomationRecipient;
42
+ defaultUser: IWorkspaceUser;
43
+ onTitleChange: (value: string, isValid: boolean) => void;
44
+ onRecurrenceChange: (cronExpression: string, startDate: Date | null, isValid: boolean) => void;
45
+ onEvaluationModeChange: (isShared: boolean) => void;
46
+ onDestinationChange: (notificationChannelId: string) => void;
47
+ onRecipientsChange: (updatedRecipients: IAutomationRecipient[]) => void;
48
+ onSubjectChange: (value: string | number, isValid: boolean) => void;
49
+ onMessageChange: (value: string, isValid: boolean) => void;
50
+ isCronValid: boolean;
51
+ isTitleValid: boolean;
52
+ isSubjectValid: boolean;
53
+ isOnMessageValid: boolean;
54
+ };
55
+ //# sourceMappingURL=useScheduledEmailFormState.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,203 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { useState } from "react";
3
+ import { setExportParametersByTab } from "../../../../../_staging/automation/index.js";
4
+ import { useAutomationsContext } from "../../../contexts/AutomationsContext.js";
5
+ import { useScheduledEmailDialogContext } from "../../../contexts/ScheduledEmailDialogContext.js";
6
+ import { convertCurrentUserToAutomationRecipient, convertCurrentUserToWorkspaceUser, convertExternalRecipientToAutomationRecipient, } from "../../../shared/utils/automationUtils.js";
7
+ import { toModifiedISOStringToTimezone, toNormalizedFirstRunAndCron } from "../../utils/date.js";
8
+ import { getUserTimezone } from "../../utils/timezone.js";
9
+ import { newDashboardExportDefinitionMetadataObjectDefinition, newWidgetExportDefinitionMetadataObjectDefinition, } from "../utils/exportDefinitions.js";
10
+ /**
11
+ * Owns the scheduled-email dialog's `editedAutomation` draft (initialized either from
12
+ * `scheduledExportToEdit` or via `newAutomationMetadataObjectDefinition`), its `originalAutomation`
13
+ * baseline, the derived defaults (`defaultRecipient`, `defaultUser`), and the form's field/message
14
+ * change handlers and their validity UI state.
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.
23
+ *
24
+ * @internal
25
+ */
26
+ export function useScheduledEmailFormState({ scheduledExportToEdit, widget, insight, notificationChannels, users, externalRecipientOverride, effectiveWidgetFilters, effectiveWidgetFiltersWithInsight, effectiveVisibleWidgetFilters, effectiveDashboardFilters, effectiveDashboardFiltersByTab, effectiveVisibleDashboardFilters, effectiveVisibleDashboardFiltersByTab, parametersByTabForNewAutomation, defaultPdfPageSize, targetTabId, }) {
27
+ const { timezone, currentUser } = useAutomationsContext();
28
+ const { dashboardId, dashboardTitle } = useScheduledEmailDialogContext();
29
+ const isWidget = !!widget && !!insight;
30
+ const defaultUser = convertCurrentUserToWorkspaceUser(users ?? [], currentUser);
31
+ const defaultRecipient = externalRecipientOverride
32
+ ? convertExternalRecipientToAutomationRecipient(externalRecipientOverride)
33
+ : convertCurrentUserToAutomationRecipient(users ?? [], currentUser);
34
+ const firstChannel = notificationChannels[0]?.id;
35
+ const [editedAutomation, setEditedAutomation] = useState(scheduledExportToEdit ??
36
+ newAutomationMetadataObjectDefinition(isWidget
37
+ ? {
38
+ timezone,
39
+ dashboardId: dashboardId,
40
+ notificationChannel: firstChannel,
41
+ insight,
42
+ widget,
43
+ recipient: defaultRecipient,
44
+ widgetFilters: effectiveWidgetFilters,
45
+ widgetFiltersWithInsight: effectiveWidgetFiltersWithInsight,
46
+ dashboardFilters: effectiveDashboardFilters,
47
+ visibleFiltersMetadata: effectiveVisibleWidgetFilters,
48
+ defaultPdfPageSize,
49
+ evaluationMode: "PER_RECIPIENT",
50
+ targetTabId,
51
+ parametersByTab: parametersByTabForNewAutomation,
52
+ }
53
+ : {
54
+ timezone,
55
+ dashboardId: dashboardId,
56
+ notificationChannel: firstChannel,
57
+ title: dashboardTitle,
58
+ recipient: defaultRecipient,
59
+ dashboardFilters: effectiveDashboardFilters,
60
+ filtersByTab: effectiveDashboardFiltersByTab,
61
+ visibleFiltersMetadata: effectiveVisibleDashboardFilters,
62
+ visibleFiltersByTab: effectiveVisibleDashboardFiltersByTab,
63
+ defaultPdfPageSize,
64
+ evaluationMode: "PER_RECIPIENT",
65
+ parametersByTab: parametersByTabForNewAutomation,
66
+ }));
67
+ const [originalAutomation] = useState(editedAutomation);
68
+ const [isCronValid, setIsCronValid] = useState(true);
69
+ const [isTitleValid, setIsTitleValid] = useState(true);
70
+ const [isSubjectValid, setIsSubjectValid] = useState(true);
71
+ const [isOnMessageValid, setIsOnMessageValid] = useState(true);
72
+ const onTitleChange = (value, isValid) => {
73
+ setIsTitleValid(isValid);
74
+ setEditedAutomation((s) => ({ ...s, title: value }));
75
+ };
76
+ const onRecurrenceChange = (cronExpression, startDate, isValid) => {
77
+ setIsCronValid(isValid);
78
+ setEditedAutomation((s) => ({
79
+ ...s,
80
+ schedule: {
81
+ ...s.schedule,
82
+ cron: cronExpression,
83
+ firstRun: toModifiedISOStringToTimezone(startDate ?? new Date(), timezone).iso,
84
+ },
85
+ }));
86
+ };
87
+ const onEvaluationModeChange = (isShared) => {
88
+ setEditedAutomation((s) => ({
89
+ ...s,
90
+ evaluationMode: isShared ? "SHARED" : "PER_RECIPIENT",
91
+ }));
92
+ };
93
+ const onDestinationChange = (notificationChannelId) => {
94
+ setEditedAutomation((s) => ({
95
+ ...s,
96
+ notificationChannel: notificationChannelId,
97
+ }));
98
+ };
99
+ const onRecipientsChange = (updatedRecipients) => {
100
+ setEditedAutomation((s) => ({
101
+ ...s,
102
+ recipients: updatedRecipients,
103
+ }));
104
+ };
105
+ const onSubjectChange = (value, isValid) => {
106
+ setIsSubjectValid(isValid);
107
+ setEditedAutomation((s) => ({
108
+ ...s,
109
+ details: {
110
+ ...s.details,
111
+ subject: value,
112
+ },
113
+ }));
114
+ };
115
+ const onMessageChange = (value, isValid) => {
116
+ setIsOnMessageValid(isValid);
117
+ setEditedAutomation((s) => ({
118
+ ...s,
119
+ details: {
120
+ ...s.details,
121
+ message: value,
122
+ },
123
+ }));
124
+ };
125
+ return {
126
+ editedAutomation,
127
+ setEditedAutomation,
128
+ originalAutomation,
129
+ defaultRecipient,
130
+ defaultUser,
131
+ onTitleChange,
132
+ onRecurrenceChange,
133
+ onEvaluationModeChange,
134
+ onDestinationChange,
135
+ onRecipientsChange,
136
+ onSubjectChange,
137
+ onMessageChange,
138
+ isCronValid,
139
+ isTitleValid,
140
+ isSubjectValid,
141
+ isOnMessageValid,
142
+ };
143
+ }
144
+ function newAutomationMetadataObjectDefinition({ timezone, dashboardId, notificationChannel, title, insight, widget, recipient, dashboardFilters, filtersByTab, widgetFilters, widgetFiltersWithInsight, visibleFiltersMetadata, visibleFiltersByTab, defaultPdfPageSize, evaluationMode, targetTabId, parametersByTab, }) {
145
+ const { firstRun, cron } = toNormalizedFirstRunAndCron(timezone);
146
+ const exportDefinition = widget && insight
147
+ ? newWidgetExportDefinitionMetadataObjectDefinition({
148
+ insight,
149
+ widget,
150
+ dashboardId,
151
+ format: "PNG",
152
+ widgetFilters,
153
+ widgetFiltersWithInsight,
154
+ dashboardFilters,
155
+ defaultPdfPageSize,
156
+ })
157
+ : newDashboardExportDefinitionMetadataObjectDefinition({
158
+ dashboardId,
159
+ dashboardTitle: title ?? "",
160
+ dashboardFilters,
161
+ filtersByTab,
162
+ format: "PDF",
163
+ });
164
+ let metadataObj = visibleFiltersMetadata || visibleFiltersByTab
165
+ ? {
166
+ metadata: {
167
+ ...(visibleFiltersMetadata ? { visibleFilters: visibleFiltersMetadata } : {}),
168
+ ...(visibleFiltersByTab ? { visibleFiltersByTab } : {}),
169
+ },
170
+ }
171
+ : {};
172
+ if (targetTabId) {
173
+ metadataObj = {
174
+ ...metadataObj,
175
+ metadata: {
176
+ ...metadataObj.metadata,
177
+ targetTabIdentifier: targetTabId,
178
+ },
179
+ };
180
+ }
181
+ const automation = {
182
+ type: "automation",
183
+ title: undefined,
184
+ description: undefined,
185
+ tags: [],
186
+ schedule: {
187
+ timezone: timezone ?? getUserTimezone().identifier,
188
+ firstRun,
189
+ cron,
190
+ },
191
+ details: {
192
+ message: "",
193
+ subject: "",
194
+ },
195
+ exportDefinitions: [{ ...exportDefinition }],
196
+ recipients: [recipient],
197
+ evaluationMode,
198
+ notificationChannel,
199
+ dashboard: dashboardId ? { id: dashboardId } : undefined,
200
+ ...metadataObj,
201
+ };
202
+ return parametersByTab ? setExportParametersByTab(automation, parametersByTab) : automation;
203
+ }
@@ -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"}