Client: Added toast appearance and role reset to free when invited to a room.
This commit is contained in:
parent
1b4180e8cd
commit
358f0b38f2
@ -331,12 +331,6 @@ const Bar = (props) => {
|
||||
// currentValue: null,
|
||||
// };
|
||||
// }
|
||||
console.log(
|
||||
"isUserTariffAlmostLimit",
|
||||
isUserTariffAlmostLimit,
|
||||
isStorageTariffAlmostLimit,
|
||||
barVisible.storageAndUserTariff,
|
||||
);
|
||||
|
||||
if (
|
||||
isRoomTariffAlmostLimit &&
|
||||
|
@ -53,8 +53,7 @@ import {
|
||||
StyledDescription,
|
||||
} from "../StyledInvitePanel";
|
||||
|
||||
import { getPaidQuotaLimitError } from "SRC_DIR/helpers/filesUtils";
|
||||
|
||||
import { getFreeUsersRoleArray, getFreeUsersTypeArray } from "../utils";
|
||||
|
||||
const ExternalLinks = ({
|
||||
t,
|
||||
@ -208,6 +207,9 @@ const ExternalLinks = ({
|
||||
[closeActionLinks],
|
||||
);
|
||||
|
||||
const availableAccess =
|
||||
roomId === -1 ? getFreeUsersTypeArray() : getFreeUsersRoleArray();
|
||||
|
||||
return (
|
||||
<StyledBlock noPadding ref={inputsRef}>
|
||||
<StyledSubHeader inline>
|
||||
@ -278,6 +280,7 @@ const ExternalLinks = ({
|
||||
isMobileView={isMobileView}
|
||||
isSelectionDisabled={isPaidUserLimit}
|
||||
selectionErrorText={<PaidQuotaLimitError />}
|
||||
availableAccess={availableAccess}
|
||||
/>
|
||||
</StyledInviteInputContainer>
|
||||
)}
|
||||
|
@ -50,7 +50,7 @@ import { isBetaLanguage } from "@docspace/shared/utils";
|
||||
import { checkIfAccessPaid } from "SRC_DIR/helpers";
|
||||
|
||||
import AddUsersPanel from "../../AddUsersPanel";
|
||||
import { getAccessOptions, getTopFreeRole } from "../utils";
|
||||
import { getAccessOptions, getTopFreeRole, isPaidRoleUser } from "../utils";
|
||||
import AccessSelector from "../../../AccessSelector";
|
||||
|
||||
import {
|
||||
@ -151,12 +151,24 @@ const InviteInput = ({
|
||||
});
|
||||
}
|
||||
|
||||
isPaidUserAccess(selectedAccess) && setInvitePaidUsersCount();
|
||||
roomId === -1 &&
|
||||
isPaidUserAccess(selectedAccess) &&
|
||||
setInvitePaidUsersCount();
|
||||
|
||||
let userAccess = selectedAccess;
|
||||
|
||||
if (isPaidUserLimit && roomId !== -1 && isPaidRoleUser(userAccess)) {
|
||||
const freeRole = getTopFreeRole(t, roomType)?.access;
|
||||
if (freeRole) {
|
||||
userAccess = freeRole;
|
||||
toastr.error(<PaidQuotaLimitError />);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
email: addresses[0].email,
|
||||
id: uid(),
|
||||
access: selectedAccess,
|
||||
access: userAccess,
|
||||
displayName: addresses[0].email,
|
||||
errors: addresses[0].parseErrors,
|
||||
isEmailInvite: true,
|
||||
@ -333,6 +345,15 @@ const InviteInput = ({
|
||||
roleName: topFreeRole.label,
|
||||
});
|
||||
}
|
||||
|
||||
if (isPaidUserLimit && isPaidRoleUser(u.access)) {
|
||||
const freeRole = getTopFreeRole(t, roomType)?.access;
|
||||
|
||||
if (freeRole) {
|
||||
u.access = freeRole;
|
||||
toastr.error(<PaidQuotaLimitError />);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const items = [...users, ...inviteItems];
|
||||
|
@ -36,7 +36,13 @@ import { Text } from "@docspace/shared/components/text";
|
||||
import { parseAddresses } from "@docspace/shared/utils";
|
||||
import { getUserTypeLabel } from "@docspace/shared/utils/common";
|
||||
|
||||
import { getAccessOptions } from "../utils";
|
||||
import {
|
||||
getAccessOptions,
|
||||
getFreeUsersRoleArray,
|
||||
getFreeUsersTypeArray,
|
||||
getTopFreeRole,
|
||||
isPaidRoleUser,
|
||||
} from "../utils";
|
||||
import {
|
||||
StyledEditInput,
|
||||
StyledEditButton,
|
||||
@ -50,7 +56,7 @@ import { filterGroupRoleOptions, filterUserRoleOptions } from "SRC_DIR/helpers";
|
||||
import AccessSelector from "../../../AccessSelector";
|
||||
|
||||
import PaidQuotaLimitError from "SRC_DIR/components/PaidQuotaLimitError";
|
||||
import { EmployeeType } from "@docspace/shared/enums";
|
||||
import { EmployeeType, ShareAccessRights } from "@docspace/shared/enums";
|
||||
|
||||
const Item = ({
|
||||
t,
|
||||
@ -81,6 +87,7 @@ const Item = ({
|
||||
isGroup,
|
||||
name: groupName,
|
||||
warning,
|
||||
isVisitor,
|
||||
} = item;
|
||||
|
||||
const name = isGroup
|
||||
@ -200,6 +207,9 @@ const Item = ({
|
||||
|
||||
const textProps = !!avatar || isGroup ? {} : { onClick: onEdit };
|
||||
|
||||
const availableAccess =
|
||||
roomId === -1 ? getFreeUsersTypeArray() : getFreeUsersRoleArray();
|
||||
|
||||
const displayBody = (
|
||||
<>
|
||||
<StyledInviteUserBody>
|
||||
@ -261,10 +271,10 @@ const Item = ({
|
||||
setIsOpenItemAccess={setIsOpenItemAccess}
|
||||
isMobileView={isMobileView}
|
||||
noBorder
|
||||
{...(roomId === -1 && {
|
||||
{...((roomId === -1 || !avatar || isVisitor) && {
|
||||
isSelectionDisabled: isPaidUserLimit,
|
||||
selectionErrorText: <PaidQuotaLimitError />,
|
||||
availableAccess: [EmployeeType.Guest],
|
||||
availableAccess,
|
||||
})}
|
||||
/>
|
||||
</>
|
||||
|
@ -258,3 +258,25 @@ export const getTopFreeRole = (t, roomType) => {
|
||||
);
|
||||
return freeAccesses[0];
|
||||
};
|
||||
|
||||
export const isPaidRoleUser = (selectedAccess) => {
|
||||
return (
|
||||
selectedAccess === ShareAccessRights.FullAccess ||
|
||||
selectedAccess === ShareAccessRights.Collaborator ||
|
||||
selectedAccess === ShareAccessRights.RoomManager
|
||||
);
|
||||
};
|
||||
|
||||
export const getFreeUsersTypeArray = () => {
|
||||
return [EmployeeType.Guest];
|
||||
};
|
||||
|
||||
export const getFreeUsersRoleArray = () => {
|
||||
return [
|
||||
ShareAccessRights.Comment,
|
||||
ShareAccessRights.Editing,
|
||||
ShareAccessRights.FormFilling,
|
||||
ShareAccessRights.ReadOnly,
|
||||
ShareAccessRights.Review,
|
||||
];
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user