ryoji-s 2 лет назад
Родитель
Сommit
7305ecd979

+ 1 - 1
apps/app/src/components/Admin/AuditLog/ActivityTable.tsx

@@ -48,7 +48,7 @@ export const ActivityTable : FC<Props> = (props: Props) => {
                   { activity.user != null && (
                     <>
                       <UserPicture user={activity.user} />
-                      <a className="ml-2" href={pagePathUtils.userPageRoot(activity.user)}>{activity.snapshot?.username}</a>
+                      <a className="ml-2" href={pagePathUtils.userHomepagePath(activity.user.username)}>{activity.snapshot?.username}</a>
                     </>
                   )}
                 </td>

+ 2 - 2
apps/app/src/components/Navbar/AuthorInfo.tsx

@@ -18,7 +18,7 @@ export const AuthorInfo = (props: AuthorInfoProps): JSX.Element => {
     date, user, mode = 'create', locate = 'subnav',
   } = props;
 
-  const { userPageRoot } = pagePathUtils;
+  const { userHomepagePath } = pagePathUtils;
   const formatType = 'yyyy/MM/dd HH:mm';
 
   const infoLabelForSubNav = mode === 'create'
@@ -32,7 +32,7 @@ export const AuthorInfo = (props: AuthorInfoProps): JSX.Element => {
     : 'Last revision posted at';
   const userLabel = user != null
     ? (
-      <Link href={userPageRoot(user)} prefetch={false}>
+      <Link href={userHomepagePath(user.username)} prefetch={false}>
         {user.name}
       </Link>
     )

+ 2 - 1
apps/app/src/components/Navbar/PersonalDropdown.jsx

@@ -1,5 +1,6 @@
 import { useRef, useState } from 'react';
 
+import { pagePathUtils } from '@growi/core';
 import { UserPicture } from '@growi/ui/dist/components/User/UserPicture';
 import { useTranslation } from 'next-i18next';
 import dynamic from 'next/dynamic';
@@ -64,7 +65,7 @@ const PersonalDropdown = () => {
 
           <div className="btn-group btn-block mt-2" role="group">
             <Link
-              href={`/user/${currentUser.username}`}
+              href={pagePathUtils.userHomepagePath(currentUser.username)}
               className="btn btn-sm btn-outline-secondary col"
               data-testid="grw-personal-dropdown-menu-user-home"
             >

+ 4 - 4
apps/app/src/components/PageCreateModal.jsx

@@ -21,7 +21,7 @@ import PagePathAutoComplete from './PagePathAutoComplete';
 import styles from './PageCreateModal.module.scss';
 
 const {
-  userPageRoot, isCreatablePage, generateEditorPath, isUsersHomePage,
+  isCreatablePage, generateEditorPath, isUsersHomePage,
 } = pagePathUtils;
 
 const PageCreateModal = () => {
@@ -35,7 +35,7 @@ const PageCreateModal = () => {
 
   const { data: isReachable } = useIsSearchServiceReachable();
   const pathname = path || '';
-  const userPageRootPath = userPageRoot(currentUser);
+  const userHomepagePath = pagePathUtils.userHomepagePath(currentUser.username);
   const isCreatable = isCreatablePage(pathname) || isUsersHomePage(pathname);
   const pageNameInputInitialValue = isCreatable ? pathUtils.addTrailingSlash(pathname) : '/';
   const now = format(new Date(), 'yyyy/MM/dd');
@@ -129,7 +129,7 @@ const PageCreateModal = () => {
     if (tmpTodayInput1 === '') {
       tmpTodayInput1 = t('Memo');
     }
-    redirectToEditor(userPageRootPath, tmpTodayInput1, now, todayInput2);
+    redirectToEditor(userHomepagePath, tmpTodayInput1, now, todayInput2);
   }
 
   /**
@@ -164,7 +164,7 @@ const PageCreateModal = () => {
 
             <div className="d-flex align-items-center flex-fill flex-wrap flex-lg-nowrap">
               <div className="d-flex align-items-center">
-                <span>{userPageRootPath}/</span>
+                <span>{userHomepagePath}/</span>
                 <form onSubmit={e => transitBySubmitEvent(e, createTodayPage)}>
                   <input
                     type="text"

+ 2 - 2
apps/app/src/components/User/Username.tsx

@@ -1,6 +1,6 @@
 import React from 'react';
 
-import type { IUser } from '@growi/core';
+import { type IUser, pagePathUtils } from '@growi/core';
 import Link from 'next/link';
 
 type UsernameProps = {
@@ -16,7 +16,7 @@ export const Username = (props: UsernameProps): JSX.Element => {
 
   const name = user.name || '(no name)';
   const username = user.username;
-  const href = `/user/${user.username}`;
+  const href = pagePathUtils.userHomepagePath(user.username);
 
   return (
     <Link href={href} prefetch={false}>

+ 3 - 2
apps/app/src/server/events/user.ts

@@ -1,6 +1,6 @@
 import EventEmitter from 'events';
 
-import type { IUserHasId } from '@growi/core';
+import { type IUserHasId, pagePathUtils } from '@growi/core';
 
 import loggerFactory from '~/utils/logger';
 
@@ -10,6 +10,7 @@ class UserEvent extends EventEmitter {
 
   crowi: any;
 
+  // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
   constructor(crowi: any) {
     super();
     this.crowi = crowi;
@@ -22,7 +23,7 @@ class UserEvent extends EventEmitter {
     }
 
     const Page = this.crowi.model('Page');
-    const userHomePagePath = `/user/${user.username}`;
+    const userHomePagePath = pagePathUtils.userHomepagePath(user.username);
     // TODO: Delete user arg.
     // see: https://redmine.weseek.co.jp/issues/124326
     let page = await Page.findByPath(userHomePagePath, user);

+ 2 - 2
apps/app/src/server/routes/apiv3/users.js

@@ -1,4 +1,4 @@
-import { ErrorV3 } from '@growi/core';
+import { ErrorV3, pagePathUtils } from '@growi/core';
 
 import { SupportedAction } from '~/interfaces/activity';
 import Activity from '~/server/models/activity';
@@ -790,7 +790,7 @@ module.exports = (crowi) => {
       const user = await User.findById(id);
       // !! DO NOT MOVE userHomePagePath FROM THIS POSITION !! -- 05.31.2023
       // catch username before delete user because username will be change to deleted_at_*
-      const userHomePagePath = `/user/${user.username}`;
+      const userHomePagePath = pagePathUtils.userHomepagePath(user.username);
 
       await UserGroupRelation.remove({ relatedUser: user });
       await user.statusDelete();

+ 2 - 2
packages/ui/src/components/User/UserPicture.tsx

@@ -10,7 +10,7 @@ import type { UncontrolledTooltipProps } from 'reactstrap';
 
 const UncontrolledTooltip = dynamic<UncontrolledTooltipProps>(() => import('reactstrap').then(mod => mod.UncontrolledTooltip), { ssr: false });
 
-const { userPageRoot } = pagePathUtils;
+const { userHomepagePath } = pagePathUtils;
 
 const DEFAULT_IMAGE = '/images/icons/user.svg';
 
@@ -29,7 +29,7 @@ const UserPictureRootWithLink = forwardRef<HTMLSpanElement, UserPictureRootProps
   const router = useRouter();
 
   const { user } = props;
-  const href = userPageRoot(user);
+  const href = userHomepagePath(user.username || '');
 
   const clickHandler = useCallback(() => {
     router.push(href);