renamed reloadAlerts to onSave wit hdeprecation (#91997)
The `reloadAlerts` properties in `AlertAdd` and `AlertEdit` are confusing property names. In this PR we deprecate those and replace them with `onSave`.
This commit is contained in:
parent
2ce344019a
commit
ee81110516
|
@ -41,7 +41,7 @@ export const MlAnomalyAlertFlyout: FC<MlAnomalyAlertFlyoutProps> = ({
|
|||
onCloseFlyout();
|
||||
},
|
||||
// Callback for successful save
|
||||
reloadAlerts: async () => {
|
||||
onSave: async () => {
|
||||
if (onSave) {
|
||||
onSave();
|
||||
}
|
||||
|
|
|
@ -833,7 +833,7 @@ interface AlertAddProps {
|
|||
alertTypeId?: string;
|
||||
canChangeTrigger?: boolean;
|
||||
initialValues?: Partial<Alert>;
|
||||
reloadAlerts?: () => Promise<void>;
|
||||
onSave?: () => Promise<void>;
|
||||
metadata?: MetaData;
|
||||
}
|
||||
```
|
||||
|
@ -845,7 +845,7 @@ interface AlertAddProps {
|
|||
|setAddFlyoutVisibility|Function for changing visibility state of the Create Alert flyout.|
|
||||
|alertTypeId|Optional property to preselect alert type.|
|
||||
|canChangeTrigger|Optional property, that hides change alert type possibility.|
|
||||
|reloadAlerts|Optional function, which will be executed if alert was saved sucsessfuly.|
|
||||
|onSave|Optional function, which will be executed if alert was saved sucsessfuly.|
|
||||
|initialValues|Default values for Alert properties.|
|
||||
|metadata|Optional generic property, which allows to define component specific metadata. This metadata can be used for passing down preloaded data for Alert type expression component.|
|
||||
|
||||
|
@ -1470,7 +1470,7 @@ interface ActionAccordionFormProps {
|
|||
|
||||
|Property|Description|
|
||||
|---|---|
|
||||
|reloadAlerts|Optional function, which will be executed if alert was saved sucsessfuly.|
|
||||
|onSave|Optional function, which will be executed if alert was saved sucsessfuly.|
|
||||
|http|HttpSetup needed for executing API calls.|
|
||||
|alertTypeRegistry|Registry for alert types.|
|
||||
|actionTypeRegistry|Registry for action types.|
|
||||
|
|
|
@ -158,7 +158,7 @@ export const AlertDetails: React.FunctionComponent<AlertDetailsProps> = ({
|
|||
}}
|
||||
actionTypeRegistry={actionTypeRegistry}
|
||||
alertTypeRegistry={alertTypeRegistry}
|
||||
reloadAlerts={setAlert}
|
||||
onSave={setAlert}
|
||||
/>
|
||||
)}
|
||||
</Fragment>
|
||||
|
|
|
@ -156,7 +156,7 @@ describe('alert_add', () => {
|
|||
consumer={ALERTS_FEATURE_ID}
|
||||
onClose={onClose}
|
||||
initialValues={initialValues}
|
||||
reloadAlerts={() => {
|
||||
onSave={() => {
|
||||
return new Promise<void>(() => {});
|
||||
}}
|
||||
actionTypeRegistry={actionTypeRegistry}
|
||||
|
|
|
@ -39,7 +39,9 @@ export interface AlertAddProps<MetaData = Record<string, any>> {
|
|||
alertTypeId?: string;
|
||||
canChangeTrigger?: boolean;
|
||||
initialValues?: Partial<Alert>;
|
||||
/** @deprecated use `onSave` as a callback after an alert is saved*/
|
||||
reloadAlerts?: () => Promise<void>;
|
||||
onSave?: () => Promise<void>;
|
||||
metadata?: MetaData;
|
||||
}
|
||||
|
||||
|
@ -52,8 +54,10 @@ const AlertAdd = ({
|
|||
alertTypeId,
|
||||
initialValues,
|
||||
reloadAlerts,
|
||||
onSave,
|
||||
metadata,
|
||||
}: AlertAddProps) => {
|
||||
const onSaveHandler = onSave ?? reloadAlerts;
|
||||
const initialAlert: InitialAlert = useMemo(
|
||||
() => ({
|
||||
params: {},
|
||||
|
@ -129,8 +133,8 @@ const AlertAdd = ({
|
|||
setIsSaving(false);
|
||||
if (savedAlert) {
|
||||
onClose(AlertFlyoutCloseReason.SAVED);
|
||||
if (reloadAlerts) {
|
||||
reloadAlerts();
|
||||
if (onSaveHandler) {
|
||||
onSaveHandler();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -167,7 +167,7 @@ describe('alert_edit', () => {
|
|||
<AlertEdit
|
||||
onClose={() => {}}
|
||||
initialAlert={alert}
|
||||
reloadAlerts={() => {
|
||||
onSave={() => {
|
||||
return new Promise<void>(() => {});
|
||||
}}
|
||||
actionTypeRegistry={actionTypeRegistry}
|
||||
|
|
|
@ -44,7 +44,9 @@ export interface AlertEditProps<MetaData = Record<string, any>> {
|
|||
alertTypeRegistry: AlertTypeRegistryContract;
|
||||
actionTypeRegistry: ActionTypeRegistryContract;
|
||||
onClose: (reason: AlertFlyoutCloseReason) => void;
|
||||
/** @deprecated use `onSave` as a callback after an alert is saved*/
|
||||
reloadAlerts?: () => Promise<void>;
|
||||
onSave?: () => Promise<void>;
|
||||
metadata?: MetaData;
|
||||
}
|
||||
|
||||
|
@ -52,10 +54,12 @@ export const AlertEdit = ({
|
|||
initialAlert,
|
||||
onClose,
|
||||
reloadAlerts,
|
||||
onSave,
|
||||
alertTypeRegistry,
|
||||
actionTypeRegistry,
|
||||
metadata,
|
||||
}: AlertEditProps) => {
|
||||
const onSaveHandler = onSave ?? reloadAlerts;
|
||||
const [{ alert }, dispatch] = useReducer(alertReducer as ConcreteAlertReducer, {
|
||||
alert: cloneDeep(initialAlert),
|
||||
});
|
||||
|
@ -203,8 +207,8 @@ export const AlertEdit = ({
|
|||
setIsSaving(false);
|
||||
if (savedAlert) {
|
||||
onClose(AlertFlyoutCloseReason.SAVED);
|
||||
if (reloadAlerts) {
|
||||
reloadAlerts();
|
||||
if (onSaveHandler) {
|
||||
onSaveHandler();
|
||||
}
|
||||
}
|
||||
}}
|
||||
|
|
|
@ -757,7 +757,7 @@ export const AlertsList: React.FunctionComponent = () => {
|
|||
}}
|
||||
actionTypeRegistry={actionTypeRegistry}
|
||||
alertTypeRegistry={alertTypeRegistry}
|
||||
reloadAlerts={loadAlertsData}
|
||||
onSave={loadAlertsData}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
|
|
Loading…
Reference in a new issue