Skip to content

Commit 0492cef

Browse files
committed
extract Project.isPrebuildsEnabled
1 parent d70fc8d commit 0492cef

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

components/dashboard/src/projects/ProjectSettings.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,7 @@ export default function ProjectSettingsView() {
123123
// TODO: Render a generic error screen for when an entity isn't found
124124
if (!project) return null;
125125

126-
const enablePrebuilds =
127-
!!project.settings?.enablePrebuilds ||
128-
// TODO(at): out of scope for now, but once we've migrated the settings of existings projects
129-
// we can remove the implicit enablement here
130-
!project.settings;
126+
const enablePrebuilds = Project.isPrebuildsEnabled(project);
131127

132128
return (
133129
<ProjectSettingsPage project={project}>

components/gitpod-protocol/src/teams-projects-protocol.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,25 @@ export namespace Project {
5555
return p.name + "-" + p.id;
5656
}
5757

58+
/**
59+
* If *no settings* are present on pre-existing projects, this defaults to `true` (enabled) for
60+
* backwards compatibility. This allows to do any explicit migration of data or adjustment of
61+
* the default behavior at a later point in time.
62+
*
63+
* Otherwise this returns the value of the `enablePrebuilds` settings persisted in the given
64+
* project.
65+
*/
66+
export function isPrebuildsEnabled(project: Project): boolean {
67+
// Defaulting to `true` for backwards compatibility. Ignoring non-boolean for `enablePrebuilds`
68+
// for evaluation here allows to do any explicit migration of data or adjustment of the default
69+
// behavior at a later point in time.
70+
if (typeof project.settings?.enablePrebuilds === "undefined") {
71+
return true;
72+
}
73+
74+
return project.settings.enablePrebuilds;
75+
}
76+
5877
export interface Overview {
5978
branches: BranchDetails[];
6079
isConsideredInactive?: boolean;

components/server/src/prebuilds/prebuild-manager.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -353,14 +353,7 @@ export class PrebuildManager {
353353
return false;
354354
}
355355

356-
// Defaulting to `true` for backwards compatibility. Ignoring non-boolean for `enablePrebuilds`
357-
// for evaluation here allows to do any explicit migration of data or adjustment of the default
358-
// behavior at a later point in time.
359-
if (typeof project.settings?.enablePrebuilds === "undefined") {
360-
return true;
361-
}
362-
363-
return project.settings.enablePrebuilds;
356+
return Project.isPrebuildsEnabled(project);
364357
}
365358

366359
protected shouldPrebuildIncrementally(cloneUrl: string, project: Project): boolean {

0 commit comments

Comments
 (0)