2023-11-28 11:38:03 +00:00
|
|
|
import AccessEditReactSvgUrl from "PUBLIC_DIR/images/access.edit.react.svg?url";
|
2023-11-29 21:10:48 +00:00
|
|
|
import AccessReviewReactSvgUrl from "PUBLIC_DIR/images/access.review.react.svg?url";
|
2023-11-28 11:38:03 +00:00
|
|
|
import CustomFilterReactSvgUrl from "PUBLIC_DIR/images/custom.filter.react.svg?url";
|
|
|
|
import AccessCommentReactSvgUrl from "PUBLIC_DIR/images/access.comment.react.svg?url";
|
|
|
|
import EyeReactSvgUrl from "PUBLIC_DIR/images/eye.react.svg?url";
|
|
|
|
import EyeOffReactSvgUrl from "PUBLIC_DIR/images/eye.off.react.svg?url";
|
|
|
|
import RemoveReactSvgUrl from "PUBLIC_DIR/images/remove.react.svg?url";
|
|
|
|
|
2024-02-13 07:10:31 +00:00
|
|
|
import { ShareAccessRights } from "../../enums";
|
|
|
|
import { TTranslation } from "../../types";
|
|
|
|
import { TAvailableExternalRights } from "../../api/files/types";
|
|
|
|
import { TOption } from "../combobox";
|
|
|
|
|
|
|
|
export const getShareOptions = (t: TTranslation) => {
|
2023-11-28 11:38:03 +00:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
internal: false,
|
|
|
|
key: "anyone",
|
2024-02-13 00:42:10 +00:00
|
|
|
label: t("Common:AnyoneWithLink"),
|
2023-11-28 11:38:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
internal: true,
|
|
|
|
key: "users",
|
2024-03-07 16:07:06 +00:00
|
|
|
label: t("Common:SpaceUsersOnly"),
|
2023-11-28 11:38:03 +00:00
|
|
|
},
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2024-02-13 07:10:31 +00:00
|
|
|
export const getAccessOptions = (
|
|
|
|
t: TTranslation,
|
|
|
|
available: TAvailableExternalRights,
|
|
|
|
) => {
|
2023-11-29 21:10:48 +00:00
|
|
|
const accessOptions = [
|
|
|
|
available.Editing && {
|
2023-11-29 01:30:15 +00:00
|
|
|
access: ShareAccessRights.Editing,
|
2023-11-28 11:38:03 +00:00
|
|
|
key: "editing",
|
2024-02-13 00:42:10 +00:00
|
|
|
label: t("Common:Editing"),
|
2023-11-28 11:38:03 +00:00
|
|
|
icon: AccessEditReactSvgUrl,
|
|
|
|
},
|
2023-11-29 21:10:48 +00:00
|
|
|
available.CustomFilter && {
|
2023-11-29 01:30:15 +00:00
|
|
|
access: ShareAccessRights.CustomFilter,
|
2023-11-28 11:38:03 +00:00
|
|
|
key: "custom-filter",
|
2024-02-13 00:42:10 +00:00
|
|
|
label: t("Common:CustomFilter"),
|
2023-11-28 11:38:03 +00:00
|
|
|
icon: CustomFilterReactSvgUrl,
|
|
|
|
},
|
2024-03-11 11:48:07 +00:00
|
|
|
available.Review && {
|
|
|
|
access: ShareAccessRights.Review,
|
|
|
|
key: "review",
|
|
|
|
label: t("Common:Review"),
|
|
|
|
icon: AccessReviewReactSvgUrl,
|
|
|
|
},
|
2023-11-29 21:10:48 +00:00
|
|
|
available.Comment && {
|
2023-11-29 01:30:15 +00:00
|
|
|
access: ShareAccessRights.Comment,
|
2023-11-28 11:38:03 +00:00
|
|
|
key: "commenting",
|
2024-02-13 00:42:10 +00:00
|
|
|
label: t("Common:Comment"),
|
2023-11-28 11:38:03 +00:00
|
|
|
icon: AccessCommentReactSvgUrl,
|
|
|
|
},
|
2023-11-29 21:10:48 +00:00
|
|
|
available.Read && {
|
2023-11-29 01:30:15 +00:00
|
|
|
access: ShareAccessRights.ReadOnly,
|
2023-11-28 11:38:03 +00:00
|
|
|
key: "viewing",
|
2024-02-26 09:06:12 +00:00
|
|
|
label: t("Common:ReadOnly"),
|
2023-11-28 11:38:03 +00:00
|
|
|
icon: EyeReactSvgUrl,
|
|
|
|
},
|
2023-11-29 21:10:48 +00:00
|
|
|
available.Restrict && {
|
2023-11-29 01:30:15 +00:00
|
|
|
access: ShareAccessRights.DenyAccess,
|
2023-11-28 11:38:03 +00:00
|
|
|
key: "deny-access",
|
2024-02-13 00:42:10 +00:00
|
|
|
label: t("Common:DenyAccess"),
|
2023-11-28 11:38:03 +00:00
|
|
|
icon: EyeOffReactSvgUrl,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "separator",
|
|
|
|
isSeparator: true,
|
|
|
|
},
|
2023-11-29 21:10:48 +00:00
|
|
|
available.None && {
|
2023-11-29 01:30:15 +00:00
|
|
|
access: ShareAccessRights.None,
|
2023-11-28 11:38:03 +00:00
|
|
|
key: "remove",
|
2024-02-13 00:42:10 +00:00
|
|
|
label: t("Common:Remove"),
|
2023-11-28 11:38:03 +00:00
|
|
|
icon: RemoveReactSvgUrl,
|
|
|
|
},
|
|
|
|
];
|
2023-11-29 21:10:48 +00:00
|
|
|
|
2024-02-13 07:10:31 +00:00
|
|
|
const items: TOption[] = [];
|
|
|
|
|
|
|
|
accessOptions.forEach((item) => {
|
|
|
|
if (item) return items.push(item as TOption);
|
|
|
|
});
|
|
|
|
|
|
|
|
return items;
|
2023-11-28 11:38:03 +00:00
|
|
|
};
|
|
|
|
|
2023-11-29 01:30:15 +00:00
|
|
|
export const getExpiredOptions = (
|
2024-02-13 07:10:31 +00:00
|
|
|
t: TTranslation,
|
|
|
|
setTwelveHours: VoidFunction,
|
|
|
|
setOneDay: VoidFunction,
|
|
|
|
setSevenDays: VoidFunction,
|
|
|
|
setUnlimited: VoidFunction,
|
|
|
|
onCalendarOpen: VoidFunction,
|
2023-11-29 01:30:15 +00:00
|
|
|
) => {
|
2023-11-28 11:38:03 +00:00
|
|
|
return [
|
2023-11-29 01:30:15 +00:00
|
|
|
{
|
|
|
|
key: "twelvehours",
|
|
|
|
label: `12 ${t("Common:Hours")}`,
|
|
|
|
onClick: () => setTwelveHours(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "oneday",
|
|
|
|
label: `1 ${t("Common:Day")}`,
|
|
|
|
onClick: () => setOneDay(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "sevendays",
|
|
|
|
label: `7 ${t("Common:Days")}`,
|
|
|
|
onClick: () => setSevenDays(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "unlimited",
|
|
|
|
label: t("Common:Unlimited"),
|
|
|
|
onClick: () => setUnlimited(),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
key: "custom",
|
2024-02-13 00:42:10 +00:00
|
|
|
label: t("Common:Custom"),
|
2023-11-29 01:30:15 +00:00
|
|
|
onClick: () => onCalendarOpen(),
|
|
|
|
},
|
2023-11-28 11:38:03 +00:00
|
|
|
];
|
|
|
|
};
|