Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sulemanof committed Oct 16, 2019
1 parent be1c9d6 commit a8a41ef
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ interface VegaActionsMenuProps {
function VegaActionsMenu({ formatHJson, formatJson }: VegaActionsMenuProps) {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);

const onButtonClick = useCallback(() => setIsPopoverOpen(!isPopoverOpen), [isPopoverOpen]);
const onButtonClick = useCallback(() => setIsPopoverOpen(isOpen => !isOpen), []);
const onHJsonCLick = useCallback(() => {
formatHJson();
setIsPopoverOpen(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ function VegaHelpMenu() {
>
<FormattedMessage
id="visTypeVega.editor.vegaHelpLinkText"
defaultMessage="Kibana Vega Help"
defaultMessage="Kibana Vega help"
/>
</EuiContextMenuItem>,
<EuiContextMenuItem
Expand All @@ -58,7 +58,7 @@ function VegaHelpMenu() {
>
<FormattedMessage
id="visTypeVega.editor.vegaLiteDocumentationLinkText"
defaultMessage="Vega-Lite Documentation"
defaultMessage="Vega-Lite documentation"
/>
</EuiContextMenuItem>,
<EuiContextMenuItem
Expand All @@ -69,7 +69,7 @@ function VegaHelpMenu() {
>
<FormattedMessage
id="visTypeVega.editor.vegaDocumentationLinkText"
defaultMessage="Vega Documentation"
defaultMessage="Vega documentation"
/>
</EuiContextMenuItem>,
];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,15 @@ const aceOptions = {
wrap: true,
};

function format(value: string, stringify: typeof compactStringify) {
const hjsonStringifyOptions = {
bracesSameLine: true,
keepWsc: true,
};

function format(value: string, stringify: typeof compactStringify, options?: any) {
try {
const spec = hjson.parse(value, { legacyRoot: false, keepWsc: true });
return stringify(spec);
return stringify(spec, options);
} catch (err) {
// This is a common case - user tries to format an invalid HJSON text
toastNotifications.addError(err, {
Expand All @@ -69,7 +74,7 @@ function VegaVisEditor({ stateParams, setValue }: VisOptionsProps<VisParams>) {
);

const formatHJson = useCallback(
() => setValue('spec', format(stateParams.spec, hjson.stringify)),
() => setValue('spec', format(stateParams.spec, hjson.stringify, hjsonStringifyOptions)),
[setValue, stateParams.spec]
);

Expand Down
5 changes: 1 addition & 4 deletions x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -3161,11 +3161,8 @@
"visTypeVega.editor.formatError": "仕様のフォーマット中にエラーが発生",
"visTypeVega.editor.reformatAsHJSONButtonLabel": "HJSON に変換",
"visTypeVega.editor.reformatAsJSONButtonLabel": "JSON に変換しコメントを削除",
"visTypeVega.editor.vegaDocumentationLinkText": "Vega ドキュメント",
"visTypeVega.editor.vegaEditorOptionsButtonAriaLabel": "Vega エディターオプション",
"visTypeVega.editor.vegaHelpButtonAriaLabel": "Vega ヘルプ",
"visTypeVega.editor.vegaHelpLinkText": "Kibana Vega ヘルプ",
"visTypeVega.editor.vegaLiteDocumentationLinkText": "Vega-Lite ドキュメンテーション",
"visTypeVega.emsFileParser.emsFileNameDoesNotExistErrorMessage": "{emsfile} {emsfileName} が存在しません",
"visTypeVega.emsFileParser.missingNameOfFileErrorMessage": "{dataUrlParamValue} の {dataUrlParam} には {nameParam} パラメーター (ファイル名) が必要です",
"visTypeVega.esQueryParser.autointervalValueTypeErrorMessage": "{autointerval} は文字 {trueValue} または数字である必要があります",
Expand Down Expand Up @@ -10514,4 +10511,4 @@
"xpack.fileUpload.fileParser.errorReadingFile": "ファイルの読み込み中にエラーが発生しました",
"xpack.fileUpload.fileParser.noFileProvided": "エラー、ファイルが提供されていません"
}
}
}
5 changes: 1 addition & 4 deletions x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -3162,11 +3162,8 @@
"visTypeVega.editor.formatError": "格式化规范时出错",
"visTypeVega.editor.reformatAsHJSONButtonLabel": "重新格式化为 HJSON",
"visTypeVega.editor.reformatAsJSONButtonLabel": "重新格式化为 JSON,删除注释",
"visTypeVega.editor.vegaDocumentationLinkText": "Vega 文档",
"visTypeVega.editor.vegaEditorOptionsButtonAriaLabel": "Vega 编辑器选项",
"visTypeVega.editor.vegaHelpButtonAriaLabel": "Vega 帮助",
"visTypeVega.editor.vegaHelpLinkText": "Kibana Vega 帮助",
"visTypeVega.editor.vegaLiteDocumentationLinkText": "Vega-Lite 文档",
"visTypeVega.emsFileParser.emsFileNameDoesNotExistErrorMessage": "{emsfile} {emsfileName} 不存在",
"visTypeVega.emsFileParser.missingNameOfFileErrorMessage": "具有 {dataUrlParamValue} 的 {dataUrlParam} 需要 {nameParam} 参数(文件名)",
"visTypeVega.esQueryParser.autointervalValueTypeErrorMessage": "{autointerval} 必须为 {trueValue} 或数字",
Expand Down Expand Up @@ -10670,4 +10667,4 @@
"xpack.fileUpload.fileParser.errorReadingFile": "读取文件时出错",
"xpack.fileUpload.fileParser.noFileProvided": "错误,未提供任何文件"
}
}
}

0 comments on commit a8a41ef

Please sign in to comment.