Skip to content

Commit

Permalink
fix spec dialog highlighting (apache#8533)
Browse files Browse the repository at this point in the history
  • Loading branch information
vogievetsky authored and clintropolis committed Sep 13, 2019
1 parent 5aee550 commit ba41ab1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
17 changes: 5 additions & 12 deletions web-console/src/dialogs/spec-dialog/spec-dialog.tsx
Expand Up @@ -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 {
Expand All @@ -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 = {
Expand All @@ -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();
}
Expand All @@ -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 => {
Expand All @@ -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>
Expand Down
16 changes: 8 additions & 8 deletions web-console/src/views/load-data-view/load-data-view.tsx
Expand Up @@ -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={[
{
Expand All @@ -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>
Expand Down

0 comments on commit ba41ab1

Please sign in to comment.