PromucFlow_constructor/app/client/src/navigation/FocusUtils.ts
Hetu Nandu 8e88676243
fix: Widget Context Switching (#29735)
## Description
Fixes context switching issues related to Widget List ensuring it also
works for current prod


#### PR fixes following issue(s)
Fixes #29695


#### Media
> A video or a GIF is preferred. when using Loom, don’t embed because it
looks like it’s a GIF. instead, just link to the video
>
>
#### Type of change
- Bug fix (non-breaking change which fixes an issue)

## Testing
>
#### How Has This Been Tested?
> Please describe the tests that you ran to verify your changes. Also
list any relevant details for your test configuration.
> Delete anything that is not relevant
- [ ] Manual
- [ ] JUnit
- [ ] Jest
- [ ] Cypress
>
>
#### Test Plan
> Add Testsmith test cases links that relate to this PR
>
>
#### Issues raised during DP testing
> Link issues raised during DP testing for better visiblity and tracking
(copy link from comments dropped on this PR)
>
>
>
## Checklist:
#### Dev activity
- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- **New Features**
  - Added a search functionality to the app.
- Integrated a search bar at the top of the `Hero` component and a
`Search` component to the `App` component.
  - Included styles for the search bar in the application.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2023-12-20 12:26:16 +05:30

45 lines
1.3 KiB
TypeScript

import type { FocusEntityInfo } from "./FocusEntity";
import { FocusEntity, identifyEntityFromPath } from "./FocusEntity";
import {
datasourcesEditorURL,
jsCollectionListURL,
queryListURL,
widgetListURL,
} from "@appsmith/RouteBuilder";
export const getEntityParentUrl = (
entityInfo: FocusEntityInfo,
parentEntity: FocusEntity,
): string => {
let parentUrl: string = "";
if (parentEntity === FocusEntity.WIDGET_LIST) {
parentUrl = widgetListURL({
pageId: entityInfo.pageId,
});
}
if (parentEntity === FocusEntity.DATASOURCE_LIST) {
parentUrl = datasourcesEditorURL({
pageId: entityInfo.pageId,
});
}
if (parentEntity === FocusEntity.JS_OBJECT_LIST) {
parentUrl = jsCollectionListURL({
pageId: entityInfo.pageId,
});
}
if (parentEntity === FocusEntity.QUERY_LIST) {
parentUrl = queryListURL({
pageId: entityInfo.pageId,
});
}
return parentUrl.split("?")[0];
};
export const isPageChange = (prevPath: string, currentPath: string) => {
const prevFocusEntityInfo = identifyEntityFromPath(prevPath);
const currFocusEntityInfo = identifyEntityFromPath(currentPath);
if (prevFocusEntityInfo.pageId === "" || currFocusEntityInfo.pageId === "") {
return false;
}
return prevFocusEntityInfo.pageId !== currFocusEntityInfo.pageId;
};