-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workspace): Workspace data source returns workspaces (#38)
Co-authored-by: Melissa Hilliard <[email protected]>
- Loading branch information
1 parent
ef51b3a
commit a8877ba
Showing
6 changed files
with
49 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 5 additions & 24 deletions
29
src/datasources/workspace/components/WorkspaceQueryEditor.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,14 @@ | ||
import React, { ChangeEvent } from 'react'; | ||
import { Input } from '@grafana/ui'; | ||
import React, { useEffect } from 'react'; | ||
import { WorkspaceQuery } from '../types'; | ||
import { QueryEditorProps } from '@grafana/data'; | ||
import { InlineField } from 'core/components/InlineField'; | ||
import { WorkspaceDataSource } from '../WorkspaceDataSource'; | ||
import { WorkspaceQuery } from '../types'; | ||
|
||
type Props = QueryEditorProps<WorkspaceDataSource, WorkspaceQuery>; | ||
|
||
export function WorkspaceQueryEditor({ query, onChange, onRunQuery }: Props) { | ||
const onQueryTextChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
onChange({ ...query, queryText: event.target.value }); | ||
}; | ||
|
||
const onConstantChange = (event: ChangeEvent<HTMLInputElement>) => { | ||
onChange({ ...query, constant: parseFloat(event.target.value) }); | ||
// executes the query | ||
onRunQuery(); | ||
}; | ||
|
||
const { queryText, constant } = query; | ||
export function WorkspaceQueryEditor({ onRunQuery }: Props) { | ||
useEffect(onRunQuery, [onRunQuery]); | ||
|
||
return ( | ||
<> | ||
<InlineField label="Constant"> | ||
<Input onChange={onConstantChange} value={constant} width={8} type="number" step="0.1" /> | ||
</InlineField> | ||
<InlineField label="Query Text" labelWidth={16} tooltip="Not used yet"> | ||
<Input onChange={onQueryTextChange} value={queryText || ''} /> | ||
</InlineField> | ||
</> | ||
<span>This data source returns all SystemLink workspaces and does not include a query editor.</span> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
import { DataQuery } from '@grafana/schema' | ||
|
||
export interface WorkspaceQuery extends DataQuery { | ||
queryText?: string; | ||
constant: number; | ||
} |