-
Notifications
You must be signed in to change notification settings - Fork 4.6k
chore: extract useCurrentAppState hook to reduce cyclic dependency #36937
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| import { useEffect, useState } from "react"; | ||
| import { EditorState } from "ee/entities/IDE/constants"; | ||
| import { useLocation } from "react-router"; | ||
| import { identifyEntityFromPath } from "navigation/FocusEntity"; | ||
|
|
||
| export const useCurrentAppState = () => { | ||
| const [appState, setAppState] = useState(EditorState.EDITOR); | ||
| const { pathname } = useLocation(); | ||
| const entityInfo = identifyEntityFromPath(pathname); | ||
|
|
||
| useEffect(() => { | ||
| setAppState(entityInfo.appState); | ||
| }, [entityInfo.appState]); | ||
|
|
||
| return appState; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| import type { ReactNode } from "react"; | ||
| import React from "react"; | ||
| import { EditorState } from "ee/entities/IDE/constants"; | ||
| import { useCurrentAppState } from "pages/Editor/IDE/hooks"; | ||
| import { useCurrentAppState } from "pages/Editor/IDE/hooks/useCurrentAppState"; | ||
|
Contributor
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. 💡 Codebase verification Update Required: Inconsistent import paths for The following files still import
Please update these imports to 🔗 Analysis chainLGTM: Import path update looks good. The more specific import path for Let's verify if this change is consistent across the codebase: Let's adjust the search commands to correctly target TypeScript files and verify the import path consistency. 🏁 Scripts executedThe following scripts were executed for the analysis: Script: #!/bin/bash
# Description: Check for any remaining imports of useCurrentAppState from the old path
# Test: Search for old import path. Expect: No results.
rg --type typescript 'from "pages/Editor/IDE/hooks";\s*$' -g '!**/NavigationAdjustedPageViewer.tsx'
# Test: Search for new import path. Expect: Multiple results.
rg --type typescript 'from "pages/Editor/IDE/hooks/useCurrentAppState";'
Length of output: 246 Script: #!/bin/bash
# Description: Check for any remaining imports of useCurrentAppState from the old path
# Test: Search for old import path. Expect: No results.
rg 'from "pages/Editor/IDE/hooks";\s*$' -g "*.ts" -g "*.tsx" -g '!**/NavigationAdjustedPageViewer.tsx'
# Test: Search for new import path. Expect: Multiple results.
rg 'from "pages/Editor/IDE/hooks/useCurrentAppState";' -g "*.ts" -g "*.tsx"
Length of output: 1514 |
||
| import { getIsAppSettingsPaneWithNavigationTabOpen } from "selectors/appSettingsPaneSelectors"; | ||
| import { useSelector } from "react-redux"; | ||
| import { combinedPreviewModeSelector } from "selectors/editorSelectors"; | ||
|
|
||
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.
💡 Codebase verification
Old import paths for hooks still present in some files.
app/client/src/pages/Editor/IDE/EditorPane/components/PageElement.tsx:import { useGetPageFocusUrl } from "pages/Editor/IDE/hooks";app/client/src/pages/Editor/IDE/MainPane/index.tsx:import { useWidgetSelectionBlockListener } from "pages/Editor/IDE/hooks";🔗 Analysis chain
Approve import path update.
The more specific import path for
useCurrentAppStatealigns with the PR objective of reducing cyclic dependencies. This change should help in isolating the hook and preventing unnecessary imports.To ensure the new import path is correct and consistent across the codebase, run the following script:
</run_scripts>
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
Length of output: 410
Script:
Length of output: 1774