mirror of
https://github.com/strapi/strapi.git
synced 2025-08-09 01:07:27 +00:00
fix: updated parts depending on lastname
This commit is contained in:
parent
6213d2dc7b
commit
5402ff323b
@ -9,12 +9,13 @@ import PluginsInitializer from '../PluginsInitializer';
|
|||||||
import RBACProvider from '../RBACProvider';
|
import RBACProvider from '../RBACProvider';
|
||||||
import { fetchAppInfo, fetchCurrentUserPermissions, fetchStrapiLatestRelease } from './utils/api';
|
import { fetchAppInfo, fetchCurrentUserPermissions, fetchStrapiLatestRelease } from './utils/api';
|
||||||
import checkLatestStrapiVersion from './utils/checkLatestStrapiVersion';
|
import checkLatestStrapiVersion from './utils/checkLatestStrapiVersion';
|
||||||
|
import { getFullName } from '../../utils';
|
||||||
|
|
||||||
const strapiVersion = packageJSON.version;
|
const strapiVersion = packageJSON.version;
|
||||||
|
|
||||||
const AuthenticatedApp = () => {
|
const AuthenticatedApp = () => {
|
||||||
const userInfo = auth.getUserInfo();
|
const userInfo = auth.getUserInfo();
|
||||||
const userName = get(userInfo, 'username') || `${userInfo.firstname} ${userInfo.lastname}`;
|
const userName = get(userInfo, 'username') || getFullName(userInfo.firstname, userInfo.lastname);
|
||||||
const [userDisplayName, setUserDisplayName] = useState(userName);
|
const [userDisplayName, setUserDisplayName] = useState(userName);
|
||||||
const { showReleaseNotification } = useConfigurations();
|
const { showReleaseNotification } = useConfigurations();
|
||||||
const [
|
const [
|
||||||
|
@ -13,6 +13,7 @@ import { useHistory } from 'react-router-dom';
|
|||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { usePluginsQueryParams } from '../../../hooks';
|
import { usePluginsQueryParams } from '../../../hooks';
|
||||||
import CellContent from '../CellContent';
|
import CellContent from '../CellContent';
|
||||||
|
import { getFullName } from '../../../../utils';
|
||||||
|
|
||||||
const TableRows = ({
|
const TableRows = ({
|
||||||
canCreate,
|
canCreate,
|
||||||
@ -69,7 +70,7 @@ const TableRows = ({
|
|||||||
id: 'app.component.table.select.one-entry',
|
id: 'app.component.table.select.one-entry',
|
||||||
defaultMessage: `Select {target}`,
|
defaultMessage: `Select {target}`,
|
||||||
},
|
},
|
||||||
{ target: `${data.firstname} ${data.lastname}` }
|
{ target: getFullName(data.firstname, data.lastname) }
|
||||||
)}
|
)}
|
||||||
checked={isChecked}
|
checked={isChecked}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
|
@ -8,6 +8,7 @@ import { Flex } from '@strapi/design-system/Flex';
|
|||||||
import { Stack } from '@strapi/design-system/Stack';
|
import { Stack } from '@strapi/design-system/Stack';
|
||||||
import { getTrad } from '../../../utils';
|
import { getTrad } from '../../../utils';
|
||||||
import getUnits from './utils/getUnits';
|
import getUnits from './utils/getUnits';
|
||||||
|
import { getFullName } from '../../../../utils';
|
||||||
|
|
||||||
const Informations = () => {
|
const Informations = () => {
|
||||||
const { formatMessage, formatRelativeTime } = useIntl();
|
const { formatMessage, formatRelativeTime } = useIntl();
|
||||||
@ -17,7 +18,7 @@ const Informations = () => {
|
|||||||
const updatedByFirstname = initialData.updatedBy?.firstname || '';
|
const updatedByFirstname = initialData.updatedBy?.firstname || '';
|
||||||
const updatedByLastname = initialData.updatedBy?.lastname || '';
|
const updatedByLastname = initialData.updatedBy?.lastname || '';
|
||||||
const updatedByUsername = initialData.updatedBy?.username;
|
const updatedByUsername = initialData.updatedBy?.username;
|
||||||
const updatedBy = updatedByUsername || `${updatedByFirstname} ${updatedByLastname}`;
|
const updatedBy = updatedByUsername || getFullName(updatedByFirstname, updatedByLastname);
|
||||||
const currentTime = useRef(Date.now());
|
const currentTime = useRef(Date.now());
|
||||||
const timestamp = initialData[updatedAt]
|
const timestamp = initialData[updatedAt]
|
||||||
? new Date(initialData[updatedAt]).getTime()
|
? new Date(initialData[updatedAt]).getTime()
|
||||||
|
@ -33,6 +33,7 @@ import Check from '@strapi/icons/Check';
|
|||||||
import useLocalesProvider from '../../components/LocalesProvider/useLocalesProvider';
|
import useLocalesProvider from '../../components/LocalesProvider/useLocalesProvider';
|
||||||
import { fetchUser, putUser } from './utils/api';
|
import { fetchUser, putUser } from './utils/api';
|
||||||
import schema from './utils/schema';
|
import schema from './utils/schema';
|
||||||
|
import { getFullName } from '../../utils';
|
||||||
|
|
||||||
const PasswordInput = styled(TextInput)`
|
const PasswordInput = styled(TextInput)`
|
||||||
::-ms-reveal {
|
::-ms-reveal {
|
||||||
@ -87,7 +88,7 @@ const ProfilePage = () => {
|
|||||||
await queryClient.invalidateQueries('user');
|
await queryClient.invalidateQueries('user');
|
||||||
|
|
||||||
auth.setUserInfo(data);
|
auth.setUserInfo(data);
|
||||||
const userDisplayName = data.username || `${data.firstname} ${data.lastname}`;
|
const userDisplayName = data.username || getFullName(data.firstname, data.lastname);
|
||||||
setUserDisplayName(userDisplayName);
|
setUserDisplayName(userDisplayName);
|
||||||
changeLocale(data.preferedLanguage);
|
changeLocale(data.preferedLanguage);
|
||||||
|
|
||||||
@ -172,7 +173,7 @@ const ProfilePage = () => {
|
|||||||
return (
|
return (
|
||||||
<Form>
|
<Form>
|
||||||
<HeaderLayout
|
<HeaderLayout
|
||||||
title={data.username || `${data.firstname} ${data.lastname}`}
|
title={data.username || getFullName(data.firstname, data.lastname)}
|
||||||
primaryAction={
|
primaryAction={
|
||||||
<Button startIcon={<Check />} loading={isSubmitting} type="submit">
|
<Button startIcon={<Check />} loading={isSubmitting} type="submit">
|
||||||
{formatMessage({ id: 'form.button.save', defaultMessage: 'Save' })}
|
{formatMessage({ id: 'form.button.save', defaultMessage: 'Save' })}
|
||||||
|
@ -29,7 +29,7 @@ import { Stack } from '@strapi/design-system/Stack';
|
|||||||
import ArrowLeft from '@strapi/icons/ArrowLeft';
|
import ArrowLeft from '@strapi/icons/ArrowLeft';
|
||||||
import Check from '@strapi/icons/Check';
|
import Check from '@strapi/icons/Check';
|
||||||
import MagicLink from 'ee_else_ce/pages/SettingsPage/pages/Users/components/MagicLink';
|
import MagicLink from 'ee_else_ce/pages/SettingsPage/pages/Users/components/MagicLink';
|
||||||
import { formatAPIErrors } from '../../../../../utils';
|
import { formatAPIErrors, getFullName } from '../../../../../utils';
|
||||||
import { fetchUser, putUser } from './utils/api';
|
import { fetchUser, putUser } from './utils/api';
|
||||||
import layout from './utils/layout';
|
import layout from './utils/layout';
|
||||||
import { editValidation } from '../utils/validations/users';
|
import { editValidation } from '../utils/validations/users';
|
||||||
@ -89,7 +89,7 @@ const EditPage = ({ canUpdate }) => {
|
|||||||
if (id.toString() === userInfos.id.toString()) {
|
if (id.toString() === userInfos.id.toString()) {
|
||||||
auth.setUserInfo(data);
|
auth.setUserInfo(data);
|
||||||
|
|
||||||
const userDisplayName = get(body, 'username') || `${body.firstname} ${body.lastname}`;
|
const userDisplayName = get(body, 'username') || getFullName(body.firstname, body.lastname);
|
||||||
|
|
||||||
setUserDisplayName(userDisplayName);
|
setUserDisplayName(userDisplayName);
|
||||||
}
|
}
|
||||||
@ -131,7 +131,7 @@ const EditPage = ({ canUpdate }) => {
|
|||||||
}, {});
|
}, {});
|
||||||
|
|
||||||
const headerLabelName =
|
const headerLabelName =
|
||||||
initialData.username || `${initialData.firstname} ${initialData.lastname}`;
|
initialData.username || getFullName(initialData.firstname, initialData.lastname);
|
||||||
|
|
||||||
const title = formatMessage(headerLabel, { name: headerLabelName });
|
const title = formatMessage(headerLabel, { name: headerLabelName });
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ import Trash from '@strapi/icons/Trash';
|
|||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { stopPropagation, onRowClick } from '@strapi/helper-plugin';
|
import { stopPropagation, onRowClick } from '@strapi/helper-plugin';
|
||||||
|
import { getFullName } from '../../../../../../../utils';
|
||||||
|
|
||||||
const TableRows = ({
|
const TableRows = ({
|
||||||
canDelete,
|
canDelete,
|
||||||
@ -49,7 +50,7 @@ const TableRows = ({
|
|||||||
id: 'app.component.table.select.one-entry',
|
id: 'app.component.table.select.one-entry',
|
||||||
defaultMessage: `Select {target}`,
|
defaultMessage: `Select {target}`,
|
||||||
},
|
},
|
||||||
{ target: `${data.firstname} ${data.lastname}` }
|
{ target: getFullName(data.firstname, data.lastname) }
|
||||||
)}
|
)}
|
||||||
checked={isChecked}
|
checked={isChecked}
|
||||||
onChange={() => {
|
onChange={() => {
|
||||||
@ -77,7 +78,7 @@ const TableRows = ({
|
|||||||
onClick={() => push(`${pathname}/${data.id}`)}
|
onClick={() => push(`${pathname}/${data.id}`)}
|
||||||
label={formatMessage(
|
label={formatMessage(
|
||||||
{ id: 'app.component.table.edit', defaultMessage: 'Edit {target}' },
|
{ id: 'app.component.table.edit', defaultMessage: 'Edit {target}' },
|
||||||
{ target: `${data.firstname} ${data.lastname}` }
|
{ target: getFullName(data.firstname, data.lastname) }
|
||||||
)}
|
)}
|
||||||
noBorder
|
noBorder
|
||||||
icon={<Pencil />}
|
icon={<Pencil />}
|
||||||
@ -89,7 +90,7 @@ const TableRows = ({
|
|||||||
onClick={() => onClickDelete(data.id)}
|
onClick={() => onClickDelete(data.id)}
|
||||||
label={formatMessage(
|
label={formatMessage(
|
||||||
{ id: 'app.component.table.delete', defaultMessage: 'Delete {target}' },
|
{ id: 'app.component.table.delete', defaultMessage: 'Delete {target}' },
|
||||||
{ target: `${data.firstname} ${data.lastname}` }
|
{ target: getFullName(data.firstname, data.lastname) }
|
||||||
)}
|
)}
|
||||||
noBorder
|
noBorder
|
||||||
icon={<Trash />}
|
icon={<Trash />}
|
||||||
|
9
packages/core/admin/admin/src/utils/getFullName.js
Normal file
9
packages/core/admin/admin/src/utils/getFullName.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* Get fullname from firstname+lastname joined with a space
|
||||||
|
* Handle missing lastname
|
||||||
|
* @param {string} firstname
|
||||||
|
* @param {string} lastname
|
||||||
|
*/
|
||||||
|
export default (firstname, lastname = '') => {
|
||||||
|
return [firstname, lastname].filter(e => e !== '').join(' ');
|
||||||
|
};
|
@ -5,5 +5,5 @@ export { default as getAttributesToDisplay } from './getAttributesToDisplay';
|
|||||||
export { default as makeUniqueRoutes } from './makeUniqueRoutes';
|
export { default as makeUniqueRoutes } from './makeUniqueRoutes';
|
||||||
export { default as sortLinks } from './sortLinks';
|
export { default as sortLinks } from './sortLinks';
|
||||||
export { default as getExistingActions } from './getExistingActions';
|
export { default as getExistingActions } from './getExistingActions';
|
||||||
|
|
||||||
export { default as getRequestUrl } from './getRequestUrl';
|
export { default as getRequestUrl } from './getRequestUrl';
|
||||||
|
export { default as getFullName } from './getFullName';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user