fix spec dialog highlighting (#8533)

This commit is contained in:
Vadim Ogievetsky 2019-09-13 15:24:08 -07:00 committed by Fangjin Yang
parent 0490909ab3
commit 6c7f36d364
2 changed files with 13 additions and 20 deletions

View File

@ -20,6 +20,8 @@ import { Button, Classes, Dialog, Intent } from '@blueprintjs/core';
import React from 'react';
import AceEditor from 'react-ace';
import { validJson } from '../../utils';
import './spec-dialog.scss';
export interface SpecDialogProps {
@ -34,15 +36,6 @@ export interface SpecDialogState {
}
export class SpecDialog extends React.PureComponent<SpecDialogProps, SpecDialogState> {
static validJson(json: string): boolean {
try {
JSON.parse(json);
return true;
} catch (e) {
return false;
}
}
constructor(props: SpecDialogProps) {
super(props);
this.state = {
@ -53,7 +46,7 @@ export class SpecDialog extends React.PureComponent<SpecDialogProps, SpecDialogS
private postSpec(): void {
const { onClose, onSubmit } = this.props;
const { spec } = this.state;
if (!SpecDialog.validJson(spec)) return;
if (!validJson(spec)) return;
onSubmit(JSON.parse(spec));
onClose();
}
@ -71,7 +64,7 @@ export class SpecDialog extends React.PureComponent<SpecDialogProps, SpecDialogS
canOutsideClickClose={false}
>
<AceEditor
mode="json"
mode="hjson"
theme="solarized_dark"
className="spec-dialog-textarea"
onChange={e => {
@ -96,7 +89,7 @@ export class SpecDialog extends React.PureComponent<SpecDialogProps, SpecDialogS
text="Submit"
intent={Intent.PRIMARY}
onClick={() => this.postSpec()}
disabled={!SpecDialog.validJson(spec)}
disabled={!validJson(spec)}
/>
</div>
</div>

View File

@ -2625,14 +2625,6 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
model={granularitySpec}
onChange={g => this.updateSpec(deepSet(spec, 'dataSchema.granularitySpec', g))}
/>
</div>
<div className="other">
<H5>Secondary partitioning</H5>
<AutoForm
fields={getPartitionRelatedTuningSpecFormFields(getSpecType(spec) || 'index')}
model={tuningConfig}
onChange={t => this.updateSpec(deepSet(spec, 'tuningConfig', t))}
/>
<AutoForm
fields={[
{
@ -2653,6 +2645,14 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
onChange={s => this.updateSpec(s)}
/>
</div>
<div className="other">
<H5>Secondary partitioning</H5>
<AutoForm
fields={getPartitionRelatedTuningSpecFormFields(getSpecType(spec) || 'index')}
model={tuningConfig}
onChange={t => this.updateSpec(deepSet(spec, 'tuningConfig', t))}
/>
</div>
<div className="control">
<Callout className="intro">
<p className="optional">Optional</p>