diff --git a/frontend/src/component/project/Project/ProjectEnterpriseSettingsForm/CollaborationModeTooltip.tsx b/frontend/src/component/project/Project/ProjectEnterpriseSettingsForm/CollaborationModeTooltip.tsx index 659ba8cdb1..fa11d1355e 100644 --- a/frontend/src/component/project/Project/ProjectEnterpriseSettingsForm/CollaborationModeTooltip.tsx +++ b/frontend/src/component/project/Project/ProjectEnterpriseSettingsForm/CollaborationModeTooltip.tsx @@ -14,7 +14,6 @@ const StyledDescription = styled(Typography)(({ theme }) => ({ })); export const CollaborationModeTooltip: FC = () => { - const privateProjects = useUiFlag('privateProjects'); return ( { requests - - private: - - Only admins, editors and project members can - see and access the project and associated - feature toggles - - - } - /> + + private: + + Only admins, editors and project members can see and + access the project and associated feature toggles + + } /> diff --git a/frontend/src/component/project/Project/ProjectEnterpriseSettingsForm/ProjectEnterpriseSettingsForm.tsx b/frontend/src/component/project/Project/ProjectEnterpriseSettingsForm/ProjectEnterpriseSettingsForm.tsx index 41f54c664d..8e73730e90 100644 --- a/frontend/src/component/project/Project/ProjectEnterpriseSettingsForm/ProjectEnterpriseSettingsForm.tsx +++ b/frontend/src/component/project/Project/ProjectEnterpriseSettingsForm/ProjectEnterpriseSettingsForm.tsx @@ -133,23 +133,15 @@ const ProjectEnterpriseSettingsForm: React.FC = setFeatureNamingDescription, setProjectMode, errors, - clearErrors, }) => { - const privateProjects = useUiFlag('privateProjects'); - const { setPreviousPattern, trackPattern } = useFeatureNamePatternTracking(); - const projectModeOptions = privateProjects - ? [ - { key: 'open', label: 'open' }, - { key: 'protected', label: 'protected' }, - { key: 'private', label: 'private' }, - ] - : [ - { key: 'open', label: 'open' }, - { key: 'protected', label: 'protected' }, - ]; + const projectModeOptions = [ + { key: 'open', label: 'open' }, + { key: 'protected', label: 'protected' }, + { key: 'private', label: 'private' }, + ]; useEffect(() => { setPreviousPattern(featureNamingPattern || ''); diff --git a/frontend/src/component/project/Project/ProjectForm/ProjectForm.tsx b/frontend/src/component/project/Project/ProjectForm/ProjectForm.tsx index 3e1f513894..010e968560 100644 --- a/frontend/src/component/project/Project/ProjectForm/ProjectForm.tsx +++ b/frontend/src/component/project/Project/ProjectForm/ProjectForm.tsx @@ -103,18 +103,12 @@ const ProjectForm: React.FC = ({ clearErrors, }) => { const { isEnterprise } = useUiConfig(); - const privateProjects = useUiFlag('privateProjects'); - const projectModeOptions = privateProjects - ? [ - { key: 'open', label: 'open' }, - { key: 'protected', label: 'protected' }, - { key: 'private', label: 'private' }, - ] - : [ - { key: 'open', label: 'open' }, - { key: 'protected', label: 'protected' }, - ]; + const projectModeOptions = [ + { key: 'open', label: 'open' }, + { key: 'protected', label: 'protected' }, + { key: 'private', label: 'private' }, + ]; return ( { const features = await this.featureToggleStore.getArchivedFeatures(); - if (this.flagResolver.isEnabled('privateProjects')) { - const projectAccess = - await this.privateProjectChecker.getUserAccessibleProjects( - userId, - ); - if (projectAccess.mode === 'all') { - return features; - } else { - return features.filter((f) => - projectAccess.projects.includes(f.project), - ); - } + const projectAccess = + await this.privateProjectChecker.getUserAccessibleProjects(userId); + if (projectAccess.mode === 'all') { + return features; + } else { + return features.filter((f) => + projectAccess.projects.includes(f.project), + ); } - return features; } async getArchivedFeaturesByProjectId( diff --git a/src/lib/features/playground/advanced-playground.test.ts b/src/lib/features/playground/advanced-playground.test.ts index 61ad62343e..0e0be020c3 100644 --- a/src/lib/features/playground/advanced-playground.test.ts +++ b/src/lib/features/playground/advanced-playground.test.ts @@ -19,7 +19,6 @@ beforeAll(async () => { advancedPlayground: true, strictSchemaValidation: true, strategyVariant: true, - privateProjects: true, }, }, }, diff --git a/src/lib/features/playground/playground-service.ts b/src/lib/features/playground/playground-service.ts index 23ab10d74a..3aa7035fd0 100644 --- a/src/lib/features/playground/playground-service.ts +++ b/src/lib/features/playground/playground-service.ts @@ -102,20 +102,17 @@ export class PlaygroundService { const segments = await this.segmentService.getActive(); let filteredProjects: typeof projects = projects; - if (this.flagResolver.isEnabled('privateProjects')) { - const projectAccess = - await this.privateProjectChecker.getUserAccessibleProjects( - userId, - ); - if (projectAccess.mode === 'all') { - filteredProjects = projects; - } else if (projects === ALL) { - filteredProjects = projectAccess.projects; - } else { - filteredProjects = projects.filter((project) => - projectAccess.projects.includes(project), - ); - } + + const projectAccess = + await this.privateProjectChecker.getUserAccessibleProjects(userId); + if (projectAccess.mode === 'all') { + filteredProjects = projects; + } else if (projects === ALL) { + filteredProjects = projectAccess.projects; + } else { + filteredProjects = projects.filter((project) => + projectAccess.projects.includes(project), + ); } const environmentFeatures = await Promise.all( diff --git a/src/lib/features/private-project/fakePrivateProjectChecker.ts b/src/lib/features/private-project/fakePrivateProjectChecker.ts index b483d2d117..26ee234633 100644 --- a/src/lib/features/private-project/fakePrivateProjectChecker.ts +++ b/src/lib/features/private-project/fakePrivateProjectChecker.ts @@ -1,10 +1,10 @@ import { IPrivateProjectChecker } from './privateProjectCheckerType'; -import { ProjectAccess } from './privateProjectStore'; +import { ALL_PROJECT_ACCESS, ProjectAccess } from './privateProjectStore'; export class FakePrivateProjectChecker implements IPrivateProjectChecker { // eslint-disable-next-line @typescript-eslint/no-unused-vars async getUserAccessibleProjects(userId: number): Promise { - throw new Error('Method not implemented.'); + return ALL_PROJECT_ACCESS; } // eslint-disable-next-line @typescript-eslint/no-unused-vars diff --git a/src/lib/services/client-metrics/instance-service.ts b/src/lib/services/client-metrics/instance-service.ts index c350afb7c8..3d152636a0 100644 --- a/src/lib/services/client-metrics/instance-service.ts +++ b/src/lib/services/client-metrics/instance-service.ts @@ -160,29 +160,24 @@ export default class ClientInstanceService { ): Promise { const applications = await this.clientApplicationsStore.getAppsForStrategy(query); - if (this.flagResolver.isEnabled('privateProjects')) { - const accessibleProjects = - await this.privateProjectChecker.getUserAccessibleProjects( - userId, - ); - if (accessibleProjects.mode === 'all') { - return applications; - } else { - return applications.map((application) => { - return { - ...application, - usage: application.usage?.filter( - (usageItem) => - usageItem.project === ALL_PROJECTS || - accessibleProjects.projects.includes( - usageItem.project, - ), - ), - }; - }); - } + const accessibleProjects = + await this.privateProjectChecker.getUserAccessibleProjects(userId); + if (accessibleProjects.mode === 'all') { + return applications; + } else { + return applications.map((application) => { + return { + ...application, + usage: application.usage?.filter( + (usageItem) => + usageItem.project === ALL_PROJECTS || + accessibleProjects.projects.includes( + usageItem.project, + ), + ), + }; + }); } - return applications; } async getApplication(appName: string): Promise { diff --git a/src/lib/services/context-service.ts b/src/lib/services/context-service.ts index 81c2e26539..2e59ec0787 100644 --- a/src/lib/services/context-service.ts +++ b/src/lib/services/context-service.ts @@ -75,24 +75,17 @@ class ContextService { ): Promise { const strategies = await this.featureStrategiesStore.getStrategiesByContextField(name); - if (this.flagResolver.isEnabled('privateProjects')) { - const accessibleProjects = - await this.privateProjectChecker.getUserAccessibleProjects( - userId, - ); - if (accessibleProjects.mode === 'all') { - return this.mapStrategies(strategies); - } else { - return this.mapStrategies( - strategies.filter((strategy) => - accessibleProjects.projects.includes( - strategy.projectId, - ), - ), - ); - } + const accessibleProjects = + await this.privateProjectChecker.getUserAccessibleProjects(userId); + if (accessibleProjects.mode === 'all') { + return this.mapStrategies(strategies); + } else { + return this.mapStrategies( + strategies.filter((strategy) => + accessibleProjects.projects.includes(strategy.projectId), + ), + ); } - return this.mapStrategies(strategies); } private mapStrategies(strategies: IFeatureStrategy[]) { diff --git a/src/lib/services/project-service.ts b/src/lib/services/project-service.ts index 59b323ebdb..e0901af9aa 100644 --- a/src/lib/services/project-service.ts +++ b/src/lib/services/project-service.ts @@ -180,7 +180,7 @@ export default class ProjectService { userId, ); - if (this.flagResolver.isEnabled('privateProjects') && userId) { + if (userId) { const projectAccess = await this.privateProjectChecker.getUserAccessibleProjects( userId, diff --git a/src/lib/services/segment-service.ts b/src/lib/services/segment-service.ts index f4c8441174..fbdaad146c 100644 --- a/src/lib/services/segment-service.ts +++ b/src/lib/services/segment-service.ts @@ -96,24 +96,19 @@ export class SegmentService implements ISegmentService { userId: number, ): Promise { const allStrategies = await this.getAllStrategies(id); - if (this.flagResolver.isEnabled('privateProjects')) { - const accessibleProjects = - await this.privateProjectChecker.getUserAccessibleProjects( - userId, - ); - if (accessibleProjects.mode === 'all') { - return allStrategies; - } else { - const filter = (strategy) => - accessibleProjects.projects.includes(strategy.projectId); - return { - strategies: allStrategies.strategies.filter(filter), - changeRequestStrategies: - allStrategies.changeRequestStrategies.filter(filter), - }; - } + const accessibleProjects = + await this.privateProjectChecker.getUserAccessibleProjects(userId); + if (accessibleProjects.mode === 'all') { + return allStrategies; + } else { + const filter = (strategy) => + accessibleProjects.projects.includes(strategy.projectId); + return { + strategies: allStrategies.strategies.filter(filter), + changeRequestStrategies: + allStrategies.changeRequestStrategies.filter(filter), + }; } - return allStrategies; } async getAllStrategies(id: number): Promise { diff --git a/src/lib/types/experimental.ts b/src/lib/types/experimental.ts index d0eebbe791..a607bf5d3d 100644 --- a/src/lib/types/experimental.ts +++ b/src/lib/types/experimental.ts @@ -23,7 +23,6 @@ export type IFlagKey = | 'advancedPlayground' | 'filterInvalidClientMetrics' | 'customRootRolesKillSwitch' - | 'privateProjects' | 'disableMetrics' | 'featureSearchAPI' | 'featureSearchFrontend' @@ -112,10 +111,6 @@ const flags: IFlags = { process.env.UNLEASH_EXPERIMENTAL_CUSTOM_ROOT_ROLES_KILL_SWITCH, false, ), - privateProjects: parseEnvVarBoolean( - process.env.UNLEASH_EXPERIMENTAL_PRIVATE_PROJECTS, - false, - ), disableMetrics: parseEnvVarBoolean( process.env.UNLEASH_EXPERIMENTAL_DISABLE_METRICS, false, diff --git a/src/server-dev.ts b/src/server-dev.ts index 0cd709ac33..745c894eec 100644 --- a/src/server-dev.ts +++ b/src/server-dev.ts @@ -40,7 +40,6 @@ process.nextTick(async () => { embedProxyFrontend: true, anonymiseEventLog: false, responseTimeWithAppNameKillSwitch: false, - privateProjects: true, featureSearchAPI: true, featureSearchFrontend: true, stripClientHeadersOn304: true, diff --git a/src/test/e2e/api/admin/context.e2e.test.ts b/src/test/e2e/api/admin/context.e2e.test.ts index 1122520998..95b630e910 100644 --- a/src/test/e2e/api/admin/context.e2e.test.ts +++ b/src/test/e2e/api/admin/context.e2e.test.ts @@ -10,13 +10,17 @@ let app: IUnleashTest; beforeAll(async () => { db = await dbInit('context_api_serial', getLogger); - app = await setupAppWithCustomConfig(db.stores, { - experimental: { - flags: { - strictSchemaValidation: true, + app = await setupAppWithCustomConfig( + db.stores, + { + experimental: { + flags: { + strictSchemaValidation: true, + }, }, }, - }); + db.rawDatabase, + ); }); afterAll(async () => { diff --git a/src/test/e2e/api/admin/metrics.e2e.test.ts b/src/test/e2e/api/admin/metrics.e2e.test.ts index 29346ba4ef..1e0b2cad86 100644 --- a/src/test/e2e/api/admin/metrics.e2e.test.ts +++ b/src/test/e2e/api/admin/metrics.e2e.test.ts @@ -10,7 +10,7 @@ let db: ITestDb; beforeAll(async () => { db = await dbInit('metrics_serial', getLogger, {}); - app = await setupAppWithCustomConfig(db.stores, {}); + app = await setupAppWithCustomConfig(db.stores, {}, db.rawDatabase); }); beforeEach(async () => { diff --git a/src/test/e2e/services/project-service.e2e.test.ts b/src/test/e2e/services/project-service.e2e.test.ts index 9058923d41..e6dd1c6ff1 100644 --- a/src/test/e2e/services/project-service.e2e.test.ts +++ b/src/test/e2e/services/project-service.e2e.test.ts @@ -61,9 +61,6 @@ beforeAll(async () => { }); const config = createTestConfig({ getLogger, - experimental: { - flags: { privateProjects: true }, - }, }); eventService = new EventService(stores, config); accessService = createAccessService(db.rawDatabase, config);