PromucFlow_constructor/app/client/src/sagas/IDESaga.tsx

29 lines
1.1 KiB
TypeScript
Raw Normal View History

chore: Show Tabs on recent access order (#30450) ## Description Update IDE tabs order and limits - Show only recently accessed tabs - If recent tab is was already on screen, do not update order - Limit to just 5 active tabs #### PR fixes following issue(s) Fixes #30365 #### Media https://github.com/appsmithorg/appsmith/assets/12022471/a53a93cd-1b5e-4341-ba4f-289c6bd82b6d > #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## 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** - Introduced new actions to manage JavaScript and query tabs within the IDE. - Enhanced IDE to update tabs based on route changes. - **Enhancements** - Improved tab management for JavaScript and queries in the IDE. - **Bug Fixes** - Ensured consistent IDE tab states during navigation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
2024-01-23 04:52:50 +00:00
import type { FocusEntityInfo } from "navigation/FocusEntity";
import { FocusEntity } from "navigation/FocusEntity";
import { call, put, select } from "redux-saga/effects";
import { getJSTabs, getQueryTabs } from "selectors/ideSelectors";
import { setJSTabs, setQueryTabs } from "actions/ideActions";
export function* updateIDETabsOnRouteChangeSaga(entityInfo: FocusEntityInfo) {
const { entity, id } = entityInfo;
if (entity === FocusEntity.JS_OBJECT) {
const jsTabs: string[] = yield select(getJSTabs);
const newTabs: string[] = yield call(getUpdatedTabs, id, jsTabs);
yield put(setJSTabs(newTabs));
}
if (entity === FocusEntity.QUERY) {
const queryTabs: string[] = yield select(getQueryTabs);
const newTabs: string[] = yield call(getUpdatedTabs, id, queryTabs);
yield put(setQueryTabs(newTabs));
}
}
function* getUpdatedTabs(newId: string, currentTabs: string[]) {
if (currentTabs.includes(newId)) return currentTabs;
let newTabs = [newId, ...currentTabs];
if (newTabs.length > 5) {
newTabs = newTabs.slice(0, 5);
}
return newTabs;
}