Skip to content
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

feat: [Context Switching] Maintain datasource collapse state #17616

Merged
merged 170 commits into from
Dec 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
170 commits
Select commit Hold shift + click to select a range
d65ac17
WIP
hetunandu Aug 9, 2022
b06c926
Store focus info example
hetunandu Aug 9, 2022
bcd2ead
selector changes
Aug 10, 2022
e0d44d8
focusable hook poc
hetunandu Aug 10, 2022
eee5597
maintaining codeEditor context and tabs context for API
Aug 10, 2022
db5a31d
Trial
hetunandu Aug 18, 2022
3b6efe9
Merge branch 'release' into task/core-navigation
hetunandu Aug 22, 2022
281a813
Merge branch 'release' into task/core-navigation
hetunandu Aug 23, 2022
07abc81
revert changes
hetunandu Aug 23, 2022
ad16881
WIP
hetunandu Aug 23, 2022
87707af
Making api pane tabs work
hetunandu Aug 24, 2022
3fee714
Clean up
hetunandu Aug 24, 2022
d73c0bf
Code Editor Focus
hetunandu Aug 25, 2022
5a212d7
code Editor Cursor position and EvaluatedPopupState
Aug 25, 2022
89d86c3
seperate out context State and restore from that state
Aug 25, 2022
eeef54f
pull from release and resolve conflicts
Aug 25, 2022
866f346
fix codeEditor Type
Aug 25, 2022
beb13e1
fix build errors
hetunandu Aug 26, 2022
f070514
Merge branch 'release' into task/core-navigation
hetunandu Aug 29, 2022
a1117d1
Add support for other entity identification
hetunandu Aug 30, 2022
4dc2854
Remove unused
hetunandu Aug 30, 2022
8ac2dc9
resolving conflicts
Aug 30, 2022
c41f845
canvas basic changes
Aug 30, 2022
20dd1f9
Refactor Api Pane form
hetunandu Sep 6, 2022
c839235
Other Api Pane focus areas
hetunandu Sep 6, 2022
06c27db
Major canvas Context Changes
Sep 6, 2022
953623c
pull from release and resolve conflicts
Sep 6, 2022
a5a7c93
restore codeEditor Index test
Sep 6, 2022
2aed155
ignore cypress changes
Sep 6, 2022
cc07195
Merge remote-tracking branch 'origin/task/core-navigation' into task/…
hetunandu Sep 7, 2022
2a9af1f
Merge branch 'release' into task/core-navigation
hetunandu Sep 7, 2022
72a54eb
Query Pane focus history
hetunandu Sep 7, 2022
feb06dd
fix Canvas Context related bugs
Sep 7, 2022
ed8ca28
Merge branch 'task/core-navigation' of github.com:appsmithorg/appsmit…
Sep 7, 2022
ce929ac
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
Sep 7, 2022
59925a7
JS Pane Focus
hetunandu Sep 8, 2022
6d8c00a
fix cyclic dependecy for test cases
Sep 8, 2022
6687b72
ignore cypress formatting changes
Sep 8, 2022
9c63467
resolve conflicts and merge from release
Sep 8, 2022
5230746
resolve conflicts and merge from feature branch
Sep 8, 2022
dd83169
Fix response pane resize
hetunandu Sep 9, 2022
c9a2ed3
Removed unused
hetunandu Sep 9, 2022
3222448
fix widget entity selection bugs
Sep 9, 2022
fd0bb5e
Merge branch 'task/core-navigation' of github.com:appsmithorg/appsmit…
Sep 9, 2022
cf60ab3
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
Sep 9, 2022
f8a9b18
fix Focus on widget click
Sep 9, 2022
87cb9bd
Merge branch 'release' into task/core-navigation
hetunandu Sep 12, 2022
afd8e7c
Fix merge issue with release
hetunandu Sep 12, 2022
6553615
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 12, 2022
d0d5a8a
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 13, 2022
3f540e5
Add fix for Js editor focus
hetunandu Sep 13, 2022
256a79a
fix: use tab keys instead of index to fix tab switching bugs
akash-codemonk Sep 13, 2022
422118f
Merge branch 'task/core-navigation' of github.com:appsmithorg/appsmit…
akash-codemonk Sep 13, 2022
ae3735b
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 13, 2022
4a75f9d
clean up canvas context code and add comments
Sep 13, 2022
be7b268
Merge branch 'task/core-navigation' of github.com:appsmithorg/appsmit…
Sep 13, 2022
ccffe07
fix: table property pane test
akash-codemonk Sep 13, 2022
a433303
Merge branch 'task/core-navigation' of github.com:appsmithorg/appsmit…
akash-codemonk Sep 13, 2022
a1626a3
more fixes
akash-codemonk Sep 13, 2022
7e080b2
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 13, 2022
7552d2c
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 14, 2022
5beb968
fix: more test fixes
akash-codemonk Sep 14, 2022
6141b25
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 14, 2022
eb9e59e
fix: guided tour
akash-codemonk Sep 14, 2022
3f20b5a
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 14, 2022
18b9c42
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 14, 2022
64ac8e0
fix panel properties tab
Sep 14, 2022
f78ecbd
Merge branch 'task/core-navigation' of github.com:appsmithorg/appsmit…
Sep 14, 2022
430896b
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 15, 2022
f89df70
Merge branch 'task/core-navigation' of github.com:appsmithorg/appsmit…
akash-codemonk Sep 15, 2022
7956b02
chore: more test fixes
akash-codemonk Sep 15, 2022
b801287
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 15, 2022
08247f3
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 15, 2022
53cbfe0
chore: update property pane tests
akash-codemonk Sep 15, 2022
c7ec888
more fixes
akash-codemonk Sep 16, 2022
4c41842
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 16, 2022
87b0648
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 16, 2022
d51b7de
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 16, 2022
d9c3d39
chore: more test fixes
akash-codemonk Sep 19, 2022
dcd6fe1
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 19, 2022
133e0c2
chore: finish pending test fixes
akash-codemonk Sep 19, 2022
51f897a
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
akash-codemonk Sep 19, 2022
a7659af
fix recent entities and sniping mode bugs
Sep 21, 2022
9c5ce40
resolve conflicts and merge from release
Sep 21, 2022
977968a
Merge branch 'release' into task/core-navigation
hetunandu Sep 22, 2022
5ddbdf8
Merge branch 'release' into task/core-navigation
hetunandu Sep 23, 2022
d772ee2
WIP tests
hetunandu Sep 23, 2022
72f1f01
resolve conflicts and merge from release
Sep 25, 2022
a56154a
Merge remote-tracking branch 'origin/task/core-navigation' into task/…
hetunandu Sep 26, 2022
cd5f3bb
WIP
hetunandu Sep 26, 2022
da394a3
Merge branch 'release' into task/core-navigation
hetunandu Sep 28, 2022
2baf812
fix modal widget context issue
Sep 28, 2022
449dad5
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
Sep 28, 2022
688f416
Merge branch 'release' into task/core-navigation
hetunandu Sep 29, 2022
226e648
fix bug in response type switch
hetunandu Sep 29, 2022
33b6903
Merge branch 'release' into task/core-navigation
hetunandu Sep 30, 2022
8c78ce6
Merge branch 'release' into task/core-navigation
hetunandu Sep 30, 2022
a7c4de2
Import the correct application
hetunandu Sep 30, 2022
bb75852
Merge branch 'release' into task/core-navigation
hetunandu Sep 30, 2022
cca7162
Fixes to tests
hetunandu Oct 3, 2022
e1e4c3f
Refactor and remove cursor position feature
hetunandu Oct 5, 2022
341ccff
Merge branch 'release' into task/core-navigation
hetunandu Oct 5, 2022
a8e6bd8
Better check
hetunandu Oct 5, 2022
f64c408
Fix sniping mode issue
hetunandu Oct 6, 2022
0e75885
Merge branch 'release' into task/core-navigation
hetunandu Oct 7, 2022
084837e
Comment out focus on first input of prop pane
hetunandu Oct 7, 2022
9c93855
Fix test of undo redo
hetunandu Oct 10, 2022
df3528d
canvas context phase 1 test cases
Oct 10, 2022
6329e8b
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
Oct 10, 2022
03049e9
Fix autocomplete test
hetunandu Oct 11, 2022
c8b0423
Fix test for Error reporting
hetunandu Oct 11, 2022
becc92d
Merge branch 'release' into task/core-navigation
hetunandu Oct 11, 2022
ffd35f0
Merge branch 'release' into task/core-navigation
hetunandu Oct 12, 2022
1610424
Omnibar test fix
hetunandu Oct 12, 2022
fc4c725
Cleanup
hetunandu Oct 12, 2022
f84e60a
fix canvas context tests
Oct 12, 2022
b0bfc44
Merge branch 'release' of github.com:appsmithorg/appsmith into task/c…
Oct 12, 2022
cee6a2b
chore: maintain datasource edit mode
akash-codemonk Oct 12, 2022
a476d3a
Merge remote-tracking branch 'origin/task/core-navigation' into task/…
hetunandu Oct 13, 2022
49dd641
Merge branch 'chore/datasource-edit' of github.com:appsmithorg/appsmi…
akash-codemonk Oct 13, 2022
472ce1f
Refactor plugin package names
hetunandu Oct 13, 2022
004c6ca
Allow for subTypes of default values
hetunandu Oct 13, 2022
ca3e971
Merge branch 'release' into task/core-navigation
hetunandu Oct 13, 2022
59e86c7
wip
akash-codemonk Oct 13, 2022
6be2754
Fix check for sub type default value
hetunandu Oct 13, 2022
374e24d
Merge branch 'release' into task/core-navigation
hetunandu Oct 13, 2022
70b94e6
Merge branch 'release' into task/core-navigation
hetunandu Oct 14, 2022
a3abd33
Fix issue
hetunandu Oct 14, 2022
7bb190c
Merge branch 'release' into task/core-navigation
hetunandu Oct 17, 2022
f0d6308
moving context swithing behind feature flags
hetunandu Oct 17, 2022
d6865ad
Merge branch 'task/core-navigation' of github.com:appsmithorg/appsmit…
akash-codemonk Oct 17, 2022
3229d96
merge
akash-codemonk Oct 17, 2022
b9a7e2a
chore: Maintain datasource collapse state
akash-codemonk Oct 17, 2022
833eca3
chore: remove change
akash-codemonk Oct 17, 2022
bc13e16
chore: changes
akash-codemonk Oct 17, 2022
fbb0f22
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 9, 2022
fd9c594
fix/google-sheets-datasource
akash-codemonk Nov 9, 2022
5b39641
chore: remove console
akash-codemonk Nov 9, 2022
39e6bb3
Merge branch 'chore/datasource-edit' of github.com:appsmithorg/appsmi…
akash-codemonk Nov 11, 2022
cc511f3
chore: remove console.log
akash-codemonk Nov 11, 2022
9eaeae9
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 22, 2022
89b1dbe
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 23, 2022
288b326
fix: new rest api datasource edit state
akash-codemonk Nov 27, 2022
3104cc7
fix: go to view mode on save of rest api datasource
akash-codemonk Nov 27, 2022
c54ddcf
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 28, 2022
1abe428
Merge branch 'chore/datasource-edit' of github.com:appsmithorg/appsmi…
akash-codemonk Nov 28, 2022
b822950
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 28, 2022
30ed004
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 28, 2022
79aff1d
fix: edit mode for new queries
akash-codemonk Nov 28, 2022
fb02212
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 29, 2022
5d962da
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 30, 2022
b0e0b42
fix: edit state of rest api datasource
akash-codemonk Nov 30, 2022
185dc97
fix: undo test update
akash-codemonk Nov 30, 2022
9f9081d
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 30, 2022
6c6f52b
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Nov 30, 2022
e1a796f
fix: fixes for auto save changes
akash-codemonk Nov 30, 2022
d16ad0e
fix: rest api edit state
akash-codemonk Dec 1, 2022
892647e
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Dec 1, 2022
61d5f83
Merge branch 'chore/datasource-edit' of github.com:appsmithorg/appsmi…
akash-codemonk Dec 1, 2022
de206e2
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Dec 1, 2022
492ef88
chore: refactor
akash-codemonk Dec 1, 2022
afebdef
chore: update test desc
akash-codemonk Dec 1, 2022
9e73f96
chore: test desc update
akash-codemonk Dec 1, 2022
94a0b4c
Merge branch 'chore/datasource-edit' of github.com:appsmithorg/appsmi…
akash-codemonk Dec 1, 2022
3387ed4
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Dec 1, 2022
c9a179a
Merge branch 'chore/datasource-edit' of github.com:appsmithorg/appsmi…
akash-codemonk Dec 1, 2022
adca177
fixes
akash-codemonk Dec 1, 2022
a03181f
Merge branch 'release' of github.com:appsmithorg/appsmith into chore/…
akash-codemonk Dec 2, 2022
1d42c93
test: fix tests
akash-codemonk Dec 2, 2022
5c932eb
fix: remove duplicate feature flag entry
akash-codemonk Dec 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,28 @@ describe("MaintainContext&Focus", function() {
ee.SelectEntityByName("Appsmith");
dataSources.AssertEditMode();
});

it("9. Datasource collapse state has to be maintained", () => {
// Create datasource 1
dataSources.SaveDSFromDialog(false);
dataSources.NavigateToDSCreateNew();
dataSources.CreatePlugIn("PostgreSQL");
agHelper.RenameWithInPane("Postgres1", false);
// Expand section with index 1
dataSources.ExpandSection(1);
// Create and switch to datasource 2
dataSources.SaveDSFromDialog(true);
dataSources.NavigateToDSCreateNew();
dataSources.CreatePlugIn("MongoDB");
agHelper.RenameWithInPane("Mongo1", false);
// Validate if section with index 1 is collapsed
dataSources.AssertSectionCollapseState(1, false);
// Switch back to datasource 1
dataSources.SaveDSFromDialog(false);
dataSources.CreateNewQueryInDS("Postgres1");
ee.SelectEntityByName("Postgres1");
dataSources.EditDatasource();
// Validate if section with index 1 is expanded
dataSources.AssertSectionCollapseState(1, false);
});
});
1 change: 1 addition & 0 deletions app/client/cypress/support/Objects/CommonLocators.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export class CommonLocators {
_chevronUp = ".bp3-icon-chevron-up";
_loading = "#loading";
_spinner = ".bp3-spinner";
_runBtnSpinner = ".cs-spinner";
Expand Down
43 changes: 39 additions & 4 deletions app/client/cypress/support/Pages/DataSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class DataSources {
private _addNewDataSource = ".t--entity-add-btn.datasources";
private _createNewPlgin = (pluginName: string) =>
".t--plugin-name:contains('" + pluginName + "')";
private _collapseContainer = ".t--collapse-section-container";
private _host = "input[name='datasourceConfiguration.endpoints[0].host']";
private _port = "input[name='datasourceConfiguration.endpoints[0].port']";
_databaseName =
Expand Down Expand Up @@ -225,6 +226,40 @@ export class DataSources {
this.agHelper.GetNClick(this._editButton);
}

public ExpandSection(index: number) {
cy.get(this._collapseContainer)
.eq(index)
.click();
cy.get(this._collapseContainer)
.eq(index)
.find(this.locator._chevronUp)
.should("be.visible");
}

public ExpandSectionByName(locator: string) {
// Click on collapse section only if it collapsed, if it is expanded
// we ignore
cy.get(`${locator} span`)
.invoke("attr", "icon")
.then((iconName) => {
if (iconName === "chevron-down") {
cy.get(locator).click();
}
});
}

public AssertSectionCollapseState(index: number, collapsed = false) {
cy.get(this._collapseContainer)
.eq(index)
.within(() => {
if (collapsed) {
cy.get(this.locator._chevronUp).should("not.exist");
} else {
cy.get(this.locator._chevronUp).should("exist");
}
});
}

public NavigateToDSCreateNew() {
this.agHelper.GetNClick(this._addNewDataSource);
// cy.get(this._dsCreateNewTab)
Expand Down Expand Up @@ -258,7 +293,7 @@ export class DataSources {
cy.get(this._databaseName)
.clear()
.type(databaseName);
cy.get(this._sectionAuthentication).click();
this.ExpandSectionByName(this._sectionAuthentication);
cy.get(this._username).type(
username == "" ? datasourceFormData["postgres-username"] : username,
);
Expand All @@ -273,7 +308,7 @@ export class DataSources {
: datasourceFormData["mongo-host"];
cy.get(this._host).type(hostAddress);
cy.get(this._port).type(datasourceFormData["mongo-port"].toString());
cy.get(this._sectionAuthentication).click();
this.ExpandSectionByName(this._sectionAuthentication);
cy.get(this._databaseName)
.clear()
.type(datasourceFormData["mongo-databaseName"]);
Expand All @@ -291,7 +326,7 @@ export class DataSources {
cy.get(this._databaseName)
.clear()
.type(databaseName);
cy.get(this._sectionAuthentication).click();
this.ExpandSectionByName(this._sectionAuthentication);
cy.get(this._username).type(datasourceFormData["mysql-username"]);
cy.get(this._password).type(datasourceFormData["mysql-password"]);
}
Expand Down Expand Up @@ -700,7 +735,7 @@ export class DataSources {

//Update with new password in the datasource conf page
public updatePassword(newPassword: string) {
cy.get(this._sectionAuthentication).click();
this.ExpandSectionByName(this._sectionAuthentication);
cy.get(this._password).type(newPassword);
}

Expand Down
17 changes: 8 additions & 9 deletions app/client/cypress/support/dataSourceCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@

require("cy-verify-downloads").addCustomCommand();
require("cypress-file-upload");
import { ObjectsRegistry } from "../support/Objects/Registry";
const pages = require("../locators/Pages.json");
const datasourceEditor = require("../locators/DatasourcesEditor.json");
const datasourceFormData = require("../fixtures/datasources.json");
const explorer = require("../locators/explorerlocators.json");
const apiWidgetslocator = require("../locators/apiWidgetslocator.json");
const apiEditorLocators = require("../locators/ApiEditor");
const dataSources = ObjectsRegistry.DataSources;

const backgroundColorBlack = "rgb(0, 0, 0)";
const backgroundColorGray1 = "rgb(250, 250, 250)";
Expand Down Expand Up @@ -116,7 +118,7 @@ Cypress.Commands.add(
//cy.get(datasourceEditor["selConnectionType"]).click();
//cy.contains(datasourceFormData["connection-type"]).click();
//cy.get(datasourceEditor["defaultDatabaseName"]).type(databaseName);//is optional hence removing
cy.get(datasourceEditor.sectionAuthentication).click();
dataSources.ExpandSectionByName(datasourceEditor.sectionAuthentication);
cy.get(datasourceEditor["databaseName"])
.clear()
.type(datasourceFormData["mongo-databaseName"]);
Expand Down Expand Up @@ -148,7 +150,7 @@ Cypress.Commands.add(
cy.get(datasourceEditor.databaseName)
.clear()
.type(databaseName);
cy.get(datasourceEditor.sectionAuthentication).click();
dataSources.ExpandSectionByName(datasourceEditor.sectionAuthentication);
cy.get(datasourceEditor.username).type(
datasourceFormData["postgres-username"],
);
Expand Down Expand Up @@ -194,8 +196,7 @@ Cypress.Commands.add(
cy.get(datasourceEditor.databaseName)
.clear()
.type(databaseName);

cy.get(datasourceEditor.sectionAuthentication).click();
dataSources.ExpandSectionByName(datasourceEditor.sectionAuthentication);
cy.get(datasourceEditor.username).type(
datasourceFormData["mysql-username"],
);
Expand All @@ -220,8 +221,7 @@ Cypress.Commands.add(
cy.get(datasourceEditor.databaseName)
.clear()
.type(databaseName);

cy.get(datasourceEditor.sectionAuthentication).click();
dataSources.ExpandSectionByName(datasourceEditor.sectionAuthentication);
cy.get(datasourceEditor.username).type(
datasourceFormData["mssql-username"],
);
Expand All @@ -247,7 +247,7 @@ Cypress.Commands.add(
.clear()
.type(databaseName);

cy.get(datasourceEditor.sectionAuthentication).click();
dataSources.ExpandSectionByName(datasourceEditor.sectionAuthentication);
cy.get(datasourceEditor.username).type(
datasourceFormData["arango-username"],
);
Expand All @@ -272,8 +272,7 @@ Cypress.Commands.add(
cy.get(datasourceEditor.databaseName)
.clear()
.type(databaseName);

cy.get(datasourceEditor.sectionAuthentication).click();
dataSources.ExpandSectionByName(datasourceEditor.sectionAuthentication);
cy.get(datasourceEditor.username).type(
datasourceFormData["redshift-username"],
);
Expand Down
16 changes: 16 additions & 0 deletions app/client/src/actions/datasourceActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,22 @@ export const setDatasourceViewMode = (payload: boolean) => {
};
};

export const setAllDatasourceCollapsible = (payload: {
[key: string]: boolean;
}) => {
return {
type: ReduxActionTypes.SET_ALL_DATASOURCE_COLLAPSIBLE_STATE,
payload,
};
};

export const setDatasourceCollapsible = (key: string, isOpen: boolean) => {
return {
type: ReduxActionTypes.SET_DATASOURCE_COLLAPSIBLE_STATE,
payload: { key, isOpen },
};
};

export const fetchDatasources = (payload?: { workspaceId?: string }) => {
return {
type: ReduxActionTypes.FETCH_DATASOURCES_INIT,
Expand Down
2 changes: 2 additions & 0 deletions app/client/src/ce/constants/ReduxActionConstants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ export const ReduxActionTypes = {
UPDATE_ACTION_SUCCESS: "UPDATE_ACTION_SUCCESS",
DELETE_ACTION_INIT: "DELETE_ACTION_INIT",
SET_DATASOURCE_EDITOR_MODE: "SET_DATASOURCE_EDITOR_MODE",
SET_DATASOURCE_COLLAPSIBLE_STATE: "SET_DATASOURCE_COLLAPSIBLE_STATE",
SET_ALL_DATASOURCE_COLLAPSIBLE_STATE: "SET_ALL_DATASOURCE_COLLAPSIBLE_STATE",
DELETE_ACTION_SUCCESS: "DELETE_ACTION_SUCCESS",
SHOW_ACTION_MODAL: "SHOW_ACTION_MODAL",
CANCEL_ACTION_MODAL: "CANCEL_ACTION_MODAL",
Expand Down
17 changes: 15 additions & 2 deletions app/client/src/navigation/FocusElements.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import {
getSelectedPropertyTabIndex,
} from "selectors/editorContextSelectors";
import { setFocusableCodeEditorField } from "actions/editorContextActions";
import { getSelectedWidgets, isDatasourceInViewMode } from "selectors/ui";
import {
getAllDatasourceCollapsibleState,
getSelectedWidgets,
isDatasourceInViewMode,
} from "selectors/ui";
import { selectMultipleWidgetsInitAction } from "actions/widgetSelectionActions";

import { FocusEntity } from "navigation/FocusEntity";
Expand Down Expand Up @@ -50,7 +54,10 @@ import {
setSelectedPropertyTabIndex,
} from "actions/propertyPaneActions";
import { setCanvasDebuggerSelectedTab } from "actions/debuggerActions";
import { setDatasourceViewMode } from "actions/datasourceActions";
import {
setAllDatasourceCollapsible,
setDatasourceViewMode,
} from "actions/datasourceActions";
import { PluginPackageName } from "entities/Action";
import { getFocusablePropertyPaneField } from "selectors/propertyPaneSelectors";

Expand All @@ -59,6 +66,7 @@ export enum FocusElement {
ApiPaneResponseTabs = "ApiPaneResponseTabs",
ApiPaneResponseHeight = "ApiPaneResponseHeight",
DatasourceViewMode = "DatasourceViewMode",
DatasourceAccordions = "DatasourceAccordions",
ApiRightPaneTabs = "ApiRightPaneTabs",
QueryPaneConfigTabs = "QueryPaneConfigTabs",
QueryPaneResponseTabs = "QueryPaneResponseTabs",
Expand Down Expand Up @@ -111,6 +119,11 @@ export const FocusElementsConfig: Record<FocusEntity, Config[]> = {
setter: setDatasourceViewMode,
defaultValue: true,
},
{
name: FocusElement.DatasourceAccordions,
selector: getAllDatasourceCollapsibleState,
setter: setAllDatasourceCollapsible,
},
],
[FocusEntity.JS_OBJECT]: [
{
Expand Down
97 changes: 51 additions & 46 deletions app/client/src/pages/Editor/DataSourceEditor/Collapsible.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import React from "react";
import React, { useCallback, useEffect } from "react";
import { Collapse, Icon } from "@blueprintjs/core";
import styled from "styled-components";
import { Icon as AdsIcon, IconName, IconSize } from "design-system";
import { useDispatch, useSelector } from "react-redux";
import { AppState } from "@appsmith/reducers";
import { getDatasourceCollapsibleState } from "selectors/ui";
import { setDatasourceCollapsible } from "actions/datasourceActions";
import isUndefined from "lodash/isUndefined";

const SectionLabel = styled.div`
font-weight: 500;
Expand Down Expand Up @@ -32,10 +37,6 @@ const TopBorder = styled.div`
margin-bottom: 24px;
`;

interface ComponentState {
isOpen: boolean;
}

interface ComponentProps {
children: any;
title: string;
Expand All @@ -49,51 +50,55 @@ interface ComponentProps {

type Props = ComponentProps;

class Collapsible extends React.Component<Props, ComponentState> {
constructor(props: Props) {
super(props);
function Collapsible(props: Props) {
const { children, defaultIsOpen, headerIcon, title } = props;
const dispatch = useDispatch();
const isOpen = useSelector((state: AppState) =>
getDatasourceCollapsibleState(state, title),
);

this.state = {
isOpen: props.defaultIsOpen || false,
};
}
const setIsOpen = useCallback((open) => {
dispatch(setDatasourceCollapsible(title, open));
}, []);

render() {
const { children, headerIcon, title } = this.props;
const { isOpen } = this.state;
useEffect(() => {
// We set the default value only when there is no state stored yet for the same
if (defaultIsOpen && isUndefined(isOpen)) {
setIsOpen(defaultIsOpen);
}
}, [defaultIsOpen, isOpen]);

return (
<>
<TopBorder className="t--collapse-top-border" />
<SectionContainer
className="t--collapse-section-container"
data-cy={`section-${title}`}
data-replay-id={`section-${title}`}
onClick={() => this.setState({ isOpen: !this.state.isOpen })}
>
<SectionLabel>
{title}
{headerIcon && (
<AdsIcon
fillColor={headerIcon.color}
name={headerIcon.name}
size={IconSize.MEDIUM}
/>
)}
</SectionLabel>
<Icon
icon={isOpen ? "chevron-up" : "chevron-down"}
iconSize={16}
style={{ color: "#2E3D49" }}
/>
</SectionContainer>
return (
<>
<TopBorder className="t--collapse-top-border" />
<SectionContainer
className="t--collapse-section-container"
data-cy={`section-${title}`}
data-replay-id={`section-${title}`}
onClick={() => setIsOpen(!isOpen)}
>
<SectionLabel>
{title}
{headerIcon && (
<AdsIcon
fillColor={headerIcon.color}
name={headerIcon.name}
size={IconSize.MEDIUM}
/>
)}
</SectionLabel>
<Icon
icon={isOpen ? "chevron-up" : "chevron-down"}
iconSize={16}
style={{ color: "#2E3D49" }}
/>
</SectionContainer>

<Collapse isOpen={this.state.isOpen} keepChildrenMounted>
{children}
</Collapse>
</>
);
}
<Collapse isOpen={isOpen} keepChildrenMounted>
{children}
</Collapse>
</>
);
}

export default Collapsible;
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class JSONtoForm<
return (
<Collapsible
defaultIsOpen={index === 0}
key={index}
key={section.sectionName}
title={section.sectionName}
>
{this.renderEachConfig(section)}
Expand Down
Loading
Loading