Skip to content

Commit

Permalink
addressing review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ankitakinger committed Mar 12, 2025
1 parent 6d8086b commit b15dd32
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,14 @@ export const AppIDEFocusStrategy: FocusStrategy = {

return entities;
},
getEntityParentUrl: (
getEntityParentUrl: function* (
entityInfo: FocusEntityInfo,
parentEntity: FocusEntity,
): string => {
) {
let parentUrl: string = "";
const branch: string | undefined = yield select(
selectGitApplicationCurrentBranch,
);

if (parentEntity === FocusEntity.WIDGET_LIST) {
parentUrl = widgetListURL({
Expand All @@ -289,7 +292,7 @@ export const AppIDEFocusStrategy: FocusStrategy = {
}

// We do not have to add any query params because this url is used as the key
return parentUrl.split("?")[0];
return parentUrl.split("?")[0] + `#${branch}`;
},
*waitForPathLoad(currentPath: string, previousPath?: string) {
if (previousPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const NoIDEFocusStrategy: FocusStrategy = {
*getEntitiesForStore() {
return [];
},
getEntityParentUrl(): string {
getEntityParentUrl: function* () {
return "";
},
*waitForPathLoad() {},
Expand Down
2 changes: 1 addition & 1 deletion app/client/src/ce/navigation/FocusStrategy/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface FocusStrategy {
getEntityParentUrl: (
entityInfo: FocusEntityInfo,
parentEntity: FocusEntity,
) => string;
) => Generator<unknown, string, unknown>;
/** Define a wait (saga) before we start setting states **/
waitForPathLoad: (
currentPath: string,
Expand Down
9 changes: 8 additions & 1 deletion app/client/src/ce/sagas/DatasourcesSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ import type { ActionParentEntityTypeInterface } from "ee/entities/Engine/actionH
import { getCurrentModuleId } from "ee/selectors/modulesSelector";
import type { ApplicationPayload } from "entities/Application";
import { openGeneratePageModalWithSelectedDS } from "../../utils/GeneratePageUtils";
import { selectGitApplicationCurrentBranch } from "selectors/gitModSelectors";

export function* fetchDatasourcesSaga(
action: ReduxAction<
Expand Down Expand Up @@ -441,6 +442,9 @@ export function* deleteDatasourceSaga(
) {
try {
const id = actionPayload.payload.id;
const branch: string | undefined = yield select(
selectGitApplicationCurrentBranch,
);
const response: ApiResponse<Datasource> =
yield DatasourcesApi.deleteDatasource(id);

Expand All @@ -450,7 +454,10 @@ export function* deleteDatasourceSaga(
const currentUrl = `${window.location.pathname}`;

yield call(handleDatasourceDeleteRedirect, id);
yield call(FocusRetention.handleRemoveFocusHistory, currentUrl);
yield call(
FocusRetention.handleRemoveFocusHistory,
`${currentUrl}#${branch}`,
);

toast.show(createMessage(DATASOURCE_DELETE, response.data.name), {
kind: "success",
Expand Down
14 changes: 12 additions & 2 deletions app/client/src/ce/sagas/JSActionSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import { CreateNewActionKey } from "ee/entities/Engine/actionHelpers";
import { getAllActionTestPayloads } from "utils/storage";
import { convertToBasePageIdSelector } from "selectors/pageListSelectors";
import type { EvaluationReduxAction } from "actions/EvaluationReduxActionTypes";
import { selectGitApplicationCurrentBranch } from "selectors/gitModSelectors";

export function* fetchJSCollectionsSaga(
action: EvaluationReduxAction<FetchActionsPayload>,
Expand Down Expand Up @@ -333,13 +334,19 @@ export function* deleteJSCollectionSaga(
const response: ApiResponse = yield JSActionAPI.deleteJSCollection(id);
const isValidResponse: boolean = yield validateResponse(response);
const ideType = getIDETypeByUrl(currentUrl);
const branch: string | undefined = yield select(
selectGitApplicationCurrentBranch,
);

if (isValidResponse) {
// @ts-expect-error: response.data is of type unknown
toast.show(createMessage(JS_ACTION_DELETE_SUCCESS, response.data.name), {
kind: "success",
});
yield call(FocusRetention.handleRemoveFocusHistory, currentUrl);
yield call(
FocusRetention.handleRemoveFocusHistory,
`${currentUrl}#${branch}`,
);

if (ideType === IDE_TYPE.App) {
yield call(handleJSEntityRedirect, id);
Expand Down Expand Up @@ -538,8 +545,11 @@ export function* closeJSActionTabSaga(
) {
const { id, parentId } = actionPayload.payload;
const currentUrl = window.location.pathname;
const branch: string | undefined = yield select(
selectGitApplicationCurrentBranch,
);

yield call(FocusRetention.handleRemoveFocusHistory, currentUrl);
yield call(FocusRetention.handleRemoveFocusHistory, `${currentUrl}${branch}`);
yield call(handleJSEntityRedirect, id);
yield put(closeJsActionTabSuccess({ id, parentId }));
}
Expand Down
17 changes: 15 additions & 2 deletions app/client/src/sagas/ActionSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ import {
import { handleQueryEntityRedirect } from "./IDESaga";
import type { EvaluationReduxAction } from "actions/EvaluationReduxActionTypes";
import { IDE_TYPE } from "ee/IDE/Interfaces/IDETypes";
import { selectGitApplicationCurrentBranch } from "selectors/gitModSelectors";

export const DEFAULT_PREFIX = {
QUERY: "Query",
Expand Down Expand Up @@ -577,6 +578,9 @@ export function* deleteActionSaga(
}>,
) {
try {
const branch: string | undefined = yield select(
selectGitApplicationCurrentBranch,
);
const id = actionPayload.payload.id;
const name = actionPayload.payload.name;
const currentUrl = window.location.pathname;
Expand Down Expand Up @@ -623,7 +627,10 @@ export function* deleteActionSaga(
});
}

yield call(FocusRetention.handleRemoveFocusHistory, currentUrl);
yield call(
FocusRetention.handleRemoveFocusHistory,
`${currentUrl}#${branch}`,
);

if (ideType === IDE_TYPE.App) {
yield call(handleQueryEntityRedirect, action.id);
Expand Down Expand Up @@ -1259,8 +1266,14 @@ export function* closeActionTabSaga(
) {
const { id, parentId } = actionPayload.payload;
const currentUrl = window.location.pathname;
const branch: string | undefined = yield select(
selectGitApplicationCurrentBranch,
);

yield call(FocusRetention.handleRemoveFocusHistory, currentUrl);
yield call(
FocusRetention.handleRemoveFocusHistory,
`${currentUrl}#${branch}`,
);
yield call(handleQueryEntityRedirect, id);
yield put(closeQueryActionTabSuccess({ id, parentId }));
}
15 changes: 4 additions & 11 deletions app/client/src/sagas/FocusRetentionSaga.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import type { Plugin } from "entities/Plugin";
import { getIDETypeByUrl } from "ee/entities/IDE/utils";
import { getIDEFocusStrategy } from "ee/navigation/FocusStrategy";
import { IDE_TYPE } from "ee/IDE/Interfaces/IDETypes";
import { selectGitApplicationCurrentBranch } from "selectors/gitModSelectors";
import type {
FocusPath,
FocusStrategy,
Expand Down Expand Up @@ -87,27 +86,21 @@ class FocusRetention {
}

public *handleRemoveFocusHistory(url: string) {
const branch: string | undefined = yield select(
selectGitApplicationCurrentBranch,
);
const removeKeys: string[] = [];
const focusEntityInfo = identifyEntityFromPath(url);

removeKeys.push(`${url}#${branch}`);
removeKeys.push(`${url}`);

const parentElement = FocusStoreHierarchy[focusEntityInfo.entity];

if (parentElement) {
const parentPath = this.focusStrategy.getEntityParentUrl(
const parentPath: string = yield call(
this.focusStrategy.getEntityParentUrl,
focusEntityInfo,
parentElement,
);

if (focusEntityInfo.params.basePageId) {
removeKeys.push(`${parentPath}#${branch}`);
} else {
removeKeys.push(parentPath);
}
removeKeys.push(parentPath);
}

for (const key of removeKeys) {
Expand Down
15 changes: 13 additions & 2 deletions app/client/src/sagas/WidgetDeletionSagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import {
getAllWidgetsInTree,
updateListWidgetPropertiesOnChildDelete,
} from "./WidgetOperationUtils";
import { selectGitApplicationCurrentBranch } from "selectors/gitModSelectors";

const WidgetTypes = WidgetFactory.widgetTypes;

Expand Down Expand Up @@ -338,8 +339,14 @@ export function* deleteSaga(deleteAction: ReduxAction<WidgetDelete>) {
templateTitle: currentApplication?.forkedFromTemplateTitle,
});
const currentUrl = window.location.pathname;
const branch: string | undefined = yield select(
selectGitApplicationCurrentBranch,
);

yield call(FocusRetention.handleRemoveFocusHistory, currentUrl);
yield call(
FocusRetention.handleRemoveFocusHistory,
`${currentUrl}#${branch}`,
);

if (!disallowUndo) {
// close property pane after delete
Expand Down Expand Up @@ -485,10 +492,14 @@ function* deleteAllSelectedWidgetsSaga(
yield put(selectWidgetInitAction(SelectionRequestType.Empty));
const bulkDeleteKey = selectedWidgets.join(",");

const branch: string | undefined = yield select(
selectGitApplicationCurrentBranch,
);

for (const widget of selectedWidgets) {
yield call(
FocusRetention.handleRemoveFocusHistory,
widgetURL({ selectedWidgets: [widget] }),
`${widgetURL({ selectedWidgets: [widget] })}#${branch}`,
);
}

Expand Down

0 comments on commit b15dd32

Please sign in to comment.