-
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.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
33 changed files
with
899 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const GLOBAL_SETTINGS_SAVED_OBJECT_TYPE = 'ingest_manager_settings'; |
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
19 changes: 19 additions & 0 deletions
19
x-pack/plugins/ingest_manager/common/types/models/settings.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,19 @@ | ||
/* | ||
* 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 { SavedObjectAttributes } from 'src/core/public'; | ||
|
||
interface BaseSettings { | ||
agent_auto_upgrade?: boolean; | ||
package_auto_upgrade?: boolean; | ||
kibana_url?: string; | ||
kibana_ca_sha256?: string; | ||
} | ||
|
||
export interface Settings extends BaseSettings { | ||
id: string; | ||
} | ||
|
||
export interface SettingsSOAttributes extends BaseSettings, SavedObjectAttributes {} |
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
40 changes: 40 additions & 0 deletions
40
x-pack/plugins/ingest_manager/common/types/rest_spec/output.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,40 @@ | ||
/* | ||
* 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 { Output } from '../models'; | ||
|
||
export interface GetOneOutputResponse { | ||
item: Output; | ||
success: boolean; | ||
} | ||
|
||
export interface GetOneOutputRequest { | ||
params: { | ||
outputId: string; | ||
}; | ||
} | ||
|
||
export interface PutOutputRequest { | ||
params: { | ||
outputId: string; | ||
}; | ||
body: { | ||
hosts?: string[]; | ||
ca_sha256?: string; | ||
}; | ||
} | ||
|
||
export interface PutOutputResponse { | ||
item: Output; | ||
success: boolean; | ||
} | ||
|
||
export interface GetOutputsResponse { | ||
items: Output[]; | ||
total: number; | ||
page: number; | ||
perPage: number; | ||
success: boolean; | ||
} |
20 changes: 20 additions & 0 deletions
20
x-pack/plugins/ingest_manager/common/types/rest_spec/settings.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,20 @@ | ||
/* | ||
* 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 { Settings } from '../models'; | ||
|
||
export interface GetSettingsResponse { | ||
item: Settings; | ||
success: boolean; | ||
} | ||
|
||
export interface PutSettingsRequest { | ||
body: Partial<Omit<Settings, 'id'>>; | ||
} | ||
|
||
export interface PutSettingsResponse { | ||
item: Settings; | ||
success: boolean; | ||
} |
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
240 changes: 240 additions & 0 deletions
240
.../plugins/ingest_manager/public/applications/ingest_manager/components/settings_flyout.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,240 @@ | ||
/* | ||
* 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, { useEffect } from 'react'; | ||
import { i18n } from '@kbn/i18n'; | ||
import { | ||
EuiFlyout, | ||
EuiFlyoutBody, | ||
EuiFlyoutHeader, | ||
EuiTitle, | ||
EuiFlexGroup, | ||
EuiFlexItem, | ||
EuiButtonEmpty, | ||
EuiSpacer, | ||
EuiButton, | ||
EuiFlyoutFooter, | ||
EuiForm, | ||
EuiFormRow, | ||
EuiFieldText, | ||
EuiRadioGroup, | ||
EuiComboBox, | ||
} from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n/react'; | ||
import { EuiText } from '@elastic/eui'; | ||
import { useInput, useComboInput, useCore, useGetSettings, sendPutSettings } from '../hooks'; | ||
import { useGetOutputs, sendPutOutput } from '../hooks/use_request/outputs'; | ||
|
||
interface Props { | ||
onClose: () => void; | ||
} | ||
|
||
function useSettingsForm(outputId: string | undefined) { | ||
const { notifications } = useCore(); | ||
const kibanaUrlInput = useInput(); | ||
const elasticsearchUrlInput = useComboInput([]); | ||
|
||
return { | ||
onSubmit: async () => { | ||
try { | ||
if (!outputId) { | ||
throw new Error('Unable to load outputs'); | ||
} | ||
await sendPutOutput(outputId, { | ||
hosts: elasticsearchUrlInput.value, | ||
}); | ||
await sendPutSettings({ | ||
kibana_url: kibanaUrlInput.value, | ||
}); | ||
} catch (error) { | ||
notifications.toasts.addError(error, { | ||
title: 'Error', | ||
}); | ||
} | ||
notifications.toasts.addSuccess( | ||
i18n.translate('xpack.ingestManager.settings.success.message', { | ||
defaultMessage: 'Settings saved', | ||
}) | ||
); | ||
}, | ||
inputs: { | ||
kibanaUrl: kibanaUrlInput, | ||
elasticsearchUrl: elasticsearchUrlInput, | ||
}, | ||
}; | ||
} | ||
|
||
export const SettingFlyout: React.FunctionComponent<Props> = ({ onClose }) => { | ||
const core = useCore(); | ||
const settingsRequest = useGetSettings(); | ||
const settings = settingsRequest?.data?.item; | ||
const outputsRequest = useGetOutputs(); | ||
const output = outputsRequest.data?.items?.[0]; | ||
const { inputs, onSubmit } = useSettingsForm(output?.id); | ||
|
||
useEffect(() => { | ||
if (output) { | ||
inputs.elasticsearchUrl.setValue(output.hosts || []); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [output]); | ||
|
||
useEffect(() => { | ||
if (settings) { | ||
inputs.kibanaUrl.setValue( | ||
settings.kibana_url || `${window.location.origin}${core.http.basePath.get()}` | ||
); | ||
} | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, [settings]); | ||
|
||
const body = ( | ||
<EuiForm> | ||
<EuiRadioGroup | ||
options={[ | ||
{ | ||
id: 'enabled', | ||
label: i18n.translate('xpack.ingestManager.settings.autoUpgradeEnabledLabel', { | ||
defaultMessage: | ||
'Automatically update agent binaries to use the latest minor version.', | ||
}), | ||
}, | ||
{ | ||
id: 'disabled', | ||
disabled: true, | ||
label: i18n.translate('xpack.ingestManager.settings.autoUpgradeDisabledLabel', { | ||
defaultMessage: 'Manually manage agent binary versions. Requires Gold license.', | ||
}), | ||
}, | ||
]} | ||
idSelected={'enabled'} | ||
onChange={id => {}} | ||
legend={{ | ||
children: ( | ||
<EuiTitle size="xs"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.ingestManager.settings.autoUpgradeFieldLabel" | ||
defaultMessage="Elastic Agent binary version" | ||
/> | ||
</h3> | ||
</EuiTitle> | ||
), | ||
}} | ||
/> | ||
<EuiSpacer size="l" /> | ||
<EuiRadioGroup | ||
options={[ | ||
{ | ||
id: 'enabled', | ||
label: i18n.translate( | ||
'xpack.ingestManager.settings.integrationUpgradeEnabledFieldLabel', | ||
{ | ||
defaultMessage: | ||
'Automatically update Integrations to the latest version to receive the latest assets. Agent configurations may need to be updated in order to use new features.', | ||
} | ||
), | ||
}, | ||
{ | ||
id: 'disabled', | ||
disabled: true, | ||
label: i18n.translate( | ||
'xpack.ingestManager.settings.integrationUpgradeDisabledFieldLabel', | ||
{ | ||
defaultMessage: 'Manually manage integration versions yourself.', | ||
} | ||
), | ||
}, | ||
]} | ||
idSelected={'enabled'} | ||
onChange={id => {}} | ||
legend={{ | ||
children: ( | ||
<EuiTitle size="xs"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.ingestManager.settings.integrationUpgradeFieldLabel" | ||
defaultMessage="Elastic integration version" | ||
/> | ||
</h3> | ||
</EuiTitle> | ||
), | ||
}} | ||
/> | ||
<EuiSpacer size="l" /> | ||
<EuiTitle size="s"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.ingestManager.settings.globalOutputTitle" | ||
defaultMessage="Global output" | ||
/> | ||
</h3> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
<EuiText color="subdued" size="s"> | ||
<FormattedMessage | ||
id="xpack.ingestManager.settings.globalOutputDescription" | ||
defaultMessage="The global output is applied to all agent configurations and specifies where data is sent." | ||
/> | ||
</EuiText> | ||
<EuiSpacer size="m" /> | ||
<EuiFormRow> | ||
<EuiFormRow | ||
label={i18n.translate('xpack.ingestManager.settings.kibanaUrlLabel', { | ||
defaultMessage: 'Kibana URL', | ||
})} | ||
> | ||
<EuiFieldText required={true} {...inputs.kibanaUrl.props} name="kibanaUrl" /> | ||
</EuiFormRow> | ||
</EuiFormRow> | ||
<EuiSpacer size="m" /> | ||
<EuiFormRow> | ||
<EuiFormRow | ||
label={i18n.translate('xpack.ingestManager.settings.elasticsearchUrlLabel', { | ||
defaultMessage: 'Elasticsearch URL', | ||
})} | ||
> | ||
<EuiComboBox noSuggestions {...inputs.elasticsearchUrl.props} /> | ||
</EuiFormRow> | ||
</EuiFormRow> | ||
</EuiForm> | ||
); | ||
|
||
return ( | ||
<EuiFlyout onClose={onClose} size="l" maxWidth={640}> | ||
<EuiFlyoutHeader hasBorder aria-labelledby="IngestManagerSettingsFlyoutTitle"> | ||
<EuiTitle size="m"> | ||
<h2 id="IngestManagerSettingsFlyoutTitle"> | ||
<FormattedMessage | ||
id="xpack.ingestManager.settings.flyoutTitle" | ||
defaultMessage="Ingest Management settings" | ||
/> | ||
</h2> | ||
</EuiTitle> | ||
</EuiFlyoutHeader> | ||
<EuiFlyoutBody>{body}</EuiFlyoutBody> | ||
<EuiFlyoutFooter> | ||
<EuiFlexGroup justifyContent="spaceBetween"> | ||
<EuiFlexItem grow={false}> | ||
<EuiButtonEmpty iconType="cross" onClick={onClose} flush="left"> | ||
<FormattedMessage | ||
id="xpack.ingestManager.settings.cancelButtonLabel" | ||
defaultMessage="Cancel" | ||
/> | ||
</EuiButtonEmpty> | ||
</EuiFlexItem> | ||
<EuiFlexItem grow={false}> | ||
<EuiButton onClick={onSubmit} iconType="save"> | ||
<FormattedMessage | ||
id="xpack.ingestManager.settings.saveButtonLabel" | ||
defaultMessage="Save settings" | ||
/> | ||
</EuiButton> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiFlyoutFooter> | ||
</EuiFlyout> | ||
); | ||
}; |
Oops, something went wrong.