mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -05:00
Added dirty state to user detail modal (#17824)
refs https://github.com/TryGhost/Product/issues/3349 --- Improved user experience for editing user details in the admin settings. Added `dirty` state to track and handle unsaved changes in the `UserDetailModal` component.
This commit is contained in:
parent
44ae0dcbe1
commit
0b720c237c
1 changed files with 8 additions and 2 deletions
|
@ -424,14 +424,19 @@ const UserMenuTrigger = () => (
|
||||||
const UserDetailModal:React.FC<UserDetailModalProps> = ({user}) => {
|
const UserDetailModal:React.FC<UserDetailModalProps> = ({user}) => {
|
||||||
const {updateRoute} = useRouting();
|
const {updateRoute} = useRouting();
|
||||||
const {ownerUser} = useStaffUsers();
|
const {ownerUser} = useStaffUsers();
|
||||||
const [userData, setUserData] = useState(user);
|
const [userData, _setUserData] = useState(user);
|
||||||
const [saveState, setSaveState] = useState('');
|
const [saveState, setSaveState] = useState<'' | 'unsaved' | 'saving' | 'saved'>('');
|
||||||
const [errors, setErrors] = useState<{
|
const [errors, setErrors] = useState<{
|
||||||
name?: string;
|
name?: string;
|
||||||
email?: string;
|
email?: string;
|
||||||
url?: string;
|
url?: string;
|
||||||
}>({});
|
}>({});
|
||||||
|
|
||||||
|
const setUserData = (newUserData: User | ((current: User) => User)) => {
|
||||||
|
_setUserData(newUserData);
|
||||||
|
setSaveState('unsaved');
|
||||||
|
};
|
||||||
|
|
||||||
const mainModal = useModal();
|
const mainModal = useModal();
|
||||||
const {mutateAsync: uploadImage} = useUploadImage();
|
const {mutateAsync: uploadImage} = useUploadImage();
|
||||||
const {mutateAsync: updateUser} = useEditUser();
|
const {mutateAsync: updateUser} = useEditUser();
|
||||||
|
@ -645,6 +650,7 @@ const UserDetailModal:React.FC<UserDetailModalProps> = ({user}) => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
afterClose={() => updateRoute('users')}
|
afterClose={() => updateRoute('users')}
|
||||||
|
dirty={saveState === 'unsaved'}
|
||||||
okLabel={okLabel}
|
okLabel={okLabel}
|
||||||
size='lg'
|
size='lg'
|
||||||
stickyFooter={true}
|
stickyFooter={true}
|
||||||
|
|
Loading…
Reference in a new issue