|
@@ -1,6 +1,7 @@
|
|
|
import React from 'react';
|
|
import React from 'react';
|
|
|
|
|
|
|
|
-import type { IUser } from '@growi/core';
|
|
|
|
|
|
|
+import type { IUserHasId } from '@growi/core';
|
|
|
|
|
+import { isPopulated, type IUser, type Ref } from '@growi/core';
|
|
|
import { pagePathUtils } from '@growi/core/dist/utils';
|
|
import { pagePathUtils } from '@growi/core/dist/utils';
|
|
|
import { UserPicture } from '@growi/ui/dist/components';
|
|
import { UserPicture } from '@growi/ui/dist/components';
|
|
|
import { format } from 'date-fns/format';
|
|
import { format } from 'date-fns/format';
|
|
@@ -10,10 +11,22 @@ import Link from 'next/link';
|
|
|
|
|
|
|
|
import styles from './AuthorInfo.module.scss';
|
|
import styles from './AuthorInfo.module.scss';
|
|
|
|
|
|
|
|
|
|
+const UserLabel = ({ user }: { user: IUserHasId | Ref<IUser> }): JSX.Element => {
|
|
|
|
|
+ if (isPopulated(user)) {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <Link href={pagePathUtils.userHomepagePath(user)} prefetch={false}>
|
|
|
|
|
+ {user.name}
|
|
|
|
|
+ </Link>
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return <i>(anyone)</i>;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
|
|
|
-export type AuthorInfoProps = {
|
|
|
|
|
|
|
+type AuthorInfoProps = {
|
|
|
date: Date,
|
|
date: Date,
|
|
|
- user: IUser,
|
|
|
|
|
|
|
+ user?: IUserHasId | Ref<IUser>,
|
|
|
mode: 'create' | 'update',
|
|
mode: 'create' | 'update',
|
|
|
locate: 'subnav' | 'footer',
|
|
locate: 'subnav' | 'footer',
|
|
|
}
|
|
}
|
|
@@ -37,9 +50,7 @@ export const AuthorInfo = (props: AuthorInfoProps): JSX.Element => {
|
|
|
: t('author_info.last_revision_posted_at');
|
|
: t('author_info.last_revision_posted_at');
|
|
|
const userLabel = user != null
|
|
const userLabel = user != null
|
|
|
? (
|
|
? (
|
|
|
- <Link href={pagePathUtils.userHomepagePath(user)} prefetch={false}>
|
|
|
|
|
- {user.name}
|
|
|
|
|
- </Link>
|
|
|
|
|
|
|
+ <UserLabel user={user} />
|
|
|
)
|
|
)
|
|
|
: <i>Unknown</i>;
|
|
: <i>Unknown</i>;
|
|
|
|
|
|