Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove deprecated EUI components from screenshotting_example plugin #164106

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
153 changes: 75 additions & 78 deletions x-pack/examples/reporting_example/public/containers/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import {
EuiLink,
EuiPage,
EuiPageBody,
EuiPageContent_Deprecated as EuiPageContent,
EuiPageContentBody_Deprecated as EuiPageContentBody,
EuiPageSection,
EuiPageHeader,
EuiPopover,
EuiSpacer,
Expand Down Expand Up @@ -292,86 +291,84 @@ export const Main = ({ basename, reporting, screenshotMode }: ReportingExampleAp
<h1>Reporting Example</h1>
</EuiTitle>
</EuiPageHeader>
<EuiPageContent>
<EuiPageContentBody>
<EuiTitle>
<h2>Example of a Sharing menu using components from Reporting</h2>
</EuiTitle>
<EuiSpacer />
<EuiText>
<EuiFlexGroup alignItems="center" gutterSize="l">
<EuiFlexItem grow={false}>
<EuiPopover
id="contextMenuExample"
button={
<EuiButton data-test-subj="shareButton" onClick={onButtonClick}>
Share
</EuiButton>
}
isOpen={isPopoverOpen}
closePopover={closePopover}
panelPaddingSize="none"
anchorPosition="downLeft"
>
<EuiContextMenu initialPanelId={0} panels={panels} />
</EuiPopover>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="s">
<EuiLink href={history.createHref(parsePath(ROUTES.captureTest))}>
Go to capture test
</EuiLink>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
<EuiPageSection>
<EuiTitle>
<h2>Example of a Sharing menu using components from Reporting</h2>
</EuiTitle>
<EuiSpacer />
<EuiText>
<EuiFlexGroup alignItems="center" gutterSize="l">
<EuiFlexItem grow={false}>
<EuiPopover
id="contextMenuExample"
button={
<EuiButton data-test-subj="shareButton" onClick={onButtonClick}>
Share
</EuiButton>
}
isOpen={isPopoverOpen}
closePopover={closePopover}
panelPaddingSize="none"
anchorPosition="downLeft"
>
<EuiContextMenu initialPanelId={0} panels={panels} />
</EuiPopover>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="s">
<EuiLink href={history.createHref(parsePath(ROUTES.captureTest))}>
Go to capture test
</EuiLink>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>

<EuiHorizontalRule />
<EuiHorizontalRule />

<div data-shared-items-container data-shared-items-count="5">
<EuiFlexGroup gutterSize="l">
<EuiFlexItem data-shared-item>
{forwardedState ? (
<>
<EuiText>
<p>
<strong>Forwarded app state</strong>
</p>
</EuiText>
<EuiCodeBlock>{JSON.stringify(forwardedState)}</EuiCodeBlock>
</>
) : (
<>
<EuiText>
<p>
<strong>No forwarded app state found</strong>
</p>
</EuiText>
<EuiCodeBlock>{'{}'}</EuiCodeBlock>
</>
)}
<div data-shared-items-container data-shared-items-count="5">
<EuiFlexGroup gutterSize="l">
<EuiFlexItem data-shared-item>
{forwardedState ? (
<>
<EuiText>
<p>
<strong>Forwarded app state</strong>
</p>
</EuiText>
<EuiCodeBlock>{JSON.stringify(forwardedState)}</EuiCodeBlock>
</>
) : (
<>
<EuiText>
<p>
<strong>No forwarded app state found</strong>
</p>
</EuiText>
<EuiCodeBlock>{'{}'}</EuiCodeBlock>
</>
)}
</EuiFlexItem>
{logos.map((item, index) => (
<EuiFlexItem
key={index}
data-shared-item
data-shared-render-error
data-render-error="This is an example error"
>
<EuiCard
icon={<EuiIcon size="xxl" type={`logo${item}`} />}
title={`Elastic ${item}`}
description="Example of a card's description. Stick to one or two sentences."
onClick={() => {}}
/>
</EuiFlexItem>
{logos.map((item, index) => (
<EuiFlexItem
key={index}
data-shared-item
data-shared-render-error
data-render-error="This is an example error"
>
<EuiCard
icon={<EuiIcon size="xxl" type={`logo${item}`} />}
title={`Elastic ${item}`}
description="Example of a card's description. Stick to one or two sentences."
onClick={() => {}}
/>
</EuiFlexItem>
))}
</EuiFlexGroup>
))}
</EuiFlexGroup>

<p>Screenshot Mode is {screenshotMode.isScreenshotMode() ? 'ON' : 'OFF'}!</p>
</div>
</EuiText>
</EuiPageContentBody>
</EuiPageContent>
<p>Screenshot Mode is {screenshotMode.isScreenshotMode() ? 'ON' : 'OFF'}!</p>
</div>
</EuiText>
</EuiPageSection>
</EuiPageBody>
</EuiPage>
</I18nProvider>
Expand Down
141 changes: 69 additions & 72 deletions x-pack/examples/screenshotting_example/public/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
EuiImage,
EuiPage,
EuiPageBody,
EuiPageContent_Deprecated as EuiPageContent,
EuiPageContentBody_Deprecated as EuiPageContentBody,
EuiPageSection,
EuiPageHeader,
EuiPageHeaderSection,
EuiSpacer,
Expand Down Expand Up @@ -60,77 +59,75 @@ export function App() {
</EuiTitle>
</EuiPageHeaderSection>
</EuiPageHeader>
<EuiPageContent>
<EuiPageContentBody>
<EuiText>
<p>This example captures a screenshot of an expression provided below.</p>
</EuiText>
<EuiSpacer size={'m'} />
<EuiTextArea
placeholder="Expression to render"
fullWidth
onChange={handleChange}
data-test-subj="expression"
/>
<EuiSpacer size={'m'} />
<EuiButton
iconType="play"
onClick={handleClick}
isDisabled={!expression}
isLoading={loading}
data-test-subj="run"
>
Run
</EuiButton>
{!!response && <EuiHorizontalRule />}
{response?.errors && (
<>
<EuiCallOut
title="Sorry, there was an error"
color="danger"
iconType="warning"
data-test-subj="error"
>
<p>{response.errors.join('\n')}</p>
</EuiCallOut>
<EuiSpacer size={'m'} />
</>
)}
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
{response?.image && (
<EuiImage
src={`data:image/png;base64,${response.image}`}
alt="Screenshot"
size="xl"
allowFullScreen
hasShadow
data-test-subj="image"
<EuiPageSection>
<EuiText>
<p>This example captures a screenshot of an expression provided below.</p>
</EuiText>
<EuiSpacer size={'m'} />
<EuiTextArea
placeholder="Expression to render"
fullWidth
onChange={handleChange}
data-test-subj="expression"
/>
<EuiSpacer size={'m'} />
<EuiButton
iconType="play"
onClick={handleClick}
isDisabled={!expression}
isLoading={loading}
data-test-subj="run"
>
Run
</EuiButton>
{!!response && <EuiHorizontalRule />}
{response?.errors && (
<>
<EuiCallOut
title="Sorry, there was an error"
color="danger"
iconType="warning"
data-test-subj="error"
>
<p>{response.errors.join('\n')}</p>
</EuiCallOut>
<EuiSpacer size={'m'} />
</>
)}
<EuiFlexGroup justifyContent="spaceBetween">
<EuiFlexItem grow={false}>
{response?.image && (
<EuiImage
src={`data:image/png;base64,${response.image}`}
alt="Screenshot"
size="xl"
allowFullScreen
hasShadow
data-test-subj="image"
/>
)}
</EuiFlexItem>
<EuiFlexItem>
{response?.metrics && (
<>
<EuiStat
title={`${response.metrics.cpuInPercentage ?? 'N/A'}%`}
description="CPU"
titleColor="primary"
data-test-subj="cpu"
/>
)}
</EuiFlexItem>
<EuiFlexItem>
{response?.metrics && (
<>
<EuiStat
title={`${response.metrics.cpuInPercentage ?? 'N/A'}%`}
description="CPU"
titleColor="primary"
data-test-subj="cpu"
/>
<EuiSpacer size={'m'} />
<EuiStat
title={`${response.metrics.memoryInMegabytes ?? 'N/A'} MB`}
description="Memory"
titleColor="primary"
data-test-subj="memory"
/>
</>
)}
</EuiFlexItem>
</EuiFlexGroup>
</EuiPageContentBody>
</EuiPageContent>
<EuiSpacer size={'m'} />
<EuiStat
title={`${response.metrics.memoryInMegabytes ?? 'N/A'} MB`}
description="Memory"
titleColor="primary"
data-test-subj="memory"
/>
</>
)}
</EuiFlexItem>
</EuiFlexGroup>
</EuiPageSection>
</EuiPageBody>
</EuiPage>
);
Expand Down
Loading