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

chore(web): Remove multi provider feature flag #4402

Merged
merged 8 commits into from
Oct 25, 2023
225 changes: 0 additions & 225 deletions apps/web/cypress/tests/integration-store.spec.ts

This file was deleted.

1 change: 0 additions & 1 deletion apps/web/cypress/tests/integrations-list-modal.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
Cypress.on('window:before:load', (win) => {
win._cypress = {
...win._cypress,
IS_MULTI_PROVIDER_CONFIGURATION_ENABLED: 'true',
};
win.isDarkTheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
});
Expand Down
1 change: 0 additions & 1 deletion apps/web/cypress/tests/integrations-list-page.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {
Cypress.on('window:before:load', (win) => {
win._cypress = {
...win._cypress,
IS_MULTI_PROVIDER_CONFIGURATION_ENABLED: 'true',
};
win.isDarkTheme = window.matchMedia('(prefers-color-scheme: dark)').matches;
});
Expand Down
9 changes: 0 additions & 9 deletions apps/web/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,6 @@ export const IS_TEMPLATE_STORE_ENABLED = isCypress
? window._env_.IS_TEMPLATE_STORE_ENABLED || process.env.IS_TEMPLATE_STORE_ENABLED || 'true'
: window._env_.IS_TEMPLATE_STORE_ENABLED || process.env.IS_TEMPLATE_STORE_ENABLED || 'false';

export const IS_MULTI_PROVIDER_CONFIGURATION_ENABLED = isCypress
? window._cypress?.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED ||
window._env_.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED ||
process.env.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED ||
'true'
: 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'
: window._env_.IS_MULTI_TENANCY_ENABLED || process.env.IS_MULTI_TENANCY_ENABLED || 'false';
9 changes: 1 addition & 8 deletions apps/web/src/hooks/integrations/useGetPrimaryIntegration.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { ChannelTypeEnum } from '@novu/shared';
import { useMemo } from 'react';
import { useIsMultiProviderConfigurationEnabled } from '../useFeatureFlags';
import { useHasActiveIntegrations } from './useHasActiveIntegrations';

type UseHasPrimaryIntegrationProps = {
Expand All @@ -13,7 +12,6 @@ export function useGetPrimaryIntegration({ filterByEnv = true, channelType }: Us
() => channelType === ChannelTypeEnum.EMAIL || channelType === ChannelTypeEnum.SMS,
[channelType]
);
const isMultiProviderConfigurationEnabled = useIsMultiProviderConfigurationEnabled();

const { activeIntegrationsByEnv, hasActiveIntegration } = useHasActiveIntegrations({
filterByEnv,
Expand All @@ -25,14 +23,9 @@ export function useGetPrimaryIntegration({ filterByEnv = true, channelType }: Us
return undefined;
}

if (!isMultiProviderConfigurationEnabled) {
return activeIntegrationsByEnv?.find((integration) => integration.channel === channelType && integration.active)
?.providerId;
}

return activeIntegrationsByEnv?.find((integration) => integration.primary && integration.channel === channelType)
?.providerId;
}, [isMultiProviderConfigurationEnabled, hasActiveIntegration, activeIntegrationsByEnv, channelType, isPrimaryStep]);
}, [hasActiveIntegration, activeIntegrationsByEnv, channelType, isPrimaryStep]);

return {
primaryIntegration: getPrimaryIntegration,
Expand Down
18 changes: 1 addition & 17 deletions apps/web/src/hooks/useFeatureFlags.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { FeatureFlagsKeysEnum } from '@novu/shared';
import { useFlags } from 'launchdarkly-react-client-sdk';

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

const prepareBooleanStringFeatureFlag = (value: string | undefined, defaultValue: boolean): boolean => {
const preparedValue = value === 'true';
Expand All @@ -29,18 +25,6 @@ export const useIsTemplateStoreEnabled = (): boolean => {
return isTemplateStoreEnabled ?? defaultValue;
};

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

const isMultiProviderConfigurationEnabled = useGetFlagByKey<boolean>(
FeatureFlagsKeysEnum.IS_MULTI_PROVIDER_CONFIGURATION_ENABLED
);

return isMultiProviderConfigurationEnabled ?? defaultValue;
};

export const useIsMultiTenancyEnabled = (): boolean => {
const value = IS_MULTI_TENANCY_ENABLED;
const fallbackValue = false;
Expand Down
7 changes: 1 addition & 6 deletions apps/web/src/pages/integrations/IntegrationsListPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@ import { useNavigate } from 'react-router-dom';
import { Row } from 'react-table';
import { ROUTES } from '../../constants/routes.enum';

import { useIsMultiProviderConfigurationEnabled } from '../../hooks';
import { IntegrationsList } from './IntegrationsList';
import { IntegrationsStore } from './IntegrationsStorePage';
import { ITableIntegration } from './types';

export const IntegrationsListPage = () => {
const navigate = useNavigate();
const isIntegrationsListPageEnabled = useIsMultiProviderConfigurationEnabled();

const onRowClickCallback = useCallback(
(item: Row<ITableIntegration>) => {
Expand All @@ -31,13 +28,11 @@ export const IntegrationsListPage = () => {
[navigate]
);

return isIntegrationsListPageEnabled ? (
return (
<IntegrationsList
onAddProviderClick={onAddProviderClickCallback}
onRowClickCallback={onRowClickCallback}
onChannelClick={onChannelClickCallback}
/>
) : (
<IntegrationsStore />
);
};
Loading