Skip to content

Add "Enable Prebuilds" to Project Settings – EXP-573 #18698

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 36 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7f57521
cleanup: remove obsolete remainings of /prebuild prefix
AlexTugarev Sep 11, 2023
1de7893
Add Project.settings.enablePrebuilds
AlexTugarev Sep 11, 2023
cbfc17d
PrebuildManager.shouldPrebuild to consider Project.settings.enablePre…
AlexTugarev Sep 11, 2023
a97bd9d
Don't install webhooks on project creation
AlexTugarev Sep 11, 2023
23c4f44
foreseeable change: don't prefetch project details
AlexTugarev Sep 11, 2023
7cc5e20
fix: unused imports
AlexTugarev Sep 11, 2023
beedf4a
redirect to project settings on project created
AlexTugarev Sep 11, 2023
936f4e4
don't trigger prebuilds on project created
AlexTugarev Sep 11, 2023
c4d3f38
fix: get rid of many ListProjects requests on Settings page
AlexTugarev Sep 11, 2023
884cda4
Project Settings: add checkbox for "enable prebuilds"
AlexTugarev Sep 11, 2023
7aa4d0d
handle "enable prebuilds" in server
AlexTugarev Sep 11, 2023
26ddfd2
updating PAPI
AlexTugarev Sep 11, 2023
5695783
fixup
AlexTugarev Sep 11, 2023
f0732bf
fixup
AlexTugarev Sep 11, 2023
c36bbfd
make PrebuildManager require a Project to work on
AlexTugarev Sep 12, 2023
44bf5ae
address feedback on useListProjectsQuery and useCurrentProject
AlexTugarev Sep 12, 2023
18a3bc1
remove empty class name attributes
AlexTugarev Sep 12, 2023
d881bea
make use of <InputField> as wrapper for <SelectWorkspaceClassComponent>
AlexTugarev Sep 12, 2023
1b6bad3
fixup <SelectWorkspaceClassComponent> width
AlexTugarev Sep 12, 2023
eab7584
update hint on "Enable Prebuilds" action
AlexTugarev Sep 12, 2023
a665f9e
fix "enablePrebuild" handling
AlexTugarev Sep 13, 2023
8f3a7f8
add [Enable Prebuilds] button to "Project Created" page
AlexTugarev Sep 13, 2023
00b7a11
show detailed prebuild setting only if prebuilds are enabled
AlexTugarev Sep 13, 2023
3de5fc8
drive-by: fix max width on "Remove Project"
AlexTugarev Sep 13, 2023
72347be
fix: re-add `loading` state to `useCurrentProject` hook
AlexTugarev Sep 13, 2023
ccd7c25
add "Enable Prebuilds" to project card
AlexTugarev Sep 13, 2023
fe2d691
fixup project-context.tsx
AlexTugarev Sep 13, 2023
cf86be3
fixup button type
AlexTugarev Sep 13, 2023
651620d
add hint to create a .gitpod.yml
AlexTugarev Sep 13, 2023
0db4005
Apply suggestions from code review
AlexTugarev Sep 13, 2023
d70fc8d
remove unnecessary !
AlexTugarev Sep 13, 2023
0492cef
extract Project.isPrebuildsEnabled
AlexTugarev Sep 14, 2023
aa51d6c
fixup: add missing await
AlexTugarev Sep 14, 2023
a3ecb47
render "Learn more" if not enabled, too.
AlexTugarev Sep 14, 2023
418a1fa
fix getCloneUrl for BBS
AlexTugarev Sep 15, 2023
453bfb3
fix getCloneUrl for GitLab
AlexTugarev Sep 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/dashboard/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function Header(p: HeaderProps) {
return (
<div className="app-container border-gray-200 dark:border-gray-800">
<div className="flex pb-8 pt-6">
<div className="">
<div>
{p.complexTitle ? p.complexTitle : <Heading1 tracking="tight">{p.title}</Heading1>}
{typeof p.subtitle === "string" ? (
<Subheading tracking="wide">{p.subtitle}</Subheading>
Expand Down
11 changes: 8 additions & 3 deletions components/dashboard/src/components/forms/InputField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,22 @@ type Props = {
error?: ReactNode;
topMargin?: boolean;
className?: string;
disabled?: boolean;
};

export const InputField: FunctionComponent<Props> = memo(
({ label, id, hint, error, topMargin = true, className, children }) => {
({ label, id, hint, error, topMargin = true, className, children, disabled = false }) => {
return (
<div className={classNames("flex flex-col space-y-2", { "mt-4": topMargin }, className)}>
{label && (
<label
className={classNames(
"text-md font-semibold dark:text-gray-400",
error ? "text-red-600" : "text-gray-600",
"text-md font-semibold",
disabled
? "text-gray-400 dark:text-gray-400"
: error
? "text-red-600 dark:text-red-400"
: "text-gray-600 dark:text-gray-100",
)}
htmlFor={id}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ export const useCreateProject = () => {
if (org) {
refreshProjects(org.id);
}

// Kick off a prebuild for the new project
getGitpodService().server.triggerPrebuild(project.id, null);
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const useListProjectsQuery = () => {
const org = useCurrentOrg().data;
const orgId = org?.id;
return useQuery<ListProjectsQueryResults>({
// Projects are either tied to current team, otherwise current user
enabled: !!orgId,
queryKey: getListProjectsQueryKey(orgId || ""),
cacheTime: 1000 * 60 * 60 * 1, // 1 hour
queryFn: async () => {
Expand Down Expand Up @@ -57,9 +57,5 @@ export const useRefreshProjects = () => {
};

export const getListProjectsQueryKey = (orgId: string) => {
if (!orgId) {
throw new Error("Must provide either an orgId for projects query key");
}

return ["projects", "list", { orgId }];
};
9 changes: 7 additions & 2 deletions components/dashboard/src/projects/NewProject.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function NewProject() {
<Heading1>Project Created</Heading1>
<Subheading className="mt-2 text-center">
Created{" "}
<a className="gp-link" href={`/projects/${Project.slug(project!)}`}>
<a className="gp-link" href={`/projects/${Project.slug(project)}/settings`}>
{project.name}
</a>{" "}
{!currentTeam ? (
Expand All @@ -80,7 +80,12 @@ export default function NewProject() {
)}
</Subheading>

<div className="mt-12">
<div className="mt-12 flex space-x-2">
<a href={`/projects/${Project.slug(project)}/settings`}>
<Button type="secondary" onClick={onNewWorkspace}>
Enable Prebuilds
</Button>
</a>
<Button onClick={onNewWorkspace}>New Workspace</Button>
</div>
</div>
Expand Down
21 changes: 18 additions & 3 deletions components/dashboard/src/projects/ProjectListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ export const ProjectListItem: FunctionComponent<ProjectListItemProps> = ({ proje
const [showRemoveModal, setShowRemoveModal] = useState(false);
const { data: prebuild, isLoading } = useLatestProjectPrebuildQuery({ projectId: project.id });

const enablePrebuilds =
!!project.settings?.enablePrebuilds ||
// TODO(at): out of scope for now, but once we've migrated the settings of existings projects
// we can remove the implicit enablement here
!project.settings;

return (
<div key={`project-${project.id}`} className="h-52">
<div className="h-42 border border-gray-100 dark:border-gray-800 rounded-t-xl">
Expand Down Expand Up @@ -72,7 +78,16 @@ export const ProjectListItem: FunctionComponent<ProjectListItemProps> = ({ proje
</div>
</div>
<div className="h-10 px-4 border rounded-b-xl dark:border-gray-800 bg-gray-100 border-gray-100 dark:bg-gray-800">
{prebuild ? (
{!enablePrebuilds ? (
<div className="flex h-full text-sm">
<Link
to={`/projects/${Project.slug(project!)}/settings`}
className="flex-shrink-0 flex items-center text-gray-400 hover:text-gray-600 dark:hover:text-gray-300"
>
Enable Prebuilds &rarr;
</Link>
</div>
) : prebuild ? (
<div className="flex flex-row h-full text-sm space-x-4">
<Link
to={`/projects/${Project.slug(project!)}/${prebuild?.info?.id}`}
Expand Down Expand Up @@ -100,11 +115,11 @@ export const ProjectListItem: FunctionComponent<ProjectListItemProps> = ({ proje
</Link>
</div>
) : isLoading ? (
<div className="flex h-full text-md">
<div className="flex h-full text-sm">
<p className="my-auto ">...</p>
</div>
) : (
<div className="flex h-full text-md">
<div className="flex h-full text-sm">
<p className="my-auto ">No recent prebuilds</p>
</div>
)}
Expand Down
Loading