Просмотр исходного кода

Replaced IUserGroup with IUserGroupHasObjectId

Taichi Masuyama 4 лет назад
Родитель
Сommit
f9df24b530

+ 4 - 4
packages/app/src/components/Admin/UserGroup/UserGroupDeleteModal.tsx

@@ -6,7 +6,7 @@ import {
 } from 'reactstrap';
 
 import AppContainer from '~/client/services/AppContainer';
-import { IUserGroup } from '~/interfaces/user';
+import { IUserGroupHasObjectId } from '~/interfaces/user';
 import { CustomWindow } from '~/interfaces/global';
 import Xss from '~/services/xss';
 
@@ -21,11 +21,11 @@ type Props = {
   t: TFunction, // i18next
   appContainer: AppContainer,
 
-  userGroups: IUserGroup[],
-  deleteUserGroup?: IUserGroup,
+  userGroups: IUserGroupHasObjectId[],
+  deleteUserGroup?: IUserGroupHasObjectId,
   onDelete?: (deleteGroupId: string, actionName: string, transferToUserGroupId: string) => Promise<void> | void,
   isShow: boolean,
-  onShow?: (group: IUserGroup) => Promise<void> | void,
+  onShow?: (group: IUserGroupHasObjectId) => Promise<void> | void,
   onHide?: () => Promise<void> | void,
 };
 type State = {

+ 4 - 4
packages/app/src/components/Admin/UserGroup/UserGroupPage.tsx

@@ -7,7 +7,7 @@ import UserGroupDeleteModal from './UserGroupDeleteModal';
 import { withUnstatedContainers } from '../../UnstatedUtils';
 import AppContainer from '~/client/services/AppContainer';
 import { toastSuccess, toastError } from '~/client/util/apiNotification';
-import { IUserGroup, IUserGroupRelation } from '~/interfaces/user';
+import { IUserGroupHasObjectId, IUserGroupRelation } from '~/interfaces/user';
 import Xss from '~/services/xss';
 import { CustomWindow } from '~/interfaces/global';
 
@@ -15,9 +15,9 @@ type Props = {
   appContainer: AppContainer,
 };
 type State = {
-  userGroups: IUserGroup[],
+  userGroups: IUserGroupHasObjectId[],
   userGroupRelations: IUserGroupRelation[],
-  selectedUserGroup: IUserGroup | undefined,
+  selectedUserGroup: IUserGroupHasObjectId | undefined,
   isDeleteModalShown: boolean,
 };
 
@@ -49,7 +49,7 @@ class UserGroupPage extends React.Component<Props, State> {
     await this.syncUserGroupAndRelations();
   }
 
-  async showDeleteModal(group: IUserGroup) {
+  async showDeleteModal(group: IUserGroupHasObjectId) {
     try {
       await this.syncUserGroupAndRelations();
 

+ 3 - 1
packages/app/src/interfaces/user.ts

@@ -1,4 +1,5 @@
 import { Ref } from './common';
+import { HasObjectId } from './has-object-id';
 
 export type IUser = {
   name: string;
@@ -14,9 +15,10 @@ export type IUserGroupRelation = {
 }
 
 export type IUserGroup = {
-  _id: string;
   name: string;
   createdAt: Date;
   description: string;
   parent: Ref<IUserGroup>;
 }
+
+export type IUserGroupHasObjectId = IUserGroup & HasObjectId;