mirror of
https://github.com/elastic/kibana.git
synced 2025-04-25 18:27:59 -04:00
* Update all usages of EuiPageTemplate to EuiPageTemplate_Deprecated * EuiPageContent_Deprecated as EuiPageContent * EuiPageContentBody_Deprecated as EuiPageContentBody * EuiPageContentHeader_Deprecated as EuiPageContentHeader * EuiPageContentHeaderSection_Deprecated as EuiPageContentHeaderSection * EuiPageSideBar_Deprecated as EuiPageSideBar * EuiPageContent__Deprecated to EuiPageContent_Deprecated * Fix rogue semi-colons * WIP: NoDataConfigPage & NoDataPage converted to new template - `withSolutionNav` not yet handled * WIP: KibanaPageTemplateInner converted to use new template - Pushes existing `pageHeader` prompts onto created EuiPageTemplate.PageHeader - Uses `isEmptyState` to push `pageHeader` props to EuiPageTemplate.EmptyPrompt instead (if `children` are not supplied) * WIP: `withSolutionNav` now renders the sidebar content properly - Collapsing isn’t working (minWidth isn’t updating) * Fixing stickiness of sidebar * [Security] Fixed SecuritySolutionTemplateWrapper’s usage - Moved `bottomBar` to EuiPageTemplate.BottomBar (now contained in just the page contents) - Change EuiPanel children wrapper with EuiPageTemplate.Section * [O11y] Wrap `children` with EuiPageTemplate.Section * Fix getting_started usage * WIP: Fixing types * Removing `template` pass through * Set EUI to 63.0.0 * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * More import fixes * Sidebar component update * Expand `KibanaPageTemplate` to all namespaced EUI counterparts - Updated `docs/tutorials` mdx page - Fixed SolutionNav prop types * Updated the tutorial mdx page * [Stack Management] Updated app layout to new template - Some temporary props applied for BWC until all other pages can be converted - Converted `API Keys` page’s layout (and especially prompt usags) to new paradigm * Fix circular dep * Fix new circular dependency - copying and pasting types from KibanaPageTemplateProps, but ah well * [Security Solution] Remove `template` prop - no longer a prop on Kibana/EuiPageTemplate * [O11y] Allow customizing EuiPageTemplate.Section wrapper - converts pageBodyProps - fixes non-centered loading template * [Enterprise Search] Update page templates - fix layouts by auto-wrapping an EuiPageSection for padding, while adding a `customPageSections` prop for more custom sections/layouts - re-center 404 errors - update tests * Update KibanaPageTemplate tests * Update snapshots * Fix FTR test with removed EUI classNames * Fix FTR tests with changed kbn classNames * Update failing dashboard snapshots - drop shadow changed slightly in EUI * Fix failing Security Cypress test * [O11y] Fix Inventory page using deprecated CSS hooks * [O11y][Uptime] Fix missing bottom bars - Modifies ObservabilityPageTemplate to accept a `bottomBar` prop (a la the old EuiPageTemplate behavior) NOTE: This opinionated page layout structure is starting to feel like it could be potentially limiting / have all the same pitfalls the previous EuiPageTemplate did. If so, consider something closer to the Enterprise Search page template conversion (`customPageSections`). - Misc cleanup: Use `KibanaPageTemplate` over `EuiPageTemplate` * [O11y] Fix route template typing - Since theObservabilityPageTemplate is using the new Eui/KibanaPageTemplate, its child templates and types need to be updated accordingly * Fix broken minWidth behavior - was an EUI issue that required a patch release + update snapshots * [Security Solution] Type fixes, restore empty state - Fix empty state logic removed in a previous commit - bogarts KibanaPageTemplate's `isEmptyState` prop instead of using `template="noData"` - extend template wrappers to past ...rest to underlying Kibana/EuiPageTemplate + replace EuiPageTemplate with KibanaPageTemplate for consistency * Fix failing synthetics selector * Grab EUI v63.0.6 - for deprecation tags and section tag support * Fix Kibana Overview plugin layout - needs to use KibanaPageTemplate.Section to get padding back - use `bottomBorder` prop over horizontal rules - restore previous page color via panelled=false * Convert Home plugin to new KibanaPageTemplate - use KibanaPageTemplate.Section instead to preserve page width/paddings - use `bottomBorder` instead of `EuiHorizontalRule` - NOTE: This causes margins to decrease slightly from xxl to xl (largest padding available for EuiPageSection) - this can be restored by CSS overrides if desired - update CSS to preserve previous looks, + convert to logical properties * [O11y] Fix non-centered empty/loading states * [O11y] Restore subdued background on various empty state prompts * [O11y] Fix all instances of views that require a scrollable full-height child + restore comment for inventory view * [O11y][ux] Fix broken sidebar - The entire app was missing a wrapping EuiProvider, and as such breakpoint utils were not working, and the sidebar was missing + misc cleanup - remove unnecessary fragment - remove role="main" attr - now that EuiPageTemplate sets a `main` tag, they'll conflict - add isEmptyState to center loading component * [APM Cypress tests] harden flaky test * [APM Cypress tests] Fix failing Cypress test, again Co-authored-by: cchaos <caroline.horn@elastic.co> Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
217 lines
6.9 KiB
TypeScript
217 lines
6.9 KiB
TypeScript
/*
|
|
* 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 and the Server Side Public License, v 1; you may not use this file except
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
* Side Public License, v 1.
|
|
*/
|
|
|
|
import React from 'react';
|
|
import {
|
|
EuiBasicTable,
|
|
EuiCallOut,
|
|
EuiCode,
|
|
EuiCodeBlock,
|
|
EuiLink,
|
|
EuiPage,
|
|
EuiPageBody,
|
|
EuiPageContent_Deprecated as EuiPageContent,
|
|
EuiPageContentBody_Deprecated as EuiPageContentBody,
|
|
EuiPageHeader,
|
|
EuiPageHeaderSection,
|
|
EuiSpacer,
|
|
EuiText,
|
|
EuiTitle,
|
|
} from '@elastic/eui';
|
|
import { FieldFormatsStart } from '@kbn/field-formats-plugin/public';
|
|
import * as example1 from './examples/1_using_existing_format';
|
|
import * as example2 from './examples/2_creating_custom_formatter';
|
|
// @ts-ignore
|
|
import example1SampleCode from '!!raw-loader!./examples/1_using_existing_format';
|
|
// @ts-ignore
|
|
import example2SampleCodePart1 from '!!raw-loader!../common/example_currency_format';
|
|
// @ts-ignore
|
|
import example2SampleCodePart2 from '!!raw-loader!./examples/2_creating_custom_formatter';
|
|
// @ts-ignore
|
|
import example2SampleCodePart3 from '!!raw-loader!../server/examples/2_creating_custom_formatter';
|
|
// @ts-ignore
|
|
import example3SampleCode from '!!raw-loader!./examples/3_creating_custom_format_editor';
|
|
|
|
export interface Deps {
|
|
fieldFormats: FieldFormatsStart;
|
|
|
|
/**
|
|
* Just for demo purposes
|
|
*/
|
|
openDateViewNumberFieldEditor: () => void;
|
|
}
|
|
|
|
const UsingAnExistingFieldFormatExample: React.FC<{ deps: Deps }> = (props) => {
|
|
const sample = example1.getSample(props.deps.fieldFormats);
|
|
|
|
return (
|
|
<>
|
|
<EuiText>
|
|
<p>
|
|
This example shows how to use existing field formatter to format values. As an example, we
|
|
have a following sample configuration{' '}
|
|
<EuiCode>{JSON.stringify(example1.sampleSerializedFieldFormat)}</EuiCode> representing a{' '}
|
|
<EuiCode>bytes</EuiCode>
|
|
field formatter with a <EuiCode>0.00b</EuiCode> pattern.
|
|
</p>
|
|
</EuiText>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiCodeBlock>{example1SampleCode}</EuiCodeBlock>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiBasicTable
|
|
data-test-subj={'example1 sample table'}
|
|
items={sample}
|
|
textOnly={true}
|
|
columns={[
|
|
{
|
|
field: 'raw',
|
|
name: 'Raw value',
|
|
'data-test-subj': 'example1 sample raw',
|
|
},
|
|
{
|
|
field: 'formatted',
|
|
name: 'Formatted value',
|
|
'data-test-subj': 'example1 sample formatted',
|
|
},
|
|
]}
|
|
/>
|
|
</>
|
|
);
|
|
};
|
|
|
|
const CreatingCustomFieldFormat: React.FC<{ deps: Deps }> = (props) => {
|
|
const sample = example2.getSample(props.deps.fieldFormats);
|
|
|
|
return (
|
|
<>
|
|
<EuiText>
|
|
<p>
|
|
This example shows how to create a custom field formatter. As an example, we create a
|
|
currency formatter and then display some values as <EuiCode>USD</EuiCode>. Custom field
|
|
formatter has to be registered both client and server side.
|
|
</p>
|
|
</EuiText>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiCodeBlock>{example2SampleCodePart1}</EuiCodeBlock>
|
|
<EuiSpacer size={'xs'} />
|
|
<EuiCodeBlock>{example2SampleCodePart2}</EuiCodeBlock>
|
|
<EuiSpacer size={'xs'} />
|
|
<EuiCodeBlock>{example2SampleCodePart3}</EuiCodeBlock>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiBasicTable
|
|
items={sample}
|
|
textOnly={true}
|
|
data-test-subj={'example2 sample table'}
|
|
columns={[
|
|
{
|
|
field: 'raw',
|
|
name: 'Raw value',
|
|
'data-test-subj': 'example2 sample raw',
|
|
},
|
|
{
|
|
field: 'formatted',
|
|
name: 'Formatted value',
|
|
'data-test-subj': 'example2 sample formatted',
|
|
},
|
|
]}
|
|
/>
|
|
<EuiSpacer size={'s'} />
|
|
|
|
<EuiCallOut
|
|
title="Seamless integration with data views!"
|
|
color="success"
|
|
iconType="indexManagementApp"
|
|
>
|
|
<p>
|
|
Currency formatter that we've just created is already integrated with data views. It
|
|
can be applied to any <EuiCode>numeric</EuiCode> field of any data view.{' '}
|
|
<EuiLink onClick={() => props.deps.openDateViewNumberFieldEditor()}>
|
|
Open data view field editor to give it a try.
|
|
</EuiLink>
|
|
</p>
|
|
</EuiCallOut>
|
|
</>
|
|
);
|
|
};
|
|
|
|
const CreatingCustomFieldFormatEditor: React.FC<{ deps: Deps }> = (props) => {
|
|
return (
|
|
<>
|
|
<EuiText>
|
|
<p>
|
|
This example shows how to create a custom field formatter editor. As an example, we will
|
|
create a format editor for the currency formatter created in the previous section. This
|
|
custom editor will allow to select either <EuiCode>USD</EuiCode> or <EuiCode>EUR</EuiCode>{' '}
|
|
currency.
|
|
</p>
|
|
</EuiText>
|
|
<EuiSpacer size={'s'} />
|
|
<EuiCodeBlock>{example3SampleCode}</EuiCodeBlock>
|
|
<EuiSpacer size={'s'} />
|
|
|
|
<EuiCallOut
|
|
title="Check the result in the data view field editor!"
|
|
color="primary"
|
|
iconType="indexManagementApp"
|
|
>
|
|
<p>
|
|
Currency formatter and its custom editor are integrated with data views. It can be applied
|
|
to any <EuiCode>numeric</EuiCode> field of any data view.{' '}
|
|
<EuiLink onClick={() => props.deps.openDateViewNumberFieldEditor()}>
|
|
Open date view field editor to give it a try.
|
|
</EuiLink>
|
|
</p>
|
|
</EuiCallOut>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export const App: React.FC<{ deps: Deps }> = (props) => {
|
|
return (
|
|
<EuiPage>
|
|
<EuiPageBody style={{ maxWidth: 1200, margin: '0 auto' }}>
|
|
<EuiPageHeader>
|
|
<EuiPageHeaderSection>
|
|
<EuiTitle size="l">
|
|
<h1>Field formats examples</h1>
|
|
</EuiTitle>
|
|
</EuiPageHeaderSection>
|
|
</EuiPageHeader>
|
|
<EuiPageContent>
|
|
<EuiPageContentBody style={{ maxWidth: 800, margin: '0 auto' }}>
|
|
<section>
|
|
<EuiTitle size="m">
|
|
<h2>Using an existing field format</h2>
|
|
</EuiTitle>
|
|
<EuiSpacer />
|
|
<UsingAnExistingFieldFormatExample deps={props.deps} />
|
|
</section>
|
|
<EuiSpacer />
|
|
<EuiSpacer />
|
|
<section>
|
|
<EuiTitle size="m">
|
|
<h2>Creating a custom field format</h2>
|
|
</EuiTitle>
|
|
<EuiSpacer />
|
|
<CreatingCustomFieldFormat deps={props.deps} />
|
|
</section>
|
|
<EuiSpacer />
|
|
<EuiSpacer />
|
|
<section>
|
|
<EuiTitle size="m">
|
|
<h2>Creating a custom field format editor</h2>
|
|
</EuiTitle>
|
|
<EuiSpacer />
|
|
<CreatingCustomFieldFormatEditor deps={props.deps} />
|
|
</section>
|
|
</EuiPageContentBody>
|
|
</EuiPageContent>
|
|
</EuiPageBody>
|
|
</EuiPage>
|
|
);
|
|
};
|