Skip to content

Commit

Permalink
chore(dashboard,web): Clean up feature flags (#7365)
Browse files Browse the repository at this point in the history
  • Loading branch information
SokratisVidros authored Dec 27, 2024
1 parent 679ee4c commit d692289
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 202 deletions.
18 changes: 4 additions & 14 deletions apps/dashboard/src/components/side-navigation/free-trial-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { RiArrowRightDoubleLine, RiInformationFill } from 'react-icons/ri';
import { Progress } from '../primitives/progress';
import { Button } from '../primitives/button';
import { Tooltip, TooltipContent, TooltipTrigger, TooltipArrow } from '../primitives/tooltip';
import { LEGACY_ROUTES, ROUTES } from '@/utils/routes';
import { ROUTES } from '@/utils/routes';
import { Link } from 'react-router-dom';
import { useFeatureFlag } from '@/hooks/use-feature-flag';
import { FeatureFlagsKeysEnum, GetSubscriptionDto } from '@novu/shared';
import { GetSubscriptionDto } from '@novu/shared';

const transition = 'transition-all duration-300 ease-out';

Expand Down Expand Up @@ -70,22 +69,13 @@ const CardContent = ({
export const FreeTrialCard = ({ subscription, daysLeft }: { subscription?: GetSubscriptionDto; daysLeft: number }) => {
const daysTotal = subscription && subscription.trial.daysTotal > 0 ? subscription.trial.daysTotal : 100;
const pluralizedDays = pluralizeDaysLeft(daysLeft);
const isV2BillingEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_V2_DASHBOARD_BILLING_ENABLED);

const cardClassName =
'bg-background group relative left-2 mb-2 flex w-[calc(100%-1rem)] cursor-pointer flex-col gap-2 rounded-lg p-3 shadow';

if (isV2BillingEnabled) {
return (
<Link to={ROUTES.SETTINGS_BILLING} className={cardClassName}>
<CardContent pluralizedDays={pluralizedDays} daysTotal={daysTotal} daysLeft={daysLeft} />
</Link>
);
}

return (
<a href={LEGACY_ROUTES.BILLING} className={cardClassName}>
<Link to={ROUTES.SETTINGS_BILLING} className={cardClassName}>
<CardContent pluralizedDays={pluralizedDays} daysTotal={daysTotal} daysLeft={daysLeft} />
</a>
</Link>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ import { useTelemetry } from '@/hooks/use-telemetry';
import { TelemetryEvent } from '@/utils/telemetry';
import { Button } from '../primitives/button';
import { Tooltip, TooltipContent, TooltipTrigger } from '../primitives/tooltip';
import { useFeatureFlag } from '@/hooks/use-feature-flag';
import { FeatureFlagsKeysEnum } from '@novu/shared';

export function GettingStartedMenuItem() {
const { totalSteps, completedSteps, steps } = useOnboardingSteps();
const isGettingStartedEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_NEW_DASHBOARD_GETTING_STARTED_ENABLED);

const { currentEnvironment } = useEnvironment();
const { user } = useUser();
Expand All @@ -41,7 +38,7 @@ export function GettingStartedMenuItem() {
});
};

if (!isGettingStartedEnabled || user?.unsafeMetadata?.hideGettingStarted) {
if (user?.unsafeMetadata?.hideGettingStarted) {
return null;
}

Expand Down
22 changes: 3 additions & 19 deletions apps/dashboard/src/components/side-navigation/side-navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,9 @@ import {
RiUserAddLine,
} from 'react-icons/ri';
import { useEnvironment } from '@/context/environment/hooks';
import { buildRoute, LEGACY_ROUTES, ROUTES } from '@/utils/routes';
import { buildRoute, ROUTES } from '@/utils/routes';
import { TelemetryEvent } from '@/utils/telemetry';
import { useTelemetry } from '@/hooks/use-telemetry';
import { useFeatureFlag } from '@/hooks/use-feature-flag';
import { FeatureFlagsKeysEnum } from '@novu/shared';
import { EnvironmentDropdown } from './environment-dropdown';
import { OrganizationDropdown } from './organization-dropdown';
import { FreeTrialCard } from './free-trial-card';
Expand All @@ -41,8 +39,6 @@ export const SideNavigation = () => {

const { currentEnvironment, environments, switchEnvironment } = useEnvironment();
const track = useTelemetry();
const isNewActivityFeedEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_NEW_DASHBOARD_ACTIVITY_FEED_ENABLED, false);
const isNewIntegrationStoreEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_ND_INTEGRATION_STORE_ENABLED, false);
const environmentNames = useMemo(() => environments?.map((env) => env.name), [environments]);

const onEnvironmentChange = (value: string) => {
Expand Down Expand Up @@ -83,26 +79,14 @@ export const SideNavigation = () => {
</NavigationGroup>
<NavigationGroup label="Monitor">
<NavigationLink
to={
isNewActivityFeedEnabled
? buildRoute(ROUTES.ACTIVITY_FEED, { environmentSlug: currentEnvironment?.slug ?? '' })
: LEGACY_ROUTES.ACTIVITY_FEED
}
isExternal={!isNewActivityFeedEnabled}
to={buildRoute(ROUTES.ACTIVITY_FEED, { environmentSlug: currentEnvironment?.slug ?? '' })}
>
<RiBarChartBoxLine className="size-4" />
<span>Activity Feed</span>
</NavigationLink>
</NavigationGroup>
<NavigationGroup label="Developer">
<NavigationLink
to={
isNewIntegrationStoreEnabled
? buildRoute(ROUTES.INTEGRATIONS, { environmentSlug: currentEnvironment?.slug ?? '' })
: LEGACY_ROUTES.INTEGRATIONS
}
isExternal={!isNewIntegrationStoreEnabled}
>
<NavigationLink to={buildRoute(ROUTES.INTEGRATIONS, { environmentSlug: currentEnvironment?.slug ?? '' })}>
<RiStore3Line className="size-4" />
<span>Integration Store</span>
</NavigationLink>
Expand Down
17 changes: 6 additions & 11 deletions apps/dashboard/src/components/welcome/progress-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@ import { Card, CardContent } from '../primitives/card';
import { RiArrowRightDoubleFill, RiCheckLine, RiLoader3Line } from 'react-icons/ri';
import { useOnboardingSteps, StepIdEnum } from '../../hooks/use-onboarding-steps';
import { Link, useParams } from 'react-router-dom';
import { buildRoute, LEGACY_ROUTES, ROUTES } from '../../utils/routes';
import { buildRoute, ROUTES } from '../../utils/routes';
import { motion } from 'motion/react';
import { mainCard, leftSection, textItem, stepsList, stepItem, logo } from './progress-section.animations';
import { PointingArrow, NovuLogo } from './icons';
import { useTelemetry } from '../../hooks/use-telemetry';
import { TelemetryEvent } from '../../utils/telemetry';
import { useFeatureFlag } from '../../hooks/use-feature-flag';
import { FeatureFlagsKeysEnum } from '@novu/shared';

interface StepItemProps {
step: {
Expand Down Expand Up @@ -45,7 +43,6 @@ export function ProgressSection() {
}

function StepItem({ step, environmentSlug }: StepItemProps) {
const isNewIntegrationStoreEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_ND_INTEGRATION_STORE_ENABLED, false);
const telemetry = useTelemetry();

const handleStepClick = () => {
Expand All @@ -69,8 +66,8 @@ function StepItem({ step, environmentSlug }: StepItemProps) {
</div>

<Link
to={getStepRoute(step.id, environmentSlug, isNewIntegrationStoreEnabled).path}
reloadDocument={getStepRoute(step.id, environmentSlug, isNewIntegrationStoreEnabled).isLegacy}
to={getStepRoute(step.id, environmentSlug).path}
reloadDocument={getStepRoute(step.id, environmentSlug).isLegacy}
className="w-full"
onClick={handleStepClick}
>
Expand Down Expand Up @@ -121,7 +118,7 @@ function WelcomeHeader() {
);
}

function getStepRoute(stepId: StepIdEnum, environmentSlug: string = '', isNewIntegrationStoreEnabled: boolean) {
function getStepRoute(stepId: StepIdEnum, environmentSlug: string = '') {
switch (stepId) {
case StepIdEnum.CREATE_A_WORKFLOW:
return {
Expand All @@ -133,10 +130,8 @@ function getStepRoute(stepId: StepIdEnum, environmentSlug: string = '', isNewInt
case StepIdEnum.CONNECT_CHAT_PROVIDER:
case StepIdEnum.CONNECT_SMS_PROVIDER:
return {
path: isNewIntegrationStoreEnabled
? buildRoute(ROUTES.INTEGRATIONS, { environmentSlug })
: LEGACY_ROUTES.INTEGRATIONS,
isLegacy: !isNewIntegrationStoreEnabled,
path: buildRoute(ROUTES.INTEGRATIONS, { environmentSlug }),
isLegacy: false,
};
case StepIdEnum.CONNECT_IN_APP_PROVIDER:
return {
Expand Down
40 changes: 6 additions & 34 deletions apps/dashboard/src/components/workflow-editor/add-step-menu.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { useFeatureFlag } from '@/hooks/use-feature-flag';
import { STEP_TYPE_TO_COLOR } from '@/utils/color';
import { StepTypeEnum } from '@/utils/enums';
import { cn } from '@/utils/ui';
import { FeatureFlagsKeysEnum } from '@novu/shared';
import { PopoverPortal } from '@radix-ui/react-popover';
import React, { ReactNode, useState } from 'react';
import { RiAddLine } from 'react-icons/ri';
Expand Down Expand Up @@ -77,8 +75,6 @@ export const AddStepMenu = ({
onMenuItemClick: (stepType: StepTypeEnum) => void;
}) => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const areNewStepsEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_ND_DELAY_DIGEST_EMAIL_ENABLED);
const arePushChatSMSEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_ND_SMS_CHAT_PUSH_ENABLED);

const handleMenuItemClick = (stepType: StepTypeEnum) => {
onMenuItemClick(stepType);
Expand Down Expand Up @@ -110,11 +106,7 @@ export const AddStepMenu = ({
<MenuGroup>
<MenuTitle>Channels</MenuTitle>
<MenuItemsGroup>
<MenuItem
stepType={StepTypeEnum.EMAIL}
disabled={!areNewStepsEnabled}
onClick={() => handleMenuItemClick(StepTypeEnum.EMAIL)}
>
<MenuItem stepType={StepTypeEnum.EMAIL} onClick={() => handleMenuItemClick(StepTypeEnum.EMAIL)}>
Email
</MenuItem>
<MenuItem
Expand All @@ -124,44 +116,24 @@ export const AddStepMenu = ({
>
In-App
</MenuItem>
<MenuItem
stepType={StepTypeEnum.PUSH}
disabled={!arePushChatSMSEnabled}
onClick={() => handleMenuItemClick(StepTypeEnum.PUSH)}
>
<MenuItem stepType={StepTypeEnum.PUSH} onClick={() => handleMenuItemClick(StepTypeEnum.PUSH)}>
Push
</MenuItem>
<MenuItem
stepType={StepTypeEnum.CHAT}
disabled={!arePushChatSMSEnabled}
onClick={() => handleMenuItemClick(StepTypeEnum.CHAT)}
>
<MenuItem stepType={StepTypeEnum.CHAT} onClick={() => handleMenuItemClick(StepTypeEnum.CHAT)}>
Chat
</MenuItem>
<MenuItem
stepType={StepTypeEnum.SMS}
disabled={!arePushChatSMSEnabled}
onClick={() => handleMenuItemClick(StepTypeEnum.SMS)}
>
<MenuItem stepType={StepTypeEnum.SMS} onClick={() => handleMenuItemClick(StepTypeEnum.SMS)}>
SMS
</MenuItem>
</MenuItemsGroup>
</MenuGroup>
<MenuGroup>
<MenuTitle>Actions</MenuTitle>
<MenuItemsGroup>
<MenuItem
stepType={StepTypeEnum.DELAY}
disabled={!areNewStepsEnabled}
onClick={() => handleMenuItemClick(StepTypeEnum.DELAY)}
>
<MenuItem stepType={StepTypeEnum.DELAY} onClick={() => handleMenuItemClick(StepTypeEnum.DELAY)}>
Delay
</MenuItem>
<MenuItem
stepType={StepTypeEnum.DIGEST}
disabled={!areNewStepsEnabled}
onClick={() => handleMenuItemClick(StepTypeEnum.DIGEST)}
>
<MenuItem stepType={StepTypeEnum.DIGEST} onClick={() => handleMenuItemClick(StepTypeEnum.DIGEST)}>
Digest
</MenuItem>
</MenuItemsGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import {
FeatureFlagsKeysEnum,
IEnvironment,
StepDataDto,
StepTypeEnum,
Expand Down Expand Up @@ -37,7 +36,6 @@ import { ConfigureInAppStepPreview } from '@/components/workflow-editor/steps/in
import { SaveFormContext } from '@/components/workflow-editor/steps/save-form-context';
import { SdkBanner } from '@/components/workflow-editor/steps/sdk-banner';
import { ConfigureSmsStepPreview } from '@/components/workflow-editor/steps/sms/configure-sms-step-preview';
import { useFeatureFlag } from '@/hooks/use-feature-flag';
import { useFormAutosave } from '@/hooks/use-form-autosave';
import {
AUTOCOMPLETE_PASSWORD_MANAGERS_OFF,
Expand Down Expand Up @@ -85,21 +83,17 @@ export const ConfigureStepForm = (props: ConfigureStepFormProps) => {
const { step, workflow, update, environment } = props;
const navigate = useNavigate();
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState(false);
const areNewStepsEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_ND_DELAY_DIGEST_EMAIL_ENABLED);

// we allow some form of configuration in the dashboard
let supportedStepTypes = [
const supportedStepTypes = [
StepTypeEnum.IN_APP,
StepTypeEnum.SMS,
StepTypeEnum.CHAT,
StepTypeEnum.PUSH,
StepTypeEnum.EMAIL,
StepTypeEnum.DIGEST,
StepTypeEnum.DELAY,
];

if (areNewStepsEnabled) {
supportedStepTypes = [...supportedStepTypes, StepTypeEnum.DIGEST, StepTypeEnum.DELAY];
}

const isSupportedStep = supportedStepTypes.includes(step.type);
const isReadOnly = !isSupportedStep || workflow.origin === WorkflowOriginEnum.EXTERNAL;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ import { RiPlayCircleLine } from 'react-icons/ri';
// eslint-disable-next-line
// @ts-ignore
import { TestWorkflowLogsSidebar } from './test-workflow-logs-sidebar';
import { useFeatureFlag } from '@/hooks/use-feature-flag';
import { createMockObjectFromSchema, FeatureFlagsKeysEnum } from '@novu/shared';
import { createMockObjectFromSchema } from '@novu/shared';
import { ToastClose, ToastIcon } from '@/components/primitives/sonner';
import { useFetchWorkflow } from '@/hooks/use-fetch-workflow';
import { useTriggerWorkflow } from '@/hooks/use-trigger-workflow';
import { buildRoute, LEGACY_ROUTES, ROUTES } from '@/utils/routes';
import { buildRoute, ROUTES } from '@/utils/routes';
import { zodResolver } from '@hookform/resolvers/zod';
import { type WorkflowTestDataResponseDto } from '@novu/shared';
import { toast } from 'sonner';
Expand All @@ -28,7 +27,6 @@ export const TestWorkflowTabs = ({ testData }: { testData?: WorkflowTestDataResp
workflowSlug,
});
const [transactionId, setTransactionId] = useState<string>();
const isNewActivityFeedEnabled = useFeatureFlag(FeatureFlagsKeysEnum.IS_NEW_DASHBOARD_ACTIVITY_FEED_ENABLED);
const to = useMemo(() => createMockObjectFromSchema(testData?.to ?? {}), [testData]);
const payload = useMemo(() => createMockObjectFromSchema(testData?.payload ?? {}), [testData]);
const form = useForm<TestWorkflowFormType>({
Expand Down Expand Up @@ -67,34 +65,6 @@ export const TestWorkflowTabs = ({ testData }: { testData?: WorkflowTestDataResp
});
}
setTransactionId(newTransactionId);

if (!isNewActivityFeedEnabled) {
showToast({
variant: 'lg',
children: ({ close }) => (
<>
<ToastIcon variant="success" />
<div className="flex flex-col gap-2">
<span className="font-medium">Test workflow succeeded</span>
<span className="text-foreground-600 inline">
Workflow <span className="font-bold">{workflow?.name}</span> was triggered successfully.
</span>
<Link
to={`${LEGACY_ROUTES.ACTIVITY_FEED}?transactionId=${transactionId}`}
reloadDocument
className="text-primary text-sm font-medium"
>
View activity feed
</Link>
</div>
<ToastClose onClick={close} />
</>
),
options: {
position: 'bottom-right',
},
});
}
} catch (e) {
toast.error('Failed to trigger workflow', {
description: e instanceof Error ? e.message : 'There was an error triggering the workflow.',
Expand Down Expand Up @@ -139,7 +109,7 @@ export const TestWorkflowTabs = ({ testData }: { testData?: WorkflowTestDataResp
<TestWorkflowForm workflow={workflow} />
</TabsContent>
</Tabs>
{isNewActivityFeedEnabled && <TestWorkflowLogsSidebar transactionId={transactionId} />}
<TestWorkflowLogsSidebar transactionId={transactionId} />
</form>
</Form>
</div>
Expand Down
Loading

0 comments on commit d692289

Please sign in to comment.