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

Remove Feature Flag on Calendar #5288

Merged
merged 2 commits into from
May 3, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { DropdownMenu } from '@/ui/layout/dropdown/components/DropdownMenu';
import { DropdownMenuItemsContainer } from '@/ui/layout/dropdown/components/DropdownMenuItemsContainer';
import { useDropdown } from '@/ui/layout/dropdown/hooks/useDropdown';
import { MenuItem } from '@/ui/navigation/menu-item/components/MenuItem';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';

type SettingsAccountsRowDropdownMenuProps = {
account: ConnectedAccount;
Expand All @@ -39,8 +38,6 @@ export const SettingsAccountsRowDropdownMenu = ({

const { triggerGoogleApisOAuth } = useTriggerGoogleApisOAuth();

const isCalendarEnabled = useIsFeatureEnabled('IS_CALENDAR_ENABLED');

return (
<Dropdown
dropdownId={dropdownId}
Expand All @@ -63,18 +60,16 @@ export const SettingsAccountsRowDropdownMenu = ({
closeDropdown();
}}
/>
{isCalendarEnabled && (
<MenuItem
LeftIcon={IconCalendarEvent}
text="Calendar settings"
onClick={() => {
navigate(
`/settings/accounts/calendars/${account.calendarChannels[0].id}`,
);
closeDropdown();
}}
/>
)}
<MenuItem
LeftIcon={IconCalendarEvent}
text="Calendar settings"
onClick={() => {
navigate(
`/settings/accounts/calendars/${account.calendarChannels[0].id}`,
);
closeDropdown();
}}
/>
{account.authFailedAt && (
<MenuItem
LeftIcon={IconRefresh}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { getSettingsPagePath } from '@/settings/utils/getSettingsPagePath';
import { SettingsPath } from '@/types/SettingsPath';
import { H2Title } from '@/ui/display/typography/components/H2Title';
import { Section } from '@/ui/layout/section/components/Section';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';

const StyledCardsContainer = styled.div`
display: flex;
Expand All @@ -17,7 +16,6 @@ const StyledCardsContainer = styled.div`

export const SettingsAccountsSettingsSection = () => {
const navigate = useNavigate();
const isCalendarEnabled = useIsFeatureEnabled('IS_CALENDAR_ENABLED');

return (
<Section>
Expand All @@ -38,7 +36,6 @@ export const SettingsAccountsSettingsSection = () => {
<SettingsNavigationCard
Icon={IconCalendarEvent}
title="Calendar"
soon={!isCalendarEnabled}
onClick={() =>
navigate(getSettingsPagePath(SettingsPath.AccountsCalendars))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { NavigationDrawerItem } from '@/ui/navigation/navigation-drawer/componen
import { NavigationDrawerItemGroup } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerItemGroup';
import { NavigationDrawerSection } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSection';
import { NavigationDrawerSectionTitle } from '@/ui/navigation/navigation-drawer/components/NavigationDrawerSectionTitle';
import { useIsFeatureEnabled } from '@/workspace/hooks/useIsFeatureEnabled';

export const SettingsNavigationDrawerItems = () => {
const navigate = useNavigate();
Expand All @@ -36,7 +35,6 @@ export const SettingsNavigationDrawerItems = () => {
navigate(AppPath.SignInUp);
}, [signOut, navigate]);

const isCalendarEnabled = useIsFeatureEnabled('IS_CALENDAR_ENABLED');
const billing = useRecoilValue(billingState);

return (
Expand Down Expand Up @@ -73,7 +71,6 @@ export const SettingsNavigationDrawerItems = () => {
path={SettingsPath.AccountsCalendars}
Icon={IconCalendarEvent}
matchSubPages
soon={!isCalendarEnabled}
/>
</NavigationDrawerItemGroup>
</NavigationDrawerSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,10 @@ export const ShowPageRightContainer = ({
const activeTabId = useRecoilValue(activeTabIdState);

const shouldDisplayCalendarTab =
useIsFeatureEnabled('IS_CALENDAR_ENABLED') &&
(targetableObject.targetObjectNameSingular ===
targetableObject.targetObjectNameSingular ===
CoreObjectNameSingular.Company ||
targetableObject.targetObjectNameSingular ===
CoreObjectNameSingular.Person);
targetableObject.targetObjectNameSingular === CoreObjectNameSingular.Person;

const shouldDisplayLogTab = useIsFeatureEnabled('IS_EVENT_OBJECT_ENABLED');

const shouldDisplayEmailsTab =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export type FeatureFlagKey =
| 'IS_BLOCKLIST_ENABLED'
| 'IS_CALENDAR_ENABLED'
| 'IS_QUICK_ACTIONS_ENABLED'
| 'IS_EVENT_OBJECT_ENABLED'
| 'IS_AIRTABLE_INTEGRATION_ENABLED'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ export const seedFeatureFlags = async (
workspaceId: workspaceId,
value: true,
},
{
key: FeatureFlagKeys.IsCalendarEnabled,
workspaceId: workspaceId,
value: true,
},
{
key: FeatureFlagKeys.IsAirtableIntegrationEnabled,
workspaceId: workspaceId,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
Injectable,
CanActivate,
NotFoundException,
ExecutionContext,
} from '@nestjs/common';
import { Injectable, CanActivate, NotFoundException } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';

import { Repository } from 'typeorm';
Expand All @@ -13,12 +8,8 @@ import {
GoogleAPIScopeConfig,
GoogleAPIsStrategy,
} from 'src/engine/core-modules/auth/strategies/google-apis.auth.strategy';
import {
FeatureFlagEntity,
FeatureFlagKeys,
} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
import { getRequest } from 'src/utils/extract-request';

@Injectable()
export class GoogleAPIsProviderEnabledGuard implements CanActivate {
Expand All @@ -29,33 +20,20 @@ export class GoogleAPIsProviderEnabledGuard implements CanActivate {
private readonly featureFlagRepository: Repository<FeatureFlagEntity>,
) {}

async canActivate(context: ExecutionContext): Promise<boolean> {
async canActivate(): Promise<boolean> {
if (
!this.environmentService.get('MESSAGING_PROVIDER_GMAIL_ENABLED') &&
!this.environmentService.get('CALENDAR_PROVIDER_GOOGLE_ENABLED')
) {
throw new NotFoundException('Google apis auth is not enabled');
}

const transientToken = getRequest(context)?.query?.transientToken;

const scopeConfig: GoogleAPIScopeConfig = {
isCalendarEnabled: false,
isCalendarEnabled: !!this.environmentService.get(
'MESSAGING_PROVIDER_GMAIL_ENABLED',
),
};

if (transientToken && typeof transientToken === 'string') {
const { workspaceId } =
await this.tokenService.verifyTransientToken(transientToken);

const isCalendarEnabledFlag = await this.featureFlagRepository.findOneBy({
workspaceId,
key: FeatureFlagKeys.IsCalendarEnabled,
value: true,
});

scopeConfig.isCalendarEnabled = !!isCalendarEnabledFlag?.value;
}

new GoogleAPIsStrategy(this.environmentService, scopeConfig);

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { Repository, EntityManager } from 'typeorm';
import { v4 } from 'uuid';

import { TypeORMService } from 'src/database/typeorm/typeorm.service';
import {
FeatureFlagEntity,
FeatureFlagKeys,
} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { EnvironmentService } from 'src/engine/integrations/environment/environment.service';
import { MessageQueue } from 'src/engine/integrations/message-queue/message-queue.constants';
import { MessageQueueService } from 'src/engine/integrations/message-queue/services/message-queue.service';
Expand Down Expand Up @@ -76,15 +73,9 @@ export class GoogleAPIsService {
const workspaceDataSource =
await this.typeORMService.connectToDataSource(dataSourceMetadata);

const isCalendarEnabledFlag = await this.featureFlagRepository.findOneBy({
workspaceId,
key: FeatureFlagKeys.IsCalendarEnabled,
value: true,
});

const isCalendarEnabled =
this.environmentService.get('CALENDAR_PROVIDER_GOOGLE_ENABLED') &&
!!isCalendarEnabledFlag?.value;
const isCalendarEnabled = this.environmentService.get(
'CALENDAR_PROVIDER_GOOGLE_ENABLED',
);

const connectedAccounts =
await this.connectedAccountRepository.getAllByHandleAndWorkspaceMemberId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import { UUIDScalarType } from 'src/engine/api/graphql/workspace-schema-builder/

export enum FeatureFlagKeys {
IsBlocklistEnabled = 'IS_BLOCKLIST_ENABLED',
IsCalendarEnabled = 'IS_CALENDAR_ENABLED',
IsEventObjectEnabled = 'IS_EVENT_OBJECT_ENABLED',
IsAirtableIntegrationEnabled = 'IS_AIRTABLE_INTEGRATION_ENABLED',
IsPostgreSQLIntegrationEnabled = 'IS_POSTGRESQL_INTEGRATION_ENABLED',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ export class AddStandardIdCommand extends CommandRunner {
},
{
IS_BLOCKLIST_ENABLED: true,
IS_CALENDAR_ENABLED: true,
IS_EVENT_OBJECT_ENABLED: true,
IS_AIRTABLE_INTEGRATION_ENABLED: true,
IS_POSTGRESQL_INTEGRATION_ENABLED: true,
Expand All @@ -69,7 +68,6 @@ export class AddStandardIdCommand extends CommandRunner {
},
{
IS_BLOCKLIST_ENABLED: true,
IS_CALENDAR_ENABLED: true,
IS_EVENT_OBJECT_ENABLED: true,
IS_AIRTABLE_INTEGRATION_ENABLED: true,
IS_POSTGRESQL_INTEGRATION_ENABLED: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { Repository } from 'typeorm';

import { MessageQueueJob } from 'src/engine/integrations/message-queue/interfaces/message-queue-job.interface';

import {
FeatureFlagEntity,
FeatureFlagKeys,
} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { CalendarEventParticipantService } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.service';
import { MessageParticipantService } from 'src/modules/messaging/services/message-participant/message-participant.service';

Expand Down Expand Up @@ -40,16 +37,6 @@ export class MatchParticipantJob
workspaceMemberId,
);

const isCalendarEnabled = await this.featureFlagRepository.findOneBy({
workspaceId,
key: FeatureFlagKeys.IsCalendarEnabled,
value: true,
});

if (!isCalendarEnabled || !isCalendarEnabled.value) {
return;
}

await this.calendarEventParticipantService.matchCalendarEventParticipants(
workspaceId,
email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { Repository } from 'typeorm';

import { MessageQueueJob } from 'src/engine/integrations/message-queue/interfaces/message-queue-job.interface';

import {
FeatureFlagEntity,
FeatureFlagKeys,
} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { CalendarEventParticipantService } from 'src/modules/calendar/services/calendar-event-participant/calendar-event-participant.service';
import { MessageParticipantService } from 'src/modules/messaging/services/message-participant/message-participant.service';

Expand Down Expand Up @@ -40,16 +37,6 @@ export class UnmatchParticipantJob
workspaceMemberId,
);

const isCalendarEnabled = await this.featureFlagRepository.findOneBy({
workspaceId,
key: FeatureFlagKeys.IsCalendarEnabled,
value: true,
});

if (!isCalendarEnabled || !isCalendarEnabled.value) {
return;
}

await this.calendarEventParticipantService.unmatchCalendarEventParticipants(
workspaceId,
email,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ import { Repository, In } from 'typeorm';

import { MessageQueueJob } from 'src/engine/integrations/message-queue/interfaces/message-queue-job.interface';

import {
FeatureFlagEntity,
FeatureFlagKeys,
} from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { FeatureFlagEntity } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { Workspace } from 'src/engine/core-modules/workspace/workspace.entity';
import { DataSourceEntity } from 'src/engine/metadata-modules/data-source/data-source.entity';
import { WorkspaceGoogleCalendarSyncService } from 'src/modules/calendar/services/workspace-google-calendar-sync/workspace-google-calendar-sync.service';
Expand Down Expand Up @@ -39,20 +36,9 @@ export class GoogleCalendarSyncCronJob implements MessageQueueJob<undefined> {
})
).map((workspace) => workspace.id);

const workspacesWithFeatureFlagActive =
await this.featureFlagRepository.find({
where: {
workspaceId: In(workspaceIds),
key: FeatureFlagKeys.IsCalendarEnabled,
value: true,
},
});

const dataSources = await this.dataSourceRepository.find({
where: {
workspaceId: In(
workspacesWithFeatureFlagActive.map((w) => w.workspaceId),
),
workspaceId: In(workspaceIds),
},
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { Relation } from 'src/engine/workspace-manager/workspace-sync-metadata/interfaces/relation.interface';

import { FeatureFlagKeys } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { CALENDAR_CHANNEL_EVENT_ASSOCIATION_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
import { FieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/gate.decorator';
import { IsSystem } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/object-metadata.decorator';
import { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
Expand All @@ -22,9 +20,6 @@ import { IsNotAuditLogged } from 'src/engine/workspace-manager/workspace-sync-me
})
@IsSystem()
@IsNotAuditLogged()
@Gate({
featureFlag: FeatureFlagKeys.IsCalendarEnabled,
})
export class CalendarChannelEventAssociationObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({
standardId:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import {
RelationMetadataType,
RelationOnDeleteAction,
} from 'src/engine/metadata-modules/relation-metadata/relation-metadata.entity';
import { FeatureFlagKeys } from 'src/engine/core-modules/feature-flag/feature-flag.entity';
import { FieldMetadataType } from 'src/engine/metadata-modules/field-metadata/field-metadata.entity';
import { CALENDAR_CHANNEL_STANDARD_FIELD_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-field-ids';
import { STANDARD_OBJECT_IDS } from 'src/engine/workspace-manager/workspace-sync-metadata/constants/standard-object-ids';
import { FieldMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/field-metadata.decorator';
import { Gate } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/gate.decorator';
import { IsSystem } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/is-system.decorator';
import { ObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/decorators/object-metadata.decorator';
import { BaseObjectMetadata } from 'src/engine/workspace-manager/workspace-sync-metadata/standard-objects/base.object-metadata';
Expand All @@ -33,9 +31,6 @@ export enum CalendarChannelVisibility {
})
@IsSystem()
@IsNotAuditLogged()
@Gate({
featureFlag: FeatureFlagKeys.IsCalendarEnabled,
})
export class CalendarChannelObjectMetadata extends BaseObjectMetadata {
@FieldMetadata({
standardId: CALENDAR_CHANNEL_STANDARD_FIELD_IDS.connectedAccount,
Expand Down
Loading
Loading