BasicSettings.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import React, { FC } from 'react';
  2. import { selectors } from '@grafana/e2e-selectors';
  3. import { InlineField, InlineSwitch, Input } from '@grafana/ui';
  4. export interface Props {
  5. dataSourceName: string;
  6. isDefault: boolean;
  7. onNameChange: (name: string) => void;
  8. onDefaultChange: (value: boolean) => void;
  9. }
  10. const BasicSettings: FC<Props> = ({ dataSourceName, isDefault, onDefaultChange, onNameChange }) => {
  11. return (
  12. <div className="gf-form-group" aria-label="Datasource settings page basic settings">
  13. <div className="gf-form-inline">
  14. <div className="gf-form max-width-30">
  15. <InlineField
  16. label="Name"
  17. tooltip="The name is used when you select the data source in panels. The default data source is
  18. 'preselected in new panels."
  19. grow
  20. >
  21. <Input
  22. id="basic-settings-name"
  23. type="text"
  24. value={dataSourceName}
  25. placeholder="Name"
  26. onChange={(event) => onNameChange(event.currentTarget.value)}
  27. required
  28. aria-label={selectors.pages.DataSource.name}
  29. />
  30. </InlineField>
  31. </div>
  32. <InlineField label="Default" labelWidth={8}>
  33. <InlineSwitch
  34. id="basic-settings-default"
  35. value={isDefault}
  36. onChange={(event: React.FormEvent<HTMLInputElement>) => {
  37. onDefaultChange(event.currentTarget.checked);
  38. }}
  39. />
  40. </InlineField>
  41. </div>
  42. </div>
  43. );
  44. };
  45. export default BasicSettings;