## Description Widget selection is driven by URL changes. This would fix browser navigation for users as they can use browser back/forward buttons to travel across older contexts on Appsmith. > Fixing browser URL navigation for widgets Fixes #19571 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 > Please delete options that are not relevant. - New feature (non-breaking change which adds functionality) ## How Has This Been Tested? - Manual - Jest - Cypress ### Test Plan > Add Testsmith [test cases](https://github.com/appsmithorg/TestSmith/issues/2171) links that relate to this PR ### Issues raised during DP testing - [X] When a selected widget is below viewport and user refreshes the page, then the widget property pane is open but the page does not navigate to the selected widget https://loom.com/share/09f1eda2f02d474981a0d48e4a6419ec - [ ] Drop 2 widgets one at a time > Delete both the widgets > Now click on back button of the browser > Observe the url it shows the widget id in the URL but the canvas remains empty https://loom.com/share/53cae28a5d224e67b783c8ccf53745f5 Dev Response: This issue is valid but not a major inconvenience. We will try to track it and see if it needed to be addressed. Many other web tools do not handle such cases - [X] Canvas scrolls down when all widgets are selected. https://loom.com/share/c8a68dadcdb040779abd3a73bde2b06c - [X] Widget is not getting highlighted when added from the API editor page. Please refer to the attached video:-https://jiju8jbmwa.vmaker.com/record/IkwiAqFgafK9dVmu ## 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: - [ ] Test plan has been approved by relevant developers - [x] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test --------- Co-authored-by: Aishwarya UR <aishwarya@appsmith.com>
100 lines
3.3 KiB
TypeScript
100 lines
3.3 KiB
TypeScript
import {
|
|
DataTree,
|
|
DataTreeAppsmith,
|
|
ENTITY_TYPE,
|
|
} from "entities/DataTree/dataTreeFactory";
|
|
import { createSelector } from "reselect";
|
|
import {
|
|
getActionsForCurrentPage,
|
|
getJSCollectionsForCurrentPage,
|
|
getPlugins,
|
|
} from "selectors/entitiesSelector";
|
|
import { getWidgets } from "sagas/selectors";
|
|
import { getCurrentPageId } from "selectors/editorSelectors";
|
|
import { getActionConfig } from "pages/Editor/Explorer/Actions/helpers";
|
|
import { jsCollectionIdURL, widgetURL } from "RouteBuilder";
|
|
import { getDataTree } from "selectors/dataTreeSelectors";
|
|
import { getActionChildrenNavData } from "utils/NavigationSelector/ActionChildren";
|
|
import { createNavData } from "utils/NavigationSelector/common";
|
|
import { getWidgetChildrenNavData } from "utils/NavigationSelector/WidgetChildren";
|
|
import { getJsChildrenNavData } from "utils/NavigationSelector/JsChildren";
|
|
import { getAppsmithNavData } from "utils/NavigationSelector/AppsmithNavData";
|
|
|
|
export type NavigationData = {
|
|
name: string;
|
|
id: string;
|
|
type: ENTITY_TYPE;
|
|
url: string | undefined;
|
|
navigable: boolean;
|
|
children: EntityNavigationData;
|
|
peekable: boolean;
|
|
peekData?: unknown;
|
|
key?: string;
|
|
};
|
|
export type EntityNavigationData = Record<string, NavigationData>;
|
|
|
|
export const getEntitiesForNavigation = createSelector(
|
|
getActionsForCurrentPage,
|
|
getPlugins,
|
|
getJSCollectionsForCurrentPage,
|
|
getWidgets,
|
|
getCurrentPageId,
|
|
getDataTree,
|
|
(actions, plugins, jsActions, widgets, pageId, dataTree: DataTree) => {
|
|
const navigationData: EntityNavigationData = {};
|
|
|
|
actions.forEach((action) => {
|
|
const plugin = plugins.find(
|
|
(plugin) => plugin.id === action.config.pluginId,
|
|
);
|
|
const config = getActionConfig(action.config.pluginType);
|
|
const result = getActionChildrenNavData(action, dataTree);
|
|
if (!config) return;
|
|
navigationData[action.config.name] = createNavData({
|
|
id: action.config.id,
|
|
name: action.config.name,
|
|
type: ENTITY_TYPE.ACTION,
|
|
url: config.getURL(
|
|
pageId,
|
|
action.config.id,
|
|
action.config.pluginType,
|
|
plugin,
|
|
),
|
|
peekable: true,
|
|
peekData: result?.peekData,
|
|
children: result?.childNavData || {},
|
|
});
|
|
});
|
|
|
|
jsActions.forEach((jsAction) => {
|
|
const result = getJsChildrenNavData(jsAction, pageId, dataTree);
|
|
navigationData[jsAction.config.name] = createNavData({
|
|
id: jsAction.config.id,
|
|
name: jsAction.config.name,
|
|
type: ENTITY_TYPE.JSACTION,
|
|
url: jsCollectionIdURL({ pageId, collectionId: jsAction.config.id }),
|
|
peekable: true,
|
|
peekData: result?.peekData,
|
|
children: result?.childNavData || {},
|
|
});
|
|
});
|
|
|
|
Object.values(widgets).forEach((widget) => {
|
|
const result = getWidgetChildrenNavData(widget, dataTree, pageId);
|
|
navigationData[widget.widgetName] = createNavData({
|
|
id: widget.widgetId,
|
|
name: widget.widgetName,
|
|
type: ENTITY_TYPE.WIDGET,
|
|
url: widgetURL({ pageId, selectedWidgets: [widget.widgetId] }),
|
|
peekable: true,
|
|
peekData: result?.peekData,
|
|
children: result?.childNavData || {},
|
|
});
|
|
});
|
|
navigationData["appsmith"] = getAppsmithNavData(
|
|
dataTree.appsmith as DataTreeAppsmith,
|
|
);
|
|
return navigationData;
|
|
},
|
|
);
|