-
Notifications
You must be signed in to change notification settings - Fork 2
Uses Suspense when loading projects #322
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
8 commits
Select commit
Hold shift + click to select a range
edd8a09
Moves MenuItemHover to client
simonbs 09440cc
Removes unused SidebarContext
simonbs 4a6b935
Uses Suspense to load projects
simonbs 857d5ca
Moves ProjectsContextProvider to fix unit tests
simonbs 8a8642d
Moves contexts.ts to client-side
simonbs 9940421
Moves ProjectsContextProvider.tsx to client-side
simonbs 4312e87
Merge branch 'develop' into enhancement/load-projects-with-suspense
simonbs 6997709
Fixes build errors
simonbs 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 was deleted.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,19 +1,14 @@ | ||
| "use client" | ||
|
|
||
| import { createContext } from "react" | ||
| import { Project, } from "@/features/projects/domain" | ||
| import { Project } from "@/features/projects/domain" | ||
|
|
||
| export const SidebarContext = createContext<{ isToggleable: boolean }>({ isToggleable: true }) | ||
|
|
||
| type ProjectsContainer = { | ||
| readonly projects: Project[] | ||
| readonly isLoading: boolean | ||
| readonly error?: Error | ||
| type ProjectsContextValue = { | ||
| projects: Project[], | ||
| setProjects: (projects: Project[]) => void | ||
| } | ||
|
|
||
| export const ProjectsContainerContext = createContext<ProjectsContainer>({ | ||
| isLoading: true, | ||
| projects: [] | ||
| export const ProjectsContext = createContext<ProjectsContextValue>({ | ||
| projects: [], | ||
| setProjects: () => {} | ||
| }) | ||
|
|
||
| export const ServerSideCachedProjectsContext = createContext<Project[] | undefined>(undefined) |
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 |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| export { default as GitHubProjectDataSource } from "./GitHubProjectDataSource" | ||
| export * from "./GitHubProjectDataSource" | ||
| export { default as useProjects } from "./useProjects" | ||
| export { default as useProjectSelection } from "./useProjectSelection" | ||
| export { default as GitHubLoginDataSource } from "./GitHubLoginDataSource" | ||
| export { default as GitHubRepositoryDataSource } from "./GitHubRepositoryDataSource" |
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 was deleted.
Oops, something went wrong.
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,22 @@ | ||
| "use client" | ||
|
|
||
| import { useState } from "react" | ||
| import { ProjectsContext } from "@/common" | ||
| import { Project } from "@/features/projects/domain" | ||
|
|
||
| const ProjectsContextProvider = ({ | ||
| initialProjects, | ||
| children | ||
| }: { | ||
| initialProjects?: Project[], | ||
| children?: React.ReactNode | ||
| }) => { | ||
| const [projects, setProjects] = useState<Project[]>(initialProjects || []) | ||
| return ( | ||
| <ProjectsContext.Provider value={{ projects, setProjects }}> | ||
| {children} | ||
| </ProjectsContext.Provider> | ||
| ) | ||
| } | ||
|
|
||
| export default ProjectsContextProvider |
20 changes: 0 additions & 20 deletions
20
src/features/projects/view/ServerSideCachedProjectsProvider.tsx
This file was deleted.
Oops, something went wrong.
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 |
|---|---|---|
| @@ -1,52 +1,22 @@ | ||
| "use client" | ||
| import ClientSplitView from "./internal/ClientSplitView" | ||
| import { projectDataSource } from "@/composition" | ||
| import BaseSidebar from "./internal/sidebar/Sidebar" | ||
| import ProjectList from "./internal/sidebar/projects/ProjectList" | ||
|
|
||
| import { useEffect } from "react" | ||
| import { Stack } from "@mui/material" | ||
| import { isMac, useKeyboardShortcut } from "@/common" | ||
| import { useSidebarOpen } from "../data" | ||
| import PrimaryContainer from "./internal/primary/Container" | ||
| import SecondaryContainer from "./internal/secondary/Container" | ||
| import Sidebar from "./internal/sidebar/Sidebar" | ||
|
|
||
| const SplitView = ({ | ||
| canToggleSidebar: _canToggleSidebar, | ||
| children | ||
| }: { | ||
| canToggleSidebar?: boolean | ||
| children?: React.ReactNode | ||
| }) => { | ||
| const [isSidebarOpen, setSidebarOpen] = useSidebarOpen() | ||
| const canToggleSidebar = _canToggleSidebar !== undefined ? _canToggleSidebar : true | ||
| useEffect(() => { | ||
| // Show the sidebar if no project is selected. | ||
| if (!canToggleSidebar) { | ||
| setSidebarOpen(true) | ||
| } | ||
| }, [canToggleSidebar, setSidebarOpen]) | ||
| useKeyboardShortcut(event => { | ||
| const isActionKey = isMac() ? event.metaKey : event.ctrlKey | ||
| if (isActionKey && event.key === ".") { | ||
| event.preventDefault() | ||
| if (canToggleSidebar) { | ||
| setSidebarOpen(!isSidebarOpen) | ||
| } | ||
| } | ||
| }, [canToggleSidebar, setSidebarOpen]) | ||
| const sidebarWidth = 320 | ||
| const SplitView = ({ children }: { children?: React.ReactNode }) => { | ||
| return ( | ||
| <Stack direction="row" spacing={0} sx={{ width: "100%", height: "100%" }}> | ||
| <PrimaryContainer | ||
| width={sidebarWidth} | ||
| isOpen={isSidebarOpen} | ||
| onClose={() => setSidebarOpen(false)} | ||
| > | ||
| <Sidebar/> | ||
| </PrimaryContainer> | ||
| <SecondaryContainer sidebarWidth={sidebarWidth} offsetContent={isSidebarOpen}> | ||
| {children} | ||
| </SecondaryContainer> | ||
| </Stack> | ||
| <ClientSplitView sidebar={<Sidebar/>}> | ||
| {children} | ||
| </ClientSplitView> | ||
| ) | ||
| } | ||
|
|
||
| export default SplitView | ||
|
|
||
| const Sidebar = () => { | ||
| return ( | ||
| <BaseSidebar> | ||
| <ProjectList projectDataSource={projectDataSource} /> | ||
| </BaseSidebar> | ||
| ) | ||
| } |
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.
Uh oh!
There was an error while loading. Please reload this page.