CSVFileEditor.tsx 999 B

123456789101112131415161718192021222324252627282930313233343536
  1. import React from 'react';
  2. import { SelectableValue } from '@grafana/data';
  3. import { InlineField, InlineFieldRow, Select } from '@grafana/ui';
  4. import { EditorProps } from '../QueryEditor';
  5. export const CSVFileEditor = ({ onChange, query }: EditorProps) => {
  6. const onChangeFileName = ({ value }: SelectableValue<string>) => {
  7. onChange({ ...query, csvFileName: value });
  8. };
  9. const files = [
  10. 'flight_info_by_state.csv',
  11. 'population_by_state.csv',
  12. 'gdp_per_capita.csv',
  13. 'js_libraries.csv',
  14. 'ohlc_dogecoin.csv',
  15. 'weight_height.csv',
  16. 'browser_marketshare.csv',
  17. ].map((name) => ({ label: name, value: name }));
  18. return (
  19. <InlineFieldRow>
  20. <InlineField label="File" labelWidth={14}>
  21. <Select
  22. width={32}
  23. onChange={onChangeFileName}
  24. placeholder="Select csv file"
  25. options={files}
  26. value={files.find((f) => f.value === query.csvFileName)}
  27. />
  28. </InlineField>
  29. </InlineFieldRow>
  30. );
  31. };