-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[CCR] Remote clusters settings sources #26067
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,10 @@ | |
import React, { Component, Fragment } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { injectI18n, FormattedMessage } from '@kbn/i18n/react'; | ||
import { i18n } from '@kbn/i18n'; | ||
|
||
import { | ||
EuiBadge, | ||
EuiButton, | ||
EuiDescriptionList, | ||
EuiDescriptionListDescription, | ||
|
@@ -19,6 +21,7 @@ import { | |
EuiFlyoutBody, | ||
EuiFlyoutHeader, | ||
EuiFlyoutFooter, | ||
EuiHorizontalRule, | ||
EuiIcon, | ||
EuiLoadingSpinner, | ||
EuiSpacer, | ||
|
@@ -31,6 +34,11 @@ import { CRUD_APP_BASE_PATH } from '../../../constants'; | |
|
||
import { ConnectionStatus, DisconnectButton } from '../components'; | ||
|
||
const disconnectButtonDisabledReason = i18n.translate( | ||
'xpack.remoteClusters.detailPanel.disconnectButtonDisabledReason', | ||
{ defaultMessage: 'Cannot disconnect from cluster configured in elasticsearch.yml' } | ||
); | ||
|
||
export class DetailPanelUi extends Component { | ||
static propTypes = { | ||
isOpen: PropTypes.bool.isRequired, | ||
|
@@ -44,15 +52,113 @@ export class DetailPanelUi extends Component { | |
super(props); | ||
} | ||
|
||
renderSkipUnavailableValue(value) { | ||
if(value === true) { | ||
return ( | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.skipUnavailableTrueValue" | ||
defaultMessage="Yes" | ||
/> | ||
); | ||
} | ||
|
||
if(value === false) { | ||
return ( | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.skipUnavailableFalseValue" | ||
defaultMessage="No" | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.skipUnavailableNullValue" | ||
defaultMessage="Default" | ||
/> | ||
); | ||
} | ||
|
||
renderSettings(settings) { | ||
const { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Code style: this could be deconstructed in the method argument. |
||
seeds, | ||
skipUnavailable, | ||
} = settings; | ||
|
||
return ( | ||
<EuiDescriptionList> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiDescriptionListTitle> | ||
<EuiTitle size="xs"> | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.seedsLabel" | ||
defaultMessage="Seeds" | ||
/> | ||
</EuiTitle> | ||
</EuiDescriptionListTitle> | ||
|
||
<EuiDescriptionListDescription> | ||
{seeds.map(seed => <EuiText key={seed}>{seed}</EuiText>)} | ||
</EuiDescriptionListDescription> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiDescriptionListTitle> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the code would be easier to read if the whole setting block would be rendered (not just the value). At first sight, |
||
<EuiTitle size="xs"> | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.skipUnavailableLabel" | ||
defaultMessage="Skip unavailable" | ||
/> | ||
</EuiTitle> | ||
</EuiDescriptionListTitle> | ||
|
||
<EuiDescriptionListDescription> | ||
{this.renderSkipUnavailableValue(skipUnavailable)} | ||
</EuiDescriptionListDescription> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiDescriptionList> | ||
); | ||
} | ||
|
||
renderActiveSettingBadge(isActive) { | ||
if(isActive) { | ||
return ( | ||
<EuiBadge color="primary"> | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.activeSettingBadge" | ||
defaultMessage="Active" | ||
/> | ||
</EuiBadge> | ||
); | ||
} | ||
return ( | ||
<EuiBadge color="hollow"> | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.fallbackSettingBadge" | ||
defaultMessage="Fallback" | ||
/> | ||
</EuiBadge> | ||
); | ||
} | ||
|
||
renderCluster() { | ||
const { cluster } = this.props; | ||
const { isConnected, seeds, connectedNodesCount } = cluster; | ||
|
||
const renderedSeeds = seeds.map(seed => <EuiText key={seed}>{seed}</EuiText>); | ||
const { isConnected, connectedNodesCount } = cluster; | ||
|
||
return ( | ||
<Fragment> | ||
<EuiFlyoutBody> | ||
|
||
<EuiTitle size="s"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.statusTitle" | ||
defaultMessage="Status" | ||
/> | ||
</h3> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
<EuiDescriptionList> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
|
@@ -85,22 +191,60 @@ export class DetailPanelUi extends Component { | |
</EuiDescriptionListDescription> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</EuiDescriptionList> | ||
{this.renderSettings(cluster)} | ||
|
||
<EuiSpacer size="s" /> | ||
<EuiHorizontalRule /> | ||
|
||
<EuiDescriptionListTitle> | ||
<EuiTitle size="xs"> | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.seedsLabel" | ||
defaultMessage="Seeds" | ||
/> | ||
{cluster.transientSettings ? ( | ||
<Fragment> | ||
<EuiTitle size="s"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.transientSettingsTitle" | ||
defaultMessage="Transient settings" | ||
/> | ||
{' '}{this.renderActiveSettingBadge(true)} | ||
</h3> | ||
</EuiTitle> | ||
</EuiDescriptionListTitle> | ||
<EuiSpacer size="s" /> | ||
{this.renderSettings(cluster.transientSettings)} | ||
<EuiSpacer size="l" /> | ||
</Fragment> | ||
) : null} | ||
|
||
<EuiDescriptionListDescription> | ||
{renderedSeeds} | ||
</EuiDescriptionListDescription> | ||
</EuiDescriptionList> | ||
{cluster.persistentSettings ? ( | ||
<Fragment> | ||
<EuiTitle size="s"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.persistentSettingsTitle" | ||
defaultMessage="Persistent settings" | ||
/> | ||
{' '}{this.renderActiveSettingBadge(!cluster.transientSettings)} | ||
</h3> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
{this.renderSettings(cluster.persistentSettings)} | ||
<EuiSpacer size="l" /> | ||
</Fragment> | ||
) : null} | ||
|
||
{!cluster.transientSettings && !cluster.persistentSettings ? ( | ||
<Fragment> | ||
<EuiTitle size="s"> | ||
<h3> | ||
<FormattedMessage | ||
id="xpack.remoteClusters.detailPanel.configurationFileSettingsTitle" | ||
defaultMessage="Configuration file settings" | ||
/> | ||
{' '}{this.renderActiveSettingBadge(true)} | ||
</h3> | ||
</EuiTitle> | ||
<EuiSpacer size="s" /> | ||
{this.renderSettings(cluster)} | ||
</Fragment> | ||
) : null} | ||
</EuiFlyoutBody> | ||
</Fragment> | ||
); | ||
|
@@ -115,6 +259,8 @@ export class DetailPanelUi extends Component { | |
clusterName, | ||
} = this.props; | ||
|
||
const isDisconnectDisabled = !cluster || !(cluster.isTransient || cluster.isPersistent); | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We might also want to disable the button if the cluster is not connected, what do you think? |
||
if (!isOpen) { | ||
return null; | ||
} | ||
|
@@ -197,6 +343,8 @@ export class DetailPanelUi extends Component { | |
<DisconnectButton | ||
clusterNames={[clusterName]} | ||
isSmallButton={true} | ||
isDisabled={isDisconnectDisabled} | ||
disabledReason={isDisconnectDisabled ? disconnectButtonDisabledReason : null} | ||
/> | ||
</EuiFlexItem> | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I must say I am surprised we don't have global translation keys for "yes" and "no" 😊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One possible explanation is that context can change the meaning of an affirmative in other languages. For example, "hai" in Japanese is required for formal responses, but in other situations a more casual "ee" is appropriate (https://www.thoughtco.com/can-i-use-ee-instead-of-hai-4037928).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, thanks for the link @cjcenizal !