Skip to content

Commit

Permalink
Add link to advanced setting in Discover (#101154) (#101474)
Browse files Browse the repository at this point in the history
Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>

Co-authored-by: Tim Roes <tim.roes@elastic.co>
  • Loading branch information
kibanamachine and Tim Roes authored Jun 7, 2021
1 parent bf35480 commit fb2b4e5
Showing 1 changed file with 30 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,21 @@ import ReactDOM from 'react-dom';
import { I18nStart } from 'kibana/public';
import { i18n } from '@kbn/i18n';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiSpacer, EuiButton, EuiText, EuiWrappingPopover, EuiCode } from '@elastic/eui';
import {
EuiSpacer,
EuiButton,
EuiText,
EuiWrappingPopover,
EuiCode,
EuiHorizontalRule,
EuiButtonEmpty,
EuiTextAlign,
} from '@elastic/eui';
import { getServices } from '../../../kibana_services';
import './open_options_popover.scss';
import { DOC_TABLE_LEGACY } from '../../../../common';

const container = document.createElement('div');
let isOpen = false;

interface OptionsPopoverProps {
Expand Down Expand Up @@ -77,11 +87,29 @@ export function OptionsPopover(props: OptionsPopoverProps) {
defaultMessage: 'Get started',
})}
</EuiButton>
<EuiHorizontalRule margin="s" />
<EuiTextAlign textAlign="center">
<EuiButtonEmpty
iconType="gear"
size="s"
href={addBasePath(`/app/management/kibana/settings?query=category:(discover)`)}
>
{i18n.translate('discover.openOptionsPopover.gotToAllSettings', {
defaultMessage: 'All Discover options',
})}
</EuiButtonEmpty>
</EuiTextAlign>
</div>
</EuiWrappingPopover>
);
}

function onClose() {
ReactDOM.unmountComponentAtNode(container);
document.body.removeChild(container);
isOpen = false;
}

export function openOptionsPopover({
I18nContext,
anchorElement,
Expand All @@ -90,17 +118,11 @@ export function openOptionsPopover({
anchorElement: HTMLElement;
}) {
if (isOpen) {
onClose();
return;
}

isOpen = true;
const container = document.createElement('div');
const onClose = () => {
ReactDOM.unmountComponentAtNode(container);
document.body.removeChild(container);
isOpen = false;
};

document.body.appendChild(container);

const element = (
Expand Down

0 comments on commit fb2b4e5

Please sign in to comment.