-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* added page to reporting example app that contains the capture tests * first version of PNG capture for test A * added types file to common * added data-shared-item attr to image, also added capture menu items * fix image CSS by providing a fixed width and height * explicitly add layout for print, does not seem to do anything though? * added magic numbers of image sizes * added reporting examples test folder * first version of capture test for generating and comparing PNGs * added PNG service and PNG baseline fixture * added pdf-to-img dev dependency * refactor compare_pngs to accept a buffer * added comment to interface * png service -> compare images service * export image compare service * added test for pdf export * clean up log * minor fixes and added pdf print optimized test * added pdf and pdf print fixtures * refactor lib function name * Update difference thresholds Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
8a643cc
commit a100416
Showing
23 changed files
with
710 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { Ensure, SerializableRecord } from '@kbn/utility-types'; | ||
|
||
export type MyForwardableState = Ensure< | ||
SerializableRecord & { captureTest: 'A' }, | ||
SerializableRecord | ||
>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
x-pack/examples/reporting_example/public/application_context.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import React, { useContext, createContext, FC } from 'react'; | ||
|
||
import type { MyForwardableState } from './types'; | ||
|
||
interface ContextValue { | ||
forwardedState?: MyForwardableState; | ||
} | ||
|
||
const ApplicationContext = createContext<undefined | ContextValue>(undefined); | ||
|
||
export const ApplicationContextProvider: FC<{ forwardedState: ContextValue['forwardedState'] }> = ({ | ||
forwardedState, | ||
children, | ||
}) => { | ||
return ( | ||
<ApplicationContext.Provider value={{ forwardedState }}>{children}</ApplicationContext.Provider> | ||
); | ||
}; | ||
|
||
export const useApplicationContext = (): ContextValue => { | ||
const ctx = useContext(ApplicationContext); | ||
if (!ctx) { | ||
throw new Error('useApplicationContext called outside of ApplicationContext!'); | ||
} | ||
return ctx; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
export { TestImageA } from './test_image_a'; |
31 changes: 31 additions & 0 deletions
31
x-pack/examples/reporting_example/public/components/test_image_a.tsx
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
// Values based on A4 page size | ||
export const VIS = { | ||
width: 1950 / 2, | ||
height: 1200 / 2, | ||
}; | ||
|
||
export const ROUTES = { | ||
captureTest: '/captureTest', | ||
main: '/', | ||
}; |
10 changes: 10 additions & 0 deletions
10
x-pack/examples/reporting_example/public/containers/capture_test.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.reportingExample { | ||
&__captureContainer { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
|
||
margin-top: $euiSizeM; | ||
margin-bottom: $euiSizeM; | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
x-pack/examples/reporting_example/public/containers/capture_test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import type { FunctionComponent } from 'react'; | ||
import React from 'react'; | ||
import { useHistory } from 'react-router-dom'; | ||
import { parsePath } from 'history'; | ||
import { | ||
EuiTabbedContent, | ||
EuiTabbedContentTab, | ||
EuiSpacer, | ||
EuiButtonEmpty, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiPage, | ||
EuiPageHeader, | ||
EuiPageBody, | ||
EuiPageContent, | ||
EuiPageContentBody, | ||
} from '@elastic/eui'; | ||
|
||
import { TestImageA } from '../components'; | ||
import { useApplicationContext } from '../application_context'; | ||
import { MyForwardableState } from '../types'; | ||
import { ROUTES } from '../constants'; | ||
|
||
import './capture_test.scss'; | ||
|
||
const ItemsContainer: FunctionComponent<{ count: string }> = ({ count, children }) => ( | ||
<div | ||
className="reportingExample__captureContainer" | ||
data-shared-items-container | ||
data-shared-items-count={count} | ||
> | ||
{children} | ||
</div> | ||
); | ||
|
||
const tabs: Array<EuiTabbedContentTab & { id: MyForwardableState['captureTest'] }> = [ | ||
{ | ||
id: 'A', | ||
name: 'Test A', | ||
content: ( | ||
<ItemsContainer count="4"> | ||
<TestImageA /> | ||
<TestImageA /> | ||
<TestImageA /> | ||
<TestImageA /> | ||
</ItemsContainer> | ||
), | ||
}, | ||
]; | ||
|
||
export const CaptureTest: FunctionComponent = () => { | ||
const { forwardedState } = useApplicationContext(); | ||
const tabToRender = forwardedState?.captureTest; | ||
const history = useHistory(); | ||
return ( | ||
<EuiPage> | ||
<EuiPageBody> | ||
<EuiPageContent> | ||
<EuiPageHeader> | ||
<EuiFlexGroup alignItems="center" justifyContent="flexEnd"> | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonEmpty | ||
iconType="arrowLeft" | ||
href={history.createHref(parsePath(ROUTES.main))} | ||
> | ||
Back to main | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiPageHeader> | ||
<EuiPageContentBody> | ||
<EuiSpacer /> | ||
<EuiTabbedContent | ||
tabs={tabs} | ||
initialSelectedTab={ | ||
tabToRender ? tabs.find((tab) => tab.id === tabToRender) : undefined | ||
} | ||
/> | ||
</EuiPageContentBody> | ||
</EuiPageContent> | ||
</EuiPageBody> | ||
</EuiPage> | ||
); | ||
}; |
Oops, something went wrong.