Skip to content

Commit cb3a7f0

Browse files
Add "Enable Prebuilds" to Project Settings – EXP-573 (#18698)
* cleanup: remove obsolete remainings of /prebuild prefix * Add Project.settings.enablePrebuilds * PrebuildManager.shouldPrebuild to consider Project.settings.enablePrebuilds * Don't install webhooks on project creation * foreseeable change: don't prefetch project details * fix: unused imports * redirect to project settings on project created * don't trigger prebuilds on project created * fix: get rid of many ListProjects requests on Settings page * Project Settings: add checkbox for "enable prebuilds" * handle "enable prebuilds" in server * updating PAPI * fixup * fixup * make PrebuildManager require a Project to work on * also SCM webhook handlers * move project usage registration to PrebuildManager * address feedback on useListProjectsQuery and useCurrentProject * remove empty class name attributes * make use of <InputField> as wrapper for <SelectWorkspaceClassComponent> * fixup <SelectWorkspaceClassComponent> width * update hint on "Enable Prebuilds" action Co-authored-by: George Tsiolis <[email protected]> * fix "enablePrebuild" handling * add [Enable Prebuilds] button to "Project Created" page * show detailed prebuild setting only if prebuilds are enabled * drive-by: fix max width on "Remove Project" * fix: re-add `loading` state to `useCurrentProject` hook this caused an issue with loading components as `useListProjectsQuery.isLoading` is false initially. * add "Enable Prebuilds" to project card * fixup project-context.tsx state should only be updated if `useListProjectsQuery` is loaded. * fixup button type * add hint to create a .gitpod.yml * Apply suggestions from code review Co-authored-by: George Tsiolis <[email protected]> * remove unnecessary ! * extract Project.isPrebuildsEnabled * fixup: add missing await * render "Learn more" if not enabled, too. * fix getCloneUrl for BBS * fix getCloneUrl for GitLab --------- Co-authored-by: George Tsiolis <[email protected]>
1 parent cff12f6 commit cb3a7f0

34 files changed

+548
-369
lines changed

components/dashboard/src/components/Header.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export default function Header(p: HeaderProps) {
2929
return (
3030
<div className="app-container border-gray-200 dark:border-gray-800">
3131
<div className="flex pb-8 pt-6">
32-
<div className="">
32+
<div>
3333
{p.complexTitle ? p.complexTitle : <Heading1 tracking="tight">{p.title}</Heading1>}
3434
{typeof p.subtitle === "string" ? (
3535
<Subheading tracking="wide">{p.subtitle}</Subheading>

components/dashboard/src/components/forms/InputField.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,22 @@ type Props = {
1515
error?: ReactNode;
1616
topMargin?: boolean;
1717
className?: string;
18+
disabled?: boolean;
1819
};
1920

2021
export const InputField: FunctionComponent<Props> = memo(
21-
({ label, id, hint, error, topMargin = true, className, children }) => {
22+
({ label, id, hint, error, topMargin = true, className, children, disabled = false }) => {
2223
return (
2324
<div className={classNames("flex flex-col space-y-2", { "mt-4": topMargin }, className)}>
2425
{label && (
2526
<label
2627
className={classNames(
27-
"text-md font-semibold dark:text-gray-400",
28-
error ? "text-red-600" : "text-gray-600",
28+
"text-md font-semibold",
29+
disabled
30+
? "text-gray-400 dark:text-gray-400"
31+
: error
32+
? "text-red-600 dark:text-red-400"
33+
: "text-gray-600 dark:text-gray-100",
2934
)}
3035
htmlFor={id}
3136
>

components/dashboard/src/data/projects/create-project-mutation.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@ export const useCreateProject = () => {
3535
if (org) {
3636
refreshProjects(org.id);
3737
}
38-
39-
// Kick off a prebuild for the new project
40-
getGitpodService().server.triggerPrebuild(project.id, null);
4138
},
4239
},
4340
);

components/dashboard/src/data/projects/list-projects-query.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const useListProjectsQuery = () => {
1818
const org = useCurrentOrg().data;
1919
const orgId = org?.id;
2020
return useQuery<ListProjectsQueryResults>({
21-
// Projects are either tied to current team, otherwise current user
21+
enabled: !!orgId,
2222
queryKey: getListProjectsQueryKey(orgId || ""),
2323
cacheTime: 1000 * 60 * 60 * 1, // 1 hour
2424
queryFn: async () => {
@@ -57,9 +57,5 @@ export const useRefreshProjects = () => {
5757
};
5858

5959
export const getListProjectsQueryKey = (orgId: string) => {
60-
if (!orgId) {
61-
throw new Error("Must provide either an orgId for projects query key");
62-
}
63-
6460
return ["projects", "list", { orgId }];
6561
};

components/dashboard/src/projects/NewProject.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export default function NewProject() {
6464
<Heading1>Project Created</Heading1>
6565
<Subheading className="mt-2 text-center">
6666
Created{" "}
67-
<a className="gp-link" href={`/projects/${Project.slug(project!)}`}>
67+
<a className="gp-link" href={`/projects/${Project.slug(project)}/settings`}>
6868
{project.name}
6969
</a>{" "}
7070
{!currentTeam ? (
@@ -80,7 +80,12 @@ export default function NewProject() {
8080
)}
8181
</Subheading>
8282

83-
<div className="mt-12">
83+
<div className="mt-12 flex space-x-2">
84+
<a href={`/projects/${Project.slug(project)}/settings`}>
85+
<Button type="secondary" onClick={onNewWorkspace}>
86+
Enable Prebuilds
87+
</Button>
88+
</a>
8489
<Button onClick={onNewWorkspace}>New Workspace</Button>
8590
</div>
8691
</div>

components/dashboard/src/projects/ProjectListItem.tsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ export const ProjectListItem: FunctionComponent<ProjectListItemProps> = ({ proje
2525
const [showRemoveModal, setShowRemoveModal] = useState(false);
2626
const { data: prebuild, isLoading } = useLatestProjectPrebuildQuery({ projectId: project.id });
2727

28+
const enablePrebuilds =
29+
!!project.settings?.enablePrebuilds ||
30+
// TODO(at): out of scope for now, but once we've migrated the settings of existings projects
31+
// we can remove the implicit enablement here
32+
!project.settings;
33+
2834
return (
2935
<div key={`project-${project.id}`} className="h-52">
3036
<div className="h-42 border border-gray-100 dark:border-gray-800 rounded-t-xl">
@@ -72,7 +78,16 @@ export const ProjectListItem: FunctionComponent<ProjectListItemProps> = ({ proje
7278
</div>
7379
</div>
7480
<div className="h-10 px-4 border rounded-b-xl dark:border-gray-800 bg-gray-100 border-gray-100 dark:bg-gray-800">
75-
{prebuild ? (
81+
{!enablePrebuilds ? (
82+
<div className="flex h-full text-sm">
83+
<Link
84+
to={`/projects/${Project.slug(project!)}/settings`}
85+
className="flex-shrink-0 flex items-center text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
86+
>
87+
Enable Prebuilds &rarr;
88+
</Link>
89+
</div>
90+
) : prebuild ? (
7691
<div className="flex flex-row h-full text-sm space-x-4">
7792
<Link
7893
to={`/projects/${Project.slug(project!)}/${prebuild?.info?.id}`}
@@ -100,11 +115,11 @@ export const ProjectListItem: FunctionComponent<ProjectListItemProps> = ({ proje
100115
</Link>
101116
</div>
102117
) : isLoading ? (
103-
<div className="flex h-full text-md">
118+
<div className="flex h-full text-sm">
104119
<p className="my-auto ">...</p>
105120
</div>
106121
) : (
107-
<div className="flex h-full text-md">
122+
<div className="flex h-full text-sm">
108123
<p className="my-auto ">No recent prebuilds</p>
109124
</div>
110125
)}

0 commit comments

Comments
 (0)