-
Notifications
You must be signed in to change notification settings - Fork 888
refactor (desktop): New workspace button #596
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
12 changes: 0 additions & 12 deletions
12
.../desktop/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSidebarHeader.tsx
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
...er/screens/main/components/WorkspaceSidebar/WorkspaceSidebarHeader/NewWorkspaceButton.tsx
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,30 @@ | ||
| import { LuPlus } from "react-icons/lu"; | ||
| import { trpc } from "renderer/lib/trpc"; | ||
| import { useOpenNewWorkspaceModal } from "renderer/stores/new-workspace-modal"; | ||
|
|
||
| export function NewWorkspaceButton() { | ||
| const openModal = useOpenNewWorkspaceModal(); | ||
| const { data: activeWorkspace, isLoading } = | ||
| trpc.workspaces.getActive.useQuery(); | ||
|
|
||
| const handleClick = () => { | ||
| // projectId may be undefined if no workspace is active or query failed | ||
| // openModal handles undefined by opening without a pre-selected project | ||
| const projectId = activeWorkspace?.projectId; | ||
| openModal(projectId); | ||
| }; | ||
|
|
||
| return ( | ||
| <button | ||
| type="button" | ||
| onClick={handleClick} | ||
| disabled={isLoading} | ||
| className="flex items-center gap-2 px-2 py-1.5 text-sm font-medium text-muted-foreground hover:text-foreground hover:bg-accent/50 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed" | ||
| > | ||
| <div className="flex items-center justify-center size-5 rounded bg-accent"> | ||
| <LuPlus className="size-3" /> | ||
| </div> | ||
| <span>New Workspace</span> | ||
| </button> | ||
| ); | ||
| } | ||
18 changes: 18 additions & 0 deletions
18
...creens/main/components/WorkspaceSidebar/WorkspaceSidebarHeader/WorkspaceSidebarHeader.tsx
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,18 @@ | ||
| import { LuLayers } from "react-icons/lu"; | ||
| import { NewWorkspaceButton } from "./NewWorkspaceButton"; | ||
|
|
||
| export function WorkspaceSidebarHeader() { | ||
| return ( | ||
| <div className="flex flex-col border-b border-border px-2 pt-2 pb-2"> | ||
| <div className="flex items-center gap-2 px-2 py-1.5"> | ||
| <div className="flex items-center justify-center size-5"> | ||
| <LuLayers className="size-4 text-muted-foreground" /> | ||
| </div> | ||
| <span className="text-sm font-medium text-muted-foreground"> | ||
| Workspaces | ||
| </span> | ||
| </div> | ||
| <NewWorkspaceButton /> | ||
| </div> | ||
| ); | ||
| } |
1 change: 1 addition & 0 deletions
1
...top/src/renderer/screens/main/components/WorkspaceSidebar/WorkspaceSidebarHeader/index.ts
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 @@ | ||
| export { WorkspaceSidebarHeader } from "./WorkspaceSidebarHeader"; |
Oops, something went wrong.
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.
🧩 Analysis chain
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 1337
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 91
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 91
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 3490
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 46
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 375
🏁 Script executed:
Repository: superset-sh/superset
Length of output: 1422
Add error handling for tRPC query failures
The component destructures
isLoadingfrom the query result but ignoresisError. Whentrpc.workspaces.getActivefails, the button remains enabled and passesundefinedtoopenModal.Per the coding guideline "Never swallow errors silently - at minimum log them with context", destructure
isErrorand log the error:export function NewWorkspaceButton() { const openModal = useOpenNewWorkspaceModal(); - const { data: activeWorkspace, isLoading } = + const { data: activeWorkspace, isLoading, isError, error } = trpc.workspaces.getActive.useQuery(); + if (isError) { + console.error('[NewWorkspaceButton/getActive]', error); + } + const handleClick = () => { // projectId may be undefined if no workspace is active or query failed // openModal handles undefined by opening without a pre-selected project const projectId = activeWorkspace?.projectId; openModal(projectId); };Alternatively or additionally, disable the button on error by changing the button's
disabledattribute todisabled={isLoading || isError}.📝 Committable suggestion
🤖 Prompt for AI Agents