mirror of
https://github.com/strapi/strapi.git
synced 2025-09-10 17:17:19 +00:00
Init migration
Signed-off-by: soupette <cyril@strapi.io>
This commit is contained in:
parent
4a49fc57a3
commit
a4b427b45d
@ -1,110 +1,132 @@
|
|||||||
// import React, { useCallback, useEffect, useMemo, useReducer, useRef, useState } from 'react';
|
import React, {
|
||||||
// import {
|
// useCallback,
|
||||||
|
useEffect,
|
||||||
|
// useMemo,
|
||||||
|
useReducer,
|
||||||
|
useRef,
|
||||||
|
// useState
|
||||||
|
} from 'react';
|
||||||
|
import {
|
||||||
// BaselineAlignment,
|
// BaselineAlignment,
|
||||||
// useQuery,
|
// useQuery,
|
||||||
// request,
|
request,
|
||||||
// useRBAC,
|
useRBAC,
|
||||||
// LoadingIndicatorPage,
|
LoadingIndicatorPage,
|
||||||
// PopUpWarning,
|
// PopUpWarning,
|
||||||
// useNotification,
|
SettingsPageTitle,
|
||||||
// SettingsPageTitle
|
useNotification,
|
||||||
// } from '@strapi/helper-plugin';
|
useFocusWhenNavigate,
|
||||||
// import { get } from 'lodash';
|
} from '@strapi/helper-plugin';
|
||||||
// import { useHistory, useLocation } from 'react-router-dom';
|
import {
|
||||||
|
Button,
|
||||||
|
// ContentLayout,
|
||||||
|
HeaderLayout,
|
||||||
|
// Table,
|
||||||
|
// TableLabel,
|
||||||
|
// Tbody,
|
||||||
|
// TFooter,
|
||||||
|
// Th,
|
||||||
|
// Thead,
|
||||||
|
// Tr,
|
||||||
|
// VisuallyHidden,
|
||||||
|
Main,
|
||||||
|
} from '@strapi/parts';
|
||||||
|
import { Mail } from '@strapi/icons';
|
||||||
|
import {
|
||||||
|
// useHistory,
|
||||||
|
useLocation,
|
||||||
|
} from 'react-router-dom';
|
||||||
|
import { useIntl } from 'react-intl';
|
||||||
|
// import get from 'lodash/get';
|
||||||
// import { Flex, Padded } from '@buffetjs/core';
|
// import { Flex, Padded } from '@buffetjs/core';
|
||||||
// import { useSettingsHeaderSearchContext } from '../../../hooks';
|
// import { useSettingsHeaderSearchContext } from '../../../hooks';
|
||||||
// import { Footer, List, Filter, FilterPicker, SortPicker } from '../../../components/Users';
|
// import { Footer, List, Filter, FilterPicker, SortPicker } from '../../../components/Users';
|
||||||
// import adminPermissions from '../../../permissions';
|
import adminPermissions from '../../../permissions';
|
||||||
// import Header from './Header';
|
// import Header from './Header';
|
||||||
// import ModalForm from './ModalForm';
|
// import ModalForm from './ModalForm';
|
||||||
// import getFilters from './utils/getFilters';
|
// import getFilters from './utils/getFilters';
|
||||||
// import init from './init';
|
import init from './init';
|
||||||
// import { initialState, reducer } from './reducer';
|
import { initialState, reducer } from './reducer';
|
||||||
|
|
||||||
// const ListPage = () => {
|
const ListPage = () => {
|
||||||
// const {
|
const {
|
||||||
// isLoading: isLoadingForPermissions,
|
isLoading: isLoadingForPermissions,
|
||||||
// allowedActions: { canCreate, canDelete, canRead, canUpdate },
|
allowedActions: {
|
||||||
// } = useRBAC(adminPermissions.settings.users);
|
canCreate,
|
||||||
// const toggleNotification = useNotification();
|
// canDelete,
|
||||||
|
canRead,
|
||||||
|
// canUpdate
|
||||||
|
},
|
||||||
|
} = useRBAC(adminPermissions.settings.users);
|
||||||
|
const toggleNotification = useNotification();
|
||||||
// const [isWarningDeleteAllOpened, setIsWarningDeleteAllOpened] = useState(false);
|
// const [isWarningDeleteAllOpened, setIsWarningDeleteAllOpened] = useState(false);
|
||||||
// const [isModalOpened, setIsModalOpened] = useState(false);
|
// const [isModalOpened, setIsModalOpened] = useState(false);
|
||||||
// const { toggleHeaderSearch } = useSettingsHeaderSearchContext();
|
const { formatMessage } = useIntl();
|
||||||
// const query = useQuery();
|
// const query = useQuery();
|
||||||
// const { push } = useHistory();
|
// const { push } = useHistory();
|
||||||
// const { search } = useLocation();
|
const { search } = useLocation();
|
||||||
|
|
||||||
|
useFocusWhenNavigate();
|
||||||
|
|
||||||
// const filters = useMemo(() => {
|
// const filters = useMemo(() => {
|
||||||
// return getFilters(search);
|
// return getFilters(search);
|
||||||
// }, [search]);
|
// }, [search]);
|
||||||
|
|
||||||
// const [
|
const [
|
||||||
// {
|
{
|
||||||
// data,
|
// data,
|
||||||
// dataToDelete,
|
// dataToDelete,
|
||||||
// isLoading,
|
isLoading,
|
||||||
// pagination: { total },
|
pagination: { total },
|
||||||
// shouldRefetchData,
|
// shouldRefetchData,
|
||||||
// showModalConfirmButtonLoading,
|
// showModalConfirmButtonLoading,
|
||||||
// },
|
},
|
||||||
// dispatch,
|
dispatch,
|
||||||
// ] = useReducer(reducer, initialState, init);
|
] = useReducer(reducer, initialState, init);
|
||||||
// const pageSize = parseInt(query.get('pageSize') || 10, 10);
|
// const pageSize = parseInt(query.get('pageSize') || 10, 10);
|
||||||
// const page = parseInt(query.get('page') || 0, 10);
|
// const page = parseInt(query.get('page') || 0, 10);
|
||||||
// const sort = decodeURIComponent(query.get('sort'));
|
// const sort = decodeURIComponent(query.get('sort'));
|
||||||
// const _q = decodeURIComponent(query.get('_q') || '');
|
// const _q = decodeURIComponent(query.get('_q') || '');
|
||||||
// const getDataRef = useRef();
|
const getDataRef = useRef();
|
||||||
// const listRef = useRef();
|
// const listRef = useRef();
|
||||||
|
|
||||||
// getDataRef.current = async () => {
|
getDataRef.current = async () => {
|
||||||
// if (!canRead) {
|
if (!canRead) {
|
||||||
// dispatch({
|
dispatch({
|
||||||
// type: 'UNSET_IS_LOADING',
|
type: 'UNSET_IS_LOADING',
|
||||||
// });
|
});
|
||||||
|
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
// // Show the loading state and reset the state
|
// Show the loading state and reset the state
|
||||||
// dispatch({
|
dispatch({
|
||||||
// type: 'GET_DATA',
|
type: 'GET_DATA',
|
||||||
// });
|
});
|
||||||
|
|
||||||
// try {
|
try {
|
||||||
// const {
|
const {
|
||||||
// data: { results, pagination },
|
data: { results, pagination },
|
||||||
// } = await request(`/admin/users${search}`, { method: 'GET' });
|
} = await request(`/admin/users${search}`, { method: 'GET' });
|
||||||
|
|
||||||
// dispatch({
|
dispatch({
|
||||||
// type: 'GET_DATA_SUCCEEDED',
|
type: 'GET_DATA_SUCCEEDED',
|
||||||
// data: results,
|
data: results,
|
||||||
// pagination,
|
pagination,
|
||||||
// });
|
});
|
||||||
// } catch (err) {
|
} catch (err) {
|
||||||
// console.error(err.response);
|
console.error(err.response);
|
||||||
// toggleNotification({
|
toggleNotification({
|
||||||
// type: 'warning',
|
type: 'warning',
|
||||||
// message: { id: 'notification.error' },
|
message: { id: 'notification.error' },
|
||||||
// });
|
});
|
||||||
// }
|
}
|
||||||
// };
|
};
|
||||||
|
|
||||||
// useEffect(() => {
|
useEffect(() => {
|
||||||
// if (!isLoadingForPermissions) {
|
if (!isLoadingForPermissions) {
|
||||||
// getDataRef.current();
|
getDataRef.current();
|
||||||
// }
|
}
|
||||||
// }, [search, isLoadingForPermissions]);
|
}, [search, isLoadingForPermissions]);
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// if (canRead) {
|
|
||||||
// toggleHeaderSearch({ id: 'Settings.permissions.menu.link.users.label' });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return () => {
|
|
||||||
// if (canRead) {
|
|
||||||
// toggleHeaderSearch();
|
|
||||||
// }
|
|
||||||
// };
|
|
||||||
// // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
// }, [canRead]);
|
|
||||||
|
|
||||||
// const handleChangeDataToDelete = ids => {
|
// const handleChangeDataToDelete = ids => {
|
||||||
// dispatch({
|
// dispatch({
|
||||||
@ -221,9 +243,38 @@
|
|||||||
// });
|
// });
|
||||||
// };
|
// };
|
||||||
|
|
||||||
// if (isLoadingForPermissions) {
|
return (
|
||||||
// return <LoadingIndicatorPage />;
|
<Main labelledBy="title">
|
||||||
// }
|
<SettingsPageTitle name="Users" />
|
||||||
|
<HeaderLayout
|
||||||
|
id="title"
|
||||||
|
primaryAction={
|
||||||
|
canCreate ? (
|
||||||
|
<Button onClick={() => 'handleToggleModalForCreatingRole'} startIcon={<Mail />}>
|
||||||
|
{formatMessage({
|
||||||
|
id: 'Settings.permissions.users.create',
|
||||||
|
defaultMessage: 'Create new user',
|
||||||
|
})}
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
undefined
|
||||||
|
)
|
||||||
|
}
|
||||||
|
title={formatMessage({
|
||||||
|
id: 'Settings.permissions.users.listview.header.title',
|
||||||
|
defaultMessage: 'Users',
|
||||||
|
})}
|
||||||
|
subtitle={formatMessage(
|
||||||
|
{
|
||||||
|
id: 'Settings.permissions.users.listview.header.subtitle',
|
||||||
|
defaultMessage: '{number, plural, =0 {# users} one {# user} other {# users}} found',
|
||||||
|
},
|
||||||
|
{ number: total }
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{isLoading ? <LoadingIndicatorPage /> : undefined}
|
||||||
|
</Main>
|
||||||
|
);
|
||||||
|
|
||||||
// return (
|
// return (
|
||||||
// <div>
|
// <div>
|
||||||
@ -286,8 +337,8 @@
|
|||||||
// />
|
// />
|
||||||
// </div>
|
// </div>
|
||||||
// );
|
// );
|
||||||
// };
|
};
|
||||||
|
|
||||||
// export default ListPage;
|
export default ListPage;
|
||||||
|
|
||||||
export default () => 'User - LV';
|
// export default () => 'User - LV';
|
||||||
|
@ -109,14 +109,13 @@
|
|||||||
"Settings.permissions.menu.link.roles.label": "Roles",
|
"Settings.permissions.menu.link.roles.label": "Roles",
|
||||||
"Settings.permissions.menu.link.users.label": "Users",
|
"Settings.permissions.menu.link.users.label": "Users",
|
||||||
"Settings.permissions.users.add-new": "Add new user",
|
"Settings.permissions.users.add-new": "Add new user",
|
||||||
"Settings.permissions.users.create": "Create new User",
|
"Settings.permissions.users.create": "Create new user",
|
||||||
"Settings.permissions.users.form.email": "Email",
|
"Settings.permissions.users.form.email": "Email",
|
||||||
"Settings.permissions.users.form.firstname": "First name",
|
"Settings.permissions.users.form.firstname": "First name",
|
||||||
"Settings.permissions.users.form.lastname": "Last name",
|
"Settings.permissions.users.form.lastname": "Last name",
|
||||||
"Settings.permissions.users.form.sso": "Connect with SSO",
|
"Settings.permissions.users.form.sso": "Connect with SSO",
|
||||||
"Settings.permissions.users.form.sso.description": "When enabled (ON), users can login via SSO",
|
"Settings.permissions.users.form.sso.description": "When enabled (ON), users can login via SSO",
|
||||||
"Settings.permissions.users.listview.header.description.plural": "{number} users found",
|
"Settings.permissions.users.listview.header.subtitle": "{number, plural, =0 {# users} one {# user } other {# users}} found",
|
||||||
"Settings.permissions.users.listview.header.description.singular": "{number} user found",
|
|
||||||
"Settings.permissions.users.listview.header.title": "Users",
|
"Settings.permissions.users.listview.header.title": "Users",
|
||||||
"Settings.permissions.select-all-by-permission": "Select all {label} permissions",
|
"Settings.permissions.select-all-by-permission": "Select all {label} permissions",
|
||||||
"Settings.permissions.select-by-permission": "Select {label} permission",
|
"Settings.permissions.select-by-permission": "Select {label} permission",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user