Skip to content

Commit

Permalink
Addressing some PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
poffdeluxe committed Sep 12, 2019
1 parent 2d9a9b0 commit dc65760
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 63 deletions.
56 changes: 28 additions & 28 deletions x-pack/legacy/plugins/canvas/i18n/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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: () =>
Expand All @@ -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: () =>
Expand Down
2 changes: 2 additions & 0 deletions x-pack/legacy/plugins/canvas/i18n/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -103,22 +104,22 @@ export const AutoRefreshControls = ({ refreshInterval, setRefresh, disableInterv
<EuiFlexGrid gutterSize="s" columns={2}>
<EuiFlexItem>
<ListGroup>
<RefreshItem duration={5000} label={timeStrings.getSecondsText(5)} />
<RefreshItem duration={15000} label={timeStrings.getSecondsText(15)} />
<RefreshItem duration={30000} label={timeStrings.getSecondsText(30)} />
<RefreshItem duration={60000} label={timeStrings.getMinutesText(1)} />
<RefreshItem duration={300000} label={timeStrings.getMinutesText(5)} />
<RefreshItem duration={900000} label={timeStrings.getMinutesText(15)} />
<RefreshItem duration={5000} label={getSecondsText(5)} />
<RefreshItem duration={15000} label={getSecondsText(15)} />
<RefreshItem duration={30000} label={getSecondsText(30)} />
<RefreshItem duration={60000} label={getMinutesText(1)} />
<RefreshItem duration={300000} label={getMinutesText(5)} />
<RefreshItem duration={900000} label={getMinutesText(15)} />
</ListGroup>
</EuiFlexItem>
<EuiFlexItem>
<ListGroup>
<RefreshItem duration={1800000} label={timeStrings.getMinutesText(30)} />
<RefreshItem duration={3600000} label={timeStrings.getHoursText(1)} />
<RefreshItem duration={7200000} label={timeStrings.getHoursText(2)} />
<RefreshItem duration={21600000} label={timeStrings.getHoursText(6)} />
<RefreshItem duration={43200000} label={timeStrings.getHoursText(12)} />
<RefreshItem duration={86400000} label={timeStrings.getHoursText(24)} />
<RefreshItem duration={1800000} label={getMinutesText(30)} />
<RefreshItem duration={3600000} label={getHoursText(1)} />
<RefreshItem duration={7200000} label={getHoursText(2)} />
<RefreshItem duration={21600000} label={getHoursText(6)} />
<RefreshItem duration={43200000} label={getHoursText(12)} />
<RefreshItem duration={86400000} label={getHoursText(24)} />
</ListGroup>
</EuiFlexItem>
</EuiFlexGrid>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ({
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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;
}

Expand All @@ -39,9 +33,7 @@ export const CustomInterval = ({ gutterSize, buttonSize, onSubmit, defaultValue
onSubmit={ev => {
ev.preventDefault();

if (refreshInterval) {
onSubmit(refreshInterval);
}
onSubmit(refreshInterval);
}}
>
<EuiFlexGroup gutterSize={gutterSize}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -88,16 +89,16 @@ export const KioskControls = ({
<EuiFlexGrid gutterSize="s" columns={2}>
<EuiFlexItem>
<ListGroup>
<RefreshItem duration={5000} label={timeStrings.getSecondsText(5)} />
<RefreshItem duration={10000} label={timeStrings.getSecondsText(10)} />
<RefreshItem duration={30000} label={timeStrings.getSecondsText(30)} />
<RefreshItem duration={5000} label={getSecondsText(5)} />
<RefreshItem duration={10000} label={getSecondsText(10)} />
<RefreshItem duration={30000} label={getSecondsText(30)} />
</ListGroup>
</EuiFlexItem>
<EuiFlexItem>
<ListGroup>
<RefreshItem duration={60000} label={timeStrings.getMinutesText(1)} />
<RefreshItem duration={300000} label={timeStrings.getMinutesText(5)} />
<RefreshItem duration={900000} label={timeStrings.getMinutesText(15)} />
<RefreshItem duration={60000} label={getMinutesText(1)} />
<RefreshItem duration={300000} label={getMinutesText(5)} />
<RefreshItem duration={900000} label={getMinutesText(15)} />
</ListGroup>
</EuiFlexItem>
</EuiFlexGrid>
Expand Down

0 comments on commit dc65760

Please sign in to comment.