@@ -51,7 +51,7 @@ export function MetadataFilterEditorList ({provider, filters, onDelete, onUpdate
label={Toggle this switch element}
checked={filter.filterEnabled}
disabled={loading}
- onChange={() => onUpdate({ ...filter, filterEnabled: !filter.filterEnabled })} />
+ onChange={({target: { checked }}) => onEnable(filter, checked)} />
{filter.disabled && }
diff --git a/ui/src/app/metadata/domain/filter/component/MetadataFilters.js b/ui/src/app/metadata/domain/filter/component/MetadataFilters.js
index 13a22b53c..d38c97013 100644
--- a/ui/src/app/metadata/domain/filter/component/MetadataFilters.js
+++ b/ui/src/app/metadata/domain/filter/component/MetadataFilters.js
@@ -1,11 +1,14 @@
import React from 'react';
import { useMetadataFilters } from '../../../hooks/api';
import { DeleteConfirmation } from '../../../component/DeleteConfirmation';
+import { NotificationContext, createNotificationAction } from '../../../../notifications/hoc/Notifications';
export const MetadataFiltersContext = React.createContext();
export function MetadataFilters ({ providerId, types = [], filters, children }) {
+ const { dispatch } = React.useContext(NotificationContext);
+
const { put, del, get, response, loading } = useMetadataFilters(providerId, {
cachePolicy: 'no-cache'
});
@@ -23,12 +26,31 @@ export function MetadataFilters ({ providerId, types = [], filters, children })
await put(`/${filter.resourceId}`, filter);
if (response.ok) {
loadFilters(providerId);
+ dispatch(createNotificationAction(
+ `Metadata Filter has been updated.`
+ ));
+ }
+ }
+
+ async function enableFilter(filter, enabled) {
+ await put(`/${filter.resourceId}`, {
+ ...filter,
+ filterEnabled: enabled
+ });
+ if (response.ok) {
+ dispatch(createNotificationAction(
+ `Metadata Filter has been ${enabled ? 'enabled' : 'disabled'}.`
+ ));
+ loadFilters(providerId);
}
}
async function deleteFilter(filterId) {
await del(`/${filterId}`);
if (response.ok) {
+ dispatch(createNotificationAction(
+ `Metadata Filter has been deleted.`
+ ));
loadFilters();
}
}
@@ -50,7 +72,7 @@ export function MetadataFilters ({ providerId, types = [], filters, children })
{(block) =>
- {children(filterData, onUpdate, (id) => block(() => onDelete(id)), loading)}
+ {children(filterData, onUpdate, (id) => block(() => onDelete(id)), enableFilter, loading)}
}
diff --git a/ui/src/app/metadata/editor/MetadataFilterList.js b/ui/src/app/metadata/editor/MetadataFilterList.js
index 9b71f6ee5..699b1c400 100644
--- a/ui/src/app/metadata/editor/MetadataFilterList.js
+++ b/ui/src/app/metadata/editor/MetadataFilterList.js
@@ -90,12 +90,13 @@ export function MetadataFilterList() {
{definition && schema && current &&
- {(filters, onUpdate, onDelete, loading) =>
+ {(filters, onUpdate, onDelete, onEnable, loading) =>
}
diff --git a/ui/src/app/metadata/hoc/MetadataSchema.js b/ui/src/app/metadata/hoc/MetadataSchema.js
index ec6dd49f0..c8a8365ee 100644
--- a/ui/src/app/metadata/hoc/MetadataSchema.js
+++ b/ui/src/app/metadata/hoc/MetadataSchema.js
@@ -9,7 +9,9 @@ export function MetadataSchema({ type, children, wizard = false }) {
const definition = React.useMemo(() => wizard ? getWizard(type) : getDefinition(type), [type, wizard]);
- const { get, response } = useFetch(``, {}, []);
+ const { get, response } = useFetch(``, {
+ cachePolicy: 'no-cache'
+ });
const [schema, setSchema] = React.useState();
diff --git a/ui/src/app/metadata/hoc/MetadataSelector.js b/ui/src/app/metadata/hoc/MetadataSelector.js
index fd37ed2c3..6174d2e3a 100644
--- a/ui/src/app/metadata/hoc/MetadataSelector.js
+++ b/ui/src/app/metadata/hoc/MetadataSelector.js
@@ -23,7 +23,7 @@ export function MetadataSelector({ children, ...props }) {
const { get, response } = useMetadataEntity(type);
- const [metadata, setMetadata] = React.useState([]);
+ const [metadata, setMetadata] = React.useState();
async function loadMetadata(id) {
const source = await get(`/${id}`);
@@ -34,7 +34,7 @@ export function MetadataSelector({ children, ...props }) {
const reload = () => loadMetadata(id);
- React.useEffect(() => { loadMetadata(id) }, [id]);
+ React.useEffect(reload, [id]);
return (
<>
diff --git a/ui/src/app/metadata/hooks/api.js b/ui/src/app/metadata/hooks/api.js
index d0f30ef38..cc2afa9c7 100644
--- a/ui/src/app/metadata/hooks/api.js
+++ b/ui/src/app/metadata/hooks/api.js
@@ -61,7 +61,8 @@ export const xmlRequestInterceptor = ({ options }) => {
export function useMetadataEntityXml(type = 'source', opts = {
interceptors: {
request: xmlRequestInterceptor
- }
+ },
+ cachePolicy: 'no-cache'
}) {
return useFetch(`${API_BASE_PATH}${getMetadataPath(type)}`, opts);
}