Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NV-2601 - Add support in the client for tenant feature #3846

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions apps/web/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,7 @@ export const IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = isCypress
: window._env_.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED ||
process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED ||
'false';

export const IS_MULTI_TENANCY_ENABLED = isCypress
? window._env_.IS_MULTI_TENANCY_ENABLED || process.env.IS_MULTI_TENANCY_ENABLED || 'true'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was not sure if to call it multi-tenancy or just tenant/tenants, naming 🤦‍♂️

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it sounds good

: window._env_.IS_MULTI_TENANCY_ENABLED || process.env.IS_MULTI_TENANCY_ENABLED || 'false';
16 changes: 15 additions & 1 deletion apps/web/src/hooks/useFeatureFlags.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { FeatureFlagsKeysEnum } from '@novu/shared';
import { useFlags } from 'launchdarkly-react-client-sdk';

import { IS_TEMPLATE_STORE_ENABLED, IS_MULTI_PROVIDER_CONFIGURATION_ENABLED } from '../config';
import {
IS_TEMPLATE_STORE_ENABLED,
IS_MULTI_PROVIDER_CONFIGURATION_ENABLED,
IS_MULTI_TENANCY_ENABLED,
} from '../config';

const prepareBooleanStringFeatureFlag = (value: string | undefined, defaultValue: boolean): boolean => {
const preparedValue = value === 'true';
Expand Down Expand Up @@ -36,3 +40,13 @@ export const useIsMultiProviderConfigurationEnabled = (): boolean => {

return isMultiProviderConfigurationEnabled ?? defaultValue;
};

export const useIsMultiTenancyEnabled = (): boolean => {
const value = IS_MULTI_TENANCY_ENABLED;
const fallbackValue = false;
const defaultValue = prepareBooleanStringFeatureFlag(value, fallbackValue);

const isMultiTenancyEnabled = useGetFlagByKey<boolean>(FeatureFlagsKeysEnum.IS_MULTI_TENANCY_ENABLED);

return isMultiTenancyEnabled ?? defaultValue;
};
1 change: 1 addition & 0 deletions libs/shared/src/types/feature-flags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum FeatureFlagsKeysEnum {
IS_TEMPLATE_STORE_ENABLED = 'IS_TEMPLATE_STORE_ENABLED',
IS_TOPIC_NOTIFICATION_ENABLED = 'IS_TOPIC_NOTIFICATION_ENABLED',
IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = 'IS_MULTI_PROVIDER_CONFIGURATION_ENABLED',
IS_MULTI_TENANCY_ENABLED = 'IS_MULTI_TENANCY_ENABLED',
}