Skip to content

Commit

Permalink
Update/Retain Options Chosen in Selects (#70)
Browse files Browse the repository at this point in the history
* Retains chosen script upon visualization change

Signed-off-by: Kartik Pattaswamy <[email protected]>

* Resolved selects showing incorrect options when the user switches things

Signed-off-by: Kartik Pattaswamy <[email protected]>

* Removed check to preset selected options to null

Signed-off-by: Kartik Pattaswamy <[email protected]>

* Removed unnecessary coalesce checks

Signed-off-by: Kartik Pattaswamy <[email protected]>
  • Loading branch information
kpattaswamy authored Jul 12, 2022
1 parent 907b1ed commit c29b7ec
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/groupby.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export class GroupbyComponents extends PureComponent<Props> {
onChange={this.onGroupBySelect.bind(this)}
closeMenuOnSelect={false}
width={34}
value={query.queryMeta?.selectedColGroupby ?? undefined}
/>
</div>
<div style={{ marginTop: '10px', marginLeft: '10px' }}>
Expand Down
4 changes: 3 additions & 1 deletion src/query_editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export class QueryEditor extends PureComponent<Props> {
onChange({
...query,
queryType: QueryType.RunScript,
queryScript: option,
queryBody: { pxlScript: option?.value.script ?? '' },
queryMeta: {
isColDisplay: option.value.isColDisplay || false,
Expand Down Expand Up @@ -99,7 +100,7 @@ export class QueryEditor extends PureComponent<Props> {
options={scriptOptions}
width={32}
onChange={this.onScriptSelect.bind(this)}
defaultValue={scriptOptions[0]}
defaultValue={query.queryScript ?? scriptOptions[0]}
/>
</div>

Expand All @@ -116,6 +117,7 @@ export class QueryEditor extends PureComponent<Props> {
closeMenuOnSelect={false}
width={32}
inputId="column-selection"
value={query.queryMeta.selectedColDisplay}
/>
</>
)}
Expand Down
3 changes: 2 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import { DataQuery, DataSourceJsonData, SelectableValue } from '@grafana/data';
import { scriptOptions } from './pxl_scripts';
import { scriptOptions, Script } from './pxl_scripts';

// Types of available queries to the backend
export const enum QueryType {
Expand Down Expand Up @@ -45,6 +45,7 @@ export interface PixieVariableQuery {
export interface PixieDataQuery extends DataQuery {
queryType: QueryType;
clusterID?: string;
queryScript?: SelectableValue<Script>;
queryBody?: {
clusterID?: string;
pxlScript?: string;
Expand Down

0 comments on commit c29b7ec

Please sign in to comment.