Client: fix import util
This commit is contained in:
parent
70b8c66f24
commit
a8f5f8b261
@ -18,7 +18,7 @@ import {
|
||||
StyledDeleteIcon,
|
||||
StyledInviteUserBody,
|
||||
} from "../StyledInvitePanel";
|
||||
import { filterUserRoleOptions } from "SRC_DIR/helpers/utils";
|
||||
import { filterUserRoleOptions } from "SRC_DIR/helpers";
|
||||
import AccessSelector from "./AccessSelector";
|
||||
|
||||
const Item = ({
|
||||
|
24
packages/client/src/helpers/index.ts
Normal file
24
packages/client/src/helpers/index.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import { TUser } from "@docspace/shared/api/people/types";
|
||||
import { ShareAccessRights } from "@docspace/shared/enums";
|
||||
|
||||
export const filterUserRoleOptions = (
|
||||
options: { access: ShareAccessRights; key: string }[],
|
||||
currentUser: TUser,
|
||||
withRemove = false
|
||||
) => {
|
||||
if (!options) return options;
|
||||
let newOptions = [...options];
|
||||
|
||||
if (currentUser?.isAdmin || currentUser?.isOwner) {
|
||||
newOptions = newOptions.filter(
|
||||
(o) =>
|
||||
+o.access === ShareAccessRights.RoomManager ||
|
||||
+o.access === ShareAccessRights.None ||
|
||||
(withRemove && (o.key === "s2" || o.key === "remove"))
|
||||
);
|
||||
|
||||
return newOptions;
|
||||
}
|
||||
|
||||
return newOptions;
|
||||
};
|
@ -207,25 +207,3 @@ export const getCategoryUrl = (categoryType, folderId = null) => {
|
||||
throw new Error("Unknown category type");
|
||||
}
|
||||
};
|
||||
|
||||
export const filterUserRoleOptions = (
|
||||
options,
|
||||
currentUser,
|
||||
withRemove = false
|
||||
) => {
|
||||
if (!options) return options;
|
||||
let newOptions = [...options];
|
||||
|
||||
if (currentUser?.isAdmin || currentUser?.isOwner) {
|
||||
newOptions = newOptions.filter(
|
||||
(o) =>
|
||||
+o.access === ShareAccessRights.RoomManager ||
|
||||
+o.access === ShareAccessRights.None ||
|
||||
(withRemove && (o.key === "s2" || o.key === "remove"))
|
||||
);
|
||||
|
||||
return newOptions;
|
||||
}
|
||||
|
||||
return newOptions;
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ import DefaultUserPhotoUrl from "PUBLIC_DIR/images/default_user_photo_size_82-82
|
||||
import { toastr } from "@docspace/shared/components/toast";
|
||||
import { isMobileOnly, isMobile } from "react-device-detect";
|
||||
import { decode } from "he";
|
||||
import { filterUserRoleOptions } from "SRC_DIR/helpers/utils";
|
||||
import { filterUserRoleOptions } from "SRC_DIR/helpers";
|
||||
import { capitalize } from "lodash";
|
||||
|
||||
import { getUserRole } from "@docspace/shared/utils/common";
|
||||
|
Loading…
Reference in New Issue
Block a user