文件操作 - NotificationChannelOptions.tsx
返回文件管理
返回主菜单
删除本文件
文件: /usr/share/grafana/public/app/features/alerting/components/NotificationChannelOptions.tsx
编辑文件内容
import React, { FC } from 'react'; import { SelectableValue } from '@grafana/data'; import { Field, FormAPI, InfoBox } from '@grafana/ui'; import { OptionElement } from './OptionElement'; import { NotificationChannel, NotificationChannelDTO, Option } from '../../../types'; interface Props extends Omit<FormAPI<NotificationChannelDTO>, 'formState' | 'getValues' | 'watch'> { selectedChannel: NotificationChannel; currentFormValues: NotificationChannelDTO; } export const NotificationChannelOptions: FC<Props> = ({ control, currentFormValues, errors, selectedChannel, register, }) => { return ( <> <h3>{selectedChannel.heading}</h3> {selectedChannel.info !== '' && <InfoBox>{selectedChannel.info}</InfoBox>} {selectedChannel.options.map((option: Option, index: number) => { const key = `${option.label}-${index}`; // Some options can be dependent on other options, this determines what is selected in the dependency options // I think this needs more thought. const selectedOptionValue = currentFormValues[`settings.${option.showWhen.field}`] && (currentFormValues[`settings.${option.showWhen.field}`] as SelectableValue<string>).value; if (option.showWhen.field && selectedOptionValue !== option.showWhen.is) { return null; } return ( <Field key={key} label={option.label} description={option.description} invalid={errors.settings && !!errors.settings[option.propertyName]} error={errors.settings && errors.settings[option.propertyName]?.message} > <OptionElement option={option} register={register} control={control} /> </Field> ); })} </> ); };
修改文件时间
将文件时间修改为当前时间的前一年
删除文件