-
Notifications
You must be signed in to change notification settings - Fork 2.4k
[WEB-4108]chore: refactored project wrapper #7066
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
Draft
vamsikrishnamathala
wants to merge
7
commits into
preview
Choose a base branch
from
chore-project_wrapper_refactor
base: preview
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
d9ef19d
chore: refactored project wrapper
vamsikrishnamathala eb14414
chore: moved core resources fetch to core
vamsikrishnamathala 091bc45
chore: added dummy avoid build errors
vamsikrishnamathala f8049d0
chore: updated project wrapper fetch calls
vamsikrishnamathala b4cc6d2
chore: addded null checks
vamsikrishnamathala 4cd6de7
chore: update project resource hook calls
vamsikrishnamathala 7a6ff6e
chore: updated argument types for useProjectResources
vamsikrishnamathala 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
vamsikrishnamathala marked this conversation as resolved.
Show resolved
Hide resolved
|
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,126 @@ | ||
import { useEffect } from "react"; | ||
import useSWR from "swr"; | ||
// hooks | ||
import { ETimeLineTypeType } from "@/components/gantt-chart/contexts"; | ||
import { | ||
useCycle, | ||
useLabel, | ||
useMember, | ||
useModule, | ||
useProject, | ||
useProjectEstimates, | ||
useProjectState, | ||
useProjectView, | ||
useUserPermissions, | ||
} from "@/hooks/store"; | ||
// local | ||
import { useTimeLineChart } from "@/hooks/use-timeline-chart"; | ||
import { persistence } from "@/local-db/storage.sqlite"; | ||
|
||
export const useProjectCoreResources = (workspaceSlug?: string, projectId?: string) => { | ||
const { fetchUserProjectInfo } = useUserPermissions(); | ||
const { fetchProjectDetails } = useProject(); | ||
const { fetchAllCycles } = useCycle(); | ||
const { fetchModulesSlim, fetchModules } = useModule(); | ||
const { initGantt } = useTimeLineChart(ETimeLineTypeType.MODULE); | ||
const { fetchViews } = useProjectView(); | ||
const { | ||
project: { fetchProjectMembers }, | ||
} = useMember(); | ||
const { fetchProjectStates } = useProjectState(); | ||
const { fetchProjectLabels } = useLabel(); | ||
const { getProjectEstimates } = useProjectEstimates(); | ||
|
||
// Initialize module timeline chart | ||
useEffect(() => { | ||
initGantt(); | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, []); | ||
|
||
// Sync issues | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_SYNC_ISSUES_${workspaceSlug.toString()}_${projectId.toString()}` : null, | ||
workspaceSlug && projectId | ||
? () => { | ||
persistence.syncIssues(projectId.toString()); | ||
} | ||
: null, | ||
{ | ||
revalidateIfStale: true, | ||
revalidateOnFocus: true, | ||
revalidateOnReconnect: true, | ||
refreshInterval: 5 * 60 * 1000, | ||
} | ||
); | ||
|
||
// Project details | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_DETAILS_${workspaceSlug.toString()}_${projectId.toString()}` : null, | ||
workspaceSlug && projectId ? () => fetchProjectDetails(workspaceSlug.toString(), projectId.toString()) : null | ||
); | ||
|
||
// User project info | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_ME_INFORMATION_${workspaceSlug}_${projectId}` : null, | ||
workspaceSlug && projectId ? () => fetchUserProjectInfo(workspaceSlug.toString(), projectId.toString()) : null | ||
); | ||
|
||
// Project labels | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_LABELS_${workspaceSlug}_${projectId}` : null, | ||
workspaceSlug && projectId ? () => fetchProjectLabels(workspaceSlug.toString(), projectId.toString()) : null, | ||
{ revalidateIfStale: false, revalidateOnFocus: false } | ||
); | ||
|
||
// Project members | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_MEMBERS_${workspaceSlug}_${projectId}` : null, | ||
workspaceSlug && projectId ? () => fetchProjectMembers(workspaceSlug.toString(), projectId.toString()) : null, | ||
{ revalidateIfStale: false, revalidateOnFocus: false } | ||
); | ||
|
||
// Project states | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_STATES_${workspaceSlug}_${projectId}` : null, | ||
workspaceSlug && projectId ? () => fetchProjectStates(workspaceSlug.toString(), projectId.toString()) : null, | ||
{ revalidateIfStale: false, revalidateOnFocus: false } | ||
); | ||
|
||
// Project estimates | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_ESTIMATES_${workspaceSlug}_${projectId}` : null, | ||
workspaceSlug && projectId ? () => getProjectEstimates(workspaceSlug.toString(), projectId.toString()) : null, | ||
{ revalidateIfStale: false, revalidateOnFocus: false } | ||
); | ||
|
||
// Project cycles | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_ALL_CYCLES_${workspaceSlug}_${projectId}` : null, | ||
workspaceSlug && projectId ? () => fetchAllCycles(workspaceSlug.toString(), projectId.toString()) : null, | ||
{ revalidateIfStale: false, revalidateOnFocus: false } | ||
); | ||
|
||
// Project modules | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_MODULES_${workspaceSlug}_${projectId}` : null, | ||
workspaceSlug && projectId | ||
? async () => { | ||
await fetchModulesSlim(workspaceSlug.toString(), projectId.toString()); | ||
await fetchModules(workspaceSlug.toString(), projectId.toString()); | ||
} | ||
: null, | ||
{ revalidateIfStale: false, revalidateOnFocus: false } | ||
); | ||
|
||
// Project views | ||
useSWR( | ||
workspaceSlug && projectId ? `PROJECT_VIEWS_${workspaceSlug}_${projectId}` : null, | ||
workspaceSlug && projectId ? () => fetchViews(workspaceSlug.toString(), projectId.toString()) : null, | ||
{ revalidateIfStale: false, revalidateOnFocus: false } | ||
); | ||
}; | ||
|
||
// Combined hook for all project resources | ||
export const useProjectResources = (workspaceSlug?: string, projectId?: string) => { | ||
vamsikrishnamathala marked this conversation as resolved.
Show resolved
Hide resolved
|
||
useProjectCoreResources(workspaceSlug, projectId); | ||
}; |
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,2 +1 @@ | ||
export * from "./workspace-wrapper"; | ||
export * from "./project-wrapper"; |
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.