From 77eedf25779e37ef440a0771b6871d025672a824 Mon Sep 17 00:00:00 2001 From: soupette Date: Thu, 19 Aug 2021 16:46:06 +0200 Subject: [PATCH] Commented the settings view that are not yet migrated Signed-off-by: soupette --- .../utils/defaultGlobalLinks.js | 7 + .../src/pages/ApplicationInfosPage/index.js | 137 ++--- .../admin/src/pages/Users/ListPage/index.js | 507 +++++++++--------- .../pages/SettingsPage/SingleSignOn/index.js | 217 ++++---- 4 files changed, 445 insertions(+), 423 deletions(-) diff --git a/packages/core/admin/admin/src/hooks/useSettingsMenu/utils/defaultGlobalLinks.js b/packages/core/admin/admin/src/hooks/useSettingsMenu/utils/defaultGlobalLinks.js index abf3f8aaf3..bc15e2f25e 100644 --- a/packages/core/admin/admin/src/hooks/useSettingsMenu/utils/defaultGlobalLinks.js +++ b/packages/core/admin/admin/src/hooks/useSettingsMenu/utils/defaultGlobalLinks.js @@ -1,6 +1,13 @@ import adminPermissions from '../../../permissions'; const defaultGlobalLinks = [ + { + intlLabel: { id: 'Settings.application.title', defaultMessage: 'Application' }, + to: '/settings/application-infos', + id: 'application-infos', + isDisplayed: false, + permissions: [], + }, { intlLabel: { id: 'Settings.webhooks.title', defaultMessage: 'Webhooks' }, to: '/settings/webhooks', diff --git a/packages/core/admin/admin/src/pages/ApplicationInfosPage/index.js b/packages/core/admin/admin/src/pages/ApplicationInfosPage/index.js index a09ba7d4e4..702db2a768 100644 --- a/packages/core/admin/admin/src/pages/ApplicationInfosPage/index.js +++ b/packages/core/admin/admin/src/pages/ApplicationInfosPage/index.js @@ -1,74 +1,75 @@ -import React from 'react'; -import { Header } from '@buffetjs/custom'; -import { Flex, Padded, Text } from '@buffetjs/core'; -import { useIntl } from 'react-intl'; -import { BaselineAlignment, useAppInfos } from '@strapi/helper-plugin'; -import Bloc from '../../components/Bloc'; -import PageTitle from '../../components/SettingsPageTitle'; -import { Detail, InfoText } from './components'; +// import React from 'react'; +// import { Header } from '@buffetjs/custom'; +// import { Flex, Padded, Text } from '@buffetjs/core'; +// import { useIntl } from 'react-intl'; +// import { BaselineAlignment, useAppInfos } from '@strapi/helper-plugin'; +// import Bloc from '../../components/Bloc'; +// import PageTitle from '../../components/SettingsPageTitle'; +// import { Detail, InfoText } from './components'; -const ApplicationInfosPage = () => { - const appInfos = useAppInfos(); - const { shouldUpdateStrapi, latestStrapiReleaseTag } = appInfos; - const { formatMessage } = useIntl(); +// const ApplicationInfosPage = () => { +// const appInfos = useAppInfos(); +// const { shouldUpdateStrapi, latestStrapiReleaseTag } = appInfos; +// const { formatMessage } = useIntl(); - const currentPlan = appInfos.communityEdition - ? 'app.components.UpgradePlanModal.text-ce' - : 'app.components.UpgradePlanModal.text-ee'; +// const currentPlan = appInfos.communityEdition +// ? 'app.components.UpgradePlanModal.text-ce' +// : 'app.components.UpgradePlanModal.text-ee'; - const headerProps = { - title: { label: formatMessage({ id: 'Settings.application.title' }) }, - content: formatMessage({ - id: 'Settings.application.description', - }), - }; - const pricingLabel = formatMessage({ id: 'Settings.application.link-pricing' }); - const upgradeLabel = formatMessage({ id: 'Settings.application.link-upgrade' }); - const strapiVersion = formatMessage({ id: 'Settings.application.strapi-version' }); - const nodeVersion = formatMessage({ id: 'Settings.application.node-version' }); - const editionTitle = formatMessage({ id: 'Settings.application.edition-title' }); +// const headerProps = { +// title: { label: formatMessage({ id: 'Settings.application.title' }) }, +// content: formatMessage({ +// id: 'Settings.application.description', +// }), +// }; +// const pricingLabel = formatMessage({ id: 'Settings.application.link-pricing' }); +// const upgradeLabel = formatMessage({ id: 'Settings.application.link-upgrade' }); +// const strapiVersion = formatMessage({ id: 'Settings.application.strapi-version' }); +// const nodeVersion = formatMessage({ id: 'Settings.application.node-version' }); +// const editionTitle = formatMessage({ id: 'Settings.application.edition-title' }); - /* eslint-disable indent */ - const upgradeLink = shouldUpdateStrapi - ? { - label: upgradeLabel, - href: `https://github.com/strapi/strapi/releases/tag/${latestStrapiReleaseTag}`, - } - : null; - /* eslint-enable indent */ +// /* eslint-disable indent */ +// const upgradeLink = shouldUpdateStrapi +// ? { +// label: upgradeLabel, +// href: `https://github.com/strapi/strapi/releases/tag/${latestStrapiReleaseTag}`, +// } +// : null; +// /* eslint-enable indent */ - return ( -
- -
- - - - - - - - - - - {nodeVersion} - - - - - - - -
- ); -}; +// return ( +//
+// +//
+// +// +// +// +// +// +// +// +// +// +// {nodeVersion} +// +// +// +// +// +// +// +//
+// ); +// }; -export default ApplicationInfosPage; +// export default ApplicationInfosPage; +export default () => 'ApplicationInfosPage'; diff --git a/packages/core/admin/admin/src/pages/Users/ListPage/index.js b/packages/core/admin/admin/src/pages/Users/ListPage/index.js index d3ce734a7f..53fc94d7f3 100644 --- a/packages/core/admin/admin/src/pages/Users/ListPage/index.js +++ b/packages/core/admin/admin/src/pages/Users/ListPage/index.js @@ -1,291 +1,292 @@ -import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'; -import { - BaselineAlignment, - useQuery, - request, - useRBAC, - LoadingIndicatorPage, - PopUpWarning, - useNotification, -} from '@strapi/helper-plugin'; -import { get } from 'lodash'; -import { useHistory, useLocation } from 'react-router-dom'; -import { Flex, Padded } from '@buffetjs/core'; -import PageTitle from '../../../components/SettingsPageTitle'; -import { useSettingsHeaderSearchContext } from '../../../hooks'; -import { Footer, List, Filter, FilterPicker, SortPicker } from '../../../components/Users'; -import adminPermissions from '../../../permissions'; -import Header from './Header'; -import ModalForm from './ModalForm'; -import getFilters from './utils/getFilters'; -import init from './init'; -import { initialState, reducer } from './reducer'; +// import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react'; +// import { +// BaselineAlignment, +// useQuery, +// request, +// useRBAC, +// LoadingIndicatorPage, +// PopUpWarning, +// useNotification, +// } from '@strapi/helper-plugin'; +// import { get } from 'lodash'; +// import { useHistory, useLocation } from 'react-router-dom'; +// import { Flex, Padded } from '@buffetjs/core'; +// import PageTitle from '../../../components/SettingsPageTitle'; +// import { useSettingsHeaderSearchContext } from '../../../hooks'; +// import { Footer, List, Filter, FilterPicker, SortPicker } from '../../../components/Users'; +// import adminPermissions from '../../../permissions'; +// import Header from './Header'; +// import ModalForm from './ModalForm'; +// import getFilters from './utils/getFilters'; +// import init from './init'; +// import { initialState, reducer } from './reducer'; -const ListPage = () => { - const { - isLoading: isLoadingForPermissions, - allowedActions: { canCreate, canDelete, canRead, canUpdate }, - } = useRBAC(adminPermissions.settings.users); - const toggleNotification = useNotification(); - const [isWarningDeleteAllOpened, setIsWarningDeleteAllOpened] = useState(false); - const [isModalOpened, setIsModalOpened] = useState(false); - const { toggleHeaderSearch } = useSettingsHeaderSearchContext(); - const query = useQuery(); - const { push } = useHistory(); - const { search } = useLocation(); - const filters = useMemo(() => { - return getFilters(search); - }, [search]); +// const ListPage = () => { +// const { +// isLoading: isLoadingForPermissions, +// allowedActions: { canCreate, canDelete, canRead, canUpdate }, +// } = useRBAC(adminPermissions.settings.users); +// const toggleNotification = useNotification(); +// const [isWarningDeleteAllOpened, setIsWarningDeleteAllOpened] = useState(false); +// const [isModalOpened, setIsModalOpened] = useState(false); +// const { toggleHeaderSearch } = useSettingsHeaderSearchContext(); +// const query = useQuery(); +// const { push } = useHistory(); +// const { search } = useLocation(); +// const filters = useMemo(() => { +// return getFilters(search); +// }, [search]); - const [ - { - data, - dataToDelete, - isLoading, - pagination: { total }, - shouldRefetchData, - showModalConfirmButtonLoading, - }, - dispatch, - ] = useReducer(reducer, initialState, init); - const pageSize = parseInt(query.get('pageSize') || 10, 10); - const page = parseInt(query.get('page') || 0, 10); - const _sort = decodeURIComponent(query.get('_sort')); - const _q = decodeURIComponent(query.get('_q') || ''); - const getDataRef = useRef(); - const listRef = useRef(); +// const [ +// { +// data, +// dataToDelete, +// isLoading, +// pagination: { total }, +// shouldRefetchData, +// showModalConfirmButtonLoading, +// }, +// dispatch, +// ] = useReducer(reducer, initialState, init); +// const pageSize = parseInt(query.get('pageSize') || 10, 10); +// const page = parseInt(query.get('page') || 0, 10); +// const _sort = decodeURIComponent(query.get('_sort')); +// const _q = decodeURIComponent(query.get('_q') || ''); +// const getDataRef = useRef(); +// const listRef = useRef(); - getDataRef.current = async () => { - if (!canRead) { - dispatch({ - type: 'UNSET_IS_LOADING', - }); +// getDataRef.current = async () => { +// if (!canRead) { +// dispatch({ +// type: 'UNSET_IS_LOADING', +// }); - return; - } - // Show the loading state and reset the state - dispatch({ - type: 'GET_DATA', - }); +// return; +// } +// // Show the loading state and reset the state +// dispatch({ +// type: 'GET_DATA', +// }); - try { - const { - data: { results, pagination }, - } = await request(`/admin/users${search}`, { method: 'GET' }); +// try { +// const { +// data: { results, pagination }, +// } = await request(`/admin/users${search}`, { method: 'GET' }); - dispatch({ - type: 'GET_DATA_SUCCEEDED', - data: results, - pagination, - }); - } catch (err) { - console.error(err.response); - toggleNotification({ - type: 'warning', - message: { id: 'notification.error' }, - }); - } - }; +// dispatch({ +// type: 'GET_DATA_SUCCEEDED', +// data: results, +// pagination, +// }); +// } catch (err) { +// console.error(err.response); +// toggleNotification({ +// type: 'warning', +// message: { id: 'notification.error' }, +// }); +// } +// }; - useEffect(() => { - if (!isLoadingForPermissions) { - getDataRef.current(); - } - }, [search, isLoadingForPermissions]); +// useEffect(() => { +// if (!isLoadingForPermissions) { +// getDataRef.current(); +// } +// }, [search, isLoadingForPermissions]); - useEffect(() => { - if (canRead) { - toggleHeaderSearch({ id: 'Settings.permissions.menu.link.users.label' }); - } +// useEffect(() => { +// if (canRead) { +// toggleHeaderSearch({ id: 'Settings.permissions.menu.link.users.label' }); +// } - return () => { - if (canRead) { - toggleHeaderSearch(); - } - }; - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [canRead]); +// return () => { +// if (canRead) { +// toggleHeaderSearch(); +// } +// }; +// // eslint-disable-next-line react-hooks/exhaustive-deps +// }, [canRead]); - const handleChangeDataToDelete = ids => { - dispatch({ - type: 'ON_CHANGE_DATA_TO_DELETE', - dataToDelete: ids, - }); - }; +// const handleChangeDataToDelete = ids => { +// dispatch({ +// type: 'ON_CHANGE_DATA_TO_DELETE', +// dataToDelete: ids, +// }); +// }; - const handleChangeFilter = ({ filter, name, value }) => { - const filterName = `${name}${filter}`; +// const handleChangeFilter = ({ filter, name, value }) => { +// const filterName = `${name}${filter}`; - updateSearchParams(filterName, encodeURIComponent(value), true); - }; +// updateSearchParams(filterName, encodeURIComponent(value), true); +// }; - const handleChangeFooterParams = ({ target: { name, value } }) => { - let paramName = name.split('.')[1].replace('_', ''); +// const handleChangeFooterParams = ({ target: { name, value } }) => { +// let paramName = name.split('.')[1].replace('_', ''); - if (paramName === 'limit') { - paramName = 'pageSize'; - } +// if (paramName === 'limit') { +// paramName = 'pageSize'; +// } - updateSearchParams(paramName, value); - }; +// updateSearchParams(paramName, value); +// }; - const handleChangeSort = ({ target: { name, value } }) => { - updateSearchParams(name, value); - }; +// const handleChangeSort = ({ target: { name, value } }) => { +// updateSearchParams(name, value); +// }; - const handleClickDeleteFilter = ({ target: { name } }) => { - const currentSearch = new URLSearchParams(search); +// const handleClickDeleteFilter = ({ target: { name } }) => { +// const currentSearch = new URLSearchParams(search); - currentSearch.delete(name); +// currentSearch.delete(name); - push({ search: currentSearch.toString() }); - }; +// push({ search: currentSearch.toString() }); +// }; - const handleClickDelete = useCallback(id => { - handleToggleModal(); +// const handleClickDelete = useCallback(id => { +// handleToggleModal(); - dispatch({ - type: 'ON_CHANGE_DATA_TO_DELETE', - dataToDelete: [id], - }); - }, []); +// dispatch({ +// type: 'ON_CHANGE_DATA_TO_DELETE', +// dataToDelete: [id], +// }); +// }, []); - const handleCloseModal = () => { - // Refetch data - getDataRef.current(); - }; +// const handleCloseModal = () => { +// // Refetch data +// getDataRef.current(); +// }; - const handleClosedModalDelete = () => { - if (shouldRefetchData) { - getDataRef.current(); - } else { - // Empty the selected ids when the modal closes - dispatch({ - type: 'RESET_DATA_TO_DELETE', - }); +// const handleClosedModalDelete = () => { +// if (shouldRefetchData) { +// getDataRef.current(); +// } else { +// // Empty the selected ids when the modal closes +// dispatch({ +// type: 'RESET_DATA_TO_DELETE', +// }); - // Reset the list's reducer dataToDelete state using a ref so we don't need an effect - listRef.current.resetDataToDelete(); - } - }; +// // Reset the list's reducer dataToDelete state using a ref so we don't need an effect +// listRef.current.resetDataToDelete(); +// } +// }; - const handleConfirmDeleteData = useCallback(async () => { - dispatch({ - type: 'ON_DELETE_USERS', - }); +// const handleConfirmDeleteData = useCallback(async () => { +// dispatch({ +// type: 'ON_DELETE_USERS', +// }); - let shouldDispatchSucceededAction = false; +// let shouldDispatchSucceededAction = false; - try { - await request('/admin/users/batch-delete', { - method: 'POST', - body: { - ids: dataToDelete, - }, - }); - shouldDispatchSucceededAction = true; - } catch (err) { - const errorMessage = get(err, 'response.payload.data', 'An error occured'); +// try { +// await request('/admin/users/batch-delete', { +// method: 'POST', +// body: { +// ids: dataToDelete, +// }, +// }); +// shouldDispatchSucceededAction = true; +// } catch (err) { +// const errorMessage = get(err, 'response.payload.data', 'An error occured'); - toggleNotification({ - type: 'warning', - message: errorMessage, - }); - } +// toggleNotification({ +// type: 'warning', +// message: errorMessage, +// }); +// } - // Only dispatch the action once - if (shouldDispatchSucceededAction) { - dispatch({ - type: 'ON_DELETE_USERS_SUCCEEDED', - }); - } +// // Only dispatch the action once +// if (shouldDispatchSucceededAction) { +// dispatch({ +// type: 'ON_DELETE_USERS_SUCCEEDED', +// }); +// } - handleToggleModal(); - }, [dataToDelete, toggleNotification]); +// handleToggleModal(); +// }, [dataToDelete, toggleNotification]); - const handleToggle = () => setIsModalOpened(prev => !prev); +// const handleToggle = () => setIsModalOpened(prev => !prev); - const handleToggleModal = () => setIsWarningDeleteAllOpened(prev => !prev); +// const handleToggleModal = () => setIsWarningDeleteAllOpened(prev => !prev); - const updateSearchParams = (name, value, shouldDeleteSearch = false) => { - const currentSearch = new URLSearchParams(search); - // Update the currentSearch - currentSearch.set(name, value); +// const updateSearchParams = (name, value, shouldDeleteSearch = false) => { +// const currentSearch = new URLSearchParams(search); +// // Update the currentSearch +// currentSearch.set(name, value); - if (shouldDeleteSearch) { - currentSearch.delete('_q'); - } +// if (shouldDeleteSearch) { +// currentSearch.delete('_q'); +// } - push({ - search: currentSearch.toString(), - }); - }; +// push({ +// search: currentSearch.toString(), +// }); +// }; - if (isLoadingForPermissions) { - return ; - } +// if (isLoadingForPermissions) { +// return ; +// } - return ( -
- -
- {canRead && ( - <> - - - - - - - - - {filters.map((filter, i) => ( - // eslint-disable-next-line react/no-array-index-key - - ))} - - - - - - -
- - )} - - -
- ); -}; +// return ( +//
+// +//
+// {canRead && ( +// <> +// +// +// +// +// +// +// +// +// {filters.map((filter, i) => ( +// // eslint-disable-next-line react/no-array-index-key +// +// ))} +// +// +// +// +// +// +//
+// +// )} +// +// +//
+// ); +// }; -export default ListPage; +// export default ListPage; +export default () => 'Users - LV'; diff --git a/packages/core/admin/ee/admin/pages/SettingsPage/SingleSignOn/index.js b/packages/core/admin/ee/admin/pages/SettingsPage/SingleSignOn/index.js index 557eb41851..55a5e25d5d 100644 --- a/packages/core/admin/ee/admin/pages/SettingsPage/SingleSignOn/index.js +++ b/packages/core/admin/ee/admin/pages/SettingsPage/SingleSignOn/index.js @@ -1,113 +1,126 @@ -import React, { memo, useMemo } from 'react'; -import { - BaselineAlignment, - CheckPagePermissions, - NotAllowedInput, - SizedInput, - useRBAC, -} from '@strapi/helper-plugin'; -import { useIntl } from 'react-intl'; -import { getRequestUrl } from '../../../../../admin/src/utils'; -import PageTitle from '../../../../../admin/src/components/SettingsPageTitle'; -import ContainerFluid from '../../../../../admin/src/components/ContainerFluid'; -import FormBloc from '../../../../../admin/src/components/FormBloc'; -import { Header } from '../../../../../admin/src/components/Settings'; -import { useRolesList, useSettingsForm } from '../../../../../admin/src/hooks'; +// import React, { memo, useMemo } from 'react'; +// import { +// BaselineAlignment, +// CheckPagePermissions, +// NotAllowedInput, +// SizedInput, +// useRBAC, +// } from '@strapi/helper-plugin'; +// import { useIntl } from 'react-intl'; +// import { getRequestUrl } from '../../../../../admin/src/utils'; +// import PageTitle from '../../../../../admin/src/components/SettingsPageTitle'; +// import ContainerFluid from '../../../../../admin/src/components/ContainerFluid'; +// import FormBloc from '../../../../../admin/src/components/FormBloc'; +// import { Header } from '../../../../../admin/src/components/Settings'; +// import { useRolesList, useSettingsForm } from '../../../../../admin/src/hooks'; +// import adminPermissions from '../../../../../admin/src/permissions'; +// import { form, schema } from './utils'; + +// const ssoPermissions = { +// ...adminPermissions.settings.sso, +// readRoles: adminPermissions.settings.roles.read, +// }; + +// const SingleSignOn = () => { +// const { formatMessage } = useIntl(); +// const { +// isLoading: isLoadingForPermissions, +// allowedActions: { canUpdate, canReadRoles }, +// } = useRBAC(ssoPermissions); + +// const [ +// { formErrors, initialData, isLoading, modifiedData, showHeaderButtonLoader }, +// // eslint-disable-next-line no-unused-vars +// dispatch, +// { handleCancel, handleChange, handleSubmit }, +// ] = useSettingsForm(getRequestUrl('providers/options'), schema, () => {}, [ +// 'autoRegister', +// 'defaultRole', +// ]); +// const { roles } = useRolesList(canReadRoles); + +// const showLoader = useMemo(() => isLoadingForPermissions || isLoading, [ +// isLoading, +// isLoadingForPermissions, +// ]); + +// const options = useMemo(() => { +// return [ +// , +// ...roles.map(({ id, name }) => ( +// +// )), +// ]; +// }, [roles, formatMessage]); + +// return ( +// <> +// +//
+// +//
+// +// +// {Object.keys(form).map(key => { +// // TODO: at some point it would be great to handle this in the upcoming input layout +// const type = key === 'defaultRole' && !canReadRoles ? 'notAllowed' : form[key].type; +// const description = +// key === 'defaultRole' && !canReadRoles +// ? form[key].notAllowedDescription +// : form[key].description; + +// return ( +// +// ); +// })} +// +// +// +// +// ); +// }; + +import React from 'react'; +import { CheckPagePermissions } from '@strapi/helper-plugin'; import adminPermissions from '../../../../../admin/src/permissions'; -import { form, schema } from './utils'; const ssoPermissions = { ...adminPermissions.settings.sso, readRoles: adminPermissions.settings.roles.read, }; -const SingleSignOn = () => { - const { formatMessage } = useIntl(); - const { - isLoading: isLoadingForPermissions, - allowedActions: { canUpdate, canReadRoles }, - } = useRBAC(ssoPermissions); - - const [ - { formErrors, initialData, isLoading, modifiedData, showHeaderButtonLoader }, - // eslint-disable-next-line no-unused-vars - dispatch, - { handleCancel, handleChange, handleSubmit }, - ] = useSettingsForm(getRequestUrl('providers/options'), schema, () => {}, [ - 'autoRegister', - 'defaultRole', - ]); - const { roles } = useRolesList(canReadRoles); - - const showLoader = useMemo(() => isLoadingForPermissions || isLoading, [ - isLoading, - isLoadingForPermissions, - ]); - - const options = useMemo(() => { - return [ - , - ...roles.map(({ id, name }) => ( - - )), - ]; - }, [roles, formatMessage]); - - return ( - <> - -
- -
- - - {Object.keys(form).map(key => { - // TODO: at some point it would be great to handle this in the upcoming input layout - const type = key === 'defaultRole' && !canReadRoles ? 'notAllowed' : form[key].type; - const description = - key === 'defaultRole' && !canReadRoles - ? form[key].notAllowedDescription - : form[key].description; - - return ( - - ); - })} - - - - - ); -}; +// const ProtectedSSO = () => ( +// +// +// +// ); const ProtectedSSO = () => ( - - - + SingleSignOn ); -export default memo(ProtectedSSO); +export default ProtectedSSO;