Skip to content

Commit

Permalink
Merge pull request #5064 from gooddata/mkn-f1-437
Browse files Browse the repository at this point in the history
feat: ui support for scheduling pdf exports
  • Loading branch information
scavnickyj committed Jun 28, 2024
2 parents de4e190 + e1e3c11 commit af8c709
Show file tree
Hide file tree
Showing 90 changed files with 2,088 additions and 5,491 deletions.
3 changes: 2 additions & 1 deletion libs/sdk-model/api/sdk-model.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ export interface IAutomationMetadataObjectBase {
// @alpha (undocumented)
export interface IAutomationMetadataObjectDefinition extends Omit<IAutomationMetadataObjectBase, "exportDefinitions">, IMetadataObjectDefinition, IAuditable {
// (undocumented)
exportDefinitions: IExportDefinitionMetadataObjectDefinition[];
exportDefinitions?: (IExportDefinitionMetadataObjectDefinition | IExportDefinitionMetadataObject)[];
// (undocumented)
type: "automation";
}
Expand Down Expand Up @@ -2776,6 +2776,7 @@ export interface ISettings {
enableRichTextDescriptions?: boolean;
enableScatterPlotClustering?: boolean;
enableScatterPlotSegmentation?: boolean;
enableScheduling?: boolean;
enableSeparateTotalLabels?: boolean;
enableTableColumnsAutoResizing?: boolean;
enableTableColumnsGrowToFit?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion libs/sdk-model/src/automations/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export interface IAutomationMetadataObjectDefinition
IMetadataObjectDefinition,
IAuditable {
type: "automation";
exportDefinitions: IExportDefinitionMetadataObjectDefinition[];
exportDefinitions?: (IExportDefinitionMetadataObjectDefinition | IExportDefinitionMetadataObject)[];
}

/**
Expand Down
5 changes: 5 additions & 0 deletions libs/sdk-model/src/settings/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ export interface ISettings {
*/
enableRichTextDescriptions?: boolean;

/**
* Enables scheduling of the dashboard pdf export.
*/
enableScheduling?: boolean;

[key: string]: number | boolean | string | object | undefined;
}

Expand Down
63 changes: 42 additions & 21 deletions libs/sdk-ui-dashboard/api/sdk-ui-dashboard.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ import { IAttributeFilter } from '@gooddata/sdk-model';
import { IAttributeFilterBaseProps } from '@gooddata/sdk-ui-filters';
import { IAttributeMetadataObject } from '@gooddata/sdk-model';
import { IAttributeOrMeasure } from '@gooddata/sdk-model';
import { IAutomationMetadataObject } from '@gooddata/sdk-model';
import { IAutomationMetadataObjectDefinition } from '@gooddata/sdk-model';
import { IAvailableDrillTargets } from '@gooddata/sdk-ui';
import { IBackendCapabilities } from '@gooddata/sdk-backend-spi';
import { IBaseWidget } from '@gooddata/sdk-model';
Expand Down Expand Up @@ -223,14 +225,13 @@ import { INegativeAttributeFilter } from '@gooddata/sdk-model';
import { InsightDisplayFormUsage } from '@gooddata/sdk-model';
import { InsightDrillDefinition } from '@gooddata/sdk-model';
import { IntlShape } from 'react-intl';
import { IOrganizationUser } from '@gooddata/sdk-model';
import { IPositiveAttributeFilter } from '@gooddata/sdk-model';
import { IPushData } from '@gooddata/sdk-ui';
import { IRelativeDateFilter } from '@gooddata/sdk-model';
import { IRenderListItemProps } from '@gooddata/sdk-ui-kit';
import { IResultWarning } from '@gooddata/sdk-model';
import { IRichTextWidget } from '@gooddata/sdk-model';
import { IScheduledMail } from '@gooddata/sdk-model';
import { IScheduledMailDefinition } from '@gooddata/sdk-model';
import { ISeparators } from '@gooddata/sdk-model';
import { ISettings } from '@gooddata/sdk-model';
import { IShareDialogInteractionData } from '@gooddata/sdk-ui-kit';
Expand All @@ -243,12 +244,12 @@ import { ITranslations } from '@gooddata/sdk-ui';
import { IUser } from '@gooddata/sdk-model';
import { IUserWorkspaceSettings } from '@gooddata/sdk-backend-spi';
import { IVisualizationCallbacks } from '@gooddata/sdk-ui';
import { IWebhookMetadataObject } from '@gooddata/sdk-model';
import { IWidget } from '@gooddata/sdk-model';
import { IWidgetAlert } from '@gooddata/sdk-model';
import { IWidgetAlertDefinition } from '@gooddata/sdk-model';
import { IWidgetDefinition } from '@gooddata/sdk-model';
import { IWorkspacePermissions } from '@gooddata/sdk-model';
import { IWorkspaceUser } from '@gooddata/sdk-model';
import { LocalIdRef } from '@gooddata/sdk-model';
import { MemoizedFunction } from 'lodash';
import { MessageDescriptor } from 'react-intl';
Expand Down Expand Up @@ -1015,12 +1016,12 @@ export interface CreateScheduledEmail extends IDashboardCommand {
}

// @beta
export function createScheduledEmail(scheduledEmail: IScheduledMailDefinition, filterContext?: IFilterContextDefinition, correlationId?: string): CreateScheduledEmail;
export function createScheduledEmail(scheduledEmail: IAutomationMetadataObjectDefinition, filterContext?: IFilterContextDefinition, correlationId?: string): CreateScheduledEmail;

// @beta
export interface CreateScheduledEmailPayload {
readonly filterContext?: IFilterContextDefinition;
readonly scheduledEmail: IScheduledMailDefinition;
readonly scheduledEmail: IAutomationMetadataObjectDefinition;
}

// @beta (undocumented)
Expand Down Expand Up @@ -2506,7 +2507,7 @@ export interface DashboardScheduledEmailCreated extends IDashboardEvent {

// @beta
export interface DashboardScheduledEmailCreatedPayload {
readonly scheduledEmail: IScheduledMail;
readonly scheduledEmail: IAutomationMetadataObject;
}

// @beta
Expand Down Expand Up @@ -2858,7 +2859,7 @@ export function DefaultSaveAsNewButton({ isVisible, onSaveAsNewClick }: ISaveAsN
export function DefaultSaveButton({ isVisible, isEnabled, isSaving, buttonTitle, buttonValue, onSaveClick, }: ISaveButtonProps): React_2.JSX.Element | null;

// @alpha (undocumented)
export const DefaultScheduledEmailDialog: (props: IScheduledEmailDialogProps) => JSX.Element | null;
export const DefaultScheduledEmailDialog: React_2.FC<IScheduledEmailDialogProps>;

// @alpha (undocumented)
export const DefaultScheduledEmailManagementDialog: React_2.FC<IScheduledEmailManagementDialogProps>;
Expand Down Expand Up @@ -4708,27 +4709,32 @@ export function isBrokenAlertDateFilterInfo(item: IBrokenAlertFilterBasicInfo):

// @alpha (undocumented)
export interface IScheduledEmailDialogProps {
editSchedule?: IScheduledMail;
automations: IAutomationMetadataObject[];
editSchedule?: IAutomationMetadataObject;
isVisible?: boolean;
onCancel?: () => void;
onError?: (error: GoodDataSdkError) => void;
onSave?: (scheduledEmailDefinition: IScheduledMailDefinition) => void;
onSave?: (scheduledEmailDefinition: IAutomationMetadataObject) => void;
onSaveError?: (error: GoodDataSdkError) => void;
onSaveSuccess?: () => void;
onSubmit?: (scheduledEmailDefinition: IScheduledMailDefinition) => void;
onSubmit?: (scheduledEmailDefinition: IAutomationMetadataObject | IAutomationMetadataObjectDefinition) => void;
onSuccess?: () => void;
users: IWorkspaceUser[];
users: IOrganizationUser[];
webhooks: IWebhookMetadataObject[];
}

// @alpha (undocumented)
export interface IScheduledEmailManagementDialogProps {
automations: IAutomationMetadataObject[];
isLoadingScheduleData: boolean;
isVisible?: boolean;
onAdd?: () => void;
onClose?: () => void;
onDeleteError?: (error: GoodDataSdkError) => void;
onDeleteSuccess?: () => void;
onEdit?: (scheduledMail: IScheduledMail, users: IWorkspaceUser[]) => void;
onLoadError?: (error: GoodDataSdkError) => void;
onEdit?: (scheduledMail: IAutomationMetadataObject) => void;
scheduleDataError?: GoodDataSdkError;
webhooks: IWebhookMetadataObject[];
}

// @internal
Expand Down Expand Up @@ -6398,12 +6404,12 @@ export interface SaveScheduledEmail extends IDashboardCommand {
}

// @beta
export function saveScheduledEmail(scheduledEmail: IScheduledMailDefinition, filterContextRef?: ObjRef, correlationId?: string): SaveScheduledEmail;
export function saveScheduledEmail(scheduledEmail: IAutomationMetadataObject, filterContextRef?: ObjRef, correlationId?: string): SaveScheduledEmail;

// @beta
export interface SaveScheduledEmailPayload {
readonly filterContextRef?: ObjRef;
readonly scheduledEmail: IScheduledMailDefinition;
readonly scheduledEmail: IAutomationMetadataObject;
}

// @public (undocumented)
Expand Down Expand Up @@ -6845,6 +6851,9 @@ export const selectEnableRenamingProjectToWorkspace: DashboardSelector<boolean>;
// @internal
export const selectEnableRichTextDescriptions: DashboardSelector<boolean>;

// @alpha (undocumented)
export const selectEnableScheduling: DashboardSelector<boolean>;

// @internal
export const selectEnableUnavailableItemsVisibility: DashboardSelector<boolean>;

Expand Down Expand Up @@ -8234,16 +8243,16 @@ export type UseDashboardQueryProcessingResult<TQueryCreatorArgs extends any[], T
};

// @alpha
export const useDashboardScheduledEmails: () => {
export const useDashboardScheduledEmails: ({ onReload }?: {
onReload?: (() => void) | undefined;
}) => {
isScheduledEmailingVisible: boolean;
enableInsightExportScheduling: boolean;
defaultOnScheduleEmailing: () => void;
isScheduleEmailingDialogOpen: boolean;
isScheduleEmailingManagementDialogOpen: boolean;
onScheduleEmailingOpen: (attachmentRef?: ObjRef) => void;
onScheduleEmailingManagementEdit: (schedule: IScheduledMail, users: IWorkspaceUser[]) => void;
scheduledEmailToEdit: IScheduledMail | undefined;
users: IWorkspaceUser[];
onScheduleEmailingOpen: () => void;
onScheduleEmailingManagementEdit: (schedule: IAutomationMetadataObject) => void;
scheduledEmailToEdit: IAutomationMetadataObject | undefined;
onScheduleEmailingCancel: () => void;
onScheduleEmailingCreateError: () => void;
onScheduleEmailingCreateSuccess: () => void;
Expand All @@ -8256,6 +8265,18 @@ export const useDashboardScheduledEmails: () => {
onScheduleEmailingManagementDeleteError: () => void;
};

// @alpha
export const useDashboardScheduledEmailsData: ({ reloadId, onLoadError, }: {
reloadId: number;
onLoadError: () => void;
}) => {
isLoading: boolean;
loadError: any;
webhooks: IWebhookMetadataObject[];
automations: IAutomationMetadataObject[];
users: IOrganizationUser[];
};

// @public
export const useDashboardSelector: TypedUseSelectorHook<DashboardState>;

Expand Down
4 changes: 2 additions & 2 deletions libs/sdk-ui-dashboard/src/internal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// (C) 2022 GoodData Corporation
// (C) 2022-2024 GoodData Corporation

/**
* This file is used to re-export internal parts of the package that are used in other GoodData applications.
Expand All @@ -10,7 +10,7 @@ export * from "./presentation/constants/index.js";
export * from "./presentation/layout/DefaultDashboardLayoutRenderer/index.js";
export * from "./presentation/presentationComponents/index.js";
export * from "./presentation/scheduledEmail/index.js";
export * from "./presentation/scheduledEmail/DefaultScheduledEmailDialog/ScheduledMailDialogRenderer/ScheduledMailDialogRenderer.js";
export * from "./presentation/scheduledEmail/DefaultScheduledEmailDialog/DefaultScheduledEmailDialog.js";
export { PLATFORM_DATE_FORMAT } from "./presentation/scheduledEmail/DefaultScheduledEmailDialog/constants.js";
export * from "./presentation/widget/kpi/ViewModeDashboardKpi/KpiAlerts/index.js";
export * from "./presentation/widget/kpi/common/KpiContent/index.js";
Expand Down
7 changes: 3 additions & 4 deletions libs/sdk-ui-dashboard/src/locales.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ export const messages: Record<string, MessageDescriptor> = defineMessages({
scheduleEmailDeleteSuccess: { id: "dialogs.schedule.email.delete.success" },
scheduleManagementLoadError: { id: "dialogs.schedule.management.load.error" },
scheduleManagementDeleteError: { id: "dialogs.schedule.management.delete.error" },

scheduleManagementTabUser: { id: "dialogs.schedule.management.tab.user" },
scheduleManagementTabAll: { id: "dialogs.schedule.management.tab.all" },
scheduleManagementNoSchedules: { id: "dialogs.schedule.management.noSchedules" },
scheduleManagementNoSchedulesByUser: { id: "dialogs.schedule.management.noSchedules.byUser" },
scheduleManagementCreate: { id: "dialogs.schedule.management.create" },
scheduleManagementListTitle: { id: "dialogs.schedule.management.list.title" },

saveAsNewAlertsAndEmailsMessage: { id: "dialogs.save.as.new.alertsAndEmailsMessage" },
saveAsNewAlertsMessage: { id: "dialogs.save.as.new.alertsMessage" },
Expand All @@ -42,6 +40,7 @@ export const messages: Record<string, MessageDescriptor> = defineMessages({
controlButtonsSaveAndPublishNoChanges: { id: "controlButtons.saveAndPublish.disable.noChanges.title" },
controlButtonsSaveAndPublishEmpty: { id: "controlButtons.saveAndPublish.disable.empty.title" },

scheduleDialogEmailRepeats_cron: { id: "dialogs.schedule.email.repeats.types.cron" },
scheduleDialogEmailRepeats_custom: { id: "dialogs.schedule.email.repeats.types.custom" },
scheduleDialogEmailRepeats_daily: { id: "dialogs.schedule.email.repeats.types.daily" },
scheduleDialogEmailRepeats_monthly: { id: "dialogs.schedule.email.repeats.types.monthly" },
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
// (C) 2021-2022 GoodData Corporation
// (C) 2021-2024 GoodData Corporation
import { SagaIterator } from "redux-saga";
import { call } from "redux-saga/effects";
import { DashboardContext } from "../../types/commonTypes.js";
import { IFilterContextDefinition, IScheduledMail, IScheduledMailDefinition } from "@gooddata/sdk-model";
import { IAutomationMetadataObject, IAutomationMetadataObjectDefinition } from "@gooddata/sdk-model";
import { PromiseFnReturnType } from "../../types/sagas.js";
import { CreateScheduledEmail } from "../../commands/scheduledEmail.js";
import { DashboardScheduledEmailCreated, scheduledEmailCreated } from "../../events/scheduledEmail.js";

function createScheduledEmail(
ctx: DashboardContext,
scheduledEmail: IScheduledMailDefinition,
filterContext?: IFilterContextDefinition,
): Promise<IScheduledMail> {
scheduledEmail: IAutomationMetadataObjectDefinition,
): Promise<IAutomationMetadataObject> {
const { backend, workspace } = ctx;

return backend.workspace(workspace).dashboards().createScheduledMail(scheduledEmail, filterContext);
return backend.workspace(workspace).automations().createAutomation(scheduledEmail);
}

export function* createScheduledEmailHandler(
Expand All @@ -25,7 +24,6 @@ export function* createScheduledEmailHandler(
createScheduledEmail,
ctx,
cmd.payload.scheduledEmail,
cmd.payload.filterContext,
);

return scheduledEmailCreated(ctx, scheduledEmail, cmd.correlationId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
// (C) 2021-2022 GoodData Corporation
// (C) 2021-2024 GoodData Corporation
import { SagaIterator } from "redux-saga";
import { call } from "redux-saga/effects";
import { DashboardContext } from "../../types/commonTypes.js";
import { IScheduledMailDefinition, ObjRef, isObjRef } from "@gooddata/sdk-model";
import { IAutomationMetadataObject, isObjRef } from "@gooddata/sdk-model";
import { SaveScheduledEmail } from "../../commands/scheduledEmail.js";
import { DashboardScheduledEmailSaved, scheduledEmailSaved } from "../../events/scheduledEmail.js";

function saveScheduledEmail(
ctx: DashboardContext,
scheduledEmail: IScheduledMailDefinition,
filterContextRef?: ObjRef,
): Promise<void> {
scheduledEmail: IAutomationMetadataObject,
): Promise<IAutomationMetadataObject> {
const { backend, workspace } = ctx;
if (!isObjRef(scheduledEmail)) {
throw new Error("Cannot save schedule not referencing to an persisted object");
}
return backend
.workspace(workspace)
.dashboards()
.updateScheduledMail(scheduledEmail, scheduledEmail, filterContextRef);
return backend.workspace(workspace).automations().updateAutomation(scheduledEmail);
}

export function* saveScheduledEmailHandler(
ctx: DashboardContext,
cmd: SaveScheduledEmail,
): SagaIterator<DashboardScheduledEmailSaved> {
const { scheduledEmail, filterContextRef } = cmd.payload;
yield call(saveScheduledEmail, ctx, scheduledEmail, filterContextRef);
const { scheduledEmail } = cmd.payload;
yield call(saveScheduledEmail, ctx, scheduledEmail);

return scheduledEmailSaved(ctx, cmd.correlationId);
}
17 changes: 11 additions & 6 deletions libs/sdk-ui-dashboard/src/model/commands/scheduledEmail.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// (C) 2021-2023 GoodData Corporation
// (C) 2021-2024 GoodData Corporation

import { IFilterContextDefinition, IScheduledMailDefinition, ObjRef } from "@gooddata/sdk-model";
import {
IFilterContextDefinition,
IAutomationMetadataObjectDefinition,
IAutomationMetadataObject,
ObjRef,
} from "@gooddata/sdk-model";
import { IDashboardCommand } from "./base.js";

/**
Expand All @@ -11,7 +16,7 @@ export interface CreateScheduledEmailPayload {
/**
* The scheduled email to create.
*/
readonly scheduledEmail: IScheduledMailDefinition;
readonly scheduledEmail: IAutomationMetadataObjectDefinition;
/**
* Filter context to use for the scheduled email. If no filter context is provided, stored dashboard filter context will be used.
*/
Expand Down Expand Up @@ -41,7 +46,7 @@ export interface CreateScheduledEmail extends IDashboardCommand {
* @beta
*/
export function createScheduledEmail(
scheduledEmail: IScheduledMailDefinition,
scheduledEmail: IAutomationMetadataObjectDefinition,
filterContext?: IFilterContextDefinition,
correlationId?: string,
): CreateScheduledEmail {
Expand Down Expand Up @@ -73,7 +78,7 @@ export interface SaveScheduledEmailPayload {
/**
* The scheduled email to save.
*/
readonly scheduledEmail: IScheduledMailDefinition;
readonly scheduledEmail: IAutomationMetadataObject;
/**
* optionally specify existing filter context reference to be used for all attachments
*/
Expand All @@ -91,7 +96,7 @@ export interface SaveScheduledEmailPayload {
* @beta
*/
export function saveScheduledEmail(
scheduledEmail: IScheduledMailDefinition,
scheduledEmail: IAutomationMetadataObject,
filterContextRef?: ObjRef,
correlationId?: string,
): SaveScheduledEmail {
Expand Down
Loading

0 comments on commit af8c709

Please sign in to comment.