Skip to content

Commit

Permalink
Move layout types constant to the common bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
dokmic committed Dec 3, 2021
1 parent f53f6bf commit 66391b4
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 22 deletions.
13 changes: 7 additions & 6 deletions x-pack/examples/reporting_example/public/containers/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ import type {
JobParamsPDFV2,
JobParamsPNGV2,
} from '../../../../plugins/reporting/public';
import { constants, ReportingStart } from '../../../../plugins/reporting/public';
import { LayoutTypes } from '../../../../plugins/screenshotting/public';
import { ReportingStart } from '../../../../plugins/reporting/public';

import { REPORTING_EXAMPLE_LOCATOR_ID } from '../../common';

Expand Down Expand Up @@ -87,7 +88,7 @@ export const Main = ({ basename, reporting, screenshotMode }: ReportingExampleAp
const getPDFJobParamsDefault = (): JobAppParamsPDF => {
return {
layout: {
id: constants.LAYOUT_TYPES.PRESERVE_LAYOUT,
id: LayoutTypes.PRESERVE_LAYOUT,
},
relativeUrls: ['/app/reportingExample#/intended-visualization'],
objectType: 'develeloperExample',
Expand All @@ -99,7 +100,7 @@ export const Main = ({ basename, reporting, screenshotMode }: ReportingExampleAp
return {
version: '8.0.0',
layout: {
id: constants.LAYOUT_TYPES.PRESERVE_LAYOUT,
id: LayoutTypes.PRESERVE_LAYOUT,
},
locatorParams: [
{ id: REPORTING_EXAMPLE_LOCATOR_ID, version: '0.5.0', params: { myTestState: {} } },
Expand All @@ -114,7 +115,7 @@ export const Main = ({ basename, reporting, screenshotMode }: ReportingExampleAp
return {
version: '8.0.0',
layout: {
id: constants.LAYOUT_TYPES.PRESERVE_LAYOUT,
id: LayoutTypes.PRESERVE_LAYOUT,
},
locatorParams: {
id: REPORTING_EXAMPLE_LOCATOR_ID,
Expand All @@ -131,7 +132,7 @@ export const Main = ({ basename, reporting, screenshotMode }: ReportingExampleAp
return {
version: '8.0.0',
layout: {
id: constants.LAYOUT_TYPES.PRESERVE_LAYOUT,
id: LayoutTypes.PRESERVE_LAYOUT,
},
locatorParams: {
id: REPORTING_EXAMPLE_LOCATOR_ID,
Expand All @@ -148,7 +149,7 @@ export const Main = ({ basename, reporting, screenshotMode }: ReportingExampleAp
return {
version: '8.0.0',
layout: {
id: print ? constants.LAYOUT_TYPES.PRINT : constants.LAYOUT_TYPES.PRESERVE_LAYOUT,
id: print ? LayoutTypes.PRINT : LayoutTypes.PRESERVE_LAYOUT,
dimensions: {
// Magic numbers based on height of components not rendered on this screen :(
height: 2400,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import apm from 'elastic-apm-node';
import * as Rx from 'rxjs';
import { finalize, map, tap } from 'rxjs/operators';
import { LayoutTypes } from '../../../../screenshotting/server';
import { LayoutTypes } from '../../../../screenshotting/common';
import { REPORTING_TRANSACTION_TYPE } from '../../../common/constants';
import { ReportingCore } from '../../';
import { ScreenshotOptions } from '../../types';
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/screenshotting/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@

export type { Context } from './context';
export type { LayoutParams } from './layout';
export { LayoutTypes } from './layout';
9 changes: 9 additions & 0 deletions x-pack/plugins/screenshotting/common/layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ export type LayoutParams = Ensure<
},
SerializableRecord
>;

/**
* Supported layout types.
*/
export const LayoutTypes = {
PRESERVE_LAYOUT: 'preserve_layout',
PRINT: 'print',
CANVAS: 'canvas', // no margins or branding in the layout
};
1 change: 1 addition & 0 deletions x-pack/plugins/screenshotting/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ export function plugin(...args: ConstructorParameters<typeof ScreenshottingPlugi
return new ScreenshottingPlugin(...args);
}

export { LayoutTypes } from '../common';
export type { ScreenshottingSetup, ScreenshottingStart } from './plugin';
1 change: 0 additions & 1 deletion x-pack/plugins/screenshotting/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function plugin(...args: ConstructorParameters<typeof ScreenshottingPlugi
}

export { config } from './config';
export { LayoutTypes } from './layouts';
export type { Layout } from './layouts';
export type { ScreenshottingStart } from './plugin';
export type { ScreenshotOptions, ScreenshotResult } from './screenshots';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
*/

import type { LayoutSelectorDictionary, Size } from '../../common/layout';
import { DEFAULT_SELECTORS, LayoutTypes } from '.';
import { LayoutTypes } from '../../common';
import { DEFAULT_SELECTORS } from '.';
import type { Layout } from '.';
import { BaseLayout } from './base_layout';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/

import type { LayoutParams } from '../../common/layout';
import { LayoutTypes } from '../../common';
import type { Layout } from '.';
import { LayoutTypes } from '.';
import { CanvasLayout } from './canvas_layout';
import { PreserveLayout } from './preserve_layout';
import { PrintLayout } from './print_layout';
Expand Down
9 changes: 0 additions & 9 deletions x-pack/plugins/screenshotting/server/layouts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ interface LayoutSelectors {

export type Layout = BaseLayout & LayoutSelectors & Partial<Size>;

/**
* Supported layout types.
*/
export const LayoutTypes = {
PRESERVE_LAYOUT: 'preserve_layout',
PRINT: 'print',
CANVAS: 'canvas', // no margins or branding in the layout
};

export const DEFAULT_SELECTORS: LayoutSelectorDictionary = {
screenshot: '[data-shared-items-container]',
renderComplete: '[data-shared-item]',
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/screenshotting/server/layouts/mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
* 2.0.
*/

import { createLayout, LayoutTypes, Layout } from '.';
import { LayoutTypes } from '../../common';
import { createLayout, Layout } from '.';

export function createMockLayout(): Layout {
const layout = createLayout({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
import path from 'path';
import type { CustomPageSize } from 'pdfmake/interfaces';
import type { LayoutSelectorDictionary, Size } from '../../common/layout';
import { DEFAULT_SELECTORS, LayoutTypes } from '.';
import { LayoutTypes } from '../../common';
import { DEFAULT_SELECTORS } from '.';
import type { Layout } from '.';
import { BaseLayout } from './base_layout';
import type { PageSizeParams } from './base_layout';
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/screenshotting/server/layouts/print_layout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@

import { PageOrientation, PredefinedPageSize } from 'pdfmake/interfaces';
import type { LayoutParams, LayoutSelectorDictionary } from '../../common/layout';
import { LayoutTypes } from '../../common';
import type { Layout } from '.';
import { DEFAULT_SELECTORS, LayoutTypes } from '.';
import { DEFAULT_SELECTORS } from '.';
import { DEFAULT_VIEWPORT } from '../browsers';
import { BaseLayout } from './base_layout';

Expand Down

0 comments on commit 66391b4

Please sign in to comment.