-
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.
[IM] add screenshot detail view and image endpoint (#48149)
* add api endpoint to handle images * #47978 add screenshots component with single image * update padding around screenshot * import existing API_ROOT * move ImageRequestParams interface and fix type * pass the content-type through and add test * fix ie11 issues with nested flex items, change radius to use eui variable * use eui variables for padding * add aria label and image description
- Loading branch information
Showing
11 changed files
with
175 additions
and
12 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
57 changes: 57 additions & 0 deletions
57
x-pack/legacy/plugins/integrations_manager/public/screens/detail/screenshots.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,57 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React, { Fragment } from 'react'; | ||
import { EuiSpacer, EuiText, EuiTitle, EuiImage, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; | ||
import styled from 'styled-components'; | ||
import { ScreenshotItem } from '../../../common/types'; | ||
import { useLinks, useCore } from '../../hooks'; | ||
|
||
interface ScreenshotProps { | ||
images: ScreenshotItem[]; | ||
} | ||
|
||
export function Screenshots(props: ScreenshotProps) { | ||
const { theme } = useCore(); | ||
const { toImage } = useLinks(); | ||
const { images } = props; | ||
|
||
// for now, just get first image | ||
const src = toImage(images[0].src); | ||
|
||
const horizontalPadding: number = parseInt(theme.eui.paddingSizes.xl, 10) * 2; | ||
const bottomPadding: number = parseInt(theme.eui.paddingSizes.xl, 10) * 1.75; | ||
|
||
const ScreenshotsContainer = styled(EuiFlexGroup)` | ||
background: linear-gradient(360deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0) 100%), | ||
${theme.eui.euiColorPrimary}; | ||
padding: ${theme.eui.paddingSizes.xl} ${horizontalPadding}px ${bottomPadding}px; | ||
flex: 0 0 auto; | ||
border-radius: ${theme.eui.euiBorderRadius}; | ||
`; | ||
// fixes ie11 problems with nested flex items | ||
const NestedEuiFlexItem = styled(EuiFlexItem)` | ||
flex: 0 0 auto !important; | ||
`; | ||
return ( | ||
<Fragment> | ||
<EuiTitle size="s"> | ||
<h3>Screenshots</h3> | ||
</EuiTitle> | ||
<EuiSpacer size="m" /> | ||
<ScreenshotsContainer gutterSize="none" direction="column" alignItems="center"> | ||
<NestedEuiFlexItem> | ||
<EuiText color="ghost" aria-label="screenschot image caption"> | ||
We need image descriptions to be returned in the response | ||
</EuiText> | ||
<EuiSpacer /> | ||
</NestedEuiFlexItem> | ||
<NestedEuiFlexItem> | ||
<EuiImage url={src} alt="screenhot image preview" size="l" allowFullScreen /> | ||
</NestedEuiFlexItem> | ||
</ScreenshotsContainer> | ||
</Fragment> | ||
); | ||
} |
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
61 changes: 61 additions & 0 deletions
61
x-pack/test/integrations_manager_api_integration/apis/image.ts
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,61 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import ServerMock from 'mock-http-server'; | ||
import { FtrProviderContext } from '../../api_integration/ftr_provider_context'; | ||
|
||
export default function({ getService }: FtrProviderContext) { | ||
describe('images', () => { | ||
const server = new ServerMock({ host: 'localhost', port: 6666 }); | ||
beforeEach(() => { | ||
server.start(() => {}); | ||
}); | ||
afterEach(() => { | ||
server.stop(() => {}); | ||
}); | ||
it('fetches a png screenshot image from the registry', async () => { | ||
server.on({ | ||
method: 'GET', | ||
path: '/package/auditd-2.0.4/img/screenshots/auditbeat-file-integrity-dashboard.png', | ||
reply: { | ||
headers: { 'content-type': 'image/png' }, | ||
}, | ||
}); | ||
|
||
const supertest = getService('supertest'); | ||
const fetchImage = async () => { | ||
await supertest | ||
.get( | ||
'/api/integrations_manager/package/auditd-2.0.4/img/screenshots/auditbeat-file-integrity-dashboard.png' | ||
) | ||
.set('kbn-xsrf', 'xxx') | ||
.expect('Content-Type', 'image/png') | ||
.expect(200); | ||
}; | ||
await fetchImage(); | ||
}); | ||
|
||
it('fetches an icon image from the registry', async () => { | ||
server.on({ | ||
method: 'GET', | ||
path: '/package/auditd-2.0.4/img/icon.svg', | ||
reply: { | ||
headers: { 'content-type': 'image/svg' }, | ||
}, | ||
}); | ||
|
||
const supertest = getService('supertest'); | ||
const fetchImage = async () => { | ||
await supertest | ||
.get('/api/integrations_manager/package/auditd-2.0.4/img/icon.svg') | ||
.set('kbn-xsrf', 'xxx') | ||
.expect('Content-Type', 'image/svg') | ||
.expect(200); | ||
}; | ||
await fetchImage(); | ||
}); | ||
}); | ||
} |
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