Skip to content

Commit

Permalink
UX Improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
HadesArchitect committed Apr 30, 2022
1 parent 80d28a1 commit 3c7eb40
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export class QueryEditor extends PureComponent<Props> {
grow
>
<QueryField
placeholder={'Enter a Cassandra query'}
placeholder={'Enter a CQL query'}
portalOrigin="cassandra"
onChange={this.onQueryTextChange}
onBlur={this.props.onRunQuery}
Expand All @@ -179,6 +179,7 @@ export class QueryEditor extends PureComponent<Props> {
onChange={this.onKeyspaceChange}
spellCheck={false}
onBlur={this.onRunQuery}
required
width={90}
/> */}
<Select
Expand All @@ -203,6 +204,7 @@ export class QueryEditor extends PureComponent<Props> {
placeholder="table name"
onChange={this.onTableChange}
onBlur={this.onRunQuery}
required
width={90}
/> */}
<Select
Expand Down Expand Up @@ -230,6 +232,7 @@ export class QueryEditor extends PureComponent<Props> {
onChange={this.onTimeColumnChange}
onBlur={this.onRunQuery}
width={90}
required
/> */}
<Select
allowCustomValue={true}
Expand Down Expand Up @@ -257,6 +260,7 @@ export class QueryEditor extends PureComponent<Props> {
onChange={this.onValueColumnChange}
onBlur={this.onRunQuery}
width={90}
required
/> */}
<Select
allowCustomValue={true}
Expand Down Expand Up @@ -284,6 +288,7 @@ export class QueryEditor extends PureComponent<Props> {
onChange={this.onIDColumnChange}
onBlur={this.onRunQuery}
width={90}
required
/> */}
<Select
allowCustomValue={true}
Expand Down Expand Up @@ -313,6 +318,7 @@ export class QueryEditor extends PureComponent<Props> {
this.onRunQuery(this.props);
}}
width={90}
required
/>
</InlineField>
</InlineFieldRow>
Expand Down
26 changes: 25 additions & 1 deletion src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface CassandraDataSourceOptions extends DataSourceJsonData {
caPath: string;
useCustomTLS: boolean;
timeout: number;

allowInsecureTLS: boolean;
}

Expand All @@ -30,9 +29,34 @@ export class CassandraDatasource extends DataSourceWithBackend<CassandraQuery, C
}

query(options: DataQueryRequest<CassandraQuery>): Observable<DataQueryResponse> {
if (this.isEditorMode(options)) {
if (!this.isEditorCompleted(options))
throw new Error("Skipping query execution while not all editor fields are filled");
} else {
if (!this.isConfiguratorCompleted(options))
throw new Error("Skipping query execution while not all configurator fields are filled");
}

return super.query(this.buildQueryParameters(options));
}

isEditorMode (options): boolean {
return !options.targets[0].rawQuery;
}

isEditorCompleted(options): boolean {
return options.targets[0].keyspace &&
options.targets[0].table &&
options.targets[0].columnTime &&
options.targets[0].columnValue &&
options.targets[0].columnId &&
options.targets[0].valueId;
}

isConfiguratorCompleted(options): boolean {
return Boolean(options.targets[0].target);
}

async getKeyspaces(): Promise<string[]> {
return this.getResource('keyspaces');
}
Expand Down

0 comments on commit 3c7eb40

Please sign in to comment.