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

[Ingest Manager] Simplify add/edit package config (integration) form #71187

Merged
merged 21 commits into from
Jul 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
bd1beef
Match add integration page with designs
jen-huang Jul 9, 2020
35a2d3a
Clean up package config layout code
jen-huang Jul 9, 2020
9c03a57
Match edit integration config page with designs
jen-huang Jul 9, 2020
94bd727
Fix typing and i18n issues
jen-huang Jul 9, 2020
56593b2
Add back data test subj
jen-huang Jul 9, 2020
9053b83
Add loading UI for second step; code clean up
jen-huang Jul 9, 2020
018a70b
Fix limited packages incorrect response
jen-huang Jul 9, 2020
d94be15
Merge remote-tracking branch 'upstream/master' into ingest/package-co…
jen-huang Jul 9, 2020
966444e
Add ability to create agent config when selecting config to add integ…
jen-huang Jul 9, 2020
8d0d898
Add error count to input-level panel; memoize children components
jen-huang Jul 9, 2020
9c0ea0f
Add error count next to all advanced options toggles
jen-huang Jul 9, 2020
8b1bb92
Move general form error to bottom bar
jen-huang Jul 9, 2020
d3301ac
#69750 Auto-expand inputs with required & empty (invalid) vars
jen-huang Jul 10, 2020
cf8fae3
#68019 Enforce unique package config names, per agent config
jen-huang Jul 10, 2020
38a90eb
Fix typing
jen-huang Jul 10, 2020
ac36a33
Fix i18n
jen-huang Jul 10, 2020
e3e33d1
Fix reloading when new agent config _wasn't_ created
jen-huang Jul 10, 2020
1666980
Merge remote-tracking branch 'upstream/master' into ingest/package-co…
jen-huang Jul 10, 2020
357774b
Memoize edit integration and fix fields not collapsing on edit
jen-huang Jul 10, 2020
05daa7b
Merge remote-tracking branch 'upstream/master' into ingest/package-co…
jen-huang Jul 12, 2020
8fdb79e
Really fix types
jen-huang Jul 13, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* 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 from 'react';
import React, { memo, useMemo } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import {
EuiFlexGroup,
Expand All @@ -27,130 +27,148 @@ export const CreatePackageConfigPageLayout: React.FunctionComponent<{
agentConfig?: AgentConfig;
packageInfo?: PackageInfo;
'data-test-subj'?: string;
}> = ({
from,
cancelUrl,
onCancel,
agentConfig,
packageInfo,
children,
'data-test-subj': dataTestSubj,
}) => {
const leftColumn = (
<EuiFlexGroup direction="column" gutterSize="s" alignItems="flexStart">
<EuiFlexItem>
{/* eslint-disable-next-line @elastic/eui/href-or-on-click */}
<EuiButtonEmpty
size="xs"
iconType="arrowLeft"
flush="left"
href={cancelUrl}
onClick={onCancel}
data-test-subj={`${dataTestSubj}_cancelBackLink`}
>
<FormattedMessage
id="xpack.ingestManager.createPackageConfig.cancelLinkText"
defaultMessage="Cancel"
/>
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem>
}> = memo(
({
from,
cancelUrl,
onCancel,
agentConfig,
packageInfo,
children,
'data-test-subj': dataTestSubj,
}) => {
const pageTitle = useMemo(() => {
if ((from === 'package' || from === 'edit') && packageInfo) {
return (
<EuiFlexGroup alignItems="center" gutterSize="m">
<EuiFlexItem grow={false}>
<PackageIcon
packageName={packageInfo?.name || ''}
version={packageInfo?.version || ''}
icons={packageInfo?.icons}
size="xl"
/>
</EuiFlexItem>
<EuiFlexItem>
<EuiText>
<h1>
{from === 'edit' ? (
<FormattedMessage
id="xpack.ingestManager.editPackageConfig.pageTitleWithPackageName"
defaultMessage="Edit {packageName} integration"
values={{
packageName: packageInfo.title,
}}
/>
) : (
<FormattedMessage
id="xpack.ingestManager.createPackageConfig.pageTitleWithPackageName"
defaultMessage="Add {packageName} integration"
values={{
packageName: packageInfo.title,
}}
/>
)}
</h1>
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
);
}

return from === 'edit' ? (
<EuiText>
<h1>
{from === 'edit' ? (
<FormattedMessage
id="xpack.ingestManager.editPackageConfig.pageTitle"
defaultMessage="Edit integration"
/>
) : (
<FormattedMessage
id="xpack.ingestManager.createPackageConfig.pageTitle"
defaultMessage="Add integration"
/>
)}
<FormattedMessage
id="xpack.ingestManager.editPackageConfig.pageTitle"
defaultMessage="Edit integration"
/>
</h1>
</EuiText>
</EuiFlexItem>
<EuiFlexItem>
<EuiSpacer size="s" />
<EuiText color="subdued" size="s">
{from === 'edit' ? (
) : (
<EuiText>
<h1>
<FormattedMessage
id="xpack.ingestManager.editPackageConfig.pageDescription"
defaultMessage="Follow the instructions below to edit this integration."
id="xpack.ingestManager.createPackageConfig.pageTitle"
defaultMessage="Add integration"
/>
) : from === 'config' ? (
</h1>
</EuiText>
);
}, [from, packageInfo]);

const pageDescription = useMemo(() => {
return from === 'edit' ? (
<FormattedMessage
id="xpack.ingestManager.editPackageConfig.pageDescription"
defaultMessage="Modify integration settings and deploy changes to the selected agent configuration."
/>
) : from === 'config' ? (
<FormattedMessage
id="xpack.ingestManager.createPackageConfig.pageDescriptionfromConfig"
defaultMessage="Configure an integration for the selected agent configuration."
/>
) : (
<FormattedMessage
id="xpack.ingestManager.createPackageConfig.pageDescriptionfromPackage"
defaultMessage="Follow the instructions below to add this integration to an agent configuraiton."
/>
);
}, [from]);

const leftColumn = (
<EuiFlexGroup direction="column" gutterSize="s" alignItems="flexStart">
<EuiFlexItem>
{/* eslint-disable-next-line @elastic/eui/href-or-on-click */}
<EuiButtonEmpty
size="xs"
iconType="arrowLeft"
flush="left"
href={cancelUrl}
onClick={onCancel}
data-test-subj={`${dataTestSubj}_cancelBackLink`}
>
<FormattedMessage
id="xpack.ingestManager.createPackageConfig.pageDescriptionfromConfig"
defaultMessage="Follow the instructions below to add an integration to this agent configuration."
id="xpack.ingestManager.createPackageConfig.cancelLinkText"
defaultMessage="Cancel"
/>
) : (
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem>{pageTitle}</EuiFlexItem>
<EuiFlexItem>
<EuiSpacer size="s" />
<EuiText color="subdued" size="s">
{pageDescription}
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
);

const rightColumn =
agentConfig && (from === 'config' || from === 'edit') ? (
<EuiDescriptionList className="eui-textRight" textStyle="reverse">
<EuiDescriptionListTitle>
<FormattedMessage
id="xpack.ingestManager.createPackageConfig.pageDescriptionfromPackage"
defaultMessage="Follow the instructions below to add this integration to an agent configuration."
id="xpack.ingestManager.createPackageConfig.agentConfigurationNameLabel"
defaultMessage="Agent configuration"
/>
)}
</EuiText>
</EuiFlexItem>
</EuiFlexGroup>
);
const rightColumn = (
<EuiFlexGroup justifyContent="flexEnd" direction={'row'} gutterSize="xl">
<EuiFlexItem grow={false}>
<EuiSpacer size="s" />
{agentConfig && (from === 'config' || from === 'edit') ? (
<EuiDescriptionList style={{ textAlign: 'right' }} textStyle="reverse">
<EuiDescriptionListTitle>
<FormattedMessage
id="xpack.ingestManager.createPackageConfig.agentConfigurationNameLabel"
defaultMessage="Configuration"
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
{agentConfig?.name || '-'}
</EuiDescriptionListDescription>
</EuiDescriptionList>
) : null}
{packageInfo && from === 'package' ? (
<EuiDescriptionList style={{ textAlign: 'right' }} textStyle="reverse">
<EuiDescriptionListTitle>
<FormattedMessage
id="xpack.ingestManager.createPackageConfig.packageNameLabel"
defaultMessage="Integration"
/>
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>
<EuiFlexGroup justifyContent="flexEnd" alignItems="center" gutterSize="s">
<EuiFlexItem grow={false}>
<PackageIcon
packageName={packageInfo?.name || ''}
version={packageInfo?.version || ''}
icons={packageInfo?.icons}
size="m"
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
{packageInfo?.title || packageInfo?.name || '-'}
</EuiFlexItem>
</EuiFlexGroup>
</EuiDescriptionListDescription>
</EuiDescriptionList>
) : null}
</EuiFlexItem>
</EuiFlexGroup>
);
</EuiDescriptionListTitle>
<EuiDescriptionListDescription>{agentConfig?.name || '-'}</EuiDescriptionListDescription>
</EuiDescriptionList>
) : undefined;

const maxWidth = 770;
return (
<WithHeaderLayout
restrictHeaderWidth={maxWidth}
restrictWidth={maxWidth}
leftColumn={leftColumn}
rightColumn={rightColumn}
rightColumnGrow={false}
data-test-subj={dataTestSubj}
>
{children}
</WithHeaderLayout>
);
};
const maxWidth = 770;
return (
<WithHeaderLayout
restrictHeaderWidth={maxWidth}
restrictWidth={maxWidth}
leftColumn={leftColumn}
rightColumn={rightColumn}
rightColumnGrow={false}
data-test-subj={dataTestSubj}
>
{children}
</WithHeaderLayout>
);
}
);
Loading