diff --git a/ui/src/app/App.js b/ui/src/app/App.js index dcce907a2..85bae3dc5 100644 --- a/ui/src/app/App.js +++ b/ui/src/app/App.js @@ -16,6 +16,8 @@ import Dashboard from './dashboard/container/Dashboard'; import Header from './core/components/Header'; import { UserProvider } from './core/user/UserContext'; import { Metadata } from './metadata/Metadata'; +import { Notifications } from './notifications/hoc/Notifications'; +import { NotificationList } from './notifications/component/NotificationList'; function App() { @@ -29,27 +31,28 @@ function App() { }; return ( -
+
- - - - - -
-
- - - - - - - -
-
- - - + + + + +
+
+ + + + + + + + +
+
+ + + +
); @@ -58,8 +61,6 @@ function App() { /*
- -
*/ diff --git a/ui/src/app/admin/container/SourcesActions.js b/ui/src/app/admin/container/SourcesActions.js index 805ffbc66..c3a8cca27 100644 --- a/ui/src/app/admin/container/SourcesActions.js +++ b/ui/src/app/admin/container/SourcesActions.js @@ -2,20 +2,40 @@ import React from 'react'; import SourceList from '../../metadata/domain/source/component/SourceList'; import { useMetadataEntity } from '../../metadata/hooks/api'; +import { NotificationContext, createNotificationAction } from '../../notifications/hoc/Notifications'; + export function SourcesActions ({sources, reloadSources}) { - const { del, response } = useMetadataEntity('source', { + const { dispatch } = React.useContext(NotificationContext); + + const { put, del, response } = useMetadataEntity('source', { cachePolicy: 'no-cache' }); async function deleteSource(id) { await del(`/${id}`); if (response.ok) { + dispatch(createNotificationAction( + `Metadata Source has been removed.` + )); + reloadSources(); + } + } + + async function enableSource(source) { + await put(`/${source.id}`, { + ...source, + serviceEnabled: true + }); + if (response.ok) { + dispatch(createNotificationAction( + `Metadata Source has been enabled.` + )); reloadSources(); } } return ( - + ); } \ No newline at end of file diff --git a/ui/src/app/admin/container/UserManagement.js b/ui/src/app/admin/container/UserManagement.js index 518a77236..777cab129 100644 --- a/ui/src/app/admin/container/UserManagement.js +++ b/ui/src/app/admin/container/UserManagement.js @@ -7,11 +7,14 @@ import { faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; import Translate from '../../i18n/components/translate'; import API_BASE_PATH from '../../App.constant'; +import { NotificationContext, createNotificationAction} from '../../notifications/hoc/Notifications'; export default function UserManagement({ users, children, reload }) { const [roles, setRoles] = React.useState([]); + const { dispatch } = React.useContext(NotificationContext); + const { get, patch, del, response } = useFetch(`${API_BASE_PATH}`, {}); async function loadRoles() { @@ -27,6 +30,9 @@ export default function UserManagement({ users, children, reload }) { role }); if (response.ok && reload) { + dispatch(createNotificationAction( + `User update successful for ${user.username}.` + )); reload(); } } @@ -34,6 +40,9 @@ export default function UserManagement({ users, children, reload }) { async function deleteUserRequest(id) { await del(`/admin/users/${id}`); if (response.ok && reload) { + dispatch(createNotificationAction( + `User deleted.` + )); reload(); } } diff --git a/ui/src/app/core/hooks/utils.js b/ui/src/app/core/hooks/utils.js index c7ae9a0cf..8ba7e8020 100644 --- a/ui/src/app/core/hooks/utils.js +++ b/ui/src/app/core/hooks/utils.js @@ -1,10 +1,5 @@ -function uuidv4() { - return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { - var r = Math.random() * 16 | 0, v = c === 'x' ? r : ((r & 0x3) | 0x8); - return v.toString(16); - }); -} +import {uuid} from '../utility/uuid'; export function useGuid() { - return uuidv4(); + return uuid(); } \ No newline at end of file diff --git a/ui/src/app/core/utility/uuid.js b/ui/src/app/core/utility/uuid.js new file mode 100644 index 000000000..b7cf7f739 --- /dev/null +++ b/ui/src/app/core/utility/uuid.js @@ -0,0 +1,6 @@ +export function uuid() { + return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) { + var r = Math.random() * 16 | 0, v = c === 'x' ? r : ((r & 0x3) | 0x8); + return v.toString(16); + }); +} \ No newline at end of file diff --git a/ui/src/app/metadata/domain/source/component/SourceList.js b/ui/src/app/metadata/domain/source/component/SourceList.js index a8358c912..ae59abf06 100644 --- a/ui/src/app/metadata/domain/source/component/SourceList.js +++ b/ui/src/app/metadata/domain/source/component/SourceList.js @@ -3,7 +3,7 @@ import { Link } from 'react-router-dom'; import { Badge, UncontrolledPopover, PopoverBody, Button, Modal, ModalHeader, ModalBody, ModalFooter } from 'reactstrap'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faTrash, faExclamationTriangle } from '@fortawesome/free-solid-svg-icons'; +import { faTrash, faExclamationTriangle, faCheck } from '@fortawesome/free-solid-svg-icons'; @@ -13,7 +13,7 @@ import { Scroller } from '../../../../dashboard/component/Scroller'; -export default function SourceList({ entities, onDelete }) { +export default function SourceList({ entities, onDelete, onEnable }) { const [modal, setModal] = React.useState(false); @@ -57,9 +57,19 @@ export default function SourceList({ entities, onDelete }) { - - - + {onEnable ? + + : + + + + }