From dc6576094504a2b7402ee628486e408894b0a167 Mon Sep 17 00:00:00 2001 From: Poff Poffenberger Date: Thu, 12 Sep 2019 17:12:16 -0500 Subject: [PATCH] Addressing some PR feedback --- .../legacy/plugins/canvas/i18n/components.ts | 56 +++++++++---------- .../legacy/plugins/canvas/i18n/constants.ts | 2 + .../auto_refresh_controls.tsx | 27 ++++----- .../control_settings/control_settings.tsx | 6 +- .../control_settings/custom_interval.tsx | 16 ++---- .../control_settings/kiosk_controls.tsx | 15 ++--- 6 files changed, 59 insertions(+), 63 deletions(-) diff --git a/x-pack/legacy/plugins/canvas/i18n/components.ts b/x-pack/legacy/plugins/canvas/i18n/components.ts index ccff5faa04f0f..a418c47621bbb 100644 --- a/x-pack/legacy/plugins/canvas/i18n/components.ts +++ b/x-pack/legacy/plugins/canvas/i18n/components.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { CANVAS, JSON as json, KIBANA as kibana, PDF as pdf, URL as url } from './constants'; +import { CANVAS, JSON, KIBANA, PDF, POST, URL } from './constants'; export const ComponentStrings = { AddEmbeddableFlyout: { @@ -236,10 +236,10 @@ export const ComponentStrings = { WorkpadHeaderWorkpadExport: { getCopyPDFMessage: () => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.copyPDFMessage', { - defaultMessage: 'The {pdf} generation {url} was copied to your clipboard.', + defaultMessage: 'The {PDF} generation {URL} was copied to your clipboard.', values: { - pdf, - url, + PDF, + URL, }, }), getCopyReportingConfigMessage: () => @@ -248,81 +248,81 @@ export const ComponentStrings = { }), getExportPDFErrorTitle: (workpadName: string) => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.exportPDFErrorMessage', { - defaultMessage: "Failed to create {pdf} for '{workpadName}'", + defaultMessage: "Failed to create {PDF} for '{workpadName}'", values: { - pdf, + PDF, workpadName, }, }), getExportPDFMessage: () => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.exportPDFMessage', { - defaultMessage: 'Exporting {pdf}. You can track the progress in Management.', + defaultMessage: 'Exporting {PDF}. You can track the progress in Management.', values: { - pdf, + PDF, }, }), getExportPDFTitle: (workpadName: string) => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.exportPDFTitle', { - defaultMessage: "{pdf} export of workpad '{workpadName}'", + defaultMessage: "{PDF} export of workpad '{workpadName}'", values: { - pdf, + PDF, workpadName, }, }), getPDFPanelCopyAriaLabel: () => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.pdfPanelCopyAriaLabel', { defaultMessage: - 'Alternatively, you can generate a {pdf} from a script or with Watcher by using this {url}. Press Enter to copy the {url} to clipboard.', + 'Alternatively, you can generate a {PDF} from a script or with Watcher by using this {URL}. Press Enter to copy the {URL} to clipboard.', values: { - pdf, - url, + PDF, + URL, }, }), getPDFPanelCopyButtonLabel: () => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.pdfPanelCopyButtonLabel', { - defaultMessage: 'Copy {post} {url}', + defaultMessage: 'Copy {POST} {URL}', values: { - post: 'POST', - url, + POST, + URL, }, }), getPDFPanelCopyDescription: () => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.pdfPanelCopyDescription', { defaultMessage: - 'Alternatively, copy this {post} {url} to call generation from outside {kibana} or from Watcher.', + 'Alternatively, copy this {POST} {URL} to call generation from outside {KIBANA} or from Watcher.', values: { - post: 'POST', - kibana, - url, + POST, + KIBANA, + URL, }, }), getPDFPanelGenerateDescription: () => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.pdfPanelGenerateDescription', { defaultMessage: - '{pdf}s can take a minute or two to generate based on the size of your workpad.', + '{PDF}s can take a minute or two to generate based on the size of your workpad.', values: { - pdf, + PDF, }, }), getPDFPanelGenerateButtonLabel: () => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.pdfPanelGenerateButtonLabel', { - defaultMessage: 'Generate {pdf}', + defaultMessage: 'Generate {PDF}', values: { - pdf, + PDF, }, }), getShareDownloadJSONTitle: () => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.shareDownloadJSONTitle', { - defaultMessage: 'Download as {json}', + defaultMessage: 'Download as {JSON}', values: { - json, + JSON, }, }), getShareDownloadPDFTitle: () => i18n.translate('xpack.canvas.workpadHeaderWorkpadExport.shareDownloadPDFTitle', { - defaultMessage: '{pdf} reports', + defaultMessage: '{PDF} reports', values: { - pdf, + PDF, }, }), getShareWorkpadMessage: () => diff --git a/x-pack/legacy/plugins/canvas/i18n/constants.ts b/x-pack/legacy/plugins/canvas/i18n/constants.ts index 29b7200e75f29..e63ca520d9154 100644 --- a/x-pack/legacy/plugins/canvas/i18n/constants.ts +++ b/x-pack/legacy/plugins/canvas/i18n/constants.ts @@ -18,12 +18,14 @@ export const FONT_FAMILY = '`font-family`'; export const FONT_WEIGHT = '`font-weight`'; export const ISO8601 = 'ISO8601'; export const JS = 'JavaScript'; +export const JSON = 'JSON'; export const KIBANA = 'Kibana'; export const LUCENE = 'Lucene'; export const MARKDOWN = 'Markdown'; export const MOMENTJS = 'MomentJS'; export const NUMERALJS = 'NumeralJS'; export const PDF = 'PDF'; +export const POST = 'POST'; export const SQL = 'SQL'; export const SVG = 'SVG'; export const TINYMATH = '`TinyMath`'; diff --git a/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/auto_refresh_controls.tsx b/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/auto_refresh_controls.tsx index 65859a026e672..fde0e2b4012c1 100644 --- a/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/auto_refresh_controls.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/auto_refresh_controls.tsx @@ -28,10 +28,11 @@ import { CustomInterval } from './custom_interval'; import { ComponentStrings, UnitStrings } from '../../../../i18n'; const { WorkpadHeaderAutoRefreshControls: strings } = ComponentStrings; const { time: timeStrings } = UnitStrings; +const { getSecondsText, getMinutesText, getHoursText } = timeStrings; interface Props { refreshInterval: number; - setRefresh: (interval: number) => void; + setRefresh: (interval: number | undefined) => void; disableInterval: () => void; } @@ -103,22 +104,22 @@ export const AutoRefreshControls = ({ refreshInterval, setRefresh, disableInterv - - - - - - + + + + + + - - - - - - + + + + + + diff --git a/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/control_settings.tsx b/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/control_settings.tsx index 429c535ef981d..f0bd140a0b725 100644 --- a/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/control_settings.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/control_settings.tsx @@ -17,11 +17,11 @@ const { WorkpadHeaderControlSettings: strings } = ComponentStrings; interface Props { refreshInterval: number; - setRefreshInterval: (interval: number) => void; + setRefreshInterval: (interval: number | undefined) => void; autoplayEnabled: boolean; autoplayInterval: number; enableAutoplay: (enable: boolean) => void; - setAutoplayInterval: (interval: number) => void; + setAutoplayInterval: (interval: number | undefined) => void; } export const ControlSettings = ({ @@ -32,7 +32,7 @@ export const ControlSettings = ({ enableAutoplay, setAutoplayInterval, }: Props) => { - const setRefresh = (val: number) => setRefreshInterval(val); + const setRefresh = (val: number | undefined) => setRefreshInterval(val); const disableInterval = () => { setRefresh(0); diff --git a/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/custom_interval.tsx b/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/custom_interval.tsx index 230737be77f74..2fa9a71c9b4ea 100644 --- a/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/custom_interval.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/custom_interval.tsx @@ -6,14 +6,8 @@ import React, { useState, ChangeEvent } from 'react'; import PropTypes from 'prop-types'; -import { - EuiFlexGroup, - EuiFlexItem, - EuiFormRow, - EuiButton, - ButtonSize, - EuiFieldText, -} from '@elastic/eui'; +import { EuiFlexGroup, EuiFlexItem, EuiFormRow, EuiButton, EuiFieldText } from '@elastic/eui'; +import { ButtonSize } from '@elastic/eui/src/components/button/button'; import { FlexGroupGutterSize } from '@elastic/eui/src/components/flex/flex_group'; import { getTimeInterval } from '../../../lib/time_interval'; @@ -23,7 +17,7 @@ const { WorkpadHeaderCustomInterval: strings } = ComponentStrings; interface Props { gutterSize: FlexGroupGutterSize; buttonSize: ButtonSize; - onSubmit: (interval: number) => void; + onSubmit: (interval: number | undefined) => void; defaultValue: any; } @@ -39,9 +33,7 @@ export const CustomInterval = ({ gutterSize, buttonSize, onSubmit, defaultValue onSubmit={ev => { ev.preventDefault(); - if (refreshInterval) { - onSubmit(refreshInterval); - } + onSubmit(refreshInterval); }} > diff --git a/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/kiosk_controls.tsx b/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/kiosk_controls.tsx index 9bf9df63cc6bf..a98cdddc21e19 100644 --- a/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/kiosk_controls.tsx +++ b/x-pack/legacy/plugins/canvas/public/components/workpad_header/control_settings/kiosk_controls.tsx @@ -26,12 +26,13 @@ import { CustomInterval } from './custom_interval'; import { ComponentStrings, UnitStrings } from '../../../../i18n'; const { WorkpadHeaderKioskControls: strings } = ComponentStrings; const { time: timeStrings } = UnitStrings; +const { getSecondsText, getMinutesText } = timeStrings; interface Props { autoplayEnabled: boolean; autoplayInterval: number; onSetEnabled: (enabled: boolean) => void; - onSetInterval: (interval: number) => void; + onSetInterval: (interval: number | undefined) => void; } interface ListGroupProps { @@ -88,16 +89,16 @@ export const KioskControls = ({ - - - + + + - - - + + +