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

View File

@ -2625,14 +2625,6 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
model={granularitySpec} model={granularitySpec}
onChange={g => this.updateSpec(deepSet(spec, 'dataSchema.granularitySpec', g))} 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 <AutoForm
fields={[ fields={[
{ {
@ -2653,6 +2645,14 @@ export class LoadDataView extends React.PureComponent<LoadDataViewProps, LoadDat
onChange={s => this.updateSpec(s)} onChange={s => this.updateSpec(s)}
/> />
</div> </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"> <div className="control">
<Callout className="intro"> <Callout className="intro">
<p className="optional">Optional</p> <p className="optional">Optional</p>