2
0
Эх сурвалжийг харах

refs 125405: remove external-user-group-ddetail route

Futa Arai 2 жил өмнө
parent
commit
4f5c9f61ef

+ 2 - 4
apps/app/src/components/Admin/UserGroup/UserGroupTable.tsx

@@ -127,8 +127,6 @@ export const UserGroupTable: FC<Props> = ({
     onDelete(userGroup);
     onDelete(userGroup);
   };
   };
 
 
-  const groupDetailPageName = isExternalGroup ? 'external-user-group-detail' : 'user-group-detail';
-
   /*
   /*
    * useEffect
    * useEffect
    */
    */
@@ -160,7 +158,7 @@ export const UserGroupTable: FC<Props> = ({
               <tr key={group._id}>
               <tr key={group._id}>
                 {isAclEnabled
                 {isAclEnabled
                   ? (
                   ? (
-                    <td><a href={`/admin/${groupDetailPageName}/${group._id}`}>{group.name}</a></td>
+                    <td><a href={`/admin/user-group-detail/${group._id}?isExternalGroup=${isExternalGroup}`}>{group.name}</a></td>
                   )
                   )
                   : (
                   : (
                     <td>{group.name}</td>
                     <td>{group.name}</td>
@@ -181,7 +179,7 @@ export const UserGroupTable: FC<Props> = ({
                         <li key={group._id} className="list-inline-item badge badge-success">
                         <li key={group._id} className="list-inline-item badge badge-success">
                           {isAclEnabled
                           {isAclEnabled
                             ? (
                             ? (
-                              <a href={`/admin/${groupDetailPageName}/${group._id}`}>{group.name}</a>
+                              <a href={`/admin/user-group-detail/${group._id}?isExternalGroup=${isExternalGroup}`}>{group.name}</a>
                             )
                             )
                             : (
                             : (
                               <p>{group.name}</p>
                               <p>{group.name}</p>

+ 6 - 1
apps/app/src/features/external-user-group/client/components/ExternalUserGroupDetail/ExternalUserGroupDetail.tsx

@@ -155,7 +155,12 @@ const ExternalUserGroupDetailPage = (props: Props): JSX.Element => {
                 { ancestorExternalUserGroup._id === currentExternalUserGroupId ? (
                 { ancestorExternalUserGroup._id === currentExternalUserGroupId ? (
                   <span>{ancestorExternalUserGroup.name}</span>
                   <span>{ancestorExternalUserGroup.name}</span>
                 ) : (
                 ) : (
-                  <Link href={`/admin/external-user-group-detail/${ancestorExternalUserGroup._id}`} prefetch={false}>
+                  <Link
+                    href={{
+                      pathname: `/admin/user-group-detail/${ancestorExternalUserGroup._id}`,
+                      query: { isExternalGroup: 'true' },
+                    }}
+                    prefetch={false}>
                     {ancestorExternalUserGroup.name}
                     {ancestorExternalUserGroup.name}
                   </Link>
                   </Link>
                 ) }
                 ) }

+ 1 - 1
apps/app/src/features/external-user-group/client/stores/external-user-group.ts

@@ -64,7 +64,7 @@ export const useSWRxExternalUserGroupRelationList = (
   );
   );
 };
 };
 
 
-export const useSWRxAncestorExternalUserGroups = (groupId: string | undefined): SWRResponse<IExternalUserGroupHasId[], Error> => {
+export const useSWRxAncestorExternalUserGroups = (groupId?: string): SWRResponse<IExternalUserGroupHasId[], Error> => {
   return useSWRImmutable(
   return useSWRImmutable(
     groupId != null ? ['/external-user-groups/ancestors', groupId] : null,
     groupId != null ? ['/external-user-groups/ancestors', groupId] : null,
     ([endpoint, groupId]) => apiv3Get(endpoint, { groupId }).then(result => result.data.ancestorExternalUserGroups),
     ([endpoint, groupId]) => apiv3Get(endpoint, { groupId }).then(result => result.data.ancestorExternalUserGroups),

+ 0 - 61
apps/app/src/pages/admin/external-user-group-detail/[externalUserGroupId].page.tsx

@@ -1,61 +0,0 @@
-import {
-  NextPage, GetServerSideProps, GetServerSidePropsContext,
-} from 'next';
-import { useTranslation } from 'next-i18next';
-import dynamic from 'next/dynamic';
-import Head from 'next/head';
-import { useRouter } from 'next/router';
-
-import ExternalUserGroupDetailPage from '~/features/external-user-group/client/components/ExternalUserGroupDetail/ExternalUserGroupDetail';
-import { CrowiRequest } from '~/interfaces/crowi-request';
-import { CommonProps, generateCustomTitle } from '~/pages/utils/commons';
-import { useIsAclEnabled, useCurrentUser } from '~/stores/context';
-import { useIsMaintenanceMode } from '~/stores/maintenanceMode';
-
-import { retrieveServerSideProps } from '../../../utils/admin-page-util';
-
-const AdminLayout = dynamic(() => import('~/components/Layout/AdminLayout'), { ssr: false });
-
-type Props = CommonProps & {
-  isAclEnabled: boolean
-}
-
-const AdminExternalUserGroupDetailPage: NextPage<Props> = (props: Props) => {
-  const { t } = useTranslation('admin');
-  useIsMaintenanceMode(props.isMaintenanceMode);
-  useCurrentUser(props.currentUser ?? null);
-  const router = useRouter();
-  const { externalUserGroupId } = router.query;
-
-  const title = t('user_group_management.user_group_management');
-  const customTitle = generateCustomTitle(props, title);
-
-  const currentExternalUserGroupId = Array.isArray(externalUserGroupId) ? externalUserGroupId[0] : externalUserGroupId;
-
-  useIsAclEnabled(props.isAclEnabled);
-
-  return (
-    <AdminLayout componentTitle={title}>
-      <Head>
-        <title>{customTitle}</title>
-      </Head>
-      {
-        currentExternalUserGroupId != null && router.isReady
-      && <ExternalUserGroupDetailPage externalUserGroupId={currentExternalUserGroupId} />
-      }
-    </AdminLayout>
-  );
-};
-
-const injectServerConfigurations = async(context: GetServerSidePropsContext, props: Props): Promise<void> => {
-  const req: CrowiRequest = context.req as CrowiRequest;
-  props.isAclEnabled = req.crowi.aclService.isAclEnabled();
-};
-
-export const getServerSideProps: GetServerSideProps = async(context: GetServerSidePropsContext) => {
-  const props = await retrieveServerSideProps(context, injectServerConfigurations);
-
-  return props;
-};
-
-export default AdminExternalUserGroupDetailPage;

+ 7 - 2
apps/app/src/pages/admin/user-group-detail/[userGroupId].page.tsx

@@ -6,6 +6,7 @@ import dynamic from 'next/dynamic';
 import Head from 'next/head';
 import Head from 'next/head';
 import { useRouter } from 'next/router';
 import { useRouter } from 'next/router';
 
 
+import ExternalUserGroupDetailPage from '~/features/external-user-group/client/components/ExternalUserGroupDetail/ExternalUserGroupDetail';
 import { CrowiRequest } from '~/interfaces/crowi-request';
 import { CrowiRequest } from '~/interfaces/crowi-request';
 import { CommonProps, generateCustomTitle } from '~/pages/utils/commons';
 import { CommonProps, generateCustomTitle } from '~/pages/utils/commons';
 import { useIsAclEnabled, useCurrentUser } from '~/stores/context';
 import { useIsAclEnabled, useCurrentUser } from '~/stores/context';
@@ -25,13 +26,15 @@ const AdminUserGroupDetailPage: NextPage<Props> = (props: Props) => {
   useIsMaintenanceMode(props.isMaintenanceMode);
   useIsMaintenanceMode(props.isMaintenanceMode);
   useCurrentUser(props.currentUser ?? null);
   useCurrentUser(props.currentUser ?? null);
   const router = useRouter();
   const router = useRouter();
-  const { userGroupId } = router.query;
+  const { userGroupId, isExternalGroup } = router.query;
 
 
   const title = t('user_group_management.user_group_management');
   const title = t('user_group_management.user_group_management');
   const customTitle = generateCustomTitle(props, title);
   const customTitle = generateCustomTitle(props, title);
 
 
   const currentUserGroupId = Array.isArray(userGroupId) ? userGroupId[0] : userGroupId;
   const currentUserGroupId = Array.isArray(userGroupId) ? userGroupId[0] : userGroupId;
 
 
+  const isExternalGroupBool = isExternalGroup === 'true';
+
   useIsAclEnabled(props.isAclEnabled);
   useIsAclEnabled(props.isAclEnabled);
 
 
   return (
   return (
@@ -41,7 +44,9 @@ const AdminUserGroupDetailPage: NextPage<Props> = (props: Props) => {
       </Head>
       </Head>
       {
       {
         currentUserGroupId != null && router.isReady
         currentUserGroupId != null && router.isReady
-      && <UserGroupDetailPage userGroupId={currentUserGroupId} />
+      && (isExternalGroupBool
+        ? <ExternalUserGroupDetailPage externalUserGroupId={currentUserGroupId}/>
+        : <UserGroupDetailPage userGroupId={currentUserGroupId} />)
       }
       }
     </AdminLayout>
     </AdminLayout>
   );
   );