mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-17 23:44:39 -05:00
Wired data to user detail modal in adminX
refs https://github.com/TryGhost/Team/issues/3151 - wires user data in the user detail modal from the api
This commit is contained in:
parent
88f3161903
commit
5c20aa08de
2 changed files with 64 additions and 34 deletions
|
@ -8,10 +8,11 @@ import SettingGroup from '../../../admin-x-ds/settings/SettingGroup';
|
||||||
import TabView from '../../../admin-x-ds/global/TabView';
|
import TabView from '../../../admin-x-ds/global/TabView';
|
||||||
import UserDetailModal from './modals/UserDetailModal';
|
import UserDetailModal from './modals/UserDetailModal';
|
||||||
import useStaffUsers from '../../../hooks/useStaffUsers';
|
import useStaffUsers from '../../../hooks/useStaffUsers';
|
||||||
|
import {User} from '../../../types/api';
|
||||||
|
|
||||||
const Owner: React.FC<any> = ({user}) => {
|
const Owner: React.FC<{user: User}> = ({user}) => {
|
||||||
const showDetailModal = () => {
|
const showDetailModal = () => {
|
||||||
NiceModal.show(UserDetailModal);
|
NiceModal.show(UserDetailModal, {user});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!user) {
|
if (!user) {
|
||||||
|
@ -25,9 +26,13 @@ const Owner: React.FC<any> = ({user}) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const UsersList: React.FC<any> = ({users}) => {
|
interface UsersListProps {
|
||||||
const showDetailModal = () => {
|
users: User[];
|
||||||
NiceModal.show(UserDetailModal);
|
}
|
||||||
|
|
||||||
|
const UsersList: React.FC<UsersListProps> = ({users}) => {
|
||||||
|
const showDetailModal = (user: User) => {
|
||||||
|
NiceModal.show(UserDetailModal, {user});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!users || !users.length) {
|
if (!users || !users.length) {
|
||||||
|
@ -40,16 +45,16 @@ const UsersList: React.FC<any> = ({users}) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<List>
|
<List>
|
||||||
{users.map((user: any) => {
|
{users.map((user) => {
|
||||||
return (
|
return (
|
||||||
<ListItem
|
<ListItem
|
||||||
key={user.id}
|
key={user.id}
|
||||||
action={<Button color='green' label='Edit' link={true} onClick={showDetailModal} />}
|
action={<Button color='green' label='Edit' link={true} onClick={() => showDetailModal(user)}/>}
|
||||||
detail={user.email}
|
detail={user.email}
|
||||||
hideActions={true}
|
hideActions={true}
|
||||||
id={`list-item-${user.id}`}
|
id={`list-item-${user.id}`}
|
||||||
title={user.name}
|
title={user.name}
|
||||||
onClick={showDetailModal} />
|
onClick={() => showDetailModal(user)} />
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</List>
|
</List>
|
||||||
|
|
|
@ -8,31 +8,35 @@ import SettingGroup from '../../../../admin-x-ds/settings/SettingGroup';
|
||||||
import SettingGroupContent from '../../../../admin-x-ds/settings/SettingGroupContent';
|
import SettingGroupContent from '../../../../admin-x-ds/settings/SettingGroupContent';
|
||||||
import TextField from '../../../../admin-x-ds/global/TextField';
|
import TextField from '../../../../admin-x-ds/global/TextField';
|
||||||
import Toggle from '../../../../admin-x-ds/global/Toggle';
|
import Toggle from '../../../../admin-x-ds/global/Toggle';
|
||||||
|
import {User} from '../../../../types/api';
|
||||||
|
|
||||||
interface CustomHeadingProps {
|
interface CustomHeadingProps {
|
||||||
children?: React.ReactNode;
|
children?: React.ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface UserDetailProps {
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
const CustomHeader: React.FC<CustomHeadingProps> = ({children}) => {
|
const CustomHeader: React.FC<CustomHeadingProps> = ({children}) => {
|
||||||
return (
|
return (
|
||||||
<Heading level={4} separator={true}>{children}</Heading>
|
<Heading level={4} separator={true}>{children}</Heading>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
const BasicInputs: React.FC<UserDetailProps> = ({user}) => {
|
||||||
const Basic: React.FC = () => {
|
return (
|
||||||
const inputs = (
|
|
||||||
<SettingGroupContent>
|
<SettingGroupContent>
|
||||||
<TextField
|
<TextField
|
||||||
hint="Use real name so people can recognize you"
|
hint="Use real name so people can recognize you"
|
||||||
title="Full name"
|
title="Full name"
|
||||||
value="Martin Culhane"
|
value={user.name}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
title="Email"
|
title="Email"
|
||||||
value="martin@culhane.com"
|
value={user.email}
|
||||||
/>
|
/>
|
||||||
<Radio
|
<Radio
|
||||||
defaultSelectedOption="administrator"
|
defaultSelectedOption={user.roles[0].name.toLowerCase()}
|
||||||
id='role'
|
id='role'
|
||||||
options={[
|
options={[
|
||||||
{
|
{
|
||||||
|
@ -61,83 +65,98 @@ const Basic: React.FC = () => {
|
||||||
/>
|
/>
|
||||||
</SettingGroupContent>
|
</SettingGroupContent>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Basic: React.FC<UserDetailProps> = ({user}) => {
|
||||||
return (
|
return (
|
||||||
<SettingGroup
|
<SettingGroup
|
||||||
border={false}
|
border={false}
|
||||||
customHeader={<CustomHeader>Basic info</CustomHeader>}
|
customHeader={<CustomHeader>Basic info</CustomHeader>}
|
||||||
title='Basic'
|
title='Basic'
|
||||||
>
|
>
|
||||||
{inputs}
|
<BasicInputs user={user} />
|
||||||
</SettingGroup>
|
</SettingGroup>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const Details: React.FC = () => {
|
const DetailsInputs: React.FC<UserDetailProps> = ({user}) => {
|
||||||
const inputs = (
|
return (
|
||||||
<SettingGroupContent>
|
<SettingGroupContent>
|
||||||
<TextField
|
<TextField
|
||||||
hint="https://example.com/author"
|
hint="https://example.com/author"
|
||||||
title="Slug"
|
title="Slug"
|
||||||
|
value={user.slug}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
title="Location"
|
title="Location"
|
||||||
|
value={user.location}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
title="Website"
|
title="Website"
|
||||||
|
value={user.website}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
title="Facebook profile"
|
title="Facebook profile"
|
||||||
|
value={user.facebook}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
title="Twitter profile"
|
title="Twitter profile"
|
||||||
|
value={user.twitter}
|
||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
hint="Recommended: 200 characters."
|
hint="Recommended: 200 characters."
|
||||||
title="Bio"
|
title="Bio"
|
||||||
|
value={user.bio}
|
||||||
/>
|
/>
|
||||||
</SettingGroupContent>
|
</SettingGroupContent>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const Details: React.FC<UserDetailProps> = ({user}) => {
|
||||||
return (
|
return (
|
||||||
<SettingGroup
|
<SettingGroup
|
||||||
border={false}
|
border={false}
|
||||||
customHeader={<CustomHeader>Details</CustomHeader>}
|
customHeader={<CustomHeader>Details</CustomHeader>}
|
||||||
title='Details'
|
title='Details'
|
||||||
>
|
>
|
||||||
{inputs}
|
<DetailsInputs user={user} />
|
||||||
</SettingGroup>
|
</SettingGroup>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const EmailNotifications: React.FC = () => {
|
const EmailNotificationsInputs: React.FC<UserDetailProps> = ({user}) => {
|
||||||
const inputs = (
|
return (
|
||||||
<SettingGroupContent>
|
<SettingGroupContent>
|
||||||
<Toggle
|
<Toggle
|
||||||
|
checked={user.comment_notifications}
|
||||||
direction='rtl'
|
direction='rtl'
|
||||||
hint='Every time a member comments on one of your posts'
|
hint='Every time a member comments on one of your posts'
|
||||||
id='comments'
|
id='comments'
|
||||||
label='Comments'
|
label='Comments'
|
||||||
/>
|
/>
|
||||||
<Toggle
|
<Toggle
|
||||||
|
checked={user.free_member_signup_notification}
|
||||||
direction='rtl'
|
direction='rtl'
|
||||||
hint='Every time a new free member signs up'
|
hint='Every time a new free member signs up'
|
||||||
id='new-signups'
|
id='new-signups'
|
||||||
label='New signups'
|
label='New signups'
|
||||||
/>
|
/>
|
||||||
<Toggle
|
<Toggle
|
||||||
|
checked={user.paid_subscription_started_notification}
|
||||||
direction='rtl'
|
direction='rtl'
|
||||||
hint='Every time a member starts a new paid subscription'
|
hint='Every time a member starts a new paid subscription'
|
||||||
id='new-paid-members'
|
id='new-paid-members'
|
||||||
label='New paid members'
|
label='New paid members'
|
||||||
/>
|
/>
|
||||||
<Toggle
|
<Toggle
|
||||||
|
checked={user.paid_subscription_canceled_notification}
|
||||||
direction='rtl'
|
direction='rtl'
|
||||||
hint='Every time a member cancels their paid subscription'
|
hint='Every time a member cancels their paid subscription'
|
||||||
id='paid-member-cancellations'
|
id='paid-member-cancellations'
|
||||||
label='Paid member cancellations'
|
label='Paid member cancellations'
|
||||||
/>
|
/>
|
||||||
<Toggle
|
<Toggle
|
||||||
|
checked={user.milestone_notifications}
|
||||||
direction='rtl'
|
direction='rtl'
|
||||||
hint='Occasional summaries of your audience & revenue growth'
|
hint='Occasional summaries of your audience & revenue growth'
|
||||||
id='milestones'
|
id='milestones'
|
||||||
|
@ -145,14 +164,16 @@ const EmailNotifications: React.FC = () => {
|
||||||
/>
|
/>
|
||||||
</SettingGroupContent>
|
</SettingGroupContent>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const EmailNotifications: React.FC<UserDetailProps> = ({user}) => {
|
||||||
return (
|
return (
|
||||||
<SettingGroup
|
<SettingGroup
|
||||||
border={false}
|
border={false}
|
||||||
customHeader={<CustomHeader>Email notifications</CustomHeader>}
|
customHeader={<CustomHeader>Email notifications</CustomHeader>}
|
||||||
title='Email notifications'
|
title='Email notifications'
|
||||||
>
|
>
|
||||||
{inputs}
|
<EmailNotificationsInputs user={user} />
|
||||||
</SettingGroup>
|
</SettingGroup>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -198,7 +219,11 @@ const Password: React.FC = () => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const UserDetailModal = NiceModal.create(() => {
|
interface UserDetailModalProps {
|
||||||
|
user: User;
|
||||||
|
}
|
||||||
|
|
||||||
|
const UserDetailModal:React.FC<UserDetailModalProps> = ({user}) => {
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
okColor='green'
|
okColor='green'
|
||||||
|
@ -211,19 +236,19 @@ const UserDetailModal = NiceModal.create(() => {
|
||||||
<div>
|
<div>
|
||||||
<div className='-mx-12 -mt-12 bg-gradient-to-tr from-grey-900 to-black p-12 text-white'>
|
<div className='-mx-12 -mt-12 bg-gradient-to-tr from-grey-900 to-black p-12 text-white'>
|
||||||
<div className='mt-60'>
|
<div className='mt-60'>
|
||||||
<Heading styles='text-white'>Martin Culhane</Heading>
|
<Heading styles='text-white'>{user.name}</Heading>
|
||||||
<span className='text-md font-semibold'>Administrator</span>
|
<span className='text-md font-semibold'>Administrator</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className='mt-10 grid grid-cols-2 gap-x-12 gap-y-20 pb-10'>
|
<div className='mt-10 grid grid-cols-2 gap-x-12 gap-y-20 pb-10'>
|
||||||
<Basic />
|
<Basic user={user} />
|
||||||
<Details />
|
<Details user={user} />
|
||||||
<EmailNotifications />
|
<EmailNotifications user={user} />
|
||||||
<Password />
|
<Password />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
});
|
};
|
||||||
|
|
||||||
export default UserDetailModal;
|
export default NiceModal.create(UserDetailModal);
|
||||||
|
|
Loading…
Add table
Reference in a new issue