-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Configure workspace classes from dashboard #11038
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
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,90 @@ | ||||||
/** | ||||||
* Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||||||
* Licensed under the GNU Affero General Public License (AGPL). | ||||||
* See License-AGPL.txt in the project root for license information. | ||||||
*/ | ||||||
|
||||||
import { useContext, useState } from "react"; | ||||||
import SelectableCardSolid from "../components/SelectableCardSolid"; | ||||||
import { getGitpodService } from "../service/service"; | ||||||
import { UserContext } from "../user-context"; | ||||||
import { trackEvent } from "../Analytics"; | ||||||
import { WorkspaceClasses } from "@gitpod/gitpod-protocol"; | ||||||
|
||||||
interface SelectWorkspaceClassProps { | ||||||
enabled: boolean; | ||||||
} | ||||||
|
||||||
export default function SelectWorkspaceClass(props: SelectWorkspaceClassProps) { | ||||||
const { user } = useContext(UserContext); | ||||||
|
||||||
const [workspaceClass, setWorkspaceClass] = useState<string>( | ||||||
user?.additionalData?.workspaceClasses?.regular || "standard", | ||||||
); | ||||||
const actuallySetWorkspaceClass = async (value: string) => { | ||||||
const additionalData = user?.additionalData || {}; | ||||||
const prevWorkspaceClass = additionalData?.workspaceClasses?.regular || "standard"; | ||||||
const workspaceClasses = (additionalData?.workspaceClasses || {}) as WorkspaceClasses; | ||||||
workspaceClasses.regular = value; | ||||||
workspaceClasses.prebuild = value; | ||||||
additionalData.workspaceClasses = workspaceClasses; | ||||||
if (value !== prevWorkspaceClass) { | ||||||
await getGitpodService().server.updateLoggedInUser({ additionalData }); | ||||||
trackEvent("workspace_class_changed", { | ||||||
previous: prevWorkspaceClass, | ||||||
current: value, | ||||||
}); | ||||||
setWorkspaceClass(value); | ||||||
} | ||||||
}; | ||||||
|
||||||
if (!props.enabled) { | ||||||
return <div></div>; | ||||||
} else { | ||||||
return ( | ||||||
<div> | ||||||
<h3 className="mt-12">Workspaces</h3> | ||||||
<p className="text-base text-gray-500 dark:text-gray-400"> | ||||||
Choose the workspace machine type for your workspaces. | ||||||
</p> | ||||||
<div className="mt-4 space-x-3 flex"> | ||||||
<SelectableCardSolid | ||||||
className="w-36 h-32" | ||||||
title="Standard" | ||||||
selected={workspaceClass === "standard"} | ||||||
onClick={() => actuallySetWorkspaceClass("standard")} | ||||||
> | ||||||
<div className="flex-grow flex items-end p-1"> | ||||||
<svg width="112" height="64" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||||||
<path | ||||||
d="M0 8a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8ZM0 32a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8ZM0 56a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8ZM40 6a6 6 0 0 1 6-6h60a6 6 0 0 1 6 6v28a6 6 0 0 1-6 6H46a6 6 0 0 1-6-6V6Z" | ||||||
fill="#D6D3D1" | ||||||
/> | ||||||
</svg> | ||||||
</div> | ||||||
</SelectableCardSolid> | ||||||
Comment on lines
+51
to
+65
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Re-posting some updated design specs after taking into account some feedback, see relevant discussion (internal) and design specs. Cc @atduarte
|
||||||
<SelectableCardSolid | ||||||
className="w-36 h-32" | ||||||
title="XL" | ||||||
selected={workspaceClass === "XL"} | ||||||
onClick={() => actuallySetWorkspaceClass("XL")} | ||||||
> | ||||||
<div className="flex-grow flex items-end p-1"> | ||||||
<svg width="112" height="64" fill="none" xmlns="http://www.w3.org/2000/svg"> | ||||||
<path | ||||||
d="M0 8a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8ZM40 6a6 6 0 0 1 6-6h60a6 6 0 0 1 6 6v28a6 6 0 0 1-6 6H46a6 6 0 0 1-6-6V6Z" | ||||||
fill="#D9D9D9" | ||||||
/> | ||||||
<path | ||||||
d="M84 0h22a6 6 0 0 1 6 6v28a6 6 0 0 1-6 6H68L84 0ZM0 32a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8Z" | ||||||
fill="#78716C" | ||||||
/> | ||||||
<path d="M0 56a8 8 0 0 1 8-8h16a8 8 0 1 1 0 16H8a8 8 0 0 1-8-8Z" fill="#D9D9D9" /> | ||||||
</svg> | ||||||
</div> | ||||||
</SelectableCardSolid> | ||||||
</div> | ||||||
</div> | ||||||
); | ||||||
} | ||||||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue: Friendly reminder to avoid merging this with SVG icons used for the theme preference. ❗
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi George, the current icons are placeholders. These icons will not be visible to the user at the moment (will be hidden behind a feature flag as the current design and workspace class names have not been finalized). This is just for setting up the logic in the frontend, so that I can continue with the other changes in the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok! Thanks for clarifying, @Furisto! 🙏
Feel free to ignore these two comments[1][2] then.