ChannelSettings.tsx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import React, { FC } from 'react';
  2. import { Alert, CollapsableSection } from '@grafana/ui';
  3. import { NotificationChannelSecureFields, NotificationChannelType } from '../../../types';
  4. import { NotificationSettingsProps } from './NotificationChannelForm';
  5. import { NotificationChannelOptions } from './NotificationChannelOptions';
  6. interface Props extends NotificationSettingsProps {
  7. selectedChannel: NotificationChannelType;
  8. secureFields: NotificationChannelSecureFields;
  9. resetSecureField: (key: string) => void;
  10. }
  11. export const ChannelSettings: FC<Props> = ({
  12. control,
  13. currentFormValues,
  14. errors,
  15. selectedChannel,
  16. secureFields,
  17. register,
  18. resetSecureField,
  19. }) => {
  20. return (
  21. <CollapsableSection label={`Optional ${selectedChannel.heading}`} isOpen={false}>
  22. {selectedChannel.info !== '' && <Alert severity="info" title={selectedChannel.info ?? ''} />}
  23. <NotificationChannelOptions
  24. selectedChannelOptions={selectedChannel.options.filter((o) => !o.required)}
  25. currentFormValues={currentFormValues}
  26. register={register}
  27. errors={errors}
  28. control={control}
  29. onResetSecureField={resetSecureField}
  30. secureFields={secureFields}
  31. />
  32. </CollapsableSection>
  33. );
  34. };