Skip to content

Commit

Permalink
chore: remove private projects flag (#5743)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjaanus authored Jan 2, 2024
1 parent 049c5b9 commit dc0df23
Show file tree
Hide file tree
Showing 18 changed files with 89 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const StyledDescription = styled(Typography)(({ theme }) => ({
}));

export const CollaborationModeTooltip: FC = () => {
const privateProjects = useUiFlag('privateProjects');
return (
<HelpIcon
htmlTooltip
Expand All @@ -33,19 +32,13 @@ export const CollaborationModeTooltip: FC = () => {
requests
</StyledDescription>
</Box>
<ConditionallyRender
condition={Boolean(privateProjects)}
show={
<Box sx={{ mt: 2 }}>
<StyledTitle>private: </StyledTitle>
<StyledDescription>
Only admins, editors and project members can
see and access the project and associated
feature toggles
</StyledDescription>
</Box>
}
/>
<Box sx={{ mt: 2 }}>
<StyledTitle>private: </StyledTitle>
<StyledDescription>
Only admins, editors and project members can see and
access the project and associated feature toggles
</StyledDescription>
</Box>
</>
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,23 +133,15 @@ const ProjectEnterpriseSettingsForm: React.FC<IProjectEnterpriseSettingsForm> =
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 || '');
Expand Down
16 changes: 5 additions & 11 deletions frontend/src/component/project/Project/ProjectForm/ProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,12 @@ const ProjectForm: React.FC<IProjectForm> = ({
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 (
<StyledForm
Expand Down
1 change: 0 additions & 1 deletion frontend/src/interfaces/uiConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export type UiFlags = {
customRootRolesKillSwitch?: boolean;
strategyVariant?: boolean;
doraMetrics?: boolean;
privateProjects?: boolean;
dependentFeatures?: boolean;
scheduledConfigurationChanges?: boolean;
featureSearchAPI?: boolean;
Expand Down
1 change: 0 additions & 1 deletion src/lib/__snapshots__/create-config.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ exports[`should create default config 1`] = `
"migrationLock": true,
"newStrategyConfiguration": false,
"personalAccessTokensKillSwitch": false,
"privateProjects": false,
"proPlanAutoCharge": false,
"responseTimeWithAppNameKillSwitch": false,
"scheduledConfigurationChanges": false,
Expand Down
23 changes: 9 additions & 14 deletions src/lib/features/feature-toggle/feature-toggle-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ class FeatureToggleService {
archived,
);

if (this.flagResolver.isEnabled('privateProjects') && userId) {
if (userId) {
const projectAccess =
await this.privateProjectChecker.getUserAccessibleProjects(
userId,
Expand Down Expand Up @@ -2053,20 +2053,15 @@ class FeatureToggleService {
): Promise<FeatureToggle[]> {
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(
Expand Down
1 change: 0 additions & 1 deletion src/lib/features/playground/advanced-playground.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ beforeAll(async () => {
advancedPlayground: true,
strictSchemaValidation: true,
strategyVariant: true,
privateProjects: true,
},
},
},
Expand Down
25 changes: 11 additions & 14 deletions src/lib/features/playground/playground-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/lib/features/private-project/fakePrivateProjectChecker.ts
Original file line number Diff line number Diff line change
@@ -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<ProjectAccess> {
throw new Error('Method not implemented.');
return ALL_PROJECT_ACCESS;
}

// eslint-disable-next-line @typescript-eslint/no-unused-vars
Expand Down
39 changes: 17 additions & 22 deletions src/lib/services/client-metrics/instance-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,29 +160,24 @@ export default class ClientInstanceService {
): Promise<IClientApplication[]> {
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<IApplication> {
Expand Down
27 changes: 10 additions & 17 deletions src/lib/services/context-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,24 +75,17 @@ class ContextService {
): Promise<ContextFieldStrategiesSchema> {
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[]) {
Expand Down
2 changes: 1 addition & 1 deletion src/lib/services/project-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export default class ProjectService {
userId,
);

if (this.flagResolver.isEnabled('privateProjects') && userId) {
if (userId) {
const projectAccess =
await this.privateProjectChecker.getUserAccessibleProjects(
userId,
Expand Down
29 changes: 12 additions & 17 deletions src/lib/services/segment-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,24 +96,19 @@ export class SegmentService implements ISegmentService {
userId: number,
): Promise<StrategiesUsingSegment> {
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<StrategiesUsingSegment> {
Expand Down
5 changes: 0 additions & 5 deletions src/lib/types/experimental.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export type IFlagKey =
| 'advancedPlayground'
| 'filterInvalidClientMetrics'
| 'customRootRolesKillSwitch'
| 'privateProjects'
| 'disableMetrics'
| 'featureSearchAPI'
| 'featureSearchFrontend'
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/server-dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ process.nextTick(async () => {
embedProxyFrontend: true,
anonymiseEventLog: false,
responseTimeWithAppNameKillSwitch: false,
privateProjects: true,
featureSearchAPI: true,
featureSearchFrontend: true,
stripClientHeadersOn304: true,
Expand Down
14 changes: 9 additions & 5 deletions src/test/e2e/api/admin/context.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/api/admin/metrics.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
3 changes: 0 additions & 3 deletions src/test/e2e/services/project-service.e2e.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ beforeAll(async () => {
});
const config = createTestConfig({
getLogger,
experimental: {
flags: { privateProjects: true },
},
});
eventService = new EventService(stores, config);
accessService = createAccessService(db.rawDatabase, config);
Expand Down

0 comments on commit dc0df23

Please sign in to comment.