Skip to content

Commit

Permalink
A few more required changes from Grafana Labs review (#16)
Browse files Browse the repository at this point in the history
* remove #irreverent-but-serious keywords

* fix: set query.type to default if undefined when panel loads

* fix: handle new dashboard panels with empty query
  • Loading branch information
dcheckoway authored Jun 2, 2024
1 parent 03a3866 commit ec769c1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ const DEFAULT_QUERY_TYPE = 'adhoc';
const DEBOUNCE_RUN_DELAY_MS = 750;

export function QueryEditor({ datasource, query, onChange, onRunQuery }: Props) {
query.type = query.type ?? DEFAULT_QUERY_TYPE;

const debouncedOnRunQuery = useRef(debounce(onRunQuery, DEBOUNCE_RUN_DELAY_MS)).current;
const [savedSearchIdOptions, setSavedSearchIdOptions] = useState<SelectableValue[]>([]);
const [savedSearchId, setSavedSearchId] = useState(query.type === 'saved' ? query.savedSearchId : '');

const [queryType, setQueryType] = useState<QueryType>(query.type ?? DEFAULT_QUERY_TYPE);
const [queryType, setQueryType] = useState<QueryType>(query.type);
const [adhocQuery, setAdhocQuery] = useState(query.type === 'adhoc' ? query.query : '');

const onQueryTypeChange = useCallback((sv: SelectableValue<string>) => {
Expand Down
7 changes: 7 additions & 0 deletions src/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@ export class CriblDataSource extends DataSourceApi<CriblQuery, CriblDataSourceOp
* @returns the DataFrame with the results
*/
private async processQuery(criblQuery: CriblQuery, range: TimeRange): Promise<DataFrame> {
if (!this.canRunQuery(criblQuery)) {
return {
fields: [],
length: 0,
};
}

let fields: Record<string, Field> = {};
let eventCount = 0;
let totalEventCount: number | undefined = undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"author": {
"name": "Cribl, Inc."
},
"keywords": ["datasource", "cribl", "search", "query", "data", "engine", "it", "security", "observability", "goat", "fafo", "deits"],
"keywords": ["datasource", "cribl", "search", "query", "data", "engine", "it", "security", "observability"],
"logos": {
"small": "img/cribl_logo.svg",
"large": "img/cribl_logo.svg"
Expand Down

0 comments on commit ec769c1

Please sign in to comment.