mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Provide more guidance on enrollment token * Added suggestions from copy review * Simplify copy * format bash commands correctly * Added suggestions from code review Co-authored-by: Thom Heymann <190132+thomheymann@users.noreply.github.com>
This commit is contained in:
parent
7d5de86dc9
commit
26c3a7223b
5 changed files with 56 additions and 5 deletions
|
@ -42,6 +42,7 @@ import { euiThemeVars } from '@kbn/ui-shared-deps-src/theme';
|
|||
|
||||
import type { Certificate } from '../common';
|
||||
import { DocLink } from './doc_link';
|
||||
import { getCommandLineSnippet } from './get_command_line_snippet';
|
||||
import { SubmitErrorCallout } from './submit_error_callout';
|
||||
import { TextTruncate } from './text_truncate';
|
||||
import type { ValidationErrors } from './use_form';
|
||||
|
@ -511,7 +512,7 @@ export const ForgotPasswordPopover: FunctionComponent<ForgotPasswordPopoverProps
|
|||
/>
|
||||
</p>
|
||||
<EuiCodeBlock language="bash" paddingSize="m" isCopyable>
|
||||
bin/elasticsearch-reset-password --username {username}
|
||||
{getCommandLineSnippet('elasticsearch-reset-password', `--username ${username}`)}
|
||||
</EuiCodeBlock>
|
||||
</EuiText>
|
||||
</EuiPopover>
|
||||
|
|
|
@ -30,6 +30,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
|
|||
|
||||
import type { EnrollmentToken } from '../common';
|
||||
import { DocLink } from './doc_link';
|
||||
import { getCommandLineSnippet } from './get_command_line_snippet';
|
||||
import { SubmitErrorCallout } from './submit_error_callout';
|
||||
import { TextTruncate } from './text_truncate';
|
||||
import type { ValidationErrors } from './use_form';
|
||||
|
@ -260,7 +261,7 @@ export const EnrollmentTokenHelpPopover = () => {
|
|||
/>
|
||||
</p>
|
||||
<EuiCodeBlock language="bash" paddingSize="m" isCopyable>
|
||||
bin/elasticsearch-create-enrollment-token --scope kibana
|
||||
{getCommandLineSnippet('elasticsearch-create-enrollment-token', '--scope kibana')}
|
||||
</EuiCodeBlock>
|
||||
</EuiText>
|
||||
<EuiPopoverFooter>
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { getCommandLineSnippet } from './get_command_line_snippet';
|
||||
|
||||
describe('getCommandLineSnippet', () => {
|
||||
const originalNavigator = window.navigator;
|
||||
|
||||
it('should format windows correctly', () => {
|
||||
Object.defineProperty(window, 'navigator', {
|
||||
value: { userAgent: 'Windows' },
|
||||
writable: true,
|
||||
});
|
||||
expect(getCommandLineSnippet('kibana')).toEqual('bin\\kibana.bat');
|
||||
expect(getCommandLineSnippet('kibana', '--silent')).toEqual('bin\\kibana.bat --silent');
|
||||
});
|
||||
|
||||
it('should format unix correctly', () => {
|
||||
Object.defineProperty(window, 'navigator', {
|
||||
value: { userAgent: 'Linux' },
|
||||
writable: true,
|
||||
});
|
||||
expect(getCommandLineSnippet('kibana')).toEqual('bin/kibana');
|
||||
expect(getCommandLineSnippet('kibana', '--silent')).toEqual('bin/kibana --silent');
|
||||
});
|
||||
|
||||
afterAll(function () {
|
||||
Object.defineProperty(window, 'navigator', {
|
||||
value: originalNavigator,
|
||||
writable: true,
|
||||
});
|
||||
});
|
||||
});
|
|
@ -0,0 +1,12 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
||||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export function getCommandLineSnippet(command: string, args?: string) {
|
||||
const isWindows = window.navigator.userAgent.includes('Win');
|
||||
return `${isWindows ? `bin\\${command}.bat` : `bin/${command}`}${args ? ` ${args}` : ''}`;
|
||||
}
|
|
@ -23,6 +23,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
|
|||
import type { IHttpFetchError, ResponseErrorBody } from 'kibana/public';
|
||||
|
||||
import { VERIFICATION_CODE_LENGTH } from '../common';
|
||||
import { getCommandLineSnippet } from './get_command_line_snippet';
|
||||
import { SingleCharsField } from './single_chars_field';
|
||||
import { SubmitErrorCallout } from './submit_error_callout';
|
||||
import type { ValidationErrors } from './use_form';
|
||||
|
@ -118,9 +119,7 @@ export const VerificationCodeForm: FunctionComponent<VerificationCodeFormProps>
|
|||
values={{
|
||||
command: (
|
||||
<EuiCode language="bash">
|
||||
{window.navigator.userAgent.includes('Win')
|
||||
? 'bin\\kibana-verification-code.bat'
|
||||
: 'bin/kibana-verification-code'}
|
||||
{getCommandLineSnippet('kibana-verification-code')}
|
||||
</EuiCode>
|
||||
),
|
||||
}}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue