Skip to content

Commit b8f0bf1

Browse files
authored
MNTOR-3863 and MNTOR-3840 - Fix user dashboard state for manual removal flag (#5473)
* fix user dashbaord state * fix unit tests * add feature flags to manualremovalview and welcome view * add feature flag to resolution container * add featureflag to monthly activity plus
1 parent d559e17 commit b8f0bf1

File tree

13 files changed

+636
-493
lines changed

13 files changed

+636
-493
lines changed

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/DashboardTopBanner/DashboardTopBannerContent.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ export const DashboardTopBannerContent = (props: DashboardTopBannerProps) => {
8080
);
8181
}
8282

83-
const relevantGuidedStep = getNextGuidedStep(stepDeterminationData);
83+
const relevantGuidedStep = getNextGuidedStep(
84+
stepDeterminationData,
85+
props.enabledFeatureFlags,
86+
);
8487

8588
const contentProps = {
8689
relevantGuidedStep,

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/View.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export const View = (props: Props) => {
198198
const removalTimeEstimate = isScanResult(exposure)
199199
? props.removalTimeEstimates.find(({ d }) => d === exposure.data_broker)
200200
: undefined;
201+
201202
return (
202203
<li key={exposureCardKey} className={styles.exposureListItem}>
203204
<ExposureCard
@@ -253,6 +254,7 @@ export const View = (props: Props) => {
253254
const dataSummary = getDashboardSummary(
254255
adjustedScanResults,
255256
props.userBreaches,
257+
props.enabledFeatureFlags,
256258
);
257259

258260
const hasExposures = combinedArray.length > 0;
@@ -513,6 +515,7 @@ export const View = (props: Props) => {
513515
bannerData={getDashboardSummary(
514516
adjustedScanResults,
515517
props.userBreaches,
518+
props.enabledFeatureFlags,
516519
)}
517520
stepDeterminationData={{
518521
countryCode,

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/ResolutionContainer.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import styles from "./ResolutionContainer.module.scss";
1212
import { ProgressCard } from "../../../../../../../components/client/ProgressCard";
1313
import { StepDeterminationData } from "../../../../../../../functions/server/getRelevantGuidedSteps";
1414
import { getDashboardSummary } from "../../../../../../../functions/server/dashboard";
15+
import { FeatureFlagName } from "../../../../../../../../db/tables/featureFlags";
1516

1617
type ResolutionContainerProps = {
1718
type: "highRisk" | "leakedPasswords" | "securityRecommendations";
@@ -25,6 +26,7 @@ type ResolutionContainerProps = {
2526
data: StepDeterminationData;
2627
label?: string;
2728
cta?: ReactNode;
29+
enabledFeatureFlags: FeatureFlagName[];
2830
};
2931

3032
export const ResolutionContainer = (props: ResolutionContainerProps) => {
@@ -40,6 +42,7 @@ export const ResolutionContainer = (props: ResolutionContainerProps) => {
4042
const resolutionSummary = getDashboardSummary(
4143
props.data.latestScanData?.results ?? [],
4244
props.data.subscriberBreaches,
45+
props.enabledFeatureFlags,
4346
);
4447

4548
return (

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/data-broker-profiles/manual-remove/ManualRemoveView.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ export function ManualRemoveView(props: Props) {
4343
const l10n = useL10n();
4444
const [activeExposureCardKey, setActiveExposureCardKey] = useState(0);
4545

46-
const summary = getDashboardSummary(props.scanData.results, props.breaches);
46+
const summary = getDashboardSummary(
47+
props.scanData.results,
48+
props.breaches,
49+
props.enabledFeatureFlags,
50+
);
4751

4852
const countOfDataBrokerProfiles = props.scanData.results.length;
4953
const estimatedTime = countOfDataBrokerProfiles * 10; // 10 minutes per data broker site.

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/data-broker-profiles/welcome-to-plus/WelcomeToPlusView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ export function WelcomeToPlusView(props: Props) {
3939
const summary = getDashboardSummary(
4040
scanResultsInProgress,
4141
props.data.subscriberBreaches,
42+
props.enabledFeatureFlags,
4243
);
4344
const dataPointReduction = getDataPointReduction(summary);
4445

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/high-risk-data-breaches/HighRiskBreachLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ export function HighRiskBreachLayout(props: HighRiskBreachLayoutProps) {
171171
illustration={illustration}
172172
isPremiumUser={hasPremium(props.data.user)}
173173
isEligibleForPremium={props.isEligibleForPremium}
174+
enabledFeatureFlags={props.enabledFeatureFlags}
174175
cta={
175176
!isStepDone && (
176177
<>

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/leaked-passwords/LeakedPasswordsLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export function LeakedPasswordsLayout(props: LeakedPasswordsLayoutProps) {
198198
title={title}
199199
illustration={illustration}
200200
isPremiumUser={hasPremium(props.data.user)}
201+
enabledFeatureFlags={props.enabledFeatureFlags}
201202
cta={
202203
!isStepDone && (
203204
<>

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/page.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { getScanResultsWithBroker } from "../../../../../../../../db/tables/oner
1515
import { getServerSession } from "../../../../../../../functions/server/getServerSession";
1616
import { refreshStoredScanResults } from "../../../../../../../functions/server/refreshStoredScanResults";
1717
import { hasPremium } from "../../../../../../../functions/universal/user";
18+
import { getEnabledFeatureFlags } from "../../../../../../../../db/tables/featureFlags";
1819

1920
export default async function FixPage() {
2021
const session = await getServerSession();
@@ -31,6 +32,9 @@ export default async function FixPage() {
3132
if (typeof profileId === "number") {
3233
await refreshStoredScanResults(profileId);
3334
}
35+
const enabledFeatureFlags = await getEnabledFeatureFlags({
36+
email: session.user.email,
37+
});
3438

3539
const scanData = await getScanResultsWithBroker(
3640
profileId,
@@ -43,6 +47,9 @@ export default async function FixPage() {
4347
latestScanData: scanData,
4448
};
4549

46-
const nextStep = getNextGuidedStep(stepDeterminationData);
50+
const nextStep = getNextGuidedStep(
51+
stepDeterminationData,
52+
enabledFeatureFlags,
53+
);
4754
redirect(nextStep.href);
4855
}

src/app/(proper_react)/(redesign)/(authenticated)/user/(dashboard)/dashboard/fix/security-recommendations/SecurityRecommendationsLayout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ export function SecurityRecommendationsLayout(
164164
title={title}
165165
illustration={illustration}
166166
isPremiumUser={hasPremium(props.data.user)}
167+
enabledFeatureFlags={props.enabledFeatureFlags}
167168
cta={
168169
!isStepDone && (
169170
<Button

src/app/functions/server/dashboard.ts

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { OnerepScanResultDataBrokerRow } from "knex/types/tables";
66
import { BreachDataTypes } from "../universal/breach";
77
import { RemovalStatusMap } from "../universal/scanResult";
88
import { SubscriberBreach } from "../../../utils/subscriberBreaches";
9+
import { DataBrokerRemovalStatusMap } from "../universal/dataBroker";
10+
import { FeatureFlagName } from "../../../db/tables/featureFlags";
911

1012
export type DataPoints = {
1113
// shared
@@ -96,6 +98,7 @@ export const dataClassKeyMap: Record<keyof DataPoints, string> = {
9698
export function getDashboardSummary(
9799
scannedResults: OnerepScanResultDataBrokerRow[],
98100
subscriberBreaches: SubscriberBreach[],
101+
enabledFeatureFlags?: FeatureFlagName[],
99102
): DashboardSummary {
100103
const summary: DashboardSummary = {
101104
dataBreachTotalNum: 0,
@@ -204,15 +207,22 @@ export function getDashboardSummary(
204207
r.status === RemovalStatusMap.WaitingForVerification) &&
205208
!isManuallyResolved;
206209

207-
// TODO: Waiting for criteria for data brokers under maintenance to be determined
208-
// const isRemovalUnderMaintenance =
209-
// r.broker_status === DataBrokerRemovalStatusMap.RemovalUnderMaintenance;
210+
// TODO: MNTOR-3886 - Remove EnableRemovalUnderMaintenanceStep feature flag
211+
// If the flag is disabled, include the data.
212+
// If the flag is enabled, include the data only if the broker status is not
213+
const isRemovalUnderMaintenance =
214+
r.broker_status === DataBrokerRemovalStatusMap.RemovalUnderMaintenance;
215+
216+
// The condition ensures that removal under maintenance is only considered when the flag is enabled.
217+
/* c8 ignore next 3 */
218+
const countRemovalUnderMaintenanceData =
219+
!enabledFeatureFlags?.includes("EnableRemovalUnderMaintenanceStep") ||
220+
!isRemovalUnderMaintenance;
210221

211222
if (isInProgress) {
212-
// TODO: Waiting for criteria for data brokers under maintenance to be determined
213-
// if (!isRemovalUnderMaintenance) {
214-
summary.dataBrokerInProgressNum++;
215-
// }
223+
if (countRemovalUnderMaintenanceData) {
224+
summary.dataBrokerInProgressNum++;
225+
}
216226
} else if (isAutoFixed) {
217227
summary.dataBrokerAutoFixedNum++;
218228
} else if (isManuallyResolved) {
@@ -234,14 +244,13 @@ export function getDashboardSummary(
234244
summary.allDataPoints.familyMembers += r.relatives.length;
235245

236246
if (isInProgress) {
237-
// TODO: Waiting for criteria for data brokers under maintenance to be determined
238-
// if (!isRemovalUnderMaintenance) {
239-
summary.inProgressDataPoints.emailAddresses += r.emails.length;
240-
summary.inProgressDataPoints.phoneNumbers += r.phones.length;
241-
summary.inProgressDataPoints.addresses += r.addresses.length;
242-
summary.inProgressDataPoints.familyMembers += r.relatives.length;
243-
summary.dataBrokerInProgressDataPointsNum += dataPointsIncrement;
244-
// }
247+
if (countRemovalUnderMaintenanceData) {
248+
summary.inProgressDataPoints.emailAddresses += r.emails.length;
249+
summary.inProgressDataPoints.phoneNumbers += r.phones.length;
250+
summary.inProgressDataPoints.addresses += r.addresses.length;
251+
summary.inProgressDataPoints.familyMembers += r.relatives.length;
252+
summary.dataBrokerInProgressDataPointsNum += dataPointsIncrement;
253+
}
245254
}
246255

247256
// for fixed data points: email, phones, addresses, relatives, full name (1)

0 commit comments

Comments
 (0)