Skip to content

Commit b8f180e

Browse files
authored
Merge pull request #817 from AppQuality/feature-flag
Tagging tootl Feature flag
2 parents f865925 + f027d4b commit b8f180e

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

src/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export const FEATURE_FLAG_EXPRESS = 'exploratory-express';
22
export const FEATURE_FLAG_SKY_JOTFORM = 'sky-custom-jotform';
33
export const FEATURE_FLAG_CATALOG = 'catalog-pages';
4+
export const FEATURE_FLAG_TAGGING_TOOL = 'tagging-tool';
45
export const EXPRESS_1_CAMPAIGN_TYPE_ID = 46;
56
export const EXPRESS_2_CAMPAIGN_TYPE_ID = 51;
67
export const EXPRESS_3_CAMPAIGN_TYPE_ID = 52;

src/pages/Campaign/pageHeader/Meta/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import styled from 'styled-components';
44
import {
55
CampaignWithOutput,
66
useGetCampaignsByCidMetaQuery,
7+
Feature,
78
} from 'src/features/api';
89
import { Link } from 'react-router-dom';
910
import { Pipe } from 'src/common/components/Pipe';
1011
import { useLocalizeRoute } from 'src/hooks/useLocalizedRoute';
12+
import { FEATURE_FLAG_TAGGING_TOOL } from 'src/constants';
13+
import { useAppSelector } from 'src/app/hooks';
1114
import { CampaignStatus } from 'src/types';
1215
import { StatusMeta } from 'src/common/components/meta/StatusMeta';
1316
import { PageMeta } from 'src/common/components/PageMeta';
@@ -64,6 +67,7 @@ export const Metas = ({ campaign }: { campaign: CampaignWithOutput }) => {
6467
} = useGetCampaignsByCidMetaQuery({ cid: campaign.id.toString() });
6568

6669
const { t } = useTranslation();
70+
const { userData } = useAppSelector((state) => state.user);
6771
const functionalDashboardLink = useLocalizeRoute(
6872
`campaigns/${campaign.id}/bugs`
6973
);
@@ -74,6 +78,12 @@ export const Metas = ({ campaign }: { campaign: CampaignWithOutput }) => {
7478

7579
if (isLoading || isFetching) return <Skeleton width="200px" height="20px" />;
7680

81+
const hasTaggingToolFeatureFlag =
82+
userData.features &&
83+
userData.features.find(
84+
(feature: Feature) => feature.slug === FEATURE_FLAG_TAGGING_TOOL
85+
);
86+
7787
return (
7888
<FooterContainer>
7989
<PageMeta>
@@ -101,7 +111,7 @@ export const Metas = ({ campaign }: { campaign: CampaignWithOutput }) => {
101111
</Button>
102112
</Link>
103113
)}
104-
{outputs?.includes('media') && (
114+
{outputs?.includes('media') && hasTaggingToolFeatureFlag && (
105115
<Link to={videoDashboardLink}>
106116
<Button id="button-bugs-list-header" isPrimary isAccent>
107117
{t('__CAMPAIGN_PAGE_BUTTON_DETAIL_VIDEO')}

src/pages/Video/index.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@ import { useLocation, useNavigate, useParams } from 'react-router-dom';
33
import { useGetCampaignWithWorkspaceQuery } from 'src/features/api/customEndpoints/getCampaignWithWorkspace';
44
import { Page } from 'src/features/templates/Page';
55
import { useLocalizeRoute } from 'src/hooks/useLocalizedRoute';
6-
import { useAppDispatch } from 'src/app/hooks';
6+
import { useAppDispatch, useAppSelector } from 'src/app/hooks';
77
import { useCampaignAnalytics } from 'src/hooks/useCampaignAnalytics';
88
import { useEffect } from 'react';
99
import {
1010
setCampaignId,
1111
setPermissionSettingsTitle,
1212
setWorkspace,
1313
} from 'src/features/navigation/navigationSlice';
14+
import { Feature } from 'src/features/api';
15+
import { FEATURE_FLAG_TAGGING_TOOL } from 'src/constants';
1416
import VideoPageContent from './Content';
1517
import VideoPageHeader from './PageHeader';
1618

@@ -21,6 +23,13 @@ const VideoPage = () => {
2123
const { campaignId } = useParams();
2224
const dispatch = useAppDispatch();
2325
const location = useLocation();
26+
const { userData, status } = useAppSelector((state) => state.user);
27+
28+
const hasTaggingToolFeatureFlag =
29+
userData.features &&
30+
userData.features.find(
31+
(feature: Feature) => feature.slug === FEATURE_FLAG_TAGGING_TOOL
32+
);
2433

2534
if (!campaignId || Number.isNaN(Number(campaignId))) {
2635
navigate(notFoundRoute, {
@@ -58,6 +67,17 @@ const VideoPage = () => {
5867
state: { from: location.pathname },
5968
});
6069
}
70+
71+
useEffect(() => {
72+
if (status === 'idle' || status === 'loading') return;
73+
74+
if (!hasTaggingToolFeatureFlag) {
75+
navigate(notFoundRoute, {
76+
state: { from: location.pathname },
77+
});
78+
}
79+
}, [status, hasTaggingToolFeatureFlag]);
80+
6181
return (
6282
<Page
6383
title={t('__VIDEO_PAGE_TITLE')}

src/pages/Videos/index.tsx

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ import { Page } from 'src/features/templates/Page';
22
import { useTranslation } from 'react-i18next';
33
import { useLocation, useNavigate, useParams } from 'react-router-dom';
44
import { useLocalizeRoute } from 'src/hooks/useLocalizedRoute';
5-
import { useAppDispatch } from 'src/app/hooks';
5+
import { useAppDispatch, useAppSelector } from 'src/app/hooks';
66
import { useCampaignAnalytics } from 'src/hooks/useCampaignAnalytics';
77
import { useGetCampaignWithWorkspaceQuery } from 'src/features/api/customEndpoints/getCampaignWithWorkspace';
8+
import { FEATURE_FLAG_TAGGING_TOOL } from 'src/constants';
9+
import { Feature } from 'src/features/api';
810
import {
911
setCampaignId,
1012
setPermissionSettingsTitle,
@@ -22,13 +24,30 @@ const VideosPage = () => {
2224
const { campaignId } = useParams();
2325
const dispatch = useAppDispatch();
2426
const location = useLocation();
27+
const { userData, status } = useAppSelector((state) => state.user);
28+
29+
const hasTaggingToolFeatureFlag =
30+
userData.features &&
31+
userData.features.find(
32+
(feature: Feature) => feature.slug === FEATURE_FLAG_TAGGING_TOOL
33+
);
2534

2635
if (!campaignId || Number.isNaN(Number(campaignId))) {
2736
navigate(notFoundRoute, {
2837
state: { from: location.pathname },
2938
});
3039
}
3140

41+
useEffect(() => {
42+
if (status === 'idle' || status === 'loading') return;
43+
44+
if (!hasTaggingToolFeatureFlag) {
45+
navigate(notFoundRoute, {
46+
state: { from: location.pathname },
47+
});
48+
}
49+
}, [status, hasTaggingToolFeatureFlag]);
50+
3251
useCampaignAnalytics(campaignId);
3352

3453
const { isError: isErrorCampaign, data: { campaign, workspace } = {} } =

0 commit comments

Comments
 (0)