-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
199 additions
and
138 deletions.
There are no files selected for viewing
83 changes: 83 additions & 0 deletions
83
x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/components/kibana_objects.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,83 @@ | ||
/* | ||
* 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, { FC, memo } from 'react'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiIcon, | ||
EuiLoadingSpinner, | ||
EuiText, | ||
EuiTitle, | ||
EuiListGroup, | ||
EuiListGroupItem, | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { KibanaObjectUi } from '../page'; | ||
|
||
export interface KibanaObjectItemProps { | ||
objectType: string; | ||
kibanaObjects: KibanaObjectUi[]; | ||
isSaving: boolean; | ||
} | ||
|
||
export const KibanaObjects: FC<KibanaObjectItemProps> = memo( | ||
({ objectType, kibanaObjects, isSaving }) => { | ||
const kibanaObjectLabels: { [key: string]: string } = { | ||
dashboard: i18n.translate('xpack.ml.newJob.simple.recognize.dashboardsLabel', { | ||
defaultMessage: 'Dashboards', | ||
}), | ||
search: i18n.translate('xpack.ml.newJob.simple.recognize.searchesLabel', { | ||
defaultMessage: 'Searches', | ||
}), | ||
visualization: i18n.translate('xpack.ml.newJob.simple.recognize.visualizationsLabel', { | ||
defaultMessage: 'Visualizations', | ||
}), | ||
}; | ||
|
||
return ( | ||
<> | ||
<EuiTitle size="s"> | ||
<h4>{kibanaObjectLabels[objectType]}</h4> | ||
</EuiTitle> | ||
<EuiListGroup bordered={false} flush={true} wrapText={true}> | ||
{kibanaObjects.map(({ id, title, success, exists }) => ( | ||
<EuiListGroupItem | ||
key={id} | ||
label={ | ||
<EuiFlexGroup alignItems="center" gutterSize="s"> | ||
<EuiFlexItem> | ||
{isSaving ? <EuiLoadingSpinner size="m" /> : null} | ||
{success !== undefined ? ( | ||
<EuiIcon | ||
type={success ? 'check' : 'cross'} | ||
color={success ? 'success' : 'danger'} | ||
/> | ||
) : null} | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiText size="s" color="secondary"> | ||
{title} | ||
</EuiText> | ||
{exists && ( | ||
<EuiText size="xs" color="danger"> | ||
<FormattedMessage | ||
id="xpack.ml.newJob.simple.recognize.alreadyExistsLabel" | ||
defaultMessage="(already exists)" | ||
/> | ||
</EuiText> | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
} | ||
/> | ||
))} | ||
</EuiListGroup> | ||
</> | ||
); | ||
} | ||
); |
102 changes: 102 additions & 0 deletions
102
x-pack/legacy/plugins/ml/public/jobs/new_job_new/recognize/components/module_jobs.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,102 @@ | ||
/* | ||
* 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, { FC, memo } from 'react'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { | ||
EuiBadge, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiListGroup, | ||
EuiListGroupItem, | ||
EuiLoadingSpinner, | ||
EuiText, | ||
EuiTitle, | ||
} from '@elastic/eui'; | ||
|
||
interface ModuleJobsProps { | ||
jobs: any[]; | ||
jobPrefix: string; | ||
isSaving: boolean; | ||
} | ||
|
||
export const ModuleJobs: FC<ModuleJobsProps> = memo(({ jobs, jobPrefix, isSaving }) => { | ||
return ( | ||
<> | ||
<EuiTitle size="s"> | ||
<h4> | ||
<FormattedMessage id="xpack.ml.newJob.simple.recognize.jobsTitle" defaultMessage="Jobs" /> | ||
</h4> | ||
</EuiTitle> | ||
|
||
<EuiListGroup bordered={false} flush={true} wrapText={true} maxWidth={false}> | ||
{jobs.map(({ id, config: { description }, setupResult, datafeedResult }) => ( | ||
<EuiListGroupItem | ||
key={id} | ||
label={ | ||
<EuiFlexGroup alignItems="center" gutterSize="s"> | ||
<EuiFlexItem> | ||
<EuiFlexGroup> | ||
<EuiFlexItem grow={false}> | ||
<EuiText size="s" color="secondary"> | ||
{jobPrefix} | ||
{id} | ||
</EuiText> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
{setupResult && datafeedResult && ( | ||
<EuiFlexGroup gutterSize="none"> | ||
<EuiBadge | ||
color={setupResult.success ? 'secondary' : 'danger'} | ||
iconType={setupResult.success ? 'check' : 'cross'} | ||
> | ||
<FormattedMessage | ||
id="xpack.ml.newJob.simple.recognize.jobLabel" | ||
defaultMessage="Job" | ||
/> | ||
</EuiBadge> | ||
<EuiBadge | ||
color={datafeedResult.success ? 'secondary' : 'danger'} | ||
iconType={datafeedResult.success ? 'check' : 'cross'} | ||
> | ||
<FormattedMessage | ||
id="xpack.ml.newJob.simple.recognize.datafeedLabel" | ||
defaultMessage="Datafeed" | ||
/> | ||
</EuiBadge> | ||
<EuiBadge | ||
color={datafeedResult.started ? 'secondary' : 'danger'} | ||
iconType={datafeedResult.started ? 'check' : 'cross'} | ||
> | ||
<FormattedMessage | ||
id="xpack.ml.newJob.simple.recognize.runningLabel" | ||
defaultMessage="Running" | ||
/> | ||
</EuiBadge> | ||
</EuiFlexGroup> | ||
)} | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
|
||
<EuiText size="s" color="subdued"> | ||
{description} | ||
</EuiText> | ||
|
||
{setupResult && setupResult.error && ( | ||
<EuiText size="xs" color="danger"> | ||
{setupResult.error.msg} | ||
</EuiText> | ||
)} | ||
</EuiFlexItem> | ||
<EuiFlexItem>{isSaving && <EuiLoadingSpinner size="m" />}</EuiFlexItem> | ||
</EuiFlexGroup> | ||
} | ||
/> | ||
))} | ||
</EuiListGroup> | ||
</> | ||
); | ||
}); |
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