mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Select: Don't portal by default * Select: Portal all the Selects * Fix indendentation in this comment * Select: Remove @example docs until formatting is correct * Docs: Add some documentation for the Select changes * Update docs/sources/whatsnew/whats-new-in-v8-1.md Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> * Update docs/sources/whatsnew/whats-new-in-v8-1.md Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> * Update packages/grafana-ui/src/components/Select/types.ts Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> * Update public/app/core/components/TransformersUI/configFromQuery/ConfigFromQueryTransformerEditor.tsx Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> * Update public/app/core/components/TransformersUI/configFromQuery/ConfigFromQueryTransformerEditor.tsx Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> * Update public/app/core/components/TransformersUI/configFromQuery/ConfigFromQueryTransformerEditor.tsx Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> * Update public/app/core/components/TransformersUI/prepareTimeSeries/PrepareTimeSeriesEditor.tsx Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> * Docs: Variants instead of varients * Update public/app/core/components/TransformersUI/configFromQuery/ConfigFromQueryTransformerEditor.tsx Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com> Co-authored-by: Ursula Kallio <73951760+osg-grafana@users.noreply.github.com>
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import React, { useEffect, useState } from 'react';
|
|
import { SelectableValue } from '@grafana/data';
|
|
import { Select } from '@grafana/ui';
|
|
import CloudMonitoringDatasource from '../datasource';
|
|
import { SELECT_WIDTH } from '../constants';
|
|
import { QueryEditorRow } from '.';
|
|
|
|
export interface Props {
|
|
datasource: CloudMonitoringDatasource;
|
|
onChange: (projectName: string) => void;
|
|
templateVariableOptions: Array<SelectableValue<string>>;
|
|
projectName: string;
|
|
}
|
|
|
|
export function Project({ projectName, datasource, onChange, templateVariableOptions }: Props) {
|
|
const [projects, setProjects] = useState<Array<SelectableValue<string>>>([]);
|
|
useEffect(() => {
|
|
datasource.getProjects().then((projects) =>
|
|
setProjects([
|
|
{
|
|
label: 'Template Variables',
|
|
options: templateVariableOptions,
|
|
},
|
|
...projects,
|
|
])
|
|
);
|
|
}, [datasource, templateVariableOptions]);
|
|
|
|
return (
|
|
<QueryEditorRow label="Project">
|
|
<Select
|
|
menuShouldPortal
|
|
width={SELECT_WIDTH}
|
|
allowCustomValue
|
|
formatCreateLabel={(v) => `Use project: ${v}`}
|
|
onChange={({ value }) => onChange(value!)}
|
|
options={projects}
|
|
value={{ value: projectName, label: projectName }}
|
|
placeholder="Select Project"
|
|
/>
|
|
</QueryEditorRow>
|
|
);
|
|
}
|