Skip to content

Commit

Permalink
linagora#1901 Resolve threads
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane VIEIRA committed Feb 3, 2022
1 parent 3543251 commit d20e22a
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 13 deletions.
2 changes: 1 addition & 1 deletion twake/backend/node/src/services/console/clients/remote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export class ConsoleRemoteClient implements ConsoleServiceClient {
[CompanyFeaturesEnum.CHAT_MULTIPLE_WORKSPACES]: true,
[CompanyFeaturesEnum.CHAT_EDIT_FILES]: true,
[CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]: true,
[CompanyFeaturesEnum.COMPANY_LIMIT_NOT_REACHED]: true,
[CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]: true,
};

if (companyDTO.limits.members < 0 && this.infos.type === "remote") {
Expand Down
2 changes: 1 addition & 1 deletion twake/backend/node/src/services/user/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class Service implements UserServiceAPI {
[CompanyFeaturesEnum.CHAT_MULTIPLE_WORKSPACES]: true,
[CompanyFeaturesEnum.CHAT_EDIT_FILES]: true,
[CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]: true,
[CompanyFeaturesEnum.COMPANY_LIMIT_NOT_REACHED]:
[CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]:
res.plan?.limits[CompanyLimitsEnum.COMPANY_MEMBERS_LIMIT] <= 0 ||
res.stats.total_members < res.plan?.limits[CompanyLimitsEnum.COMPANY_MEMBERS_LIMIT],
},
Expand Down
2 changes: 1 addition & 1 deletion twake/backend/node/src/services/user/web/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ const companyObjectSchema = {
[CompanyFeaturesEnum.CHAT_MESSAGE_HISTORY]: { type: "boolean" },
[CompanyFeaturesEnum.CHAT_MULTIPLE_WORKSPACES]: { type: "boolean" },
[CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]: { type: "boolean" },
[CompanyFeaturesEnum.COMPANY_LIMIT_NOT_REACHED]: { type: "boolean" },
[CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]: { type: "boolean" },
guests: { type: "number" }, // to rename or delete
members: { type: "number" }, // to rename or delete
storage: { type: "number" }, // to rename or delete
Expand Down
4 changes: 2 additions & 2 deletions twake/backend/node/src/services/user/web/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export enum CompanyFeaturesEnum {
CHAT_MULTIPLE_WORKSPACES = "chat:multiple_workspaces",
CHAT_EDIT_FILES = "chat:edit_files",
CHAT_UNLIMITED_STORAGE = "chat:unlimited_storage",
COMPANY_LIMIT_NOT_REACHED = "company:limit_not_reached",
COMPANY_INVITE_MEMBER = "company:invite_member",
}

export type CompanyFeaturesObject = {
Expand All @@ -85,7 +85,7 @@ export type CompanyFeaturesObject = {
[CompanyFeaturesEnum.CHAT_MULTIPLE_WORKSPACES]?: boolean;
[CompanyFeaturesEnum.CHAT_EDIT_FILES]?: boolean;
[CompanyFeaturesEnum.CHAT_UNLIMITED_STORAGE]?: boolean;
[CompanyFeaturesEnum.COMPANY_LIMIT_NOT_REACHED]?: boolean;
[CompanyFeaturesEnum.COMPANY_INVITE_MEMBER]?: boolean;
};

export type CompanyLimitsObject = {
Expand Down
3 changes: 0 additions & 3 deletions twake/backend/node/src/services/workspaces/web/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ const routes: FastifyPluginCallback<{
request: FastifyRequest<{ Params: WorkspaceUsersRequest }>,
) => {
if (!request.currentUser.id) {
// TODO error auth msg
throw fastify.httpErrors.forbidden("You must be authenticated");
}
const companyUser = await options.service.companies.getCompanyUser(
Expand All @@ -132,7 +131,6 @@ const routes: FastifyPluginCallback<{
request: FastifyRequest<{ Params: WorkspaceUsersRequest }>,
) => {
if (!request.currentUser.id) {
// TODO error auth msg
throw fastify.httpErrors.forbidden("You must be authenticated");
}
const workspaceUser = await checkUserWorkspace(request);
Expand All @@ -149,7 +147,6 @@ const routes: FastifyPluginCallback<{
request: FastifyRequest<{ Params: WorkspaceUsersRequest }>,
) => {
if (!request.currentUser.id) {
// TODO error auth msg
throw fastify.httpErrors.forbidden("You must be authenticated");
}
const workspaceUser = await checkUserWorkspace(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export enum FeatureNames {
MULTIPLE_WORKSPACES = 'chat:multiple_workspaces',
EDIT_FILES = 'chat:edit_files',
UNLIMITED_STORAGE = 'chat:unlimited_storage', //Currently inactive
COMPANY_LIMIT_NOT_REACHED = 'company:limit_not_reached',
COMPANY_INVITE_MEMBER = 'company:invite_member',
}

export type FeatureValueType = boolean | number;
Expand All @@ -20,7 +20,7 @@ availableFeaturesWithDefaults.set(FeatureNames.MESSAGE_HISTORY_LIMIT, 10000);
availableFeaturesWithDefaults.set(FeatureNames.MULTIPLE_WORKSPACES, true);
availableFeaturesWithDefaults.set(FeatureNames.EDIT_FILES, true);
availableFeaturesWithDefaults.set(FeatureNames.UNLIMITED_STORAGE, true);
availableFeaturesWithDefaults.set(FeatureNames.COMPANY_LIMIT_NOT_REACHED, true);
availableFeaturesWithDefaults.set(FeatureNames.COMPANY_INVITE_MEMBER, true);

/**
* Service that allow you to manage feature flipping in Twake using react feature toggles
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default (props: PropsType): JSX.Element => {
};

useEffect(() => {
if (!FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_LIMIT_NOT_REACHED))
if (!FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_INVITE_MEMBER))
setDisabled(true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
Expand All @@ -76,7 +76,7 @@ export default (props: PropsType): JSX.Element => {
{Languages.t('scenes.app.workspaces.create_company.invitations.title_2')}{' '}
</Typography.Title>

{!FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_LIMIT_NOT_REACHED) && (
{!FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_INVITE_MEMBER) && (
<div style={{ maxWidth: 328 }}>
<LockedInviteAlert />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default () => {

<Divider />

{!FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_LIMIT_NOT_REACHED) ? (
{!FeatureTogglesService.isActiveFeatureName(FeatureNames.COMPANY_INVITE_MEMBER) ? (
<LockedInviteAlert />
) : (
<></>
Expand Down

0 comments on commit d20e22a

Please sign in to comment.