Skip to content

Commit

Permalink
[Fix] [GRAFX-4154] Adjust output settings interface by replacing outp…
Browse files Browse the repository at this point in the history
…utType with dataSourceEnabled (#270)
  • Loading branch information
alexandraFlavia9 authored Jan 31, 2025
1 parent 9b9ba63 commit a5fe48a
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 27 deletions.
5 changes: 2 additions & 3 deletions __mocks__/mockOutputSetting.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { DownloadFormats } from '@chili-publish/studio-sdk';
import { OutputType } from '../src/utils/ApiTypes';

export const mockOutputSetting = {
id: '1',
Expand All @@ -10,7 +9,7 @@ export const mockOutputSetting = {
maxFileSizeInKiloBytes: 120,
scaling: 1.5,
watermark: true,
outputType: OutputType.Single,
dataSourceEnabled: false,
};

export const mockOutputSetting2 = {
Expand All @@ -22,5 +21,5 @@ export const mockOutputSetting2 = {
maxFileSizeInKiloBytes: 120,
scaling: 1.5,
watermark: true,
outputType: OutputType.Single,
dataSourceEnabled: false,
};
3 changes: 1 addition & 2 deletions src/contexts/UiConfigContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
defaultOutputSettings,
defaultUiOptions,
} from '../types/types';
import { OutputType } from '../utils/ApiTypes';
import { useAppContext } from './AppProvider';
import { IUiConfigContext } from './UiConfigContext.types';

Expand Down Expand Up @@ -61,7 +60,7 @@ export function UiConfigContextProvider({
val.layoutIntents.includes(layoutIntent ?? ''),
);

settings = dataSource ? settings : settings?.filter((s) => s.outputType !== OutputType.Batch);
settings = dataSource ? settings : settings?.filter((s) => !s.dataSourceEnabled);
setUserInterfaceOutputSettings(settings ?? null);
setSelectedUserInterfaceId(res?.userInterface?.id || null);
});
Expand Down
13 changes: 6 additions & 7 deletions src/tests/navbar/Navbar.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Navbar from '../../components/navbar/Navbar';
import AppProvider from '../../contexts/AppProvider';
import * as UiConfigContext from '../../contexts/UiConfigContext';
import { ProjectConfig, defaultOutputSettings, defaultPlatformUiOptions } from '../../types/types';
import { OutputType } from '../../utils/ApiTypes';
import { APP_WRAPPER_ID } from '../../utils/constants';
import { getDataTestIdForSUI } from '../../utils/dataIds';

Expand Down Expand Up @@ -181,15 +180,15 @@ describe('Navbar', () => {
description: 'some decs',
type: DownloadFormats.MP4,
layoutIntents: ['digitalAnimated'],
outputType: OutputType.Single,
dataSourceEnabled: false,
},
{
name: 'user interface GIF',
id: '2',
description: 'some decs',
type: DownloadFormats.MP4,
layoutIntents: ['digitalAnimated'],
outputType: OutputType.Single,
dataSourceEnabled: false,
},
],
}),
Expand Down Expand Up @@ -243,15 +242,15 @@ describe('Navbar', () => {
description: 'some decs',
type: DownloadFormats.PDF,
layoutIntents: ['print'],
outputType: OutputType.Batch,
dataSourceEnabled: true,
},
{
name: 'Single for PDF',
id: '1',
description: 'some decs',
type: DownloadFormats.PDF,
layoutIntents: ['print'],
outputType: OutputType.Single,
dataSourceEnabled: false,
},
],
}),
Expand Down Expand Up @@ -302,15 +301,15 @@ describe('Navbar', () => {
description: 'some decs',
type: DownloadFormats.PDF,
layoutIntents: ['print'],
outputType: OutputType.Batch,
dataSourceEnabled: true,
},
{
name: 'Single for PDF',
id: '1',
description: 'some decs',
type: DownloadFormats.PDF,
layoutIntents: ['print'],
outputType: OutputType.Single,
dataSourceEnabled: false,
},
],
}),
Expand Down
5 changes: 2 additions & 3 deletions src/tests/navbar/useDownload.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DownloadFormats } from '@chili-publish/studio-sdk';
import { renderHook } from '@testing-library/react';
import useDownload from '../../components/navbar/downloadPanel/useDownload';
import * as UiConfigContext from '../../contexts/UiConfigContext';
import { OutputType } from '../../utils/ApiTypes';

describe('useDownload', () => {
test('default download options show all download options', () => {
Expand Down Expand Up @@ -60,15 +59,15 @@ describe('useDownload', () => {
description: 'some decs',
type: DownloadFormats.MP4,
layoutIntents: ['digitalAnimated'],
outputType: OutputType.Single,
dataSourceEnabled: false,
},
{
name: 'GIF',
id: '2',
description: 'some decs',
type: DownloadFormats.MP4,
layoutIntents: ['digitalAnimated'],
outputType: OutputType.Single,
dataSourceEnabled: false,
},
],
};
Expand Down
3 changes: 1 addition & 2 deletions src/tests/utils/documentExportHelper.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DownloadFormats } from '@chili-publish/studio-sdk';
import axios from 'axios';
import { OutputType } from '../../utils/ApiTypes';
import { addTrailingSlash, getDownloadLink } from '../../utils/documentExportHelper';

jest.mock('axios');
Expand Down Expand Up @@ -155,7 +154,7 @@ describe('"getDownloadLink', () => {
it('should send data source', async () => {
(axios.get as jest.Mock).mockResolvedValue({
data: {
outputType: OutputType.Batch,
dataSourceEnabled: true,
},
});
await getDownloadLink(DownloadFormats.PDF, '', 'Token', '1', 'projectId', 'outputId', false);
Expand Down
3 changes: 1 addition & 2 deletions src/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { ITheme, UiThemeConfig } from '@chili-publish/grafx-shared-components';
import { DownloadFormats } from '@chili-publish/studio-sdk';
import { AxiosError, AxiosResponse } from 'axios';
import { OutputType } from '../utils/ApiTypes';
import { ConnectorAuthenticationResult } from './ConnectorAuthenticationResult';

export type FeatureFlagsType = Record<string, boolean>;
Expand Down Expand Up @@ -106,7 +105,7 @@ export type UserInterfaceOutputSettings = {
id: string;
description: string;
type: DownloadFormats;
outputType: OutputType;
dataSourceEnabled: boolean;
layoutIntents: string[];
};

Expand Down
5 changes: 0 additions & 5 deletions src/utils/ApiTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ export enum AssetTypeToString {
FOLDER = 'Folder',
}

export enum OutputType {
Single = 'single',
Batch = 'batch',
}

// It partially describe the API Connector Entity
// https://main.cpstaging.online/grafx/swagger/index.html?urls.primaryName=experimental#/Connectors/get_api_experimental_environment__environment__connectors__connectorId_
export type RemoteConnector = {
Expand Down
5 changes: 2 additions & 3 deletions src/utils/documentExportHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DownloadFormats, Id } from '@chili-publish/studio-sdk';
import axios from 'axios';
import { DataConnectorConfiguration } from '../types/OutputGenerationTypes';
import { DownloadLinkResult } from '../types/types';
import { OutputType } from './ApiTypes';
import { getConnectorConfigurationOptions, getEnvId } from './connectors';

type HttpHeaders = { method: string; body: string | null; headers: { 'Content-Type': string; Authorization?: string } };
Expand Down Expand Up @@ -156,7 +155,7 @@ const getDataSourceConfig = async (
return undefined;
}

const { data: setting } = await axios.get<{ outputType: OutputType }>(
const { data: setting } = await axios.get<{ dataSourceEnabled: boolean }>(
`${baseUrl}/output/settings/${outputSettingsId}`,
{
headers: {
Expand All @@ -165,7 +164,7 @@ const getDataSourceConfig = async (
},
},
);
if (setting.outputType !== OutputType.Batch) {
if (!setting.dataSourceEnabled) {
return undefined;
}
return {
Expand Down

0 comments on commit a5fe48a

Please sign in to comment.