From 283ed52354d07e348efbc79aa68a6ad81ddff640 Mon Sep 17 00:00:00 2001 From: Yukti Goyal Date: Mon, 3 Mar 2025 14:06:51 +0530 Subject: [PATCH 001/236] added create user cases --- .../platform/externalApi/apiUsers.cy.js | 383 ++++++++++++++++++ cypress-tests/cypress/support/utils/api.js | 24 ++ 2 files changed, 407 insertions(+) create mode 100644 cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js create mode 100644 cypress-tests/cypress/support/utils/api.js diff --git a/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js b/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js new file mode 100644 index 0000000000..7e836be426 --- /dev/null +++ b/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js @@ -0,0 +1,383 @@ +import { fake } from "Fixtures/fake"; +import { createUser, getUser, updateUser } from 'Support/utils/api'; +import { commonSelectors } from 'Selectors/common'; +import { searchUser, navigateToManageUsers, logout, navigateToManageGroups } from 'Support/utils/common'; + +describe("API Test", () => { + const sanitize = (str) => str.toLowerCase().replace(/[^A-Za-z]/g, ""); + const data = { + firstName: fake.firstName, + lastName: fake.lastName, + firstName1: fake.firstName, + lastName1: fake.lastName, + email: sanitize(fake.email), + email1: sanitize(fake.email), + workspaceName: sanitize(fake.lastName), + workspaceSlug: sanitize(fake.lastName), + workspaceName1: sanitize(fake.firstName), + workspaceSlug1: sanitize(fake.firstName) + }; + it("should create a new user and verify", () => { + cy.defaultWorkspaceLogin(); + /* const userData = { + name: `${data.firstName} ${data.lastName}`, + email: data.email, + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + groups: [{ name: "all_users" }] + } + ] + }; + + createUser(userData).then((response) => { + expect(response.status).to.eq(201); + cy.defaultWorkspaceLogin(); + navigateToManageUsers(); + searchUser(data.email); + cy.contains("td", data.email) + .parent() + .within(() => { + cy.get("td small").should("have.text", "active"); + }); + cy.logoutApi(); + cy.apiLogin(data.email, "password"); + cy.visit("/my-workspace"); + cy.get(commonSelectors.workspaceName).should("have.text", "My workspace"); + logout(); + + cy.defaultWorkspaceLogin(); + cy.getCookie("tj_auth_token").then((cookie) => { + cy.request({ + method: "GET", + url: `${Cypress.env('API_URL')}/users/all?page=1&searchText=${data.email}&status=`, + headers: { + "Tj-Workspace-Id": Cypress.env("workspaceId"), + Cookie: `tj_auth_token=${cookie.value}`, + }, + }).then((response) => { + expect(response.status).to.eq(200); + const userId = response.body.users[0].id; + + getUser(userId).then((response) => { + expect(response.status).to.eq(200); + expect(response.body).to.have.property("name", `${data.firstName} ${data.lastName}`); + expect(response.body).to.have.property("email", data.email); + }); + + const updatedUserData = { + name: `${data.lastName} ${data.firstName}`, + email: data.email2, + }; + + updateUser(userId, updatedUserData).then((response) => { + expect(response.status).to.eq(200); + navigateToManageUsers(); + searchUser(data.email2); + cy.contains("td", data.email2) + .parent() + .within(() => { + cy.get("td small").should("have.text", "active"); + }); + cy.logoutApi(); + cy.apiLogin(data.email2, "password"); + cy.visit("/my-workspace"); + cy.get(commonSelectors.workspaceName).should("have.text", "My workspace"); + logout(); + }); + }); + }); + });*/ + }); + + it("should handle negative cases", () => { + const invalidUserId = "1d8a92b1-4925-4fbf-tool-0jet45d98487"; + const invalidAuthToken = "Basic invalidAuthToken"; + + cy.request({ + method: "GET", + url: `${Cypress.env('API_URL')}/ext/user/${invalidUserId}`, + headers: { + Authorization: invalidAuthToken, + "Content-Type": "application/json", + }, + failOnStatusCode: false, + }).then((response) => { + expect(response.status).to.eq(403); + expect(response.body.message).to.eq("Unauthorized"); + }); + + cy.request({ + method: "POST", + url: `${Cypress.env('API_URL')}/ext/users`, + body: { + name: `${data.lastName} ${data.firstName}`, + email: `${data.email2}`, + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + groups: [{ name: "all_users" }], + }, + ], + }, + headers: { + Authorization: Cypress.env('AUTH_TOKEN'), + "Content-Type": "application/json", + }, + failOnStatusCode: false, + }).then((response) => { + expect(response.status).to.eq(422); + expect(response.body.message).to.eq("Already exists!"); + }); + + cy.request({ + method: "GET", + url: `${Cypress.env('API_URL')}/ext/user/nonExistingUserId`, + headers: { + Authorization: Cypress.env('AUTH_TOKEN'), + "Content-Type": "application/json", + }, + failOnStatusCode: false, + }).then((response) => { + expect(response.status).to.eq(422); + expect(response.body.message).to.contain("invalid input syntax for type uuid"); + }); + + cy.request({ + method: "POST", + url: `${Cypress.env('API_URL')}/ext/users`, + body: { + name: `${data.firstName} ${data.lastName}`, + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + groups: [{ name: "all_users" }], + }, + ], + }, + headers: { + Authorization: Cypress.env('AUTH_TOKEN'), + "Content-Type": "application/json", + }, + failOnStatusCode: false, + }).then((response) => { + expect(response.status).to.eq(400); + expect(response.body.message).to.deep.equal(["email must be an email"]); + }); + + cy.request({ + method: "GET", + url: `${Cypress.env('API_URL')}/users/all`, + failOnStatusCode: false, + }).then((response) => { + expect(response.status).to.eq(401); + expect(response.body.message).to.eq("Unauthorized"); + }); + }); + + it.only("create user", () => { + + cy.defaultWorkspaceLogin(); + navigateToManageGroups(); + + const createGroup = (groupName) => { + cy.get(groupsSelector.createNewGroupButton).click(); + cy.clearAndType(groupsSelector.groupNameInput, groupName); + cy.get(groupsSelector.createGroupButton).click(); + } + ["group1", "group2"].forEach(createGroup); + + [ + { name: data.workspaceName, slug: data.workspaceSlug, group: "ws1group1" }, + { name: data.workspaceName1, slug: data.workspaceSlug1, group: "ws2group2" } + ].forEach(({ name, slug, group }) => { + cy.apiCreateWorkspace(name, slug); + cy.visit(slug); + navigateToManageGroups(); + createGroup(group); + }); + + + //create user with all valid details + const userData = { + name: `${data.firstName} ${data.lastName}`, + email: data.email, + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + groups: [ + { name: "group1" }, + { name: "group2" } + ] + }, + { + name: data.workspaceName, + status: "active", + role: "builder", + groups: [{ name: "ws1group1" }] + }, + { + name: data.workspaceName1, + status: "archived", + role: "admin", + groups: [{ name: "ws2group2" }] + } + ] + }; + + // Added valid user and logged-in in the workpsace + createUser(userData).then((response) => { + expect(response.status).to.eq(201); + cy.defaultWorkspaceLogin(); + navigateToManageUsers(); + searchUser(data.email); + cy.contains("td", data.email) + .parent() + .within(() => { + cy.get("td small").should("have.text", "active"); + }); + + cy.get(commonSelectors.manageGroupsOption).click(); + cy.get(groupsSelector.groupLink("end-user")).click(); + cy.get(groupsSelector.usersLink).click(); + cy.get(`[data-cy="${data.email}-user-row"]`).should("exist"); + + cy.visit(data.workspaceSlug); + navigateToManageGroups(); + cy.get(groupsSelector.groupLink("builder")).click(); + cy.get(groupsSelector.usersLink).click(); + cy.get(`[data-cy="${data.email}-user-row"]`).should("exist"); + + cy.visit(data.workspaceSlug1); + navigateToManageGroups(); + cy.get(groupsSelector.groupLink("admin")).click(); + cy.get(groupsSelector.usersLink).click(); + cy.get(`[data-cy="${data.email}-user-row"]`).should("exist"); + + cy.logoutApi(); + + cy.apiLogin(data.email, "password"); + cy.visit("/my-workspace"); + cy.get(commonSelectors.workspaceName).should("have.text", "My workspace"); + logout(); + + //add user with invalid data and verify error + // const data = { + // firstName1: fake.firstName, + // lastName1: fake.lastName, + // }; + + cy.defaultWorkspaceLogin(); + userData = { + name: `${data.firstName} ${data.lastName}`, + email: data.email, + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + } + ] + } + createUser(userData).then((response) => { + expect(response.status).to.eq(422); + expect(response.body.message).to.eq("Already exists!"); + }); + + userData = { + name: `${data.firstName1} ${data.lastName1}`, + email: "test@tooljet.com1", + password: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the test", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + groups: [{ name: "group1" }] + } + ] + }; + + createUser(userData).then((response) => { + expect(response.status).to.eq(400); + expect(response.body.message).to.eq("email must be an email", + "password must be shorter than or equal to 100 characters"); + }) + + //create and add user in non existing group and non existing workspace + userData = { + name: `${data.firstName1} ${data.lastName1}`, + email: "test@tooljet.com", + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + groups: [{ name: "Group1" }] + } + ] + }; + createUser(userData).then((response) => { + expect(response.status).to.eq(400); + expect(response.body.message).to.eq("Group permission id or name not found: id undefined, name Group1"); + }); + + userData = { + name: `${data.firstName1} ${data.lastName1}`, + email: "test@tooljet.com", + password: "password", + status: "active", + workspaces: [ + { + name: "testws", + status: "active" + } + ] + }; + createUser(userData).then((response) => { + expect(response.status).to.eq(400); + expect(response.body.message).to.eq("The workspaces id or name do not exist: id undefined, name testws"); + }); + + + + //conflict permission + userData = { + name: `${data.firstName1} ${data.lastName1}`, + email: `${data.email1}`, + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + groups: [{ name: "builder groups" }] + } + ] + }; + navigateToManageGroups(); + createGroup("builder groups"); + cy.get(groupsSelector.groupLink("builder groups")).click(); + cy.get(groupsSelector.permissionsLink).click(); + cy.get(groupsSelector.appsCreateCheck).check(); + createUser(userData).then((response) => { + expect(response.status).to.eq(400); + expect(response.body.message).to.eq("End-users can only be granted permission to view apps. Kindly change the user role or custom group to continue."); + }) + }) + }) +}); \ No newline at end of file diff --git a/cypress-tests/cypress/support/utils/api.js b/cypress-tests/cypress/support/utils/api.js new file mode 100644 index 0000000000..3feb609b8e --- /dev/null +++ b/cypress-tests/cypress/support/utils/api.js @@ -0,0 +1,24 @@ +export const apiRequest = (method, url, body = {}, headers = {}) => { + return cy.request({ + method, + url, + body, + headers: { + Authorization: Cypress.env('AUTH_TOKEN'), + "Content-Type": "application/json", + ...headers, + }, + }); +}; + +export const createUser = (userData) => { + return apiRequest("POST", `${Cypress.env('API_URL')}/ext/users`, userData); +}; + +export const getUser = (userId) => { + return apiRequest("GET", `${Cypress.env('API_URL')}/ext/user/${userId}`); +}; + +export const updateUser = (userId, userData) => { + return apiRequest("PATCH", `${Cypress.env('API_URL')}/ext/user/${userId}`, userData); +}; From 1e1ebf6f01080b4d5db9a8cc0b9d40877b47191e Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Wed, 19 Feb 2025 01:34:30 +0530 Subject: [PATCH 002/236] Added option for sorting in the properties panel. --- .../RightSideBar/Inspector/Components/Select.jsx | 13 +++++++++++++ .../AppBuilder/WidgetManager/widgets/dropdownV2.js | 13 +++++++++++++ .../WidgetManager/widgets/multiselectV2.js | 13 +++++++++++++ .../src/Editor/WidgetManager/configs/dropdownV2.js | 13 +++++++++++++ .../Editor/WidgetManager/configs/multiselectV2.js | 13 +++++++++++++ .../apps/services/widget-config/dropdownV2.js | 13 +++++++++++++ .../apps/services/widget-config/multiselectV2.js | 13 +++++++++++++ 7 files changed, 91 insertions(+) diff --git a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx index a57c879121..959a0571c6 100644 --- a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx +++ b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx @@ -32,6 +32,8 @@ export function Select({ componentMeta, darkMode, ...restProps }) { const isDynamicOptionsEnabled = getResolvedValue(component?.component?.definition?.properties?.advanced?.value); + const isSortingEnabled = componentMeta?.properties['sort'] ?? false; + const constructOptions = () => { let optionsValue = component?.component?.definition?.properties?.options?.value; if (!Array.isArray(optionsValue)) { @@ -512,6 +514,17 @@ export function Select({ componentMeta, darkMode, ...restProps }) { currentState, allComponents )} + {isSortingEnabled && + renderElement( + component, + componentMeta, + paramUpdated, + dataQueries, + 'sort', + 'properties', + currentState, + allComponents + )} ), }); diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js b/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js index 247af3ccef..befb739c2a 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js @@ -63,6 +63,18 @@ export const dropdownV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -301,6 +313,7 @@ export const dropdownV2Config = { label: { value: 'Select' }, value: { value: '{{"2"}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select an option' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js b/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js index 6aefd71067..a6bf6f80e2 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js @@ -130,6 +130,18 @@ export const multiselectV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -313,6 +325,7 @@ export const multiselectV2Config = { advanced: { value: `{{false}}` }, showAllOption: { value: '{{false}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select the options' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/Editor/WidgetManager/configs/dropdownV2.js b/frontend/src/Editor/WidgetManager/configs/dropdownV2.js index 247af3ccef..befb739c2a 100644 --- a/frontend/src/Editor/WidgetManager/configs/dropdownV2.js +++ b/frontend/src/Editor/WidgetManager/configs/dropdownV2.js @@ -63,6 +63,18 @@ export const dropdownV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -301,6 +313,7 @@ export const dropdownV2Config = { label: { value: 'Select' }, value: { value: '{{"2"}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select an option' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/Editor/WidgetManager/configs/multiselectV2.js b/frontend/src/Editor/WidgetManager/configs/multiselectV2.js index 6aefd71067..a6bf6f80e2 100644 --- a/frontend/src/Editor/WidgetManager/configs/multiselectV2.js +++ b/frontend/src/Editor/WidgetManager/configs/multiselectV2.js @@ -130,6 +130,18 @@ export const multiselectV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -313,6 +325,7 @@ export const multiselectV2Config = { advanced: { value: `{{false}}` }, showAllOption: { value: '{{false}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select the options' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/server/src/modules/apps/services/widget-config/dropdownV2.js b/server/src/modules/apps/services/widget-config/dropdownV2.js index 247af3ccef..befb739c2a 100644 --- a/server/src/modules/apps/services/widget-config/dropdownV2.js +++ b/server/src/modules/apps/services/widget-config/dropdownV2.js @@ -63,6 +63,18 @@ export const dropdownV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -301,6 +313,7 @@ export const dropdownV2Config = { label: { value: 'Select' }, value: { value: '{{"2"}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select an option' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/server/src/modules/apps/services/widget-config/multiselectV2.js b/server/src/modules/apps/services/widget-config/multiselectV2.js index 6aefd71067..a6bf6f80e2 100644 --- a/server/src/modules/apps/services/widget-config/multiselectV2.js +++ b/server/src/modules/apps/services/widget-config/multiselectV2.js @@ -130,6 +130,18 @@ export const multiselectV2Config = { }, accordian: 'Options', }, + sort: { + type: 'switch', + displayName: 'Sort options', + validation: { schema: { type: 'string' }, defaultValue: 'none' }, + options: [ + { displayName: 'None', value: 'none' }, + { displayName: 'a-z', value: 'asc' }, + { displayName: 'z-a', value: 'desc' }, + ], + accordian: 'Options', + isFxNotRequired: true, + }, loadingState: { type: 'toggle', displayName: 'Loading state', @@ -313,6 +325,7 @@ export const multiselectV2Config = { advanced: { value: `{{false}}` }, showAllOption: { value: '{{false}}' }, optionsLoadingState: { value: '{{false}}' }, + sort: { value: 'none' }, placeholder: { value: 'Select the options' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, From 1082190e98c5c55515bae292fd772365047bbee7 Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Wed, 19 Feb 2025 11:51:02 +0530 Subject: [PATCH 003/236] Changed the default value of Sorting. --- frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js | 4 ++-- .../src/AppBuilder/WidgetManager/widgets/multiselectV2.js | 4 ++-- frontend/src/Editor/WidgetManager/configs/dropdownV2.js | 4 ++-- frontend/src/Editor/WidgetManager/configs/multiselectV2.js | 4 ++-- server/src/modules/apps/services/widget-config/dropdownV2.js | 4 ++-- .../src/modules/apps/services/widget-config/multiselectV2.js | 4 ++-- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js b/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js index befb739c2a..b4672c6afe 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/dropdownV2.js @@ -66,7 +66,7 @@ export const dropdownV2Config = { sort: { type: 'switch', displayName: 'Sort options', - validation: { schema: { type: 'string' }, defaultValue: 'none' }, + validation: { schema: { type: 'string' }, defaultValue: 'asc' }, options: [ { displayName: 'None', value: 'none' }, { displayName: 'a-z', value: 'asc' }, @@ -313,7 +313,7 @@ export const dropdownV2Config = { label: { value: 'Select' }, value: { value: '{{"2"}}' }, optionsLoadingState: { value: '{{false}}' }, - sort: { value: 'none' }, + sort: { value: 'asc' }, placeholder: { value: 'Select an option' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js b/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js index a6bf6f80e2..b603db9c4a 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/multiselectV2.js @@ -133,7 +133,7 @@ export const multiselectV2Config = { sort: { type: 'switch', displayName: 'Sort options', - validation: { schema: { type: 'string' }, defaultValue: 'none' }, + validation: { schema: { type: 'string' }, defaultValue: 'asc' }, options: [ { displayName: 'None', value: 'none' }, { displayName: 'a-z', value: 'asc' }, @@ -325,7 +325,7 @@ export const multiselectV2Config = { advanced: { value: `{{false}}` }, showAllOption: { value: '{{false}}' }, optionsLoadingState: { value: '{{false}}' }, - sort: { value: 'none' }, + sort: { value: 'asc' }, placeholder: { value: 'Select the options' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/Editor/WidgetManager/configs/dropdownV2.js b/frontend/src/Editor/WidgetManager/configs/dropdownV2.js index befb739c2a..b4672c6afe 100644 --- a/frontend/src/Editor/WidgetManager/configs/dropdownV2.js +++ b/frontend/src/Editor/WidgetManager/configs/dropdownV2.js @@ -66,7 +66,7 @@ export const dropdownV2Config = { sort: { type: 'switch', displayName: 'Sort options', - validation: { schema: { type: 'string' }, defaultValue: 'none' }, + validation: { schema: { type: 'string' }, defaultValue: 'asc' }, options: [ { displayName: 'None', value: 'none' }, { displayName: 'a-z', value: 'asc' }, @@ -313,7 +313,7 @@ export const dropdownV2Config = { label: { value: 'Select' }, value: { value: '{{"2"}}' }, optionsLoadingState: { value: '{{false}}' }, - sort: { value: 'none' }, + sort: { value: 'asc' }, placeholder: { value: 'Select an option' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/Editor/WidgetManager/configs/multiselectV2.js b/frontend/src/Editor/WidgetManager/configs/multiselectV2.js index a6bf6f80e2..b603db9c4a 100644 --- a/frontend/src/Editor/WidgetManager/configs/multiselectV2.js +++ b/frontend/src/Editor/WidgetManager/configs/multiselectV2.js @@ -133,7 +133,7 @@ export const multiselectV2Config = { sort: { type: 'switch', displayName: 'Sort options', - validation: { schema: { type: 'string' }, defaultValue: 'none' }, + validation: { schema: { type: 'string' }, defaultValue: 'asc' }, options: [ { displayName: 'None', value: 'none' }, { displayName: 'a-z', value: 'asc' }, @@ -325,7 +325,7 @@ export const multiselectV2Config = { advanced: { value: `{{false}}` }, showAllOption: { value: '{{false}}' }, optionsLoadingState: { value: '{{false}}' }, - sort: { value: 'none' }, + sort: { value: 'asc' }, placeholder: { value: 'Select the options' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/server/src/modules/apps/services/widget-config/dropdownV2.js b/server/src/modules/apps/services/widget-config/dropdownV2.js index befb739c2a..b4672c6afe 100644 --- a/server/src/modules/apps/services/widget-config/dropdownV2.js +++ b/server/src/modules/apps/services/widget-config/dropdownV2.js @@ -66,7 +66,7 @@ export const dropdownV2Config = { sort: { type: 'switch', displayName: 'Sort options', - validation: { schema: { type: 'string' }, defaultValue: 'none' }, + validation: { schema: { type: 'string' }, defaultValue: 'asc' }, options: [ { displayName: 'None', value: 'none' }, { displayName: 'a-z', value: 'asc' }, @@ -313,7 +313,7 @@ export const dropdownV2Config = { label: { value: 'Select' }, value: { value: '{{"2"}}' }, optionsLoadingState: { value: '{{false}}' }, - sort: { value: 'none' }, + sort: { value: 'asc' }, placeholder: { value: 'Select an option' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/server/src/modules/apps/services/widget-config/multiselectV2.js b/server/src/modules/apps/services/widget-config/multiselectV2.js index a6bf6f80e2..b603db9c4a 100644 --- a/server/src/modules/apps/services/widget-config/multiselectV2.js +++ b/server/src/modules/apps/services/widget-config/multiselectV2.js @@ -133,7 +133,7 @@ export const multiselectV2Config = { sort: { type: 'switch', displayName: 'Sort options', - validation: { schema: { type: 'string' }, defaultValue: 'none' }, + validation: { schema: { type: 'string' }, defaultValue: 'asc' }, options: [ { displayName: 'None', value: 'none' }, { displayName: 'a-z', value: 'asc' }, @@ -325,7 +325,7 @@ export const multiselectV2Config = { advanced: { value: `{{false}}` }, showAllOption: { value: '{{false}}' }, optionsLoadingState: { value: '{{false}}' }, - sort: { value: 'none' }, + sort: { value: 'asc' }, placeholder: { value: 'Select the options' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, From 26ac5ffdceba957007f12601e64eea220fd59e50 Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Fri, 21 Feb 2025 10:00:55 +0530 Subject: [PATCH 004/236] Implemented sorting for dropdown and multiselect in component and properties panel. --- .../Inspector/Components/Select.jsx | 70 +++++++++++++------ .../Components/DropdownV2/DropdownV2.jsx | 15 +++- .../MultiselectV2/MultiselectV2.jsx | 14 +++- 3 files changed, 75 insertions(+), 24 deletions(-) diff --git a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx index 959a0571c6..cf5bc97d1a 100644 --- a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx +++ b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect, useRef } from 'react'; import Accordion from '@/_ui/Accordion'; import { EventManager } from '../EventManager'; import { renderElement } from '../Utils'; @@ -27,12 +27,13 @@ export function Select({ componentMeta, darkMode, ...restProps }) { allComponents, pages, } = restProps; + + const isInitialRender = useRef(true); const getResolvedValue = useStore((state) => state.getResolvedValue, shallow); const isMultiSelect = component?.component?.component === 'MultiselectV2'; - const isDynamicOptionsEnabled = getResolvedValue(component?.component?.definition?.properties?.advanced?.value); - const isSortingEnabled = componentMeta?.properties['sort'] ?? false; + const sort = component?.component?.definition?.properties?.sort?.value; const constructOptions = () => { let optionsValue = component?.component?.definition?.properties?.options?.value; @@ -83,6 +84,15 @@ export function Select({ componentMeta, darkMode, ...restProps }) { } } + const sortArray = (arr) => { + if (sort === 'asc') { + return arr.sort((a, b) => a.label?.localeCompare(b.label)); + } else if (sort === 'desc') { + return arr.sort((a, b) => b.label?.localeCompare(a.label)); + } + return arr; + }; + const getItemStyle = (isDragging, draggableStyle) => ({ userSelect: 'none', ...draggableStyle, @@ -92,6 +102,15 @@ export function Select({ componentMeta, darkMode, ...restProps }) { paramUpdated({ name: 'options' }, 'value', options, 'properties', false, props); }; + const updateSortParam = (value) => { + paramUpdated({ name: 'sort' }, 'value', value, 'properties'); + }; + + const updateOptions = (options) => { + setOptions(options); + updateAllOptionsParams(options); + }; + const generateNewOptions = () => { let found = false; let label = ''; @@ -117,8 +136,8 @@ export function Select({ componentMeta, darkMode, ...restProps }) { const handleAddOption = () => { let _option = generateNewOptions(); const _items = [...options, _option]; - setOptions(_items); - updateAllOptionsParams(_items); + const sortedItems = sortArray(_items); + updateOptions(sortedItems); }; const handleDeleteOption = (index) => { @@ -137,8 +156,7 @@ export function Select({ componentMeta, darkMode, ...restProps }) { } return option; }); - setOptions(_options); - updateAllOptionsParams(_options); + updateOptions(_options); }; const handleValueChange = (value, index) => { @@ -151,16 +169,17 @@ export function Select({ componentMeta, darkMode, ...restProps }) { } return option; }); - setOptions(_options); - updateAllOptionsParams(_options); + updateOptions(_options); }; const reorderOptions = async (startIndex, endIndex) => { const result = [...options]; const [removed] = result.splice(startIndex, 1); result.splice(endIndex, 0, removed); - setOptions(result); - updateAllOptionsParams(result); + updateOptions(result); + if (isSortingEnabled && sort !== 'none') { + updateSortParam('none'); + } }; const onDragEnd = ({ source, destination }) => { @@ -203,8 +222,7 @@ export function Select({ componentMeta, darkMode, ...restProps }) { }; } }); - setOptions(_options); - updateAllOptionsParams(_options); + updateOptions(_options); setMarkedAsDefault(_value); paramUpdated({ name: 'value' }, 'value', _value, 'properties'); } @@ -223,8 +241,7 @@ export function Select({ componentMeta, darkMode, ...restProps }) { } return option; }); - setOptions(_options); - updateAllOptionsParams(_options); + updateOptions(_options); }; const handleDisableChange = (value, index) => { @@ -240,8 +257,7 @@ export function Select({ componentMeta, darkMode, ...restProps }) { } return option; }); - setOptions(_options); - updateAllOptionsParams(_options); + updateOptions(_options); }; const handleOnFxPress = (active, index, key) => { @@ -257,12 +273,20 @@ export function Select({ componentMeta, darkMode, ...restProps }) { } return option; }); - setOptions(_options); - updateAllOptionsParams(_options); + updateOptions(_options); }; useEffect(() => { - setOptions(constructOptions()); + if (!isInitialRender.current && isSortingEnabled) { + const sortedOptions = sortArray([...options]); + updateOptions(sortedOptions); + } + }, [sort]); + + useEffect(() => { + const sortedOptions = sortArray(constructOptions()); + updateOptions(sortedOptions); + isInitialRender.current = false; }, [isMultiSelect, component?.id]); const _renderOverlay = (item, index) => { @@ -389,6 +413,12 @@ export function Select({ componentMeta, darkMode, ...restProps }) { trigger="click" placement="left" rootClose + onExited={() => { + if (isSortingEnabled && sort !== 'none') { + const sortedOptions = sortArray([...options]); + updateOptions(sortedOptions); + } + }} overlay={_renderOverlay(item, index)} >
diff --git a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx index ae976e54ea..4cb5309d46 100644 --- a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx +++ b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx @@ -68,6 +68,7 @@ export const DropdownV2 = ({ loadingState: dropdownLoadingState, disabledState, optionsLoadingState, + sort, } = properties; const { selectedTextColor, @@ -112,6 +113,16 @@ export const DropdownV2 = ({ const foundItem = _schema?.find((item) => item?.default === true); return !hasVisibleFalse(foundItem?.value) ? foundItem?.value : undefined; } + + const sortArray = (arr) => { + if (sort === 'asc') { + return arr.sort((a, b) => a.label?.localeCompare(b.label)); + } else if (sort === 'desc') { + return arr.sort((a, b) => b.label?.localeCompare(a.label)); + } + return arr; + }; + const selectOptions = useMemo(() => { let _options = advanced ? schema : options; if (Array.isArray(_options)) { @@ -124,11 +135,11 @@ export const DropdownV2 = ({ isDisabled: data?.disable ?? false, })); - return _selectOptions; + return sortArray(_selectOptions); } else { return []; } - }, [advanced, schema, options]); + }, [advanced, schema, options, sort]); function selectOption(value) { const val = selectOptions.filter((option) => !option.isDisabled)?.find((option) => option.value === value); diff --git a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx index 6ef45e84d9..e7dcd52a1a 100644 --- a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx +++ b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx @@ -36,6 +36,7 @@ export const MultiselectV2 = ({ placeholder, loadingState: multiSelectLoadingState, optionsLoadingState, + sort, } = properties; const { selectedTextColor, @@ -84,6 +85,15 @@ export const MultiselectV2 = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [properties.visibility, multiSelectLoadingState, disabledState]); + const sortArray = (arr) => { + if (sort === 'asc') { + return arr.sort((a, b) => a.label?.localeCompare(b.label)); + } else if (sort === 'desc') { + return arr.sort((a, b) => b.label?.localeCompare(a.label)); + } + return arr; + }; + const selectOptions = useMemo(() => { const _options = advanced ? schema : options; let _selectOptions = Array.isArray(_options) @@ -96,9 +106,9 @@ export const MultiselectV2 = ({ isDisabled: data?.disable ?? false, })) : []; - return _selectOptions; + return sortArray(_selectOptions); // eslint-disable-next-line react-hooks/exhaustive-deps - }, [advanced, JSON.stringify(schema), JSON.stringify(options)]); + }, [advanced, JSON.stringify(schema), JSON.stringify(options), sort]); function findDefaultItem(value, isAdvanced, isDefault) { if (isAdvanced) { From 592f273e3ba3a61667477ddc8418875ab75def03 Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Thu, 6 Mar 2025 13:20:20 +0530 Subject: [PATCH 005/236] Convert sortArray func into a utility func to reuse it. --- .../Inspector/Components/Select.jsx | 18 +++++------------- .../Components/DropdownV2/DropdownV2.jsx | 13 ++----------- .../src/Editor/Components/DropdownV2/utils.js | 9 +++++++++ .../Components/MultiselectV2/MultiselectV2.jsx | 13 ++----------- 4 files changed, 18 insertions(+), 35 deletions(-) diff --git a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx index cf5bc97d1a..a99ce25ac6 100644 --- a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx +++ b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Select.jsx @@ -14,6 +14,7 @@ import { ButtonSolid } from '@/_ui/AppButton/AppButton'; import SortableList from '@/_components/SortableList'; import Trash from '@/_ui/Icon/solidIcons/Trash'; import { shallow } from 'zustand/shallow'; +import { sortArray } from '@/Editor/Components/DropdownV2/utils'; export function Select({ componentMeta, darkMode, ...restProps }) { const { @@ -84,15 +85,6 @@ export function Select({ componentMeta, darkMode, ...restProps }) { } } - const sortArray = (arr) => { - if (sort === 'asc') { - return arr.sort((a, b) => a.label?.localeCompare(b.label)); - } else if (sort === 'desc') { - return arr.sort((a, b) => b.label?.localeCompare(a.label)); - } - return arr; - }; - const getItemStyle = (isDragging, draggableStyle) => ({ userSelect: 'none', ...draggableStyle, @@ -136,7 +128,7 @@ export function Select({ componentMeta, darkMode, ...restProps }) { const handleAddOption = () => { let _option = generateNewOptions(); const _items = [...options, _option]; - const sortedItems = sortArray(_items); + const sortedItems = sortArray(_items, sort); updateOptions(sortedItems); }; @@ -278,13 +270,13 @@ export function Select({ componentMeta, darkMode, ...restProps }) { useEffect(() => { if (!isInitialRender.current && isSortingEnabled) { - const sortedOptions = sortArray([...options]); + const sortedOptions = sortArray([...options], sort); updateOptions(sortedOptions); } }, [sort]); useEffect(() => { - const sortedOptions = sortArray(constructOptions()); + const sortedOptions = sortArray(constructOptions(), sort); updateOptions(sortedOptions); isInitialRender.current = false; }, [isMultiSelect, component?.id]); @@ -415,7 +407,7 @@ export function Select({ componentMeta, darkMode, ...restProps }) { rootClose onExited={() => { if (isSortingEnabled && sort !== 'none') { - const sortedOptions = sortArray([...options]); + const sortedOptions = sortArray([...options], sort); updateOptions(sortedOptions); } }} diff --git a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx index 4cb5309d46..ce286d7fb8 100644 --- a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx +++ b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx @@ -13,7 +13,7 @@ import CustomMenuList from './CustomMenuList'; import CustomOption from './CustomOption'; import Label from '@/_ui/Label'; import cx from 'classnames'; -import { getInputBackgroundColor, getInputBorderColor, getInputFocusedColor } from './utils'; +import { getInputBackgroundColor, getInputBorderColor, getInputFocusedColor, sortArray } from './utils'; import { isMobileDevice } from '@/_helpers/appUtils'; const { DropdownIndicator, ClearIndicator } = components; @@ -114,15 +114,6 @@ export const DropdownV2 = ({ return !hasVisibleFalse(foundItem?.value) ? foundItem?.value : undefined; } - const sortArray = (arr) => { - if (sort === 'asc') { - return arr.sort((a, b) => a.label?.localeCompare(b.label)); - } else if (sort === 'desc') { - return arr.sort((a, b) => b.label?.localeCompare(a.label)); - } - return arr; - }; - const selectOptions = useMemo(() => { let _options = advanced ? schema : options; if (Array.isArray(_options)) { @@ -135,7 +126,7 @@ export const DropdownV2 = ({ isDisabled: data?.disable ?? false, })); - return sortArray(_selectOptions); + return sortArray(_selectOptions, sort); } else { return []; } diff --git a/frontend/src/Editor/Components/DropdownV2/utils.js b/frontend/src/Editor/Components/DropdownV2/utils.js index 3c8edb9b9b..ed58cbe73d 100644 --- a/frontend/src/Editor/Components/DropdownV2/utils.js +++ b/frontend/src/Editor/Components/DropdownV2/utils.js @@ -67,3 +67,12 @@ export const highlightText = (text = '', highlight) => { ); }; + +export const sortArray = (arr, sort) => { + if (sort === 'asc') { + return arr.sort((a, b) => a.label?.localeCompare(b.label)); + } else if (sort === 'desc') { + return arr.sort((a, b) => b.label?.localeCompare(a.label)); + } + return arr; +}; diff --git a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx index e7dcd52a1a..90b612b0c1 100644 --- a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx +++ b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx @@ -11,7 +11,7 @@ import cx from 'classnames'; import Label from '@/_ui/Label'; const tinycolor = require('tinycolor2'); import { CustomDropdownIndicator, CustomClearIndicator } from '../DropdownV2/DropdownV2'; -import { getInputBackgroundColor, getInputBorderColor, getInputFocusedColor } from '../DropdownV2/utils'; +import { getInputBackgroundColor, getInputBorderColor, getInputFocusedColor, sortArray } from '../DropdownV2/utils'; export const MultiselectV2 = ({ id, @@ -85,15 +85,6 @@ export const MultiselectV2 = ({ // eslint-disable-next-line react-hooks/exhaustive-deps }, [properties.visibility, multiSelectLoadingState, disabledState]); - const sortArray = (arr) => { - if (sort === 'asc') { - return arr.sort((a, b) => a.label?.localeCompare(b.label)); - } else if (sort === 'desc') { - return arr.sort((a, b) => b.label?.localeCompare(a.label)); - } - return arr; - }; - const selectOptions = useMemo(() => { const _options = advanced ? schema : options; let _selectOptions = Array.isArray(_options) @@ -106,7 +97,7 @@ export const MultiselectV2 = ({ isDisabled: data?.disable ?? false, })) : []; - return sortArray(_selectOptions); + return sortArray(_selectOptions, sort); // eslint-disable-next-line react-hooks/exhaustive-deps }, [advanced, JSON.stringify(schema), JSON.stringify(options), sort]); From c4b5ce499ddee694b3d3bc3b542372f9af0775a3 Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Thu, 13 Feb 2025 15:40:51 +0530 Subject: [PATCH 006/236] Added shortcuts to run and preview a query in query panel. --- .../AppBuilder/QueryPanel/QueryKeyHooks.jsx | 48 +++++++++++++++++++ .../src/AppBuilder/QueryPanel/QueryPanel.jsx | 5 +- 2 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 frontend/src/AppBuilder/QueryPanel/QueryKeyHooks.jsx diff --git a/frontend/src/AppBuilder/QueryPanel/QueryKeyHooks.jsx b/frontend/src/AppBuilder/QueryPanel/QueryKeyHooks.jsx new file mode 100644 index 0000000000..06d8958cab --- /dev/null +++ b/frontend/src/AppBuilder/QueryPanel/QueryKeyHooks.jsx @@ -0,0 +1,48 @@ +import React from 'react'; +import useStore from '@/AppBuilder/_stores/store'; +import { useHotkeys } from 'react-hotkeys-hook'; +import { useModuleId } from '@/AppBuilder/_contexts/ModuleContext'; + +const QueryKeyHooks = ({ children, isExpanded }) => { + const runQuery = useStore((state) => state.queryPanel.runQuery); + const selectedQuery = useStore((state) => state.queryPanel.selectedQuery); + const moduleId = useModuleId(); + const previewQuery = useStore((state) => state.queryPanel.previewQuery); + const selectedDataSource = useStore((state) => state.queryPanel.selectedDataSource); + const queryName = selectedQuery?.name ?? ''; + + const previewButtonOnClick = () => { + const _options = { ...selectedQuery.options }; + const query = { + data_source_id: selectedDataSource.id === 'null' ? null : selectedDataSource.id, + pluginId: selectedDataSource.pluginId, + options: _options, + kind: selectedDataSource.kind, + name: queryName, + id: selectedQuery?.id, + }; + previewQuery(query, false, undefined, moduleId).catch(({ error, data }) => { + console.log(error, data); + }); + }; + + const shortcutRef = useHotkeys( + ['mod+enter', 'mod+shift+enter'], + (event, handler) => { + if (handler.mod && handler.keys[0] === 'enter') { + if (handler.shift) { + previewButtonOnClick(); + } else runQuery(selectedQuery?.id, selectedQuery?.name, undefined, 'edit', {}, true); + } + }, + { enabled: isExpanded } + ); + + return ( +
+ {children} +
+ ); +}; + +export default QueryKeyHooks; diff --git a/frontend/src/AppBuilder/QueryPanel/QueryPanel.jsx b/frontend/src/AppBuilder/QueryPanel/QueryPanel.jsx index 827efe6d33..8bf5d2ea53 100644 --- a/frontend/src/AppBuilder/QueryPanel/QueryPanel.jsx +++ b/frontend/src/AppBuilder/QueryPanel/QueryPanel.jsx @@ -11,6 +11,7 @@ import useStore from '@/AppBuilder/_stores/store'; import SectionCollapse from '@/_ui/Icon/solidIcons/SectionCollapse'; import SectionExpand from '@/_ui/Icon/solidIcons/SectionExpand'; import { shallow } from 'zustand/shallow'; +import QueryKeyHooks from './QueryKeyHooks'; const MemoizedQueryDataPane = memo(QueryDataPane); const MemoizedQueryManager = memo(QueryManager); @@ -192,14 +193,14 @@ export const QueryPanel = ({ darkMode }) => { }} > {isExpanded && ( -
+
-
+ )}
From d083420616f7f3ce89cb7dbf5a96ada01f3b8682 Mon Sep 17 00:00:00 2001 From: Yukti Goyal Date: Fri, 7 Mar 2025 11:13:04 +0530 Subject: [PATCH 007/236] added few cases --- .../workspace/groups/permissions.cy.js | 2 - .../platform/externalApi/apiUsers.cy.js | 503 ++++++------------ cypress-tests/cypress/support/utils/api.js | 20 + 3 files changed, 174 insertions(+), 351 deletions(-) diff --git a/cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/permissions.cy.js b/cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/permissions.cy.js index 8fefd2bb5c..9ce1736842 100644 --- a/cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/permissions.cy.js +++ b/cypress-tests/cypress/e2e/happyPath/platform/commonTestcases/workspace/groups/permissions.cy.js @@ -522,10 +522,8 @@ describe("Manage Groups", () => { commonSelectors.buttonSelector(exportAppModalText.exportSelectedVersion) ).click(); cy.exec("ls ./cypress/downloads/").then((result) => { - cy.log(result); const downloadedAppExportFileName = result.stdout.split("\n")[0]; exportedFilePath = `cypress/downloads/${downloadedAppExportFileName}`; - cy.log(exportedFilePath); cy.get(importSelectors.dropDownMenu).should("be.visible").click(); cy.get(importSelectors.importOptionInput).selectFile(exportedFilePath, { force: true, diff --git a/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js b/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js index 7e836be426..41deec86c4 100644 --- a/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js +++ b/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js @@ -1,204 +1,78 @@ import { fake } from "Fixtures/fake"; -import { createUser, getUser, updateUser } from 'Support/utils/api'; +import { createUser, getAllUsers, getUser, updateUser, createGroup, validateUserInGroup } from 'Support/utils/api'; +import { groupsSelector } from "Selectors/manageGroups"; import { commonSelectors } from 'Selectors/common'; import { searchUser, navigateToManageUsers, logout, navigateToManageGroups } from 'Support/utils/common'; describe("API Test", () => { + const sanitize = (str) => str.toLowerCase().replace(/[^A-Za-z]/g, ""); + let userId; const data = { firstName: fake.firstName, lastName: fake.lastName, firstName1: fake.firstName, lastName1: fake.lastName, - email: sanitize(fake.email), - email1: sanitize(fake.email), + email: fake.email.toLowerCase().replaceAll("[^A-Za-z]", ""), + email1: fake.email.toLowerCase().replaceAll("[^A-Za-z]", ""), workspaceName: sanitize(fake.lastName), workspaceSlug: sanitize(fake.lastName), workspaceName1: sanitize(fake.firstName), - workspaceSlug1: sanitize(fake.firstName) + workspaceSlug1: sanitize(fake.firstName), + group1: sanitize(fake.firstName), + group2: sanitize(fake.firstName), + group3: sanitize(fake.firstName), + group4: sanitize(fake.firstName), + group5: sanitize(fake.firstName) }; - it("should create a new user and verify", () => { + + //user with all valid details + const userData = { + name: `${data.firstName} ${data.lastName}`, + email: data.email, + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + groups: [ + { name: data.group1 }, + { name: data.group2 } + ] + }, + { + name: data.workspaceName, + status: "active", + role: "builder", + groups: [{ name: data.group3 }] + }, + { + name: data.workspaceName1, + status: "archived", + role: "admin", + groups: [{ name: data.group4 }] + } + ] + }; + + beforeEach(() => { cy.defaultWorkspaceLogin(); - /* const userData = { - name: `${data.firstName} ${data.lastName}`, - email: data.email, - password: "password", - status: "active", - workspaces: [ - { - name: "My workspace", - status: "active", - groups: [{ name: "all_users" }] - } - ] - }; - - createUser(userData).then((response) => { - expect(response.status).to.eq(201); - cy.defaultWorkspaceLogin(); - navigateToManageUsers(); - searchUser(data.email); - cy.contains("td", data.email) - .parent() - .within(() => { - cy.get("td small").should("have.text", "active"); - }); - cy.logoutApi(); - cy.apiLogin(data.email, "password"); - cy.visit("/my-workspace"); - cy.get(commonSelectors.workspaceName).should("have.text", "My workspace"); - logout(); - - cy.defaultWorkspaceLogin(); - cy.getCookie("tj_auth_token").then((cookie) => { - cy.request({ - method: "GET", - url: `${Cypress.env('API_URL')}/users/all?page=1&searchText=${data.email}&status=`, - headers: { - "Tj-Workspace-Id": Cypress.env("workspaceId"), - Cookie: `tj_auth_token=${cookie.value}`, - }, - }).then((response) => { - expect(response.status).to.eq(200); - const userId = response.body.users[0].id; - - getUser(userId).then((response) => { - expect(response.status).to.eq(200); - expect(response.body).to.have.property("name", `${data.firstName} ${data.lastName}`); - expect(response.body).to.have.property("email", data.email); - }); - - const updatedUserData = { - name: `${data.lastName} ${data.firstName}`, - email: data.email2, - }; - - updateUser(userId, updatedUserData).then((response) => { - expect(response.status).to.eq(200); - navigateToManageUsers(); - searchUser(data.email2); - cy.contains("td", data.email2) - .parent() - .within(() => { - cy.get("td small").should("have.text", "active"); - }); - cy.logoutApi(); - cy.apiLogin(data.email2, "password"); - cy.visit("/my-workspace"); - cy.get(commonSelectors.workspaceName).should("have.text", "My workspace"); - logout(); - }); - }); - }); - });*/ }); - it("should handle negative cases", () => { - const invalidUserId = "1d8a92b1-4925-4fbf-tool-0jet45d98487"; - const invalidAuthToken = "Basic invalidAuthToken"; - - cy.request({ - method: "GET", - url: `${Cypress.env('API_URL')}/ext/user/${invalidUserId}`, - headers: { - Authorization: invalidAuthToken, - "Content-Type": "application/json", - }, - failOnStatusCode: false, - }).then((response) => { - expect(response.status).to.eq(403); - expect(response.body.message).to.eq("Unauthorized"); - }); - - cy.request({ - method: "POST", - url: `${Cypress.env('API_URL')}/ext/users`, - body: { - name: `${data.lastName} ${data.firstName}`, - email: `${data.email2}`, - password: "password", - status: "active", - workspaces: [ - { - name: "My workspace", - status: "active", - groups: [{ name: "all_users" }], - }, - ], - }, - headers: { - Authorization: Cypress.env('AUTH_TOKEN'), - "Content-Type": "application/json", - }, - failOnStatusCode: false, - }).then((response) => { - expect(response.status).to.eq(422); - expect(response.body.message).to.eq("Already exists!"); - }); - - cy.request({ - method: "GET", - url: `${Cypress.env('API_URL')}/ext/user/nonExistingUserId`, - headers: { - Authorization: Cypress.env('AUTH_TOKEN'), - "Content-Type": "application/json", - }, - failOnStatusCode: false, - }).then((response) => { - expect(response.status).to.eq(422); - expect(response.body.message).to.contain("invalid input syntax for type uuid"); - }); - - cy.request({ - method: "POST", - url: `${Cypress.env('API_URL')}/ext/users`, - body: { - name: `${data.firstName} ${data.lastName}`, - password: "password", - status: "active", - workspaces: [ - { - name: "My workspace", - status: "active", - groups: [{ name: "all_users" }], - }, - ], - }, - headers: { - Authorization: Cypress.env('AUTH_TOKEN'), - "Content-Type": "application/json", - }, - failOnStatusCode: false, - }).then((response) => { - expect(response.status).to.eq(400); - expect(response.body.message).to.deep.equal(["email must be an email"]); - }); - - cy.request({ - method: "GET", - url: `${Cypress.env('API_URL')}/users/all`, - failOnStatusCode: false, - }).then((response) => { - expect(response.status).to.eq(401); - expect(response.body.message).to.eq("Unauthorized"); - }); - }); - - it.only("create user", () => { - - cy.defaultWorkspaceLogin(); + it("Create user with valid details", () => { + // create multiple groups in different workspaces navigateToManageGroups(); + [data.group1, data.group2, data.group5].forEach(createGroup); - const createGroup = (groupName) => { - cy.get(groupsSelector.createNewGroupButton).click(); - cy.clearAndType(groupsSelector.groupNameInput, groupName); - cy.get(groupsSelector.createGroupButton).click(); - } - ["group1", "group2"].forEach(createGroup); + //builder group + cy.get(groupsSelector.groupLink(data.group5)).click(); + cy.get(groupsSelector.permissionsLink).click(); + cy.get(groupsSelector.appsCreateCheck).check(); [ - { name: data.workspaceName, slug: data.workspaceSlug, group: "ws1group1" }, - { name: data.workspaceName1, slug: data.workspaceSlug1, group: "ws2group2" } + { name: data.workspaceName, slug: data.workspaceSlug, group: data.group3 }, + { name: data.workspaceName1, slug: data.workspaceSlug1, group: data.group4 } ].forEach(({ name, slug, group }) => { cy.apiCreateWorkspace(name, slug); cy.visit(slug); @@ -206,178 +80,109 @@ describe("API Test", () => { createGroup(group); }); - - //create user with all valid details - const userData = { - name: `${data.firstName} ${data.lastName}`, - email: data.email, - password: "password", - status: "active", - workspaces: [ - { - name: "My workspace", - status: "active", - groups: [ - { name: "group1" }, - { name: "group2" } - ] - }, - { - name: data.workspaceName, - status: "active", - role: "builder", - groups: [{ name: "ws1group1" }] - }, - { - name: data.workspaceName1, - status: "archived", - role: "admin", - groups: [{ name: "ws2group2" }] - } - ] - }; - // Added valid user and logged-in in the workpsace + cy.visit("/my-workspace"); + cy.wait(500); createUser(userData).then((response) => { expect(response.status).to.eq(201); - cy.defaultWorkspaceLogin(); - navigateToManageUsers(); - searchUser(data.email); - cy.contains("td", data.email) - .parent() - .within(() => { - cy.get("td small").should("have.text", "active"); - }); - - cy.get(commonSelectors.manageGroupsOption).click(); - cy.get(groupsSelector.groupLink("end-user")).click(); - cy.get(groupsSelector.usersLink).click(); - cy.get(`[data-cy="${data.email}-user-row"]`).should("exist"); - - cy.visit(data.workspaceSlug); - navigateToManageGroups(); - cy.get(groupsSelector.groupLink("builder")).click(); - cy.get(groupsSelector.usersLink).click(); - cy.get(`[data-cy="${data.email}-user-row"]`).should("exist"); - - cy.visit(data.workspaceSlug1); - navigateToManageGroups(); - cy.get(groupsSelector.groupLink("admin")).click(); - cy.get(groupsSelector.usersLink).click(); - cy.get(`[data-cy="${data.email}-user-row"]`).should("exist"); - - cy.logoutApi(); - - cy.apiLogin(data.email, "password"); - cy.visit("/my-workspace"); - cy.get(commonSelectors.workspaceName).should("have.text", "My workspace"); - logout(); - - //add user with invalid data and verify error - // const data = { - // firstName1: fake.firstName, - // lastName1: fake.lastName, - // }; - - cy.defaultWorkspaceLogin(); - userData = { - name: `${data.firstName} ${data.lastName}`, - email: data.email, - password: "password", - status: "active", - workspaces: [ - { - name: "My workspace", - status: "active", - } - ] - } - createUser(userData).then((response) => { - expect(response.status).to.eq(422); - expect(response.body.message).to.eq("Already exists!"); - }); - - userData = { - name: `${data.firstName1} ${data.lastName1}`, - email: "test@tooljet.com1", - password: "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the test", - status: "active", - workspaces: [ - { - name: "My workspace", - status: "active", - groups: [{ name: "group1" }] - } - ] - }; - - createUser(userData).then((response) => { - expect(response.status).to.eq(400); - expect(response.body.message).to.eq("email must be an email", - "password must be shorter than or equal to 100 characters"); - }) - - //create and add user in non existing group and non existing workspace - userData = { - name: `${data.firstName1} ${data.lastName1}`, - email: "test@tooljet.com", - password: "password", - status: "active", - workspaces: [ - { - name: "My workspace", - status: "active", - groups: [{ name: "Group1" }] - } - ] - }; - createUser(userData).then((response) => { - expect(response.status).to.eq(400); - expect(response.body.message).to.eq("Group permission id or name not found: id undefined, name Group1"); - }); - - userData = { - name: `${data.firstName1} ${data.lastName1}`, - email: "test@tooljet.com", - password: "password", - status: "active", - workspaces: [ - { - name: "testws", - status: "active" - } - ] - }; - createUser(userData).then((response) => { - expect(response.status).to.eq(400); - expect(response.body.message).to.eq("The workspaces id or name do not exist: id undefined, name testws"); - }); - - - - //conflict permission - userData = { - name: `${data.firstName1} ${data.lastName1}`, - email: `${data.email1}`, - password: "password", - status: "active", - workspaces: [ - { - name: "My workspace", - status: "active", - groups: [{ name: "builder groups" }] - } - ] - }; - navigateToManageGroups(); - createGroup("builder groups"); - cy.get(groupsSelector.groupLink("builder groups")).click(); - cy.get(groupsSelector.permissionsLink).click(); - cy.get(groupsSelector.appsCreateCheck).check(); - createUser(userData).then((response) => { - expect(response.status).to.eq(400); - expect(response.body.message).to.eq("End-users can only be granted permission to view apps. Kindly change the user role or custom group to continue."); - }) + userId = response.body.id; + /* navigateToManageUsers(); + searchUser(data.email); + cy.contains("td", data.email) + .parent() + .within(() => { + cy.get("td small").should("have.text", "active"); + }); + + validateUserInGroup(data.email, "my-workspace", "end-user"); + validateUserInGroup(data.email, data.workspaceSlug, "builder"); + validateUserInGroup(data.email, data.workspaceSlug1, "admin", false); + cy.apiLogout(); + + cy.apiLogin(data.email, "password"); + cy.visit("/my-workspace"); + cy.get(commonSelectors.workspaceName).should("have.text", "My workspace"); + logout();*/ }) }) -}); \ No newline at end of file + + it.skip('Handles user creation errors', () => { + const invalidUserData = [ + { // Duplicate user + data: { ...userData }, + expectedStatus: 422, + expectedMessage: 'Already exists!' + }, + { // Invalid email and long password + data: { + ...userData, + name: `${data.firstName1} ${data.lastName1}`, + email: 'invalid-email', + password: 'a'.repeat(101) + }, + expectedStatus: 400, + expectedMessages: ['email must be an email', 'password must be shorter than or equal to 100 characters'] + }, + { // Non-existing group + data: { + ...userData, + name: `${data.firstName1} ${data.lastName1}`, + email: `${data.email1}`, + workspaces: [{ name: 'My workspace', status: 'active', groups: [{ name: 'NonExistingGroup' }] }] + }, + expectedStatus: 400, + expectedMessage: 'Group permission id or name not found:' + }, + { // Non-existing workspace + data: { + ...userData, + name: `${data.firstName1} ${data.lastName1}`, + email: `${data.email1}`, + workspaces: [{ name: 'NonExistingWorkspace', status: 'active' }] + }, + expectedStatus: 400, + expectedMessage: 'The workspaces id or name do not exist:' + } + ]; + + invalidUserData.forEach(({ data, expectedStatus, expectedMessages, expectedMessage }) => { + createUser(data).then((response) => { + expect(response.status).to.eq(expectedStatus); + if (expectedMessages) { + expectedMessages.forEach(msg => expect(response.body.message).to.include(msg)); + } else { + expect(response.body.message).to.include(expectedMessage); + } + }); + }); + //Conflict permission + const enduserData = { + ...userData, + name: `${data.firstName1} ${data.lastName1}`, + email: `${data.email1}`, + workspaces: [{ name: 'My workspace', status: 'active', groups: [{ name: data.group5 }] }] + } + createUser(enduserData).then((response) => { + expect(response.status).to.eq(400); + expect(response.body.message.title).to.include("Conflicting permissions"); + }) + }); + + it("Get all users and by user id", () => { + navigateToManageUsers(); + let number = 0; + cy.get('[data-cy="title-users-page"]').invoke('text').then((text) => { + number = parseInt(text.match(/\d+/)[0], 10); + cy.log('Number of users:', number); + }); + getAllUsers().then((response) => { + expect(response.status).to.eq(200); + expect(response.body.length).to.eq(number); + }); + + getUser(userId).then((response) => { + expect(response.status).to.eq(200); + expect(response.body.name).to.eq(`${data.firstName} ${data.lastName}`); + }); + }); +}); diff --git a/cypress-tests/cypress/support/utils/api.js b/cypress-tests/cypress/support/utils/api.js index 3feb609b8e..8532b89bb2 100644 --- a/cypress-tests/cypress/support/utils/api.js +++ b/cypress-tests/cypress/support/utils/api.js @@ -1,3 +1,5 @@ +import { groupsSelector } from "Selectors/manageGroups"; +import { navigateToManageGroups } from 'Support/utils/common'; export const apiRequest = (method, url, body = {}, headers = {}) => { return cy.request({ method, @@ -8,6 +10,7 @@ export const apiRequest = (method, url, body = {}, headers = {}) => { "Content-Type": "application/json", ...headers, }, + failOnStatusCode: false }); }; @@ -19,6 +22,23 @@ export const getUser = (userId) => { return apiRequest("GET", `${Cypress.env('API_URL')}/ext/user/${userId}`); }; +export const getAllUsers = () => { + return apiRequest("GET", `${Cypress.env('API_URL')}/ext/users`); +}; + export const updateUser = (userId, userData) => { return apiRequest("PATCH", `${Cypress.env('API_URL')}/ext/user/${userId}`, userData); }; +export const createGroup = (groupName) => { + cy.get(groupsSelector.createNewGroupButton).click(); + cy.clearAndType(groupsSelector.groupNameInput, groupName); + cy.get(groupsSelector.createGroupButton).click(); +} +export const validateUserInGroup = (email, workspaceSlug, groupName, shouldExist = true) => { + if (workspaceSlug) cy.visit(workspaceSlug); + navigateToManageGroups(); + cy.get(groupsSelector.groupLink(groupName)).click(); + cy.get(groupsSelector.usersLink).click(); + const userRow = `[data-cy="${email}-user-row"]`; + cy.get(userRow).should(shouldExist ? "exist" : "not.exist"); +}; \ No newline at end of file From f234384f2528be4e08e05839fd5d1bbd8564a7af Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Fri, 7 Mar 2025 15:34:31 +0530 Subject: [PATCH 008/236] Fix: shortcut can be used throughtout the editor and added custom hook in codeeditor for query panel shortcuts. --- .../CodeEditor/MultiLineCodeEditor.jsx | 12 +++- .../CodeEditor/SingleLineCodeEditor.jsx | 10 +++- .../CodeEditor/useQueryPanelKeyHooks.js | 58 +++++++++++++++++++ .../AppBuilder/QueryPanel/QueryKeyHooks.jsx | 36 +++--------- .../_stores/slices/queryPanelSlice.js | 18 ++++++ 5 files changed, 103 insertions(+), 31 deletions(-) create mode 100644 frontend/src/AppBuilder/CodeEditor/useQueryPanelKeyHooks.js diff --git a/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx b/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx index 033d266e03..44259ce3a8 100644 --- a/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx +++ b/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx @@ -21,6 +21,7 @@ import useStore from '@/AppBuilder/_stores/store'; import { shallow } from 'zustand/shallow'; import { search, searchKeymap, searchPanelOpen } from '@codemirror/search'; import { handleSearchPanel, SearchBtn } from './SearchBox'; +import { useQueryPanelKeyHooks } from './useQueryPanelKeyHooks'; const langSupport = Object.freeze({ javascript: javascript(), @@ -64,6 +65,8 @@ const MultiLineCodeEditor = (props) => { const [editorView, setEditorView] = React.useState(null); + const { queryPanelKeybindings } = useQueryPanelKeyHooks(onChange, currentValueRef, 'multiline'); + const handleOnBlur = () => { if (!delayOnChange) return onChange(currentValueRef.current); setTimeout(() => { @@ -85,6 +88,7 @@ const MultiLineCodeEditor = (props) => { highlightActiveLine: false, autocompletion: hideSuggestion ?? true, highlightActiveLineGutter: false, + defaultKeymap: false, completionKeymap: true, searchKeymap: false, }; @@ -187,7 +191,12 @@ const MultiLineCodeEditor = (props) => { }; } - const customKeyMaps = [...defaultKeymap, ...completionKeymap, ...searchKeymap]; + const customKeyMaps = [ + ...defaultKeymap.filter((keyBinding) => keyBinding.key !== 'Mod-Enter'), // Remove default keybinding for Mod-Enter + ...completionKeymap, + ...searchKeymap, + ]; + const customTabKeymap = keymap.of([ { key: 'Tab', @@ -208,6 +217,7 @@ const MultiLineCodeEditor = (props) => { return true; }, }, + ...queryPanelKeybindings, ]); // eslint-disable-next-line react-hooks/exhaustive-deps diff --git a/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx b/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx index 1243f26f43..09489a6e2f 100644 --- a/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx +++ b/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx @@ -22,6 +22,7 @@ import CodeHinter from './CodeHinter'; import { removeNestedDoubleCurlyBraces } from '@/_helpers/utils'; import useStore from '@/AppBuilder/_stores/store'; import { shallow } from 'zustand/shallow'; +import { useQueryPanelKeyHooks } from './useQueryPanelKeyHooks'; const SingleLineCodeEditor = ({ componentName, fieldMeta = {}, componentId, ...restProps }) => { const { initialValue, onChange, enablePreview = true, portalProps } = restProps; @@ -170,6 +171,8 @@ const EditorInput = ({ onInputChange, }) => { const getSuggestions = useStore((state) => state.getSuggestions, shallow); + const { queryPanelKeybindings } = useQueryPanelKeyHooks(onBlurUpdate, currentValue, 'singleline'); + function autoCompleteExtensionConfig(context) { const hints = getSuggestions(); let word = context.matchBefore(/\w*/); @@ -229,7 +232,10 @@ const EditorInput = ({ maxRenderedOptions: 10, }); - const customKeyMaps = [...defaultKeymap, ...completionKeymap]; + const customKeyMaps = [ + ...defaultKeymap.filter((keyBinding) => keyBinding.key !== 'Mod-Enter'), // Remove default keybinding for Mod-Enter + ...completionKeymap, + ]; const customTabKeymap = keymap.of([ { key: 'Tab', @@ -251,6 +257,7 @@ const EditorInput = ({ } }, }, + ...queryPanelKeybindings, ]); const handleOnChange = React.useCallback((val) => { @@ -395,6 +402,7 @@ const EditorInput = ({ foldGutter: false, highlightActiveLine: false, autocompletion: true, + defaultKeymap: false, completionKeymap: true, searchKeymap: false, }} diff --git a/frontend/src/AppBuilder/CodeEditor/useQueryPanelKeyHooks.js b/frontend/src/AppBuilder/CodeEditor/useQueryPanelKeyHooks.js new file mode 100644 index 0000000000..1a41a7f19b --- /dev/null +++ b/frontend/src/AppBuilder/CodeEditor/useQueryPanelKeyHooks.js @@ -0,0 +1,58 @@ +import { useModuleId } from '@/AppBuilder/_contexts/ModuleContext'; +import useStore from '@/AppBuilder/_stores/store'; +import { useCallback, useEffect, useState } from 'react'; +import { useLocation } from 'react-router-dom'; + +export const useQueryPanelKeyHooks = (onChange, value, type) => { + const queryPanelHeight = useStore((state) => state.queryPanel.queryPanelHeight); + const runQueryOnShortcut = useStore((state) => state.queryPanel.runQueryOnShortcut); + const previewQueryOnShortcut = useStore((state) => state.queryPanel.previewQueryOnShortcut); + const moduleId = useModuleId(); + const location = useLocation(); + const { pathname } = location; + + const [queryPanelKeybindings, setQueryPanelKeybindings] = useState([]); + + const handleRunQuery = useCallback( + (view) => { + const isEditor = pathname.includes('/apps/'); + if (queryPanelHeight !== 0 && isEditor) { + onChange(type === 'multiline' ? value.current : value); + runQueryOnShortcut(); + } + return true; + }, + [queryPanelHeight, onChange, runQueryOnShortcut, value] + ); + + const handlePreviewQuery = useCallback( + (view) => { + const isEditor = pathname.includes('/apps/'); + if (queryPanelHeight !== 0 && isEditor) { + onChange(type === 'multiline' ? value.current : value); + previewQueryOnShortcut(moduleId); + } + return true; + }, + [queryPanelHeight, moduleId, onChange, previewQueryOnShortcut, value] + ); + + useEffect(() => { + setQueryPanelKeybindings([ + { + key: 'Mod-Enter', + preventDefault: true, + run: handleRunQuery, + }, + { + key: 'Mod-Shift-Enter', + preventDefault: true, + run: handlePreviewQuery, + }, + ]); + }, [handleRunQuery, handlePreviewQuery]); + + return { + queryPanelKeybindings, + }; +}; diff --git a/frontend/src/AppBuilder/QueryPanel/QueryKeyHooks.jsx b/frontend/src/AppBuilder/QueryPanel/QueryKeyHooks.jsx index 06d8958cab..13e29d5531 100644 --- a/frontend/src/AppBuilder/QueryPanel/QueryKeyHooks.jsx +++ b/frontend/src/AppBuilder/QueryPanel/QueryKeyHooks.jsx @@ -4,45 +4,23 @@ import { useHotkeys } from 'react-hotkeys-hook'; import { useModuleId } from '@/AppBuilder/_contexts/ModuleContext'; const QueryKeyHooks = ({ children, isExpanded }) => { - const runQuery = useStore((state) => state.queryPanel.runQuery); - const selectedQuery = useStore((state) => state.queryPanel.selectedQuery); + const runQueryOnShortcut = useStore((state) => state.queryPanel.runQueryOnShortcut); + const previewQueryOnShortcut = useStore((state) => state.queryPanel.previewQueryOnShortcut); const moduleId = useModuleId(); - const previewQuery = useStore((state) => state.queryPanel.previewQuery); - const selectedDataSource = useStore((state) => state.queryPanel.selectedDataSource); - const queryName = selectedQuery?.name ?? ''; - const previewButtonOnClick = () => { - const _options = { ...selectedQuery.options }; - const query = { - data_source_id: selectedDataSource.id === 'null' ? null : selectedDataSource.id, - pluginId: selectedDataSource.pluginId, - options: _options, - kind: selectedDataSource.kind, - name: queryName, - id: selectedQuery?.id, - }; - previewQuery(query, false, undefined, moduleId).catch(({ error, data }) => { - console.log(error, data); - }); - }; - - const shortcutRef = useHotkeys( + useHotkeys( ['mod+enter', 'mod+shift+enter'], (event, handler) => { if (handler.mod && handler.keys[0] === 'enter') { if (handler.shift) { - previewButtonOnClick(); - } else runQuery(selectedQuery?.id, selectedQuery?.name, undefined, 'edit', {}, true); + previewQueryOnShortcut(moduleId); + } else runQueryOnShortcut(); } }, - { enabled: isExpanded } + { enabled: isExpanded, enableOnFormTags: ['input'] } ); - return ( -
- {children} -
- ); + return
{children}
; }; export default QueryKeyHooks; diff --git a/frontend/src/AppBuilder/_stores/slices/queryPanelSlice.js b/frontend/src/AppBuilder/_stores/slices/queryPanelSlice.js index fd49d2a5e4..bc695d3c9b 100644 --- a/frontend/src/AppBuilder/_stores/slices/queryPanelSlice.js +++ b/frontend/src/AppBuilder/_stores/slices/queryPanelSlice.js @@ -1028,5 +1028,23 @@ export const createQueryPanelSlice = (set, get) => ({ isQuerySelected: (queryId) => { return get().queryPanel.selectedQuery?.id === queryId; }, + runQueryOnShortcut: () => { + const { queryPanel } = get(); + const { runQuery, selectedQuery } = queryPanel; + runQuery(selectedQuery?.id, selectedQuery?.name, undefined, 'edit', {}, true); + }, + previewQueryOnShortcut: (moduleId = 'canvas') => { + const { queryPanel } = get(); + const { previewQuery, selectedQuery, selectedDataSource } = queryPanel; + const query = { + data_source_id: selectedDataSource.id === 'null' ? null : selectedDataSource.id, + pluginId: selectedDataSource.pluginId, + options: { ...selectedQuery?.options }, + kind: selectedDataSource.kind, + name: selectedQuery?.name ?? '', + id: selectedQuery?.id, + }; + previewQuery(query, false, undefined, moduleId); + }, }, }); From e143b3b0e719e745a1e00756ef88e58b8ba9f2bc Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Fri, 7 Mar 2025 19:31:58 +0530 Subject: [PATCH 009/236] Horizontal and vertical divider revamp --- .../src/AppBuilder/AppCanvas/RenderWidget.jsx | 8 +- .../Inspector/Components/DefaultComponent.jsx | 7 +- .../RightSideBar/Inspector/Inspector.jsx | 2 + .../WidgetManager/widgets/divider.js | 96 +++++++++++++++++-- .../WidgetManager/widgets/verticalDivider.js | 68 +++++++++++-- .../src/AppBuilder/_helpers/editorHelpers.js | 2 +- frontend/src/Editor/Components/Divider.jsx | 79 +++++++++++++-- .../src/Editor/Components/verticalDivider.jsx | 15 ++- .../Editor/WidgetManager/configs/divider.js | 96 +++++++++++++++++-- .../WidgetManager/configs/verticalDivider.js | 68 +++++++++++-- frontend/src/_helpers/editorHelpers.js | 2 +- .../apps/services/widget-config/divider.js | 96 +++++++++++++++++-- .../services/widget-config/verticalDivider.js | 68 +++++++++++-- 13 files changed, 532 insertions(+), 75 deletions(-) diff --git a/frontend/src/AppBuilder/AppCanvas/RenderWidget.jsx b/frontend/src/AppBuilder/AppCanvas/RenderWidget.jsx index 427cced97b..3bdb18929e 100644 --- a/frontend/src/AppBuilder/AppCanvas/RenderWidget.jsx +++ b/frontend/src/AppBuilder/AppCanvas/RenderWidget.jsx @@ -7,7 +7,7 @@ import { renderTooltip } from '@/_helpers/appUtils'; import { useTranslation } from 'react-i18next'; import ErrorBoundary from '@/_ui/ErrorBoundary'; -const shouldAddBoxShadowAndVisibility = [ +const SHOULD_ADD_BOX_SHADOW_AND_VISIBILITY = [ 'Table', 'TextInput', 'PasswordInput', @@ -25,6 +25,8 @@ const shouldAddBoxShadowAndVisibility = [ 'DaterangePicker', 'DatePickerV2', 'TimePicker', + 'Divider', + 'VerticalDivider', ]; const RenderWidget = ({ @@ -140,7 +142,7 @@ const RenderWidget = ({ placement={inCanvas ? 'auto' : 'top'} delay={{ show: 500, hide: 0 }} trigger={ - inCanvas && shouldAddBoxShadowAndVisibility.includes(component?.component) + inCanvas && SHOULD_ADD_BOX_SHADOW_AND_VISIBILITY.includes(component?.component) ? !resolvedProperties?.tooltip?.toString().trim() ? null : ['hover', 'focus'] @@ -153,7 +155,7 @@ const RenderWidget = ({ props, text: inCanvas ? `${ - shouldAddBoxShadowAndVisibility.includes(component?.component) + SHOULD_ADD_BOX_SHADOW_AND_VISIBILITY.includes(component?.component) ? resolvedProperties?.tooltip : resolvedGeneralProperties?.tooltip }` diff --git a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/DefaultComponent.jsx b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/DefaultComponent.jsx index acd1908bba..395c4e5187 100644 --- a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/DefaultComponent.jsx +++ b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/DefaultComponent.jsx @@ -23,6 +23,8 @@ const SHOW_ADDITIONAL_ACTIONS = [ 'Button', 'RichTextEditor', 'Image', + 'Divider', + 'VerticalDivider', ]; const PROPERTIES_VS_ACCORDION_TITLE = { Text: 'Data', @@ -34,6 +36,8 @@ const PROPERTIES_VS_ACCORDION_TITLE = { Button: 'Data', Image: 'Data', Container: 'Data', + Divider: 'Data', + VerticalDivider: 'Data', }; export const DefaultComponent = ({ componentMeta, darkMode, ...restProps }) => { @@ -127,6 +131,8 @@ export const baseComponentProperties = ( 'DropdownV2', 'MultiselectV2', 'Image', + 'Divider', + 'VerticalDivider', ], Layout: [], }; @@ -265,7 +271,6 @@ export const baseComponentProperties = ( ), }); - return items.filter( (item) => !(item.title in accordionFilters && accordionFilters[item.title].includes(componentMeta.component)) ); diff --git a/frontend/src/AppBuilder/RightSideBar/Inspector/Inspector.jsx b/frontend/src/AppBuilder/RightSideBar/Inspector/Inspector.jsx index 16ed1112b7..585e7ce26e 100644 --- a/frontend/src/AppBuilder/RightSideBar/Inspector/Inspector.jsx +++ b/frontend/src/AppBuilder/RightSideBar/Inspector/Inspector.jsx @@ -78,6 +78,8 @@ const NEW_REVAMPED_COMPONENTS = [ 'Icon', 'Image', 'Container', + 'Divider', + 'VerticalDivider', ]; export const Inspector = ({ componentDefinitionChanged, darkMode, pages, selectedComponentId }) => { diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/divider.js b/frontend/src/AppBuilder/WidgetManager/widgets/divider.js index 045f894816..4b35d28719 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/divider.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/divider.js @@ -11,15 +11,12 @@ export const dividerConfig = { showOnDesktop: { type: 'toggle', displayName: 'Show on desktop' }, showOnMobile: { type: 'toggle', displayName: 'Show on mobile' }, }, - properties: {}, - events: {}, - styles: { - dividerColor: { - type: 'color', - displayName: 'Divider color', + properties: { + label: { + type: 'code', + displayName: 'Label', validation: { schema: { type: 'string' }, - defaultValue: '#000000', }, }, visibility: { @@ -29,6 +26,77 @@ export const dividerConfig = { schema: { type: 'boolean' }, defaultValue: true, }, + section: 'additionalActions', + }, + tooltip: { + type: 'code', + displayName: 'Tooltip', + validation: { schema: { type: 'string' }, defaultValue: 'Tooltip text' }, + section: 'additionalActions', + placeholder: 'Enter tooltip text', + }, + }, + events: {}, + styles: { + dividerColor: { + type: 'color', + displayName: 'Divider color', + validation: { + schema: { type: 'string' }, + defaultValue: '#000000', + }, + accordian: 'Divider', + }, + labelAlignment: { + type: 'code', + displayName: 'Label Alignment', + validation: { + schema: { type: 'string' }, + }, + accordian: 'Divider', + }, + dividerStyle: { + type: 'switch', + displayName: 'Style', + validation: { + schema: { type: 'string' }, + }, + options: [ + { displayName: 'Solid', value: 'solid' }, + { displayName: 'Dashed', value: 'dashed' }, + ], + accordian: 'Divider', + }, + labelColor: { + type: 'color', + displayName: 'Label Color', + validation: { + schema: { type: 'string' }, + }, + accordian: 'Divider', + }, + boxShadow: { + type: 'boxShadow', + displayName: 'Box Shadow', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: '0px 0px 0px 0px #00000040', + }, + accordian: 'Divider', + }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'container', }, }, exposedVariables: { @@ -39,11 +107,19 @@ export const dividerConfig = { showOnDesktop: { value: '{{true}}' }, showOnMobile: { value: '{{false}}' }, }, - properties: {}, + properties: { + label: { value: '' }, + visibility: { value: '{{true}}' }, + tooltip: { value: '' }, + }, events: [], styles: { - visibility: { value: '{{true}}' }, - dividerColor: { value: '#000000' }, + dividerColor: { value: '#CCD1D5' }, + labelAlignment: { value: 'center' }, + dividerStyle: { value: 'solid' }, + labelColor: { value: '#6A727C' }, + padding: { value: 'default' }, + boxShadow: { value: '0px 0px 0px 0px #00000040' }, }, }, }; diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js b/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js index 443526c3b8..3e0d1cf740 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js @@ -11,7 +11,24 @@ export const verticalDividerConfig = { showOnDesktop: { type: 'toggle', displayName: 'Show on desktop' }, showOnMobile: { type: 'toggle', displayName: 'Show on mobile' }, }, - properties: {}, + properties: { + visibility: { + type: 'toggle', + displayName: 'Visibility', + validation: { + schema: { type: 'boolean' }, + defaultValue: true, + }, + section: 'additionalActions', + }, + tooltip: { + type: 'code', + displayName: 'Tooltip', + validation: { schema: { type: 'string' }, defaultValue: 'Tooltip text' }, + section: 'additionalActions', + placeholder: 'Enter tooltip text', + }, + }, events: {}, styles: { dividerColor: { @@ -21,14 +38,42 @@ export const verticalDividerConfig = { schema: { type: 'string' }, defaultValue: '#000000', }, + accordian: 'Divider', }, - visibility: { - type: 'toggle', - displayName: 'Visibility', + dividerStyle: { + type: 'switch', + displayName: 'Style', validation: { - schema: { type: 'boolean' }, - defaultValue: true, + schema: { type: 'string' }, }, + options: [ + { displayName: 'Solid', value: 'solid' }, + { displayName: 'Dashed', value: 'dashed' }, + ], + accordian: 'Divider', + }, + boxShadow: { + type: 'boxShadow', + displayName: 'Box Shadow', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: '0px 0px 0px 0px #00000040', + }, + accordian: 'Divider', + }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'container', }, }, exposedVariables: { @@ -39,11 +84,16 @@ export const verticalDividerConfig = { showOnDesktop: { value: '{{true}}' }, showOnMobile: { value: '{{false}}' }, }, - properties: {}, + properties: { + visibility: { value: '{{true}}' }, + tooltip: { value: '' }, + }, events: [], styles: { - visibility: { value: '{{true}}' }, - dividerColor: { value: '#000000' }, + dividerColor: { value: '#CCD1D5' }, + dividerStyle: { value: 'solid' }, + padding: { value: 'default' }, + boxShadow: { value: '0px 0px 0px 0px #00000040' }, }, }, }; diff --git a/frontend/src/AppBuilder/_helpers/editorHelpers.js b/frontend/src/AppBuilder/_helpers/editorHelpers.js index 9abeb9a56b..7120173bb3 100644 --- a/frontend/src/AppBuilder/_helpers/editorHelpers.js +++ b/frontend/src/AppBuilder/_helpers/editorHelpers.js @@ -46,7 +46,7 @@ import { SvgImage } from '@/Editor/Components/SvgImage'; import { Html } from '@/Editor/Components/Html'; import { ButtonGroup } from '@/Editor/Components/ButtonGroup'; import { CustomComponent } from '@/Editor/Components/CustomComponent/CustomComponent'; -import { VerticalDivider } from '@/Editor/Components/verticalDivider'; +import { VerticalDivider } from '@/Editor/Components/VerticalDivider'; import { ColorPicker } from '@/Editor/Components/ColorPicker'; import { KanbanBoard } from '@/Editor/Components/KanbanBoard/KanbanBoard'; // import { Kanban } from '@/Editor/Components/Kanban/Kanban'; diff --git a/frontend/src/Editor/Components/Divider.jsx b/frontend/src/Editor/Components/Divider.jsx index 5935181bf7..e519f64aea 100644 --- a/frontend/src/Editor/Components/Divider.jsx +++ b/frontend/src/Editor/Components/Divider.jsx @@ -1,20 +1,81 @@ import React from 'react'; -export const Divider = function Divider({ styles, dataCy, height, width, darkMode }) { - const { visibility, dividerColor, boxShadow } = styles; - +export const Divider = function Divider({ dataCy, height, width, darkMode, styles, properties }) { + const { labelAlignment, labelColor, dividerColor, boxShadow, dividerStyle } = styles; + const { label, visibility } = properties; const color = dividerColor === '' || ['#000', '#000000'].includes(dividerColor) ? (darkMode ? '#fff' : '#000') : dividerColor; + + const dividerLineStyle = { + width, + padding: '0rem', + boxShadow, + ...(dividerStyle === 'dashed' + ? { + height: 0, // No height for dashed, use border instead + borderTop: `1px dashed ${color}`, + backgroundColor: 'transparent', + } + : { + height: '1px', + backgroundColor: color, + borderTop: 'none', + }), + }; + // If no label, render the original divider + if (!label) { + return ( +
+
+
+ ); + } + + // With label - handle different positions return (
-
+ {labelAlignment === 'start' && ( + <> + {label} +
+ + )} + + {labelAlignment === 'center' && ( +
+
+ {label} +
+
+ )} + + {labelAlignment === 'end' && ( + <> +
+ {label} + + )}
); }; diff --git a/frontend/src/Editor/Components/verticalDivider.jsx b/frontend/src/Editor/Components/verticalDivider.jsx index ba6a38748c..ed9f2d9bfd 100644 --- a/frontend/src/Editor/Components/verticalDivider.jsx +++ b/frontend/src/Editor/Components/verticalDivider.jsx @@ -1,7 +1,8 @@ import React from 'react'; -export const VerticalDivider = function Divider({ styles, height, width, dataCy, darkMode }) { - const { visibility, dividerColor, boxShadow } = styles; +export const VerticalDivider = function Divider({ styles, height, width, dataCy, darkMode, properties }) { + const { dividerColor, boxShadow, dividerStyle } = styles; + const { visibility } = properties; const color = dividerColor === '' || ['#000', '#000000'].includes(dividerColor) ? (darkMode ? '#fff' : '#000') : dividerColor; @@ -14,7 +15,15 @@ export const VerticalDivider = function Divider({ styles, height, width, dataCy,
); diff --git a/frontend/src/Editor/WidgetManager/configs/divider.js b/frontend/src/Editor/WidgetManager/configs/divider.js index 045f894816..4b35d28719 100644 --- a/frontend/src/Editor/WidgetManager/configs/divider.js +++ b/frontend/src/Editor/WidgetManager/configs/divider.js @@ -11,15 +11,12 @@ export const dividerConfig = { showOnDesktop: { type: 'toggle', displayName: 'Show on desktop' }, showOnMobile: { type: 'toggle', displayName: 'Show on mobile' }, }, - properties: {}, - events: {}, - styles: { - dividerColor: { - type: 'color', - displayName: 'Divider color', + properties: { + label: { + type: 'code', + displayName: 'Label', validation: { schema: { type: 'string' }, - defaultValue: '#000000', }, }, visibility: { @@ -29,6 +26,77 @@ export const dividerConfig = { schema: { type: 'boolean' }, defaultValue: true, }, + section: 'additionalActions', + }, + tooltip: { + type: 'code', + displayName: 'Tooltip', + validation: { schema: { type: 'string' }, defaultValue: 'Tooltip text' }, + section: 'additionalActions', + placeholder: 'Enter tooltip text', + }, + }, + events: {}, + styles: { + dividerColor: { + type: 'color', + displayName: 'Divider color', + validation: { + schema: { type: 'string' }, + defaultValue: '#000000', + }, + accordian: 'Divider', + }, + labelAlignment: { + type: 'code', + displayName: 'Label Alignment', + validation: { + schema: { type: 'string' }, + }, + accordian: 'Divider', + }, + dividerStyle: { + type: 'switch', + displayName: 'Style', + validation: { + schema: { type: 'string' }, + }, + options: [ + { displayName: 'Solid', value: 'solid' }, + { displayName: 'Dashed', value: 'dashed' }, + ], + accordian: 'Divider', + }, + labelColor: { + type: 'color', + displayName: 'Label Color', + validation: { + schema: { type: 'string' }, + }, + accordian: 'Divider', + }, + boxShadow: { + type: 'boxShadow', + displayName: 'Box Shadow', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: '0px 0px 0px 0px #00000040', + }, + accordian: 'Divider', + }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'container', }, }, exposedVariables: { @@ -39,11 +107,19 @@ export const dividerConfig = { showOnDesktop: { value: '{{true}}' }, showOnMobile: { value: '{{false}}' }, }, - properties: {}, + properties: { + label: { value: '' }, + visibility: { value: '{{true}}' }, + tooltip: { value: '' }, + }, events: [], styles: { - visibility: { value: '{{true}}' }, - dividerColor: { value: '#000000' }, + dividerColor: { value: '#CCD1D5' }, + labelAlignment: { value: 'center' }, + dividerStyle: { value: 'solid' }, + labelColor: { value: '#6A727C' }, + padding: { value: 'default' }, + boxShadow: { value: '0px 0px 0px 0px #00000040' }, }, }, }; diff --git a/frontend/src/Editor/WidgetManager/configs/verticalDivider.js b/frontend/src/Editor/WidgetManager/configs/verticalDivider.js index 443526c3b8..3e0d1cf740 100644 --- a/frontend/src/Editor/WidgetManager/configs/verticalDivider.js +++ b/frontend/src/Editor/WidgetManager/configs/verticalDivider.js @@ -11,7 +11,24 @@ export const verticalDividerConfig = { showOnDesktop: { type: 'toggle', displayName: 'Show on desktop' }, showOnMobile: { type: 'toggle', displayName: 'Show on mobile' }, }, - properties: {}, + properties: { + visibility: { + type: 'toggle', + displayName: 'Visibility', + validation: { + schema: { type: 'boolean' }, + defaultValue: true, + }, + section: 'additionalActions', + }, + tooltip: { + type: 'code', + displayName: 'Tooltip', + validation: { schema: { type: 'string' }, defaultValue: 'Tooltip text' }, + section: 'additionalActions', + placeholder: 'Enter tooltip text', + }, + }, events: {}, styles: { dividerColor: { @@ -21,14 +38,42 @@ export const verticalDividerConfig = { schema: { type: 'string' }, defaultValue: '#000000', }, + accordian: 'Divider', }, - visibility: { - type: 'toggle', - displayName: 'Visibility', + dividerStyle: { + type: 'switch', + displayName: 'Style', validation: { - schema: { type: 'boolean' }, - defaultValue: true, + schema: { type: 'string' }, }, + options: [ + { displayName: 'Solid', value: 'solid' }, + { displayName: 'Dashed', value: 'dashed' }, + ], + accordian: 'Divider', + }, + boxShadow: { + type: 'boxShadow', + displayName: 'Box Shadow', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: '0px 0px 0px 0px #00000040', + }, + accordian: 'Divider', + }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'container', }, }, exposedVariables: { @@ -39,11 +84,16 @@ export const verticalDividerConfig = { showOnDesktop: { value: '{{true}}' }, showOnMobile: { value: '{{false}}' }, }, - properties: {}, + properties: { + visibility: { value: '{{true}}' }, + tooltip: { value: '' }, + }, events: [], styles: { - visibility: { value: '{{true}}' }, - dividerColor: { value: '#000000' }, + dividerColor: { value: '#CCD1D5' }, + dividerStyle: { value: 'solid' }, + padding: { value: 'default' }, + boxShadow: { value: '0px 0px 0px 0px #00000040' }, }, }, }; diff --git a/frontend/src/_helpers/editorHelpers.js b/frontend/src/_helpers/editorHelpers.js index 1f97cc42ee..927dbe00c1 100644 --- a/frontend/src/_helpers/editorHelpers.js +++ b/frontend/src/_helpers/editorHelpers.js @@ -43,7 +43,7 @@ import { SvgImage } from '@/Editor/Components/SvgImage'; import { Html } from '@/Editor/Components/Html'; import { ButtonGroup } from '@/Editor/Components/ButtonGroup'; import { CustomComponent } from '@/Editor/Components/CustomComponent/CustomComponent'; -import { VerticalDivider } from '@/Editor/Components/verticalDivider'; +import { VerticalDivider } from '@/Editor/Components/VerticalDivider'; import { ColorPicker } from '@/Editor/Components/ColorPicker'; import { KanbanBoard } from '@/Editor/Components/KanbanBoard/KanbanBoard'; import { Kanban } from '@/Editor/Components/Kanban/Kanban'; diff --git a/server/src/modules/apps/services/widget-config/divider.js b/server/src/modules/apps/services/widget-config/divider.js index 045f894816..4b35d28719 100644 --- a/server/src/modules/apps/services/widget-config/divider.js +++ b/server/src/modules/apps/services/widget-config/divider.js @@ -11,15 +11,12 @@ export const dividerConfig = { showOnDesktop: { type: 'toggle', displayName: 'Show on desktop' }, showOnMobile: { type: 'toggle', displayName: 'Show on mobile' }, }, - properties: {}, - events: {}, - styles: { - dividerColor: { - type: 'color', - displayName: 'Divider color', + properties: { + label: { + type: 'code', + displayName: 'Label', validation: { schema: { type: 'string' }, - defaultValue: '#000000', }, }, visibility: { @@ -29,6 +26,77 @@ export const dividerConfig = { schema: { type: 'boolean' }, defaultValue: true, }, + section: 'additionalActions', + }, + tooltip: { + type: 'code', + displayName: 'Tooltip', + validation: { schema: { type: 'string' }, defaultValue: 'Tooltip text' }, + section: 'additionalActions', + placeholder: 'Enter tooltip text', + }, + }, + events: {}, + styles: { + dividerColor: { + type: 'color', + displayName: 'Divider color', + validation: { + schema: { type: 'string' }, + defaultValue: '#000000', + }, + accordian: 'Divider', + }, + labelAlignment: { + type: 'code', + displayName: 'Label Alignment', + validation: { + schema: { type: 'string' }, + }, + accordian: 'Divider', + }, + dividerStyle: { + type: 'switch', + displayName: 'Style', + validation: { + schema: { type: 'string' }, + }, + options: [ + { displayName: 'Solid', value: 'solid' }, + { displayName: 'Dashed', value: 'dashed' }, + ], + accordian: 'Divider', + }, + labelColor: { + type: 'color', + displayName: 'Label Color', + validation: { + schema: { type: 'string' }, + }, + accordian: 'Divider', + }, + boxShadow: { + type: 'boxShadow', + displayName: 'Box Shadow', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: '0px 0px 0px 0px #00000040', + }, + accordian: 'Divider', + }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'container', }, }, exposedVariables: { @@ -39,11 +107,19 @@ export const dividerConfig = { showOnDesktop: { value: '{{true}}' }, showOnMobile: { value: '{{false}}' }, }, - properties: {}, + properties: { + label: { value: '' }, + visibility: { value: '{{true}}' }, + tooltip: { value: '' }, + }, events: [], styles: { - visibility: { value: '{{true}}' }, - dividerColor: { value: '#000000' }, + dividerColor: { value: '#CCD1D5' }, + labelAlignment: { value: 'center' }, + dividerStyle: { value: 'solid' }, + labelColor: { value: '#6A727C' }, + padding: { value: 'default' }, + boxShadow: { value: '0px 0px 0px 0px #00000040' }, }, }, }; diff --git a/server/src/modules/apps/services/widget-config/verticalDivider.js b/server/src/modules/apps/services/widget-config/verticalDivider.js index 443526c3b8..3e0d1cf740 100644 --- a/server/src/modules/apps/services/widget-config/verticalDivider.js +++ b/server/src/modules/apps/services/widget-config/verticalDivider.js @@ -11,7 +11,24 @@ export const verticalDividerConfig = { showOnDesktop: { type: 'toggle', displayName: 'Show on desktop' }, showOnMobile: { type: 'toggle', displayName: 'Show on mobile' }, }, - properties: {}, + properties: { + visibility: { + type: 'toggle', + displayName: 'Visibility', + validation: { + schema: { type: 'boolean' }, + defaultValue: true, + }, + section: 'additionalActions', + }, + tooltip: { + type: 'code', + displayName: 'Tooltip', + validation: { schema: { type: 'string' }, defaultValue: 'Tooltip text' }, + section: 'additionalActions', + placeholder: 'Enter tooltip text', + }, + }, events: {}, styles: { dividerColor: { @@ -21,14 +38,42 @@ export const verticalDividerConfig = { schema: { type: 'string' }, defaultValue: '#000000', }, + accordian: 'Divider', }, - visibility: { - type: 'toggle', - displayName: 'Visibility', + dividerStyle: { + type: 'switch', + displayName: 'Style', validation: { - schema: { type: 'boolean' }, - defaultValue: true, + schema: { type: 'string' }, }, + options: [ + { displayName: 'Solid', value: 'solid' }, + { displayName: 'Dashed', value: 'dashed' }, + ], + accordian: 'Divider', + }, + boxShadow: { + type: 'boxShadow', + displayName: 'Box Shadow', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: '0px 0px 0px 0px #00000040', + }, + accordian: 'Divider', + }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'container', }, }, exposedVariables: { @@ -39,11 +84,16 @@ export const verticalDividerConfig = { showOnDesktop: { value: '{{true}}' }, showOnMobile: { value: '{{false}}' }, }, - properties: {}, + properties: { + visibility: { value: '{{true}}' }, + tooltip: { value: '' }, + }, events: [], styles: { - visibility: { value: '{{true}}' }, - dividerColor: { value: '#000000' }, + dividerColor: { value: '#CCD1D5' }, + dividerStyle: { value: 'solid' }, + padding: { value: 'default' }, + boxShadow: { value: '0px 0px 0px 0px #00000040' }, }, }, }; From 2da6fdde4a49bf3f2fe593c62ad61badd36ae0f2 Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Tue, 11 Mar 2025 14:18:32 +0530 Subject: [PATCH 010/236] Added icons for shortcuts in the run and preview button. --- .../QueryManager/Components/QueryManagerHeader.jsx | 13 +++++++++---- frontend/src/_styles/theme.scss | 8 ++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx index 75cbe9cef7..15eef7c6a6 100644 --- a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx +++ b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx @@ -252,7 +252,7 @@ const RunButton = ({ buttonLoadingState }) => { > {isInDraft && } @@ -299,6 +303,7 @@ const PreviewButton = ({ buttonLoadingState, onClick }) => { {t('editor.queryManager.preview', 'Preview')} + ⌘↑↩ ); }; diff --git a/frontend/src/_styles/theme.scss b/frontend/src/_styles/theme.scss index 2d1f28be3d..f5f2131c59 100644 --- a/frontend/src/_styles/theme.scss +++ b/frontend/src/_styles/theme.scss @@ -8054,6 +8054,10 @@ tbody { min-width: 22px; } + .query-manager-btn-shortcut { + color: var(--text-disabled) !important; + } + &:hover { background-color: $color-light-indigo-04; color: $color-light-indigo-10; @@ -8142,6 +8146,10 @@ tbody { } + .query-manager-btn-shortcut { + color: var(--text-disabled) !important; + } + &:hover { border: 1px solid $color-light-slate-08; color: $color-light-slate-11; From 41cff2484022aa220a12c6d866a1452645b24c90 Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Tue, 11 Mar 2025 17:29:15 +0530 Subject: [PATCH 011/236] Replaced run and preview buttons with design system button. --- .../Components/QueryManagerHeader.jsx | 47 +++++++------------ frontend/src/_styles/theme.scss | 12 ++--- frontend/src/_ui/Icon/solidIcons/Play01.jsx | 19 ++++++++ frontend/src/_ui/Icon/solidIcons/index.js | 3 ++ frontend/src/components/ui/Button/Button.jsx | 14 +++++- 5 files changed, 56 insertions(+), 39 deletions(-) create mode 100644 frontend/src/_ui/Icon/solidIcons/Play01.jsx diff --git a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx index 15eef7c6a6..6055c0538a 100644 --- a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx +++ b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx @@ -1,7 +1,5 @@ import React, { useState, forwardRef, useRef, useEffect } from 'react'; import RenameIcon from '../Icons/RenameIcon'; -import Eye1 from '@/_ui/Icon/solidIcons/Eye1'; -import Play from '@/_ui/Icon/solidIcons/Play'; import cx from 'classnames'; import { toast } from 'react-hot-toast'; import { useTranslation } from 'react-i18next'; @@ -13,6 +11,7 @@ import { decodeEntities } from '@/_helpers/utils'; import { canDeleteDataSource, canReadDataSource, canUpdateDataSource } from '@/_helpers'; import useStore from '@/AppBuilder/_stores/store'; import { useModuleId } from '@/AppBuilder/_contexts/ModuleContext'; +import { Button as ButtonComponent } from '@/components/ui/Button/Button'; export const QueryManagerHeader = forwardRef(({ darkMode, setActiveTab, activeTab }, ref) => { const moduleId = useModuleId(); @@ -250,29 +249,22 @@ const RunButton = ({ buttonLoadingState }) => { 'data-tooltip-content': 'Connect a data source to run', })} > - + Run ⌘↩ + {isInDraft && } ); @@ -291,19 +283,16 @@ const PreviewButton = ({ buttonLoadingState, onClick }) => { const { t } = useTranslation(); return ( - + Preview ⌘↑↩ + ); }; diff --git a/frontend/src/_styles/theme.scss b/frontend/src/_styles/theme.scss index f5f2131c59..0eedde77da 100644 --- a/frontend/src/_styles/theme.scss +++ b/frontend/src/_styles/theme.scss @@ -8054,10 +8054,6 @@ tbody { min-width: 22px; } - .query-manager-btn-shortcut { - color: var(--text-disabled) !important; - } - &:hover { background-color: $color-light-indigo-04; color: $color-light-indigo-10; @@ -8146,10 +8142,6 @@ tbody { } - .query-manager-btn-shortcut { - color: var(--text-disabled) !important; - } - &:hover { border: 1px solid $color-light-slate-08; color: $color-light-slate-11; @@ -8257,6 +8249,10 @@ tbody { } } +.query-manager-btn-shortcut { + color: var(--text-disabled) !important; +} + .font-weight-500 { font-weight: 500; } diff --git a/frontend/src/_ui/Icon/solidIcons/Play01.jsx b/frontend/src/_ui/Icon/solidIcons/Play01.jsx new file mode 100644 index 0000000000..42d3c88835 --- /dev/null +++ b/frontend/src/_ui/Icon/solidIcons/Play01.jsx @@ -0,0 +1,19 @@ +import React from 'react'; + +const Play01 = ({ fill = '#6A727C', width = '24', className = '', viewBox = '0 0 24 24' }) => ( + + + +); + +export default Play01; diff --git a/frontend/src/_ui/Icon/solidIcons/index.js b/frontend/src/_ui/Icon/solidIcons/index.js index 34a2410e1d..aa0c307fec 100644 --- a/frontend/src/_ui/Icon/solidIcons/index.js +++ b/frontend/src/_ui/Icon/solidIcons/index.js @@ -87,6 +87,7 @@ import Pin from './Pin.jsx'; import Unpin from './Unpin.jsx'; import AlignRight from './AlignRight'; import Play from './Play.jsx'; +import Play01 from './Play01.jsx'; import Plus from './Plus.jsx'; import Plus01 from './Plus01.jsx'; import Reload from './Reload.jsx'; @@ -692,6 +693,8 @@ const Icon = (props) => { return ; case 'ai-crown': return ; + case 'play01': + return ; default: return ; } diff --git a/frontend/src/components/ui/Button/Button.jsx b/frontend/src/components/ui/Button/Button.jsx index 03919b8e93..6f95221805 100644 --- a/frontend/src/components/ui/Button/Button.jsx +++ b/frontend/src/components/ui/Button/Button.jsx @@ -133,10 +133,20 @@ const Button = forwardRef( const iconFillColor = !defaultButtonFillColour.includes(fill) && fill ? fill : getDefaultIconFillColor(variant); const Comp = asChild ? Slot : 'Button'; const leadingIconElement = leadingIcon && ( - +
+ +
); const trailingIconElement = trailingIcon && ( - +
+ +
); return ( From 5df43f3cda99a7eca6b2d9404a65f76a7f6f4b48 Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Tue, 18 Mar 2025 12:59:43 +0530 Subject: [PATCH 012/236] Add mssing icon --- .../AppBuilder/WidgetManager/widgets/divider.js | 16 +++++++++++----- frontend/src/Editor/Components/Divider.jsx | 17 ++++++++++++----- .../src/Editor/WidgetManager/configs/divider.js | 16 +++++++++++----- .../Icon/solidIcons/AlignHorizontalCenter.jsx | 16 ++++++++++++++++ frontend/src/_ui/Icon/solidIcons/index.js | 7 +++++-- .../apps/services/widget-config/divider.js | 16 +++++++++++----- 6 files changed, 66 insertions(+), 22 deletions(-) create mode 100644 frontend/src/_ui/Icon/solidIcons/AlignHorizontalCenter.jsx diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/divider.js b/frontend/src/AppBuilder/WidgetManager/widgets/divider.js index 4b35d28719..6c4478ef55 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/divider.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/divider.js @@ -48,12 +48,18 @@ export const dividerConfig = { accordian: 'Divider', }, labelAlignment: { - type: 'code', - displayName: 'Label Alignment', - validation: { - schema: { type: 'string' }, - }, + type: 'switch', + displayName: 'Label alignment', + validation: { schema: { type: 'string' }, defaultValue: 'left' }, + showLabel: true, + isIcon: true, + options: [ + { displayName: 'alignleftinspector', value: 'left', iconName: 'alignleftinspector' }, + { displayName: 'alignhorizontalcenter', value: 'center', iconName: 'alignhorizontalcenter' }, + { displayName: 'alignrightinspector', value: 'right', iconName: 'alignrightinspector' }, + ], accordian: 'Divider', + isFxNotRequired: true, }, dividerStyle: { type: 'switch', diff --git a/frontend/src/Editor/Components/Divider.jsx b/frontend/src/Editor/Components/Divider.jsx index e519f64aea..18a57ccaee 100644 --- a/frontend/src/Editor/Components/Divider.jsx +++ b/frontend/src/Editor/Components/Divider.jsx @@ -9,7 +9,6 @@ export const Divider = function Divider({ dataCy, height, width, darkMode, style const dividerLineStyle = { width, padding: '0rem', - boxShadow, ...(dividerStyle === 'dashed' ? { height: 0, // No height for dashed, use border instead @@ -27,7 +26,14 @@ export const Divider = function Divider({ dataCy, height, width, darkMode, style return (
@@ -44,11 +50,12 @@ export const Divider = function Divider({ dataCy, height, width, darkMode, style width, height, alignItems: 'center', - justifyContent: labelAlignment === 'start' ? 'flex-start' : labelAlignment === 'end' ? 'flex-end' : 'center', + justifyContent: labelAlignment === 'left' ? 'flex-start' : labelAlignment === 'right' ? 'flex-end' : 'center', + boxShadow, }} data-cy={dataCy} > - {labelAlignment === 'start' && ( + {labelAlignment === 'left' && ( <> {label}
@@ -70,7 +77,7 @@ export const Divider = function Divider({ dataCy, height, width, darkMode, style
)} - {labelAlignment === 'end' && ( + {labelAlignment === 'right' && ( <>
{label} diff --git a/frontend/src/Editor/WidgetManager/configs/divider.js b/frontend/src/Editor/WidgetManager/configs/divider.js index 4b35d28719..6c4478ef55 100644 --- a/frontend/src/Editor/WidgetManager/configs/divider.js +++ b/frontend/src/Editor/WidgetManager/configs/divider.js @@ -48,12 +48,18 @@ export const dividerConfig = { accordian: 'Divider', }, labelAlignment: { - type: 'code', - displayName: 'Label Alignment', - validation: { - schema: { type: 'string' }, - }, + type: 'switch', + displayName: 'Label alignment', + validation: { schema: { type: 'string' }, defaultValue: 'left' }, + showLabel: true, + isIcon: true, + options: [ + { displayName: 'alignleftinspector', value: 'left', iconName: 'alignleftinspector' }, + { displayName: 'alignhorizontalcenter', value: 'center', iconName: 'alignhorizontalcenter' }, + { displayName: 'alignrightinspector', value: 'right', iconName: 'alignrightinspector' }, + ], accordian: 'Divider', + isFxNotRequired: true, }, dividerStyle: { type: 'switch', diff --git a/frontend/src/_ui/Icon/solidIcons/AlignHorizontalCenter.jsx b/frontend/src/_ui/Icon/solidIcons/AlignHorizontalCenter.jsx new file mode 100644 index 0000000000..6b7b2f39ab --- /dev/null +++ b/frontend/src/_ui/Icon/solidIcons/AlignHorizontalCenter.jsx @@ -0,0 +1,16 @@ +import React from 'react'; + +const AlignHorizontalCenter = ({ fill = '', width = '25', className = '', viewBox = '0 0 25 25' }) => { + return ( + + + + ); +}; + +export default AlignHorizontalCenter; diff --git a/frontend/src/_ui/Icon/solidIcons/index.js b/frontend/src/_ui/Icon/solidIcons/index.js index 34a2410e1d..fa22345559 100644 --- a/frontend/src/_ui/Icon/solidIcons/index.js +++ b/frontend/src/_ui/Icon/solidIcons/index.js @@ -171,6 +171,7 @@ import WorkspaceConstants from './WorkspaceConstants.jsx'; import ArrowBackDown from './ArrowBackDown.jsx'; import AlignRightinspector from './AlignRightinspector.jsx'; import AlignLeftinspector from './AlignLeftinspector.jsx'; +import AlignHorizontalCenter from './AlignHorizontalCenter.jsx'; import AlignVerticallyTop from './AlignVerticallyTop.jsx'; import AlignVerticallyBottom from './AlignVerticallyBottom.jsx'; import AlignVerticallyCenter from './AlignVerticallyCenter.jsx'; @@ -241,9 +242,11 @@ const Icon = (props) => { case 'addrectangle': return ; case 'alignleftinspector': - return ; - case 'alignrightinspector': return ; + case 'alignrightinspector': + return ; + case 'alignhorizontalcenter': + return ; case 'alignverticallytop': return ; case 'alignverticallybottom': diff --git a/server/src/modules/apps/services/widget-config/divider.js b/server/src/modules/apps/services/widget-config/divider.js index 4b35d28719..2e53f6d8e0 100644 --- a/server/src/modules/apps/services/widget-config/divider.js +++ b/server/src/modules/apps/services/widget-config/divider.js @@ -48,12 +48,18 @@ export const dividerConfig = { accordian: 'Divider', }, labelAlignment: { - type: 'code', - displayName: 'Label Alignment', - validation: { - schema: { type: 'string' }, - }, + type: 'switch', + displayName: 'Label alignment', + validation: { schema: { type: 'string' }, defaultValue: 'left' }, + isIcon: true, + showLabel: true, + options: [ + { displayName: 'alignleftinspector', value: 'left', iconName: 'alignleftinspector' }, + { displayName: 'alignhorizontalcenter', value: 'center', iconName: 'alignhorizontalcenter' }, + { displayName: 'alignrightinspector', value: 'right', iconName: 'alignrightinspector' }, + ], accordian: 'Divider', + isFxNotRequired: true, }, dividerStyle: { type: 'switch', From a3db1f4b3b57ca0ee3baa8ef2b8c254779e00463 Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Tue, 18 Mar 2025 14:45:19 +0530 Subject: [PATCH 013/236] Added tooltips to run and preview buttons. --- .../Components/QueryManagerHeader.jsx | 64 +++++++++---------- 1 file changed, 29 insertions(+), 35 deletions(-) diff --git a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx index 6055c0538a..5edd5421d4 100644 --- a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx +++ b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerHeader.jsx @@ -5,7 +5,7 @@ import { toast } from 'react-hot-toast'; import { useTranslation } from 'react-i18next'; import { DATA_SOURCE_TYPE } from '@/_helpers/constants'; import { shallow } from 'zustand/shallow'; -import { Tooltip } from 'react-tooltip'; +import { ToolTip } from '@/_components'; import { Button } from 'react-bootstrap'; import { decodeEntities } from '@/_helpers/utils'; import { canDeleteDataSource, canReadDataSource, canUpdateDataSource } from '@/_helpers'; @@ -243,29 +243,21 @@ const RunButton = ({ buttonLoadingState }) => { ); return ( - - runQuery(selectedQuery?.id, selectedQuery?.name, undefined, 'edit', {}, true)} - leadingIcon="play01" - disabled={isInDraft} - isLoading={isLoading} - className="!tw-w-[88px]" - data-cy="query-run-button" - {...(isInDraft && { - 'data-tooltip-id': 'query-header-btn-run', - 'data-tooltip-content': 'Publish the query to run', - })} - > - Run ⌘↩ - - {isInDraft && } + + + runQuery(selectedQuery?.id, selectedQuery?.name, undefined, 'edit', {}, true)} + leadingIcon="play01" + disabled={isInDraft} + isLoading={isLoading} + className="!tw-w-[88px]" + data-cy="query-run-button" + > + Run ⌘↩ + + ); }; @@ -283,16 +275,18 @@ const PreviewButton = ({ buttonLoadingState, onClick }) => { const { t } = useTranslation(); return ( - - Preview ⌘↑↩ - + + + Preview + + ); }; From f13d3053260af848e19287e2aa07457475d53aa7 Mon Sep 17 00:00:00 2001 From: Yukti Goyal Date: Wed, 19 Mar 2025 20:25:44 +0530 Subject: [PATCH 014/236] Added import,export and user onboard cases --- cypress-tests/cypress/commands/apiCommands.js | 1 + .../platform/externalApi/apiUsers.cy.js | 264 +++- .../externalApi/appImportAndExportAPI.cy.js | 160 +++ .../fixtures/templates/import_named_file.json | 1198 +++++++++++++++++ .../templates/import_unnamed_file.json | 1197 ++++++++++++++++ cypress-tests/cypress/support/utils/api.js | 28 + .../cypress/support/utils/manageGroups.js | 5 +- 7 files changed, 2817 insertions(+), 36 deletions(-) create mode 100644 cypress-tests/cypress/e2e/happyPath/platform/externalApi/appImportAndExportAPI.cy.js create mode 100644 cypress-tests/cypress/fixtures/templates/import_named_file.json create mode 100644 cypress-tests/cypress/fixtures/templates/import_unnamed_file.json diff --git a/cypress-tests/cypress/commands/apiCommands.js b/cypress-tests/cypress/commands/apiCommands.js index 0a0dc58e3e..f5ed132944 100644 --- a/cypress-tests/cypress/commands/apiCommands.js +++ b/cypress-tests/cypress/commands/apiCommands.js @@ -166,6 +166,7 @@ Cypress.Commands.add("apiCreateWorkspace", (workspaceName, workspaceSlug) => { { log: false } ).then((response) => { expect(response.status).to.equal(201); + return response; }); }); }); diff --git a/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js b/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js index 41deec86c4..b95970d349 100644 --- a/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js +++ b/cypress-tests/cypress/e2e/happyPath/platform/externalApi/apiUsers.cy.js @@ -1,20 +1,26 @@ import { fake } from "Fixtures/fake"; -import { createUser, getAllUsers, getUser, updateUser, createGroup, validateUserInGroup } from 'Support/utils/api'; +import { + createUser, getAllUsers, getUser, updateUser, createGroup, validateUserInGroup, updateUserRole, + getAllWorkspaces, replaceUserWorkspace, replaceUserWorkspacesRelations +} from 'Support/utils/api'; import { groupsSelector } from "Selectors/manageGroups"; import { commonSelectors } from 'Selectors/common'; import { searchUser, navigateToManageUsers, logout, navigateToManageGroups } from 'Support/utils/common'; - describe("API Test", () => { const sanitize = (str) => str.toLowerCase().replace(/[^A-Za-z]/g, ""); let userId; + let workspaceId; const data = { firstName: fake.firstName, lastName: fake.lastName, firstName1: fake.firstName, lastName1: fake.lastName, + firstName2: fake.firstName, + lastName2: fake.lastName, email: fake.email.toLowerCase().replaceAll("[^A-Za-z]", ""), email1: fake.email.toLowerCase().replaceAll("[^A-Za-z]", ""), + email2: fake.email.toLowerCase().replaceAll("[^A-Za-z]", ""), workspaceName: sanitize(fake.lastName), workspaceSlug: sanitize(fake.lastName), workspaceName1: sanitize(fake.firstName), @@ -23,7 +29,8 @@ describe("API Test", () => { group2: sanitize(fake.firstName), group3: sanitize(fake.firstName), group4: sanitize(fake.firstName), - group5: sanitize(fake.firstName) + group5: sanitize(fake.firstName), + appName: fake.companyName }; //user with all valid details @@ -86,27 +93,50 @@ describe("API Test", () => { createUser(userData).then((response) => { expect(response.status).to.eq(201); userId = response.body.id; - /* navigateToManageUsers(); - searchUser(data.email); - cy.contains("td", data.email) - .parent() - .within(() => { - cy.get("td small").should("have.text", "active"); - }); - - validateUserInGroup(data.email, "my-workspace", "end-user"); - validateUserInGroup(data.email, data.workspaceSlug, "builder"); - validateUserInGroup(data.email, data.workspaceSlug1, "admin", false); - cy.apiLogout(); - - cy.apiLogin(data.email, "password"); - cy.visit("/my-workspace"); - cy.get(commonSelectors.workspaceName).should("have.text", "My workspace"); - logout();*/ - }) - }) + workspaceId = response.body.workspaces[0].id; + navigateToManageUsers(); + searchUser(data.email); + cy.contains("td", data.email) + .parent() + .within(() => { + cy.get("td small").should("have.text", "active"); + }); - it.skip('Handles user creation errors', () => { + validateUserInGroup(data.email, "my-workspace", "end-user"); + validateUserInGroup(data.email, data.workspaceSlug, "builder"); + validateUserInGroup(data.email, data.workspaceSlug1, "admin", false); + cy.apiLogout(); + + cy.apiLogin(data.email, "password"); + cy.visit("/my-workspace"); + cy.get(commonSelectors.workspaceName).should("have.text", "My workspace"); + logout(); + + //Retrieve all users, a specific user by ID, and all workspaces + cy.defaultWorkspaceLogin(); + navigateToManageUsers(); + let number = 0; + cy.get('[data-cy="title-users-page"]').invoke('text').then((text) => { + number = parseInt(text.match(/\d+/)[0], 10); + }); + + getAllUsers().then((response) => { + expect(response.status).to.eq(200); + //expect(response.body.length).to.eq(number); //error due to removal of user from instance + }); + + getUser(userId).then((response) => { + expect(response.status).to.eq(200); + expect(response.body.name).to.eq(`${data.firstName} ${data.lastName}`); + }); + + getAllWorkspaces().then((response) => { + expect(response.status).to.eq(200); + }); + }); + }); + + it('Handles user creation errors', () => { const invalidUserData = [ { // Duplicate user data: { ...userData }, @@ -168,21 +198,185 @@ describe("API Test", () => { }) }); - it("Get all users and by user id", () => { - navigateToManageUsers(); - let number = 0; - cy.get('[data-cy="title-users-page"]').invoke('text').then((text) => { - number = parseInt(text.match(/\d+/)[0], 10); - cy.log('Number of users:', number); - }); - getAllUsers().then((response) => { + it("Update user details and workspaces relations", () => { + const updatedUserData = { + name: `${data.firstName1} ${data.lastName1}`, + email: data.email1, + password: "updatedpassword" + } + updateUser(userId, updatedUserData).then((response) => { expect(response.status).to.eq(200); - expect(response.body.length).to.eq(number); - }); + }) + cy.apiLogout(); + cy.apiLogin(updatedUserData.email, updatedUserData.password); + cy.apiLogout(); - getUser(userId).then((response) => { + // Replace user workspaces relations + cy.apiLogin(); + validateUserInGroup(updatedUserData.email, "my-workspace", data.group2); + validateUserInGroup(updatedUserData.email, data.workspaceSlug, data.group3); + cy.visit(data.workspaceSlug1); + navigateToManageUsers(); + searchUser(updatedUserData.email); + cy.contains("td", updatedUserData.email); + + replaceUserWorkspacesRelations(userId, [ + { name: "My workspace", status: "active", role: "end-user", groups: [{ name: data.group1 }] }, + { name: data.workspaceName, status: "active", role: "builder", groups: [] } + ]).then((response) => { expect(response.status).to.eq(200); - expect(response.body.name).to.eq(`${data.firstName} ${data.lastName}`); + }); + navigateToManageUsers(); + validateUserInGroup(updatedUserData.email, "my-workspace", data.group2, false); + validateUserInGroup(updatedUserData.email, data.workspaceSlug, data.group3, false); + + cy.visit(data.workspaceSlug1); + navigateToManageUsers(); + searchUser(updatedUserData.email); + cy.get('[data-cy="text-no-result-found"]').contains("No result found"); + replaceUserWorkspacesRelations(userId, []).then((response) => { + expect(response.status).to.eq(200); + }); + cy.visit("my-workspace"); + navigateToManageUsers(); + searchUser(updatedUserData.email); + cy.get('[data-cy="text-no-result-found"]').contains("No result found"); + }); + + it("update user role", () => { + const userData2 = { + name: `${data.firstName} ${data.lastName}`, + email: data.email, + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active" + } + ] + } + let userId1; + let workspaceId1; + createUser(userData2).then((response) => { + expect(response.status).to.eq(201); + userId1 = response.body.id; + workspaceId1 = response.body.workspaces[0].id; + //update role to builder and validate user in builder's group + updateUserRole(workspaceId1, { newRole: "builder", userId: userId1 }) + .then((response) => { + expect(response.status).to.eq(200); + }); + validateUserInGroup(userData2.email, "my-workspace", "builder"); + + //update role to end-user and validate user is removed from builder's group + updateUserRole(workspaceId1, { newRole: "end-user", userId: userId1 }) + .then((response) => { + expect(response.status).to.eq(200); + }); + validateUserInGroup(userData2.email, "my-workspace", data.group5, false); + + // update role to builders and validate app's owner role can't be updated + updateUserRole(workspaceId1, { newRole: "builder", userId: userId1 }) + .then((response) => { + expect(response.status).to.eq(200); + }); + cy.apiLogout(); + cy.apiLogin(userData2.email, userData2.password); + cy.apiCreateApp(data.appName); + cy.apiLogout(); + cy.defaultWorkspaceLogin(); + updateUserRole(workspaceId1, { newRole: "end-user", userId: userId1 }) + .then((response) => { + expect(response.status).to.eq(400); + expect(response.body.message.title).to.include("Can not change user role"); + }); + + }); + }); + const userData3 = { + name: `${data.firstName2} ${data.lastName2}`, + email: data.email2, + password: "password", + status: "active", + workspaces: [ + { + name: "My workspace", + status: "active", + groups: [ + { name: data.group1 }, + { name: data.group2 } + ] + }, + { + name: data.workspaceName, + status: "active", + role: "builder", + groups: [{ name: data.group3 }] + }, + { + name: data.workspaceName1, + status: "archived", + role: "admin", + groups: [{ name: data.group4 }] + } + ] + }; + it("Replace user workspace", () => { + let userId1, workspaceId1; + createUser(userData3).then((response) => { + expect(response.status).to.eq(201); + userId1 = response.body.id; + workspaceId1 = response.body.workspaces[0].id; + + // Helper function to replace user workspace and validate response + const replaceAndValidate = (payload, expectedStatus = 200) => { + return replaceUserWorkspace(userId1, workspaceId1, payload).then((response) => { + expect(response.status).to.eq(expectedStatus); + }); + }; + + // No change if empty request body + replaceAndValidate({}).then(() => { + validateUserInGroup(userData3.email, "my-workspace", data.group1); + validateUserInGroup(userData3.email, "my-workspace", data.group2); + }); + + // Archive the user and verify status + replaceAndValidate({ status: "archived" }).then(() => { + navigateToManageUsers(); + searchUser(userData3.email); + cy.contains("td", userData3.email) + .parent() + .within(() => { + cy.get("td small").should("have.text", "archived"); + }); + }); + + // Reactivate user and validate groups + replaceAndValidate({ status: "active" }).then(() => { + validateUserInGroup(userData3.email, "my-workspace", data.group1); + validateUserInGroup(userData3.email, "my-workspace", data.group2); + }); + + // Update groups and validate removal + replaceAndValidate({ groups: [{ name: data.group1 }] }).then(() => { + validateUserInGroup(userData3.email, "my-workspace", data.group2, false); + }); + + //Empty group array, user removed from groups + replaceAndValidate({ groups: [] }).then(() => { + validateUserInGroup(userData3.email, "my-workspace", data.group1, false); + }); + + //Conflict permission + replaceAndValidate({ groups: [{ name: data.group5 }] }, 400); + + //Add user in groups and validate + replaceAndValidate({ groups: [{ name: data.group1 }, { name: data.group2 }] }); + validateUserInGroup(userData3.email, "my-workspace", data.group1); + validateUserInGroup(userData3.email, "my-workspace", data.group2); }); }); }); + diff --git a/cypress-tests/cypress/e2e/happyPath/platform/externalApi/appImportAndExportAPI.cy.js b/cypress-tests/cypress/e2e/happyPath/platform/externalApi/appImportAndExportAPI.cy.js new file mode 100644 index 0000000000..f2e522b22a --- /dev/null +++ b/cypress-tests/cypress/e2e/happyPath/platform/externalApi/appImportAndExportAPI.cy.js @@ -0,0 +1,160 @@ +import { importApp, exportApp, allAppsDetails } from 'Support/utils/api'; +import { fake } from "Fixtures/fake"; + +describe("Export and Import API ", () => { + + const sanitize = (str) => str.toLowerCase().replace(/[^A-Za-z]/g, ""); + const data = { + workspaceName: sanitize(fake.lastName), + workspaceSlug: sanitize(fake.lastName), + } + + const fixtureFiles = { + requestData: "templates/import_unnamed_file.json", + requestData2: "templates/import_named_file.json", + requestData3: "templates/three-versions.json", + }; + let requestData, requestData2, requestData3; + + beforeEach(() => { + cy.defaultWorkspaceLogin(); + + const fixturePromises = Object.entries(fixtureFiles).map(([key, file]) => + cy.fixture(file).then((data) => ({ key, data })) + ); + + // Assign loaded data to respective variables + return Promise.all(fixturePromises).then((results) => { + results.forEach(({ key, data }) => { + ({ requestData, requestData2, requestData3 }[key] = data); + }); + }); + + }); + it("Import App API", () => { + const workspaceId = Cypress.env("workspaceId"); + + importApp(workspaceId, requestData).then((response) => { + expect(response.status).to.eq(201); + expect(response.body.message).to.include("App imported successfully into workspace"); + }); + + //Invalid access token and workspace + importApp(workspaceId, requestData, { + Authorization: "Basic xyz", + "Content-Type": "application/json" + }).then((response) => { + expect(response.status).to.eq(403); + }); + + importApp(workspaceId, requestData, { + Authorization: "", + "Content-Type": "application/json" + }).then((response) => { + expect(response.status).to.eq(403); + }); + + importApp(`${workspaceId}ee`, requestData).then((response) => { + expect(response.status).to.eq(400); + }); + + //Import named file + importApp(workspaceId, requestData2).then((response) => { + expect(response.status).to.eq(201); + expect(response.body.message).to.include("App imported successfully into workspace"); + }); + cy.reload(); + cy.get('[data-cy="app_json-title"]').should("exist"); + + //duplicate app + importApp(workspaceId, requestData2).then((response) => { + expect(response.status).to.eq(409); + expect(response.body.message).to.include("App with app_json already exists in the workspace"); + }); + cy.deleteApp("app_json"); + cy.get('[data-cy="app_json-title"]').should("not.exist"); + + //Import app in another workpsace + let newWorkspaceId; + cy.apiCreateWorkspace(data.workspaceName, data.workspaceSlug).then((res) => { + newWorkspaceId = res.body.organization_id; + cy.visit(data.workspaceSlug); + + importApp(newWorkspaceId, requestData).then((response) => { + expect(response.status).to.eq(201); + expect(response.body.message).to.include("App imported successfully into workspace"); + }); + }); + }); + + it("Export App API", () => { + const workspaceId = Cypress.env("workspaceId"); + let appId; + importApp(workspaceId, requestData3).then((response) => { + expect(response.status).to.eq(201); + expect(response.body.message).to.include("App imported successfully into workspace"); + }).then(() => { + cy.get('[data-cy^="import-export-app"]') + .first() + .find('[data-cy="edit-button"]') + .click({ force: true }); + cy.skipWalkthrough(); + }); + + cy.get('[data-cy="left-sidebar-settings-button"]').click(); + cy.get('[data-cy="app-slug-input-field"]').invoke('val').then((value) => { + appId = value; + + //export last created version + exportApp(workspaceId, appId, "").then((response) => { + expect(response.status).to.eq(201); + expect(response.body.app[0].definition.appV2.appVersions.length).to.eq(1); + expect(response.body.app[0].definition.appV2.appVersions[0].name).to.eq("v3"); + }); + //export specific versions + exportApp(workspaceId, appId, "?appVersion=v2").then((response) => { + expect(response.status).to.eq(201); + expect(response.body.app[0].definition.appV2.appVersions.length).to.eq(1); + expect(response.body.app[0].definition.appV2.appVersions[0].name).to.eq("v2"); + }); + //export all versions + exportApp(workspaceId, appId, "?exportAllVersions=true").then((response) => { + expect(response.status).to.eq(201); + expect(response.body.app[0].definition.appV2.appVersions.length).to.eq(3); + }); + + //Invalid access token and workspace + /* exportApp(workspaceId, appId, "", { + Authorization: "", + "Content-Type": "application/json" + }).then((response) => { + expect(response.status).to.eq(403); + }); + + exportApp(workspaceId, appId, "", { + Authorization: "", + "Content-Type": "application/json" + }).then((response) => { + expect(response.status).to.eq(403); + }); + + exportApp(`${workspaceId}ee`, appId, "").then((response) => { + expect(response.status).to.eq(400); + }); + */ + //with and without TJDB -x.tooljet_database + exportApp(workspaceId, appId, "?exportTJDB=false").then((response) => { + expect(response.status).to.eq(201); + expect(response.body).not.to.have.property("tooljet_database"); + }); + exportApp(workspaceId, appId, "?exportTJDB=true").then((response) => { + expect(response.status).to.eq(201); + expect(response.body).to.have.property("tooljet_database"); + }); + }); + //All Apps details + allAppsDetails(workspaceId).then((response) => { + expect(response.status).to.eq(200); + }); + }); +}); \ No newline at end of file diff --git a/cypress-tests/cypress/fixtures/templates/import_named_file.json b/cypress-tests/cypress/fixtures/templates/import_named_file.json new file mode 100644 index 0000000000..0636a8b3b3 --- /dev/null +++ b/cypress-tests/cypress/fixtures/templates/import_named_file.json @@ -0,0 +1,1198 @@ +{ + "app": [ + { + "definition": { + "appV2": { + "type": "front-end", + "id": "8819afae-57b6-447d-93dd-6dc108169bfe", + "name": "AI powered code explainer", + "slug": "8819afae-57b6-447d-93dd-6dc108169bfe", + "isPublic": false, + "isMaintenanceOn": false, + "icon": "apps", + "organizationId": "a51da635-3a28-4b10-a6f4-7ba34e254987", + "currentVersionId": null, + "userId": "988bb9f5-e577-4065-8d3c-4fcf731ee15d", + "workflowApiToken": null, + "workflowEnabled": false, + "createdAt": "2025-02-27T07:28:52.129Z", + "creationMode": "DEFAULT", + "updatedAt": "2025-02-27T07:28:52.281Z", + "editingVersion": { + "id": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "name": "v1", + "definition": null, + "globalSettings": { + "hideHeader": true, + "appInMaintenance": false, + "canvasMaxWidth": 100, + "canvasMaxWidthType": "%", + "canvasMaxHeight": 2400, + "canvasBackgroundColor": "#edeff5", + "backgroundFxQuery": "", + "appMode": "auto" + }, + "pageSettings": { + "properties": { + "disableMenu": { + "value": "{{true}}", + "fxActive": false + } + } + }, + "showViewerNavigation": false, + "homePageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "appId": "8819afae-57b6-447d-93dd-6dc108169bfe", + "currentEnvironmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "promotedFrom": null, + "createdAt": "2025-02-27T07:28:52.144Z", + "updatedAt": "2025-02-27T07:28:52.274Z" + }, + "components": [ + { + "id": "7bf37542-4eaa-42d8-9827-1cf1f1649791", + "name": "container1", + "type": "Container", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": null, + "properties": {}, + "general": {}, + "styles": { + "backgroundColor": { + "value": "#ffffffff" + }, + "borderRadius": { + "value": "10" + }, + "borderColor": { + "value": "#ffffff00", + "fxActive": false + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "7367ab91-9541-4bd9-96f7-32da8bb61cf5", + "type": "desktop", + "top": 20, + "left": 1, + "width": 41, + "height": 70, + "componentId": "7bf37542-4eaa-42d8-9827-1cf1f1649791", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "9b1d3bec-c586-4f2b-acdf-09cea7addecc", + "name": "text1", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "7bf37542-4eaa-42d8-9827-1cf1f1649791", + "properties": { + "text": { + "value": "B R A N D" + } + }, + "general": {}, + "styles": { + "textColor": { + "value": "#000", + "fxActive": false + }, + "textSize": { + "value": "{{24}}" + }, + "fontWeight": { + "value": "bold" + }, + "boxShadow": { + "value": "0px 0px 0px 0px #00000040" + }, + "isScrollRequired": { + "value": "disabled" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "8c07e506-b1f5-4715-ab02-718fcce9295b", + "type": "desktop", + "top": 10, + "left": 1, + "width": 6, + "height": 40, + "componentId": "9b1d3bec-c586-4f2b-acdf-09cea7addecc", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "38100944-4325-49b7-8c70-de75cf5ce63d", + "name": "text2", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "7bf37542-4eaa-42d8-9827-1cf1f1649791", + "properties": { + "text": { + "value": "
AI Code Explainer
" + } + }, + "general": {}, + "styles": { + "textColor": { + "value": "#000", + "fxActive": false + }, + "textSize": { + "value": "{{20}}" + }, + "textAlign": { + "value": "right" + }, + "boxShadow": { + "value": "0px 0px 0px 0px #00000040" + }, + "isScrollRequired": { + "value": "disabled" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "129e63b6-9456-4cb7-94b0-7379743fec88", + "type": "desktop", + "top": 10, + "left": 25, + "width": 17, + "height": 40, + "componentId": "38100944-4325-49b7-8c70-de75cf5ce63d", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "name": "container2", + "type": "Container", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": null, + "properties": {}, + "general": {}, + "styles": { + "borderRadius": { + "value": "10" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "14b7706c-cebf-45dc-a555-3a60fdf01f3b", + "type": "desktop", + "top": 110, + "left": 1, + "width": 41, + "height": 620, + "componentId": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "ef46f35d-bf64-4ea0-8c9b-c525b87d6120", + "type": "mobile", + "top": 110, + "left": 1, + "width": 5, + "height": 200, + "componentId": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "fbdab782-4a3b-4811-9f43-35f6dfae8735", + "name": "text3", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Code to be explained" + } + }, + "general": {}, + "styles": { + "textSize": { + "value": "24" + }, + "fontWeight": { + "value": "bold" + }, + "isScrollRequired": { + "value": "disabled" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "cfc25680-87fe-45d1-8431-f009ba351ae2", + "type": "desktop", + "top": 20, + "left": 1, + "width": 20, + "height": 40, + "componentId": "fbdab782-4a3b-4811-9f43-35f6dfae8735", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "bbb13f33-25ee-4c97-8c08-7d7df99ab431", + "type": "mobile", + "top": 20, + "left": 9, + "width": 13.953488372093023, + "height": 40, + "componentId": "fbdab782-4a3b-4811-9f43-35f6dfae8735", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "dca350e6-c9f8-44aa-94d5-e6245cfb0ae2", + "name": "dropdown1", + "type": "DropDown", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "label": { + "value": "" + }, + "value": { + "value": "" + }, + "values": { + "value": "{{queries.32ff6874-7da0-4b88-ae05-3c9cda4a07dc.data.models.map(item => item.name)}}" + }, + "display_values": { + "value": "{{queries.32ff6874-7da0-4b88-ae05-3c9cda4a07dc.data.models.map(item => item.displayName)}}" + }, + "loadingState": { + "value": "{{queries.32ff6874-7da0-4b88-ae05-3c9cda4a07dc.isLoading}}", + "fxActive": true + }, + "placeholder": { + "value": "Select a model" + } + }, + "general": {}, + "styles": { + "borderRadius": { + "value": "5" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.267Z", + "layouts": [ + { + "id": "91cae02e-6d00-48ad-9750-1ae74bc9fd7f", + "type": "mobile", + "top": 10, + "left": 27, + "width": 18.6046511627907, + "height": 30, + "componentId": "dca350e6-c9f8-44aa-94d5-e6245cfb0ae2", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "bb56cbd1-57f7-4917-8a32-046a8e77ed33", + "type": "desktop", + "top": 480, + "left": 1, + "width": 20, + "height": 40, + "componentId": "dca350e6-c9f8-44aa-94d5-e6245cfb0ae2", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "98a7f66e-d446-4be5-b2e8-6bde808e9461", + "name": "textarea1", + "type": "TextArea", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "value": { + "value": "function addNumbers(a, b) {\n return a + b;\n}\n\nconst sum = addNumbers(5, 3);\nconsole.log(sum);" + }, + "placeholder": { + "value": "function addNumbers(a, b) {\n return a + b;\n}\n\nconst sum = addNumbers(5, 3);\nconsole.log(sum);" + } + }, + "general": {}, + "styles": { + "borderRadius": { + "value": "{{5}}" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "db411aca-2e7e-46ae-8bf6-75f664a636ea", + "type": "mobile", + "top": 100, + "left": 3, + "width": 13.953488372093023, + "height": 100, + "componentId": "98a7f66e-d446-4be5-b2e8-6bde808e9461", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "abdc0362-e37b-48d6-9cad-ccbdfcf6fd55", + "type": "desktop", + "top": 70, + "left": 1, + "width": 20, + "height": 270, + "componentId": "98a7f66e-d446-4be5-b2e8-6bde808e9461", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "37fbb9ed-5ac6-439b-82cb-35e276c89f49", + "name": "button1", + "type": "Button", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Generate explanation >>" + }, + "loadingState": { + "value": "{{false}}", + "fxActive": false + }, + "disabledState": { + "value": "{{components.dca350e6-c9f8-44aa-94d5-e6245cfb0ae2.value == undefined || queries.getCodeExplanation.isLoading}}", + "fxActive": true + } + }, + "general": {}, + "styles": { + "backgroundColor": { + "value": "#ffffff00" + }, + "textColor": { + "value": "#3e63ddff" + }, + "loaderColor": { + "value": "#3e63ddff" + }, + "borderRadius": { + "value": "{{5}}" + }, + "borderColor": { + "value": "#3e63ddff" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.267Z", + "layouts": [ + { + "id": "c110426c-5994-4d04-901d-883aafb9d2eb", + "type": "mobile", + "top": 420, + "left": 7, + "width": 6.976744186046512, + "height": 30, + "componentId": "37fbb9ed-5ac6-439b-82cb-35e276c89f49", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "a6a6b92e-0984-4e21-87fc-462a307e06dd", + "type": "desktop", + "top": 550, + "left": 1, + "width": 20, + "height": 40, + "componentId": "37fbb9ed-5ac6-439b-82cb-35e276c89f49", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "b56cb989-9b4f-4dcf-a6c4-70dcfe6aac1a", + "name": "dropdown2", + "type": "DropDown", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "values": { + "value": "{{[\n \"\",\n \"C#\",\n \"C++\",\n \"Dart\",\n \"Elixir\",\n \"Erlang\",\n \"F#\",\n \"Go\",\n \"Groovy\",\n \"Haskell\",\n \"Java\",\n \"JavaScript\",\n \"Kotlin\",\n \"Lua\",\n \"MATLAB\",\n \"Objective-C\",\n \"Perl\",\n \"PHP\",\n \"Python\",\n \"R\",\n \"Ruby\",\n \"Rust\",\n \"Scala\",\n \"Shell\",\n \"SQL\",\n \"Swift\",\n \"TypeScript\"\n]}}" + }, + "display_values": { + "value": "{{[\n \"Any language\",\n \"C#\",\n \"C++\",\n \"Dart\",\n \"Elixir\",\n \"Erlang\",\n \"F#\",\n \"Go\",\n \"Groovy\",\n \"Haskell\",\n \"Java\",\n \"JavaScript\",\n \"Kotlin\",\n \"Lua\",\n \"MATLAB\",\n \"Objective-C\",\n \"Perl\",\n \"PHP\",\n \"Python\",\n \"R\",\n \"Ruby\",\n \"Rust\",\n \"Scala\",\n \"Shell\",\n \"SQL\",\n \"Swift\",\n \"TypeScript\"\n]}}" + }, + "value": { + "value": "" + }, + "placeholder": { + "value": "Select a language" + }, + "label": { + "value": "" + } + }, + "general": {}, + "styles": {}, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "553e50a3-c9d4-4ae7-9b8d-da129cb2f32d", + "type": "mobile", + "top": 420, + "left": 2, + "width": 8, + "height": 30, + "componentId": "b56cb989-9b4f-4dcf-a6c4-70dcfe6aac1a", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "abeda4d6-0111-4b9a-bfb1-234c986ee777", + "type": "desktop", + "top": 390, + "left": 1, + "width": 20, + "height": 40, + "componentId": "b56cb989-9b4f-4dcf-a6c4-70dcfe6aac1a", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "7112d3b6-f7d5-4da8-84ad-f2db9ab962d8", + "name": "text6", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Language" + } + }, + "general": {}, + "styles": { + "fontWeight": { + "value": "bold" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "3b6ce6c5-bb8b-4145-991b-b4dc659ac9ae", + "type": "desktop", + "top": 360, + "left": 1, + "width": 14, + "height": 30, + "componentId": "7112d3b6-f7d5-4da8-84ad-f2db9ab962d8", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "d907a75f-162c-4e89-8bef-8ad4a6b10f6a", + "type": "mobile", + "top": 70, + "left": 4, + "width": 13.953488372093023, + "height": 40, + "componentId": "7112d3b6-f7d5-4da8-84ad-f2db9ab962d8", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "052d73d1-c415-4720-8963-36c94ce54b19", + "name": "text7", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "{{`
${queries.getCodeExplanation.data.candidates ? queries.getCodeExplanation.data.candidates[0].content.parts[0].text : \"
  • Language: JavaScript
  • function addNumbers(a, b) {: Defines a function named addNumbers that takes two parameters a and b.
  • return a + b;: The function returns the sum of a and b.
  • }: Ends the function definition.
  • const sum = addNumbers(5, 3);: Calls the addNumbers function with arguments 5 and 3, and assigns the result to the constant sum.
  • console.log(sum);: Outputs the value of sum to the console, which is 8.
\"}
`}}" + }, + "textFormat": { + "value": "html" + }, + "loadingState": { + "fxActive": true, + "value": "{{queries.5774aa01-0931-4036-8bfa-4d12e0b6bc8b.isLoading}}" + } + }, + "general": {}, + "styles": { + "borderColor": { + "value": "#ddddddff" + }, + "borderRadius": { + "value": "5" + }, + "verticalAlignment": { + "value": "top" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.267Z", + "layouts": [ + { + "id": "388a36e0-95ac-49f3-a97b-ad413efafb3a", + "type": "desktop", + "top": 70, + "left": 22, + "width": 20, + "height": 520, + "componentId": "052d73d1-c415-4720-8963-36c94ce54b19", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "1f2da6ab-3493-4ace-b5ae-ceadbd3e2fb0", + "type": "mobile", + "top": 290, + "left": 23, + "width": 6, + "height": 40, + "componentId": "052d73d1-c415-4720-8963-36c94ce54b19", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "3c5278e8-8cc5-442a-bc70-19d4cd72cec7", + "name": "text8", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Gemini Model" + } + }, + "general": {}, + "styles": { + "fontWeight": { + "value": "bold" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "e41fd57d-29e6-49e2-b3ee-75b3769f6d27", + "type": "mobile", + "top": 70, + "left": 4, + "width": 13.953488372093023, + "height": 40, + "componentId": "3c5278e8-8cc5-442a-bc70-19d4cd72cec7", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "7a1d68a9-e9f5-496e-9947-3d6e12c55b0c", + "type": "desktop", + "top": 450, + "left": 1, + "width": 14, + "height": 30, + "componentId": "3c5278e8-8cc5-442a-bc70-19d4cd72cec7", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "521f0268-02d8-4571-9efe-030c9816bdea", + "name": "text9", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Explanation" + } + }, + "general": {}, + "styles": { + "textSize": { + "value": "24" + }, + "fontWeight": { + "value": "bold" + }, + "isScrollRequired": { + "value": "disabled" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "81f9d6a1-90c4-422c-8602-1675a76f6de4", + "type": "desktop", + "top": 20, + "left": 22, + "width": 20, + "height": 40, + "componentId": "521f0268-02d8-4571-9efe-030c9816bdea", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "da2abfa1-769b-4784-87fb-5020e6610fed", + "type": "mobile", + "top": 20, + "left": 9, + "width": 13.953488372093023, + "height": 40, + "componentId": "521f0268-02d8-4571-9efe-030c9816bdea", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + } + ], + "pages": [ + { + "id": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "name": "Home", + "handle": "home", + "index": 1, + "disabled": false, + "hidden": false, + "icon": null, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.366Z", + "autoComputeLayout": true, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "pageGroupIndex": 1, + "pageGroupId": null, + "isPageGroup": false + } + ], + "events": [ + { + "id": "9417716e-b415-4532-aea4-8a2afa224f10", + "name": "onClick", + "index": 0, + "event": { + "eventId": "onClick", + "message": "Hello world!", + "queryId": "5774aa01-0931-4036-8bfa-4d12e0b6bc8b", + "actionId": "run-query", + "alertType": "info", + "queryName": "getCodeExplanation", + "parameters": {} + }, + "sourceId": "37fbb9ed-5ac6-439b-82cb-35e276c89f49", + "target": "component", + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.260Z" + } + ], + "dataQueries": [ + { + "id": "5774aa01-0931-4036-8bfa-4d12e0b6bc8b", + "name": "getCodeExplanation", + "options": { + "method": "post", + "url": "https://generativelanguage.googleapis.com/v1beta/{{components.dropdown1.value}}:generateContent", + "url_params": [ + [ + "key", + "{{constants.GEMINI_API_KEY}}" + ], + [ + "", + "" + ] + ], + "headers": [ + [ + "Content-Type", + "application/json" + ], + [ + "", + "" + ] + ], + "body": [ + [ + "", + "" + ] + ], + "json_body": "{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"{{components.textarea1.value.replaceAll('\\n','\\\\n')}} - Generate a point-wise line by line explanation of this code in html formatting only. Keep only the explanation, and nothing else. {{components.dropdown2.value ? `The code is in ${components.dropdown2.value} language.` : 'Also identify the language of the code.'}}\"\n }\n ]\n }\n ]\n}", + "body_toggle": true, + "transformationLanguage": "javascript", + "enableTransformation": false, + "arrayValuesChanged": false, + "transformation": "// write your code here\n// return value will be set as data and the original data will be available as rawData\nreturn data.filter(row => row.amount > 1000);\n " + }, + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "32ff6874-7da0-4b88-ae05-3c9cda4a07dc", + "name": "getGeminiModels", + "options": { + "method": "get", + "url": "https://generativelanguage.googleapis.com/v1beta/models?key={{constants.GEMINI_API_KEY}}", + "url_params": [ + [ + "", + "" + ] + ], + "headers": [ + [ + "", + "" + ] + ], + "body": [ + [ + "", + "" + ] + ], + "json_body": null, + "body_toggle": false, + "transformationLanguage": "javascript", + "enableTransformation": false, + "runOnPageLoad": true + }, + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.983Z" + } + ], + "dataSources": [ + { + "id": "489072da-3239-4bd5-91b9-dee5f5da5335", + "name": "restapidefault", + "kind": "restapi", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.153Z", + "updatedAt": "2025-02-27T07:28:52.153Z" + }, + { + "id": "c462a40f-c7fa-4d55-98fe-9bc445271cab", + "name": "runjsdefault", + "kind": "runjs", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.163Z", + "updatedAt": "2025-02-27T07:28:52.163Z" + }, + { + "id": "cc0b5feb-29ea-47c0-9a9a-62c0e0b89ccb", + "name": "runpydefault", + "kind": "runpy", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.170Z", + "updatedAt": "2025-02-27T07:28:52.170Z" + }, + { + "id": "907dde15-1ac2-4f53-ba72-8e4e1d066f0e", + "name": "tooljetdbdefault", + "kind": "tooljetdb", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.176Z", + "updatedAt": "2025-02-27T07:28:52.176Z" + }, + { + "id": "66ad4e35-f981-47a6-99cd-31e9e7bbd9b3", + "name": "workflowsdefault", + "kind": "workflows", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.183Z", + "updatedAt": "2025-02-27T07:28:52.183Z" + } + ], + "appVersions": [ + { + "id": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "name": "v1", + "definition": null, + "globalSettings": { + "hideHeader": true, + "appInMaintenance": false, + "canvasMaxWidth": 100, + "canvasMaxWidthType": "%", + "canvasMaxHeight": 2400, + "canvasBackgroundColor": "#edeff5", + "backgroundFxQuery": "", + "appMode": "auto" + }, + "pageSettings": { + "properties": { + "disableMenu": { + "value": "{{true}}", + "fxActive": false + } + } + }, + "showViewerNavigation": false, + "homePageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "appId": "8819afae-57b6-447d-93dd-6dc108169bfe", + "currentEnvironmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "promotedFrom": null, + "createdAt": "2025-02-27T07:28:52.144Z", + "updatedAt": "2025-02-27T07:28:52.274Z" + } + ], + "appEnvironments": [ + { + "id": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "organizationId": "a51da635-3a28-4b10-a6f4-7ba34e254987", + "name": "development", + "isDefault": false, + "priority": 1, + "enabled": true, + "createdAt": "2025-02-27T07:28:36.425Z", + "updatedAt": "2025-02-27T07:28:36.425Z" + }, + { + "id": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "organizationId": "a51da635-3a28-4b10-a6f4-7ba34e254987", + "name": "staging", + "isDefault": false, + "priority": 2, + "enabled": true, + "createdAt": "2025-02-27T07:28:36.425Z", + "updatedAt": "2025-02-27T07:28:36.425Z" + }, + { + "id": "eb006618-493c-48ac-8a4d-e80d208d29de", + "organizationId": "a51da635-3a28-4b10-a6f4-7ba34e254987", + "name": "production", + "isDefault": true, + "priority": 3, + "enabled": true, + "createdAt": "2025-02-27T07:28:36.425Z", + "updatedAt": "2025-02-27T07:28:36.425Z" + } + ], + "dataSourceOptions": [ + { + "id": "98e3239b-e54b-4b59-992b-d9bbfb68d1e6", + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.159Z", + "updatedAt": "2025-02-27T07:28:52.159Z" + }, + { + "id": "c997ee43-2f17-46aa-bc35-32af668d546b", + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.159Z", + "updatedAt": "2025-02-27T07:28:52.159Z" + }, + { + "id": "01bbd244-59c9-4965-8024-401c8f1961fd", + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.159Z", + "updatedAt": "2025-02-27T07:28:52.159Z" + }, + { + "id": "8a8096f7-6b6f-49ca-95de-596c5670c832", + "dataSourceId": "c462a40f-c7fa-4d55-98fe-9bc445271cab", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.167Z", + "updatedAt": "2025-02-27T07:28:52.167Z" + }, + { + "id": "1e2dcc6d-8944-4b5b-abd4-72f7201bf657", + "dataSourceId": "c462a40f-c7fa-4d55-98fe-9bc445271cab", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.167Z", + "updatedAt": "2025-02-27T07:28:52.167Z" + }, + { + "id": "24bfe83d-b2d3-4bf0-8730-1bd14d96cf7a", + "dataSourceId": "c462a40f-c7fa-4d55-98fe-9bc445271cab", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.167Z", + "updatedAt": "2025-02-27T07:28:52.167Z" + }, + { + "id": "44600a77-04bf-4b30-8613-bd7a7bff6508", + "dataSourceId": "cc0b5feb-29ea-47c0-9a9a-62c0e0b89ccb", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.174Z", + "updatedAt": "2025-02-27T07:28:52.174Z" + }, + { + "id": "b70c436e-70e5-48d3-84d2-ca2c784c7425", + "dataSourceId": "cc0b5feb-29ea-47c0-9a9a-62c0e0b89ccb", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.174Z", + "updatedAt": "2025-02-27T07:28:52.174Z" + }, + { + "id": "7bd1351e-61b9-4ba6-9e57-8eca1a3a0df3", + "dataSourceId": "cc0b5feb-29ea-47c0-9a9a-62c0e0b89ccb", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.174Z", + "updatedAt": "2025-02-27T07:28:52.174Z" + }, + { + "id": "f8268c18-8453-48ac-acf7-46c2d0c75c75", + "dataSourceId": "907dde15-1ac2-4f53-ba72-8e4e1d066f0e", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.181Z", + "updatedAt": "2025-02-27T07:28:52.181Z" + }, + { + "id": "cd59c697-6ac2-4594-b8f6-493676e8b3c7", + "dataSourceId": "907dde15-1ac2-4f53-ba72-8e4e1d066f0e", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.181Z", + "updatedAt": "2025-02-27T07:28:52.181Z" + }, + { + "id": "7270ef0a-f6d6-498e-9959-4b646a30d5d1", + "dataSourceId": "907dde15-1ac2-4f53-ba72-8e4e1d066f0e", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.181Z", + "updatedAt": "2025-02-27T07:28:52.181Z" + }, + { + "id": "fe4824d5-57fa-42dc-9812-4af634737898", + "dataSourceId": "66ad4e35-f981-47a6-99cd-31e9e7bbd9b3", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.189Z", + "updatedAt": "2025-02-27T07:28:52.189Z" + }, + { + "id": "521a6d91-484b-45bc-af8f-aaceb0dc515c", + "dataSourceId": "66ad4e35-f981-47a6-99cd-31e9e7bbd9b3", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.189Z", + "updatedAt": "2025-02-27T07:28:52.189Z" + }, + { + "id": "f5955bf2-c148-4544-acd9-a9a92a943e5b", + "dataSourceId": "66ad4e35-f981-47a6-99cd-31e9e7bbd9b3", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.189Z", + "updatedAt": "2025-02-27T07:28:52.189Z" + } + ], + "schemaDetails": { + "multiPages": true, + "multiEnv": true, + "globalDataSources": true + } + } + } + } + ], + "tooljet_version": "3.5.3-ee-lts", + "appName": "app_json" +} \ No newline at end of file diff --git a/cypress-tests/cypress/fixtures/templates/import_unnamed_file.json b/cypress-tests/cypress/fixtures/templates/import_unnamed_file.json new file mode 100644 index 0000000000..93c2501a51 --- /dev/null +++ b/cypress-tests/cypress/fixtures/templates/import_unnamed_file.json @@ -0,0 +1,1197 @@ +{ + "app": [ + { + "definition": { + "appV2": { + "type": "front-end", + "id": "8819afae-57b6-447d-93dd-6dc108169bfe", + "name": "AI powered code explainer", + "slug": "8819afae-57b6-447d-93dd-6dc108169bfe", + "isPublic": false, + "isMaintenanceOn": false, + "icon": "apps", + "organizationId": "a51da635-3a28-4b10-a6f4-7ba34e254987", + "currentVersionId": null, + "userId": "988bb9f5-e577-4065-8d3c-4fcf731ee15d", + "workflowApiToken": null, + "workflowEnabled": false, + "createdAt": "2025-02-27T07:28:52.129Z", + "creationMode": "DEFAULT", + "updatedAt": "2025-02-27T07:28:52.281Z", + "editingVersion": { + "id": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "name": "v1", + "definition": null, + "globalSettings": { + "hideHeader": true, + "appInMaintenance": false, + "canvasMaxWidth": 100, + "canvasMaxWidthType": "%", + "canvasMaxHeight": 2400, + "canvasBackgroundColor": "#edeff5", + "backgroundFxQuery": "", + "appMode": "auto" + }, + "pageSettings": { + "properties": { + "disableMenu": { + "value": "{{true}}", + "fxActive": false + } + } + }, + "showViewerNavigation": false, + "homePageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "appId": "8819afae-57b6-447d-93dd-6dc108169bfe", + "currentEnvironmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "promotedFrom": null, + "createdAt": "2025-02-27T07:28:52.144Z", + "updatedAt": "2025-02-27T07:28:52.274Z" + }, + "components": [ + { + "id": "7bf37542-4eaa-42d8-9827-1cf1f1649791", + "name": "container1", + "type": "Container", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": null, + "properties": {}, + "general": {}, + "styles": { + "backgroundColor": { + "value": "#ffffffff" + }, + "borderRadius": { + "value": "10" + }, + "borderColor": { + "value": "#ffffff00", + "fxActive": false + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "7367ab91-9541-4bd9-96f7-32da8bb61cf5", + "type": "desktop", + "top": 20, + "left": 1, + "width": 41, + "height": 70, + "componentId": "7bf37542-4eaa-42d8-9827-1cf1f1649791", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "9b1d3bec-c586-4f2b-acdf-09cea7addecc", + "name": "text1", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "7bf37542-4eaa-42d8-9827-1cf1f1649791", + "properties": { + "text": { + "value": "B R A N D" + } + }, + "general": {}, + "styles": { + "textColor": { + "value": "#000", + "fxActive": false + }, + "textSize": { + "value": "{{24}}" + }, + "fontWeight": { + "value": "bold" + }, + "boxShadow": { + "value": "0px 0px 0px 0px #00000040" + }, + "isScrollRequired": { + "value": "disabled" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "8c07e506-b1f5-4715-ab02-718fcce9295b", + "type": "desktop", + "top": 10, + "left": 1, + "width": 6, + "height": 40, + "componentId": "9b1d3bec-c586-4f2b-acdf-09cea7addecc", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "38100944-4325-49b7-8c70-de75cf5ce63d", + "name": "text2", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "7bf37542-4eaa-42d8-9827-1cf1f1649791", + "properties": { + "text": { + "value": "
AI Code Explainer
" + } + }, + "general": {}, + "styles": { + "textColor": { + "value": "#000", + "fxActive": false + }, + "textSize": { + "value": "{{20}}" + }, + "textAlign": { + "value": "right" + }, + "boxShadow": { + "value": "0px 0px 0px 0px #00000040" + }, + "isScrollRequired": { + "value": "disabled" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "129e63b6-9456-4cb7-94b0-7379743fec88", + "type": "desktop", + "top": 10, + "left": 25, + "width": 17, + "height": 40, + "componentId": "38100944-4325-49b7-8c70-de75cf5ce63d", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "name": "container2", + "type": "Container", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": null, + "properties": {}, + "general": {}, + "styles": { + "borderRadius": { + "value": "10" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "14b7706c-cebf-45dc-a555-3a60fdf01f3b", + "type": "desktop", + "top": 110, + "left": 1, + "width": 41, + "height": 620, + "componentId": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "ef46f35d-bf64-4ea0-8c9b-c525b87d6120", + "type": "mobile", + "top": 110, + "left": 1, + "width": 5, + "height": 200, + "componentId": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "fbdab782-4a3b-4811-9f43-35f6dfae8735", + "name": "text3", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Code to be explained" + } + }, + "general": {}, + "styles": { + "textSize": { + "value": "24" + }, + "fontWeight": { + "value": "bold" + }, + "isScrollRequired": { + "value": "disabled" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "cfc25680-87fe-45d1-8431-f009ba351ae2", + "type": "desktop", + "top": 20, + "left": 1, + "width": 20, + "height": 40, + "componentId": "fbdab782-4a3b-4811-9f43-35f6dfae8735", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "bbb13f33-25ee-4c97-8c08-7d7df99ab431", + "type": "mobile", + "top": 20, + "left": 9, + "width": 13.953488372093023, + "height": 40, + "componentId": "fbdab782-4a3b-4811-9f43-35f6dfae8735", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "dca350e6-c9f8-44aa-94d5-e6245cfb0ae2", + "name": "dropdown1", + "type": "DropDown", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "label": { + "value": "" + }, + "value": { + "value": "" + }, + "values": { + "value": "{{queries.32ff6874-7da0-4b88-ae05-3c9cda4a07dc.data.models.map(item => item.name)}}" + }, + "display_values": { + "value": "{{queries.32ff6874-7da0-4b88-ae05-3c9cda4a07dc.data.models.map(item => item.displayName)}}" + }, + "loadingState": { + "value": "{{queries.32ff6874-7da0-4b88-ae05-3c9cda4a07dc.isLoading}}", + "fxActive": true + }, + "placeholder": { + "value": "Select a model" + } + }, + "general": {}, + "styles": { + "borderRadius": { + "value": "5" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.267Z", + "layouts": [ + { + "id": "91cae02e-6d00-48ad-9750-1ae74bc9fd7f", + "type": "mobile", + "top": 10, + "left": 27, + "width": 18.6046511627907, + "height": 30, + "componentId": "dca350e6-c9f8-44aa-94d5-e6245cfb0ae2", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "bb56cbd1-57f7-4917-8a32-046a8e77ed33", + "type": "desktop", + "top": 480, + "left": 1, + "width": 20, + "height": 40, + "componentId": "dca350e6-c9f8-44aa-94d5-e6245cfb0ae2", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "98a7f66e-d446-4be5-b2e8-6bde808e9461", + "name": "textarea1", + "type": "TextArea", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "value": { + "value": "function addNumbers(a, b) {\n return a + b;\n}\n\nconst sum = addNumbers(5, 3);\nconsole.log(sum);" + }, + "placeholder": { + "value": "function addNumbers(a, b) {\n return a + b;\n}\n\nconst sum = addNumbers(5, 3);\nconsole.log(sum);" + } + }, + "general": {}, + "styles": { + "borderRadius": { + "value": "{{5}}" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "db411aca-2e7e-46ae-8bf6-75f664a636ea", + "type": "mobile", + "top": 100, + "left": 3, + "width": 13.953488372093023, + "height": 100, + "componentId": "98a7f66e-d446-4be5-b2e8-6bde808e9461", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "abdc0362-e37b-48d6-9cad-ccbdfcf6fd55", + "type": "desktop", + "top": 70, + "left": 1, + "width": 20, + "height": 270, + "componentId": "98a7f66e-d446-4be5-b2e8-6bde808e9461", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "37fbb9ed-5ac6-439b-82cb-35e276c89f49", + "name": "button1", + "type": "Button", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Generate explanation >>" + }, + "loadingState": { + "value": "{{false}}", + "fxActive": false + }, + "disabledState": { + "value": "{{components.dca350e6-c9f8-44aa-94d5-e6245cfb0ae2.value == undefined || queries.getCodeExplanation.isLoading}}", + "fxActive": true + } + }, + "general": {}, + "styles": { + "backgroundColor": { + "value": "#ffffff00" + }, + "textColor": { + "value": "#3e63ddff" + }, + "loaderColor": { + "value": "#3e63ddff" + }, + "borderRadius": { + "value": "{{5}}" + }, + "borderColor": { + "value": "#3e63ddff" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.267Z", + "layouts": [ + { + "id": "c110426c-5994-4d04-901d-883aafb9d2eb", + "type": "mobile", + "top": 420, + "left": 7, + "width": 6.976744186046512, + "height": 30, + "componentId": "37fbb9ed-5ac6-439b-82cb-35e276c89f49", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "a6a6b92e-0984-4e21-87fc-462a307e06dd", + "type": "desktop", + "top": 550, + "left": 1, + "width": 20, + "height": 40, + "componentId": "37fbb9ed-5ac6-439b-82cb-35e276c89f49", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "b56cb989-9b4f-4dcf-a6c4-70dcfe6aac1a", + "name": "dropdown2", + "type": "DropDown", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "values": { + "value": "{{[\n \"\",\n \"C#\",\n \"C++\",\n \"Dart\",\n \"Elixir\",\n \"Erlang\",\n \"F#\",\n \"Go\",\n \"Groovy\",\n \"Haskell\",\n \"Java\",\n \"JavaScript\",\n \"Kotlin\",\n \"Lua\",\n \"MATLAB\",\n \"Objective-C\",\n \"Perl\",\n \"PHP\",\n \"Python\",\n \"R\",\n \"Ruby\",\n \"Rust\",\n \"Scala\",\n \"Shell\",\n \"SQL\",\n \"Swift\",\n \"TypeScript\"\n]}}" + }, + "display_values": { + "value": "{{[\n \"Any language\",\n \"C#\",\n \"C++\",\n \"Dart\",\n \"Elixir\",\n \"Erlang\",\n \"F#\",\n \"Go\",\n \"Groovy\",\n \"Haskell\",\n \"Java\",\n \"JavaScript\",\n \"Kotlin\",\n \"Lua\",\n \"MATLAB\",\n \"Objective-C\",\n \"Perl\",\n \"PHP\",\n \"Python\",\n \"R\",\n \"Ruby\",\n \"Rust\",\n \"Scala\",\n \"Shell\",\n \"SQL\",\n \"Swift\",\n \"TypeScript\"\n]}}" + }, + "value": { + "value": "" + }, + "placeholder": { + "value": "Select a language" + }, + "label": { + "value": "" + } + }, + "general": {}, + "styles": {}, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "553e50a3-c9d4-4ae7-9b8d-da129cb2f32d", + "type": "mobile", + "top": 420, + "left": 2, + "width": 8, + "height": 30, + "componentId": "b56cb989-9b4f-4dcf-a6c4-70dcfe6aac1a", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "abeda4d6-0111-4b9a-bfb1-234c986ee777", + "type": "desktop", + "top": 390, + "left": 1, + "width": 20, + "height": 40, + "componentId": "b56cb989-9b4f-4dcf-a6c4-70dcfe6aac1a", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "7112d3b6-f7d5-4da8-84ad-f2db9ab962d8", + "name": "text6", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Language" + } + }, + "general": {}, + "styles": { + "fontWeight": { + "value": "bold" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "3b6ce6c5-bb8b-4145-991b-b4dc659ac9ae", + "type": "desktop", + "top": 360, + "left": 1, + "width": 14, + "height": 30, + "componentId": "7112d3b6-f7d5-4da8-84ad-f2db9ab962d8", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "d907a75f-162c-4e89-8bef-8ad4a6b10f6a", + "type": "mobile", + "top": 70, + "left": 4, + "width": 13.953488372093023, + "height": 40, + "componentId": "7112d3b6-f7d5-4da8-84ad-f2db9ab962d8", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "052d73d1-c415-4720-8963-36c94ce54b19", + "name": "text7", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "{{`
${queries.getCodeExplanation.data.candidates ? queries.getCodeExplanation.data.candidates[0].content.parts[0].text : \"
  • Language: JavaScript
  • function addNumbers(a, b) {: Defines a function named addNumbers that takes two parameters a and b.
  • return a + b;: The function returns the sum of a and b.
  • }: Ends the function definition.
  • const sum = addNumbers(5, 3);: Calls the addNumbers function with arguments 5 and 3, and assigns the result to the constant sum.
  • console.log(sum);: Outputs the value of sum to the console, which is 8.
\"}
`}}" + }, + "textFormat": { + "value": "html" + }, + "loadingState": { + "fxActive": true, + "value": "{{queries.5774aa01-0931-4036-8bfa-4d12e0b6bc8b.isLoading}}" + } + }, + "general": {}, + "styles": { + "borderColor": { + "value": "#ddddddff" + }, + "borderRadius": { + "value": "5" + }, + "verticalAlignment": { + "value": "top" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.267Z", + "layouts": [ + { + "id": "388a36e0-95ac-49f3-a97b-ad413efafb3a", + "type": "desktop", + "top": 70, + "left": 22, + "width": 20, + "height": 520, + "componentId": "052d73d1-c415-4720-8963-36c94ce54b19", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "1f2da6ab-3493-4ace-b5ae-ceadbd3e2fb0", + "type": "mobile", + "top": 290, + "left": 23, + "width": 6, + "height": 40, + "componentId": "052d73d1-c415-4720-8963-36c94ce54b19", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "3c5278e8-8cc5-442a-bc70-19d4cd72cec7", + "name": "text8", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Gemini Model" + } + }, + "general": {}, + "styles": { + "fontWeight": { + "value": "bold" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "e41fd57d-29e6-49e2-b3ee-75b3769f6d27", + "type": "mobile", + "top": 70, + "left": 4, + "width": 13.953488372093023, + "height": 40, + "componentId": "3c5278e8-8cc5-442a-bc70-19d4cd72cec7", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "7a1d68a9-e9f5-496e-9947-3d6e12c55b0c", + "type": "desktop", + "top": 450, + "left": 1, + "width": 14, + "height": 30, + "componentId": "3c5278e8-8cc5-442a-bc70-19d4cd72cec7", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + }, + { + "id": "521f0268-02d8-4571-9efe-030c9816bdea", + "name": "text9", + "type": "Text", + "pageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "parent": "2727cf8a-1856-41cb-b716-c25afc2a15ad", + "properties": { + "text": { + "value": "Explanation" + } + }, + "general": {}, + "styles": { + "textSize": { + "value": "24" + }, + "fontWeight": { + "value": "bold" + }, + "isScrollRequired": { + "value": "disabled" + } + }, + "generalStyles": {}, + "displayPreferences": { + "showOnDesktop": { + "value": "{{true}}" + }, + "showOnMobile": { + "value": "{{false}}" + } + }, + "validation": {}, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z", + "layouts": [ + { + "id": "81f9d6a1-90c4-422c-8602-1675a76f6de4", + "type": "desktop", + "top": 20, + "left": 22, + "width": 20, + "height": 40, + "componentId": "521f0268-02d8-4571-9efe-030c9816bdea", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "da2abfa1-769b-4784-87fb-5020e6610fed", + "type": "mobile", + "top": 20, + "left": 9, + "width": 13.953488372093023, + "height": 40, + "componentId": "521f0268-02d8-4571-9efe-030c9816bdea", + "dimensionUnit": "count", + "updatedAt": "2025-02-27T07:28:52.148Z" + } + ] + } + ], + "pages": [ + { + "id": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "name": "Home", + "handle": "home", + "index": 1, + "disabled": false, + "hidden": false, + "icon": null, + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.366Z", + "autoComputeLayout": true, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "pageGroupIndex": 1, + "pageGroupId": null, + "isPageGroup": false + } + ], + "events": [ + { + "id": "9417716e-b415-4532-aea4-8a2afa224f10", + "name": "onClick", + "index": 0, + "event": { + "eventId": "onClick", + "message": "Hello world!", + "queryId": "5774aa01-0931-4036-8bfa-4d12e0b6bc8b", + "actionId": "run-query", + "alertType": "info", + "queryName": "getCodeExplanation", + "parameters": {} + }, + "sourceId": "37fbb9ed-5ac6-439b-82cb-35e276c89f49", + "target": "component", + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.260Z" + } + ], + "dataQueries": [ + { + "id": "5774aa01-0931-4036-8bfa-4d12e0b6bc8b", + "name": "getCodeExplanation", + "options": { + "method": "post", + "url": "https://generativelanguage.googleapis.com/v1beta/{{components.dropdown1.value}}:generateContent", + "url_params": [ + [ + "key", + "{{constants.GEMINI_API_KEY}}" + ], + [ + "", + "" + ] + ], + "headers": [ + [ + "Content-Type", + "application/json" + ], + [ + "", + "" + ] + ], + "body": [ + [ + "", + "" + ] + ], + "json_body": "{\n \"contents\": [\n {\n \"parts\": [\n {\n \"text\": \"{{components.textarea1.value.replaceAll('\\n','\\\\n')}} - Generate a point-wise line by line explanation of this code in html formatting only. Keep only the explanation, and nothing else. {{components.dropdown2.value ? `The code is in ${components.dropdown2.value} language.` : 'Also identify the language of the code.'}}\"\n }\n ]\n }\n ]\n}", + "body_toggle": true, + "transformationLanguage": "javascript", + "enableTransformation": false, + "arrayValuesChanged": false, + "transformation": "// write your code here\n// return value will be set as data and the original data will be available as rawData\nreturn data.filter(row => row.amount > 1000);\n " + }, + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.148Z" + }, + { + "id": "32ff6874-7da0-4b88-ae05-3c9cda4a07dc", + "name": "getGeminiModels", + "options": { + "method": "get", + "url": "https://generativelanguage.googleapis.com/v1beta/models?key={{constants.GEMINI_API_KEY}}", + "url_params": [ + [ + "", + "" + ] + ], + "headers": [ + [ + "", + "" + ] + ], + "body": [ + [ + "", + "" + ] + ], + "json_body": null, + "body_toggle": false, + "transformationLanguage": "javascript", + "enableTransformation": false, + "runOnPageLoad": true + }, + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "createdAt": "2025-02-27T07:28:52.148Z", + "updatedAt": "2025-02-27T07:28:52.983Z" + } + ], + "dataSources": [ + { + "id": "489072da-3239-4bd5-91b9-dee5f5da5335", + "name": "restapidefault", + "kind": "restapi", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.153Z", + "updatedAt": "2025-02-27T07:28:52.153Z" + }, + { + "id": "c462a40f-c7fa-4d55-98fe-9bc445271cab", + "name": "runjsdefault", + "kind": "runjs", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.163Z", + "updatedAt": "2025-02-27T07:28:52.163Z" + }, + { + "id": "cc0b5feb-29ea-47c0-9a9a-62c0e0b89ccb", + "name": "runpydefault", + "kind": "runpy", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.170Z", + "updatedAt": "2025-02-27T07:28:52.170Z" + }, + { + "id": "907dde15-1ac2-4f53-ba72-8e4e1d066f0e", + "name": "tooljetdbdefault", + "kind": "tooljetdb", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.176Z", + "updatedAt": "2025-02-27T07:28:52.176Z" + }, + { + "id": "66ad4e35-f981-47a6-99cd-31e9e7bbd9b3", + "name": "workflowsdefault", + "kind": "workflows", + "type": "static", + "pluginId": null, + "appVersionId": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "organizationId": null, + "scope": "local", + "createdAt": "2025-02-27T07:28:52.183Z", + "updatedAt": "2025-02-27T07:28:52.183Z" + } + ], + "appVersions": [ + { + "id": "430dd7d7-1cd1-4c36-975f-229a1aa7dcb8", + "name": "v1", + "definition": null, + "globalSettings": { + "hideHeader": true, + "appInMaintenance": false, + "canvasMaxWidth": 100, + "canvasMaxWidthType": "%", + "canvasMaxHeight": 2400, + "canvasBackgroundColor": "#edeff5", + "backgroundFxQuery": "", + "appMode": "auto" + }, + "pageSettings": { + "properties": { + "disableMenu": { + "value": "{{true}}", + "fxActive": false + } + } + }, + "showViewerNavigation": false, + "homePageId": "93c0473f-6ada-4f1d-9c05-8a4775466aab", + "appId": "8819afae-57b6-447d-93dd-6dc108169bfe", + "currentEnvironmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "promotedFrom": null, + "createdAt": "2025-02-27T07:28:52.144Z", + "updatedAt": "2025-02-27T07:28:52.274Z" + } + ], + "appEnvironments": [ + { + "id": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "organizationId": "a51da635-3a28-4b10-a6f4-7ba34e254987", + "name": "development", + "isDefault": false, + "priority": 1, + "enabled": true, + "createdAt": "2025-02-27T07:28:36.425Z", + "updatedAt": "2025-02-27T07:28:36.425Z" + }, + { + "id": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "organizationId": "a51da635-3a28-4b10-a6f4-7ba34e254987", + "name": "staging", + "isDefault": false, + "priority": 2, + "enabled": true, + "createdAt": "2025-02-27T07:28:36.425Z", + "updatedAt": "2025-02-27T07:28:36.425Z" + }, + { + "id": "eb006618-493c-48ac-8a4d-e80d208d29de", + "organizationId": "a51da635-3a28-4b10-a6f4-7ba34e254987", + "name": "production", + "isDefault": true, + "priority": 3, + "enabled": true, + "createdAt": "2025-02-27T07:28:36.425Z", + "updatedAt": "2025-02-27T07:28:36.425Z" + } + ], + "dataSourceOptions": [ + { + "id": "98e3239b-e54b-4b59-992b-d9bbfb68d1e6", + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.159Z", + "updatedAt": "2025-02-27T07:28:52.159Z" + }, + { + "id": "c997ee43-2f17-46aa-bc35-32af668d546b", + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.159Z", + "updatedAt": "2025-02-27T07:28:52.159Z" + }, + { + "id": "01bbd244-59c9-4965-8024-401c8f1961fd", + "dataSourceId": "489072da-3239-4bd5-91b9-dee5f5da5335", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.159Z", + "updatedAt": "2025-02-27T07:28:52.159Z" + }, + { + "id": "8a8096f7-6b6f-49ca-95de-596c5670c832", + "dataSourceId": "c462a40f-c7fa-4d55-98fe-9bc445271cab", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.167Z", + "updatedAt": "2025-02-27T07:28:52.167Z" + }, + { + "id": "1e2dcc6d-8944-4b5b-abd4-72f7201bf657", + "dataSourceId": "c462a40f-c7fa-4d55-98fe-9bc445271cab", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.167Z", + "updatedAt": "2025-02-27T07:28:52.167Z" + }, + { + "id": "24bfe83d-b2d3-4bf0-8730-1bd14d96cf7a", + "dataSourceId": "c462a40f-c7fa-4d55-98fe-9bc445271cab", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.167Z", + "updatedAt": "2025-02-27T07:28:52.167Z" + }, + { + "id": "44600a77-04bf-4b30-8613-bd7a7bff6508", + "dataSourceId": "cc0b5feb-29ea-47c0-9a9a-62c0e0b89ccb", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.174Z", + "updatedAt": "2025-02-27T07:28:52.174Z" + }, + { + "id": "b70c436e-70e5-48d3-84d2-ca2c784c7425", + "dataSourceId": "cc0b5feb-29ea-47c0-9a9a-62c0e0b89ccb", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.174Z", + "updatedAt": "2025-02-27T07:28:52.174Z" + }, + { + "id": "7bd1351e-61b9-4ba6-9e57-8eca1a3a0df3", + "dataSourceId": "cc0b5feb-29ea-47c0-9a9a-62c0e0b89ccb", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.174Z", + "updatedAt": "2025-02-27T07:28:52.174Z" + }, + { + "id": "f8268c18-8453-48ac-acf7-46c2d0c75c75", + "dataSourceId": "907dde15-1ac2-4f53-ba72-8e4e1d066f0e", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.181Z", + "updatedAt": "2025-02-27T07:28:52.181Z" + }, + { + "id": "cd59c697-6ac2-4594-b8f6-493676e8b3c7", + "dataSourceId": "907dde15-1ac2-4f53-ba72-8e4e1d066f0e", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.181Z", + "updatedAt": "2025-02-27T07:28:52.181Z" + }, + { + "id": "7270ef0a-f6d6-498e-9959-4b646a30d5d1", + "dataSourceId": "907dde15-1ac2-4f53-ba72-8e4e1d066f0e", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.181Z", + "updatedAt": "2025-02-27T07:28:52.181Z" + }, + { + "id": "fe4824d5-57fa-42dc-9812-4af634737898", + "dataSourceId": "66ad4e35-f981-47a6-99cd-31e9e7bbd9b3", + "environmentId": "4efb81aa-756a-4a8f-a017-e167f0720b85", + "options": null, + "createdAt": "2025-02-27T07:28:52.189Z", + "updatedAt": "2025-02-27T07:28:52.189Z" + }, + { + "id": "521a6d91-484b-45bc-af8f-aaceb0dc515c", + "dataSourceId": "66ad4e35-f981-47a6-99cd-31e9e7bbd9b3", + "environmentId": "ed48a4ab-ef5c-47c0-b99c-453fec90b9ec", + "options": null, + "createdAt": "2025-02-27T07:28:52.189Z", + "updatedAt": "2025-02-27T07:28:52.189Z" + }, + { + "id": "f5955bf2-c148-4544-acd9-a9a92a943e5b", + "dataSourceId": "66ad4e35-f981-47a6-99cd-31e9e7bbd9b3", + "environmentId": "eb006618-493c-48ac-8a4d-e80d208d29de", + "options": null, + "createdAt": "2025-02-27T07:28:52.189Z", + "updatedAt": "2025-02-27T07:28:52.189Z" + } + ], + "schemaDetails": { + "multiPages": true, + "multiEnv": true, + "globalDataSources": true + } + } + } + } + ], + "tooljet_version": "3.5.3-ee-lts" +} \ No newline at end of file diff --git a/cypress-tests/cypress/support/utils/api.js b/cypress-tests/cypress/support/utils/api.js index 8532b89bb2..1ea37104f8 100644 --- a/cypress-tests/cypress/support/utils/api.js +++ b/cypress-tests/cypress/support/utils/api.js @@ -29,6 +29,34 @@ export const getAllUsers = () => { export const updateUser = (userId, userData) => { return apiRequest("PATCH", `${Cypress.env('API_URL')}/ext/user/${userId}`, userData); }; +export const updateUserRole = (workspaceId, userData) => { + return apiRequest("PUT", `${Cypress.env('API_URL')}/ext/update-user-role/workspace/${workspaceId}`, userData); +} + +export const replaceUserWorkspace = (userId, workspaceId, userData) => { + return apiRequest("PATCH", `${Cypress.env('API_URL')}/ext/user/${userId}/workspace/${workspaceId}`, userData); +} + +export const replaceUserWorkspacesRelations = (userId, userData) => { + return apiRequest("PUT", `${Cypress.env('API_URL')}/ext/user/${userId}/workspaces`, userData); +} + +export const getAllWorkspaces = () => { + return apiRequest("GET", `${Cypress.env('API_URL')}/ext/workspaces`); +} + +export const importApp = (workspaceId, appData, headers) => { + return apiRequest("POST", `${Cypress.env('API_URL')}/ext/import/workspace/${workspaceId}/apps`, appData, headers); +} + +export const exportApp = (workspaceId, appId, endpoint, headers) => { + return apiRequest("POST", `${Cypress.env('API_URL')}/ext/export/workspace/${workspaceId}/apps/${appId}${endpoint}`, headers); +} + +export const allAppsDetails = (workspaceIds) => { + return apiRequest("GET", `${Cypress.env('API_URL')}/ext/workspace/${workspaceIds}/apps`); +} + export const createGroup = (groupName) => { cy.get(groupsSelector.createNewGroupButton).click(); cy.clearAndType(groupsSelector.groupNameInput, groupName); diff --git a/cypress-tests/cypress/support/utils/manageGroups.js b/cypress-tests/cypress/support/utils/manageGroups.js index 2c114dfad8..2b7300d760 100644 --- a/cypress-tests/cypress/support/utils/manageGroups.js +++ b/cypress-tests/cypress/support/utils/manageGroups.js @@ -850,6 +850,9 @@ export const createGroupsAndAddUserInGroup = (groupName, email) => { commonSelectors.toastMessage, groupsText.groupCreatedToast ); + addUserInGroup(groupName, email); +}; +export const addUserInGroup = (groupName, email) => { cy.get(groupsSelector.groupLink(groupName)).click(); cy.clearAndType(groupsSelector.multiSelectSearchInput, email); cy.wait(2000); @@ -859,7 +862,7 @@ export const createGroupsAndAddUserInGroup = (groupName, email) => { commonSelectors.toastMessage, groupsText.userAddedToast ); -}; +} export const inviteUserBasedOnRole = (firstName, email, role = "end-user") => { fillUserInviteForm(firstName, email); From 2a4fb0055dc81bf5c6d1c97c460441557d3cf352 Mon Sep 17 00:00:00 2001 From: Kartik Gupta Date: Thu, 20 Mar 2025 14:16:29 +0530 Subject: [PATCH 015/236] control overflow chaining for code editor --- frontend/src/_styles/queryManager.scss | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/src/_styles/queryManager.scss b/frontend/src/_styles/queryManager.scss index 7b256c3812..057dbc7a2d 100644 --- a/frontend/src/_styles/queryManager.scss +++ b/frontend/src/_styles/queryManager.scss @@ -1250,6 +1250,7 @@ $border-radius: 4px; color: var(--slate12) !important; } } + &.data-source-exists { .cm-editor { border-radius: 0 4px 4px 0 !important; @@ -1834,6 +1835,7 @@ $border-radius: 4px; .cm-scroller { border-bottom-left-radius: 4px; + overscroll-behavior: auto !important; } } @@ -1853,18 +1855,19 @@ $border-radius: 4px; margin-left: 32px !important; } -.tjdb-codhinter-wrapper{ - .codehinter-input{ - .cm-editor{ +.tjdb-codhinter-wrapper { + .codehinter-input { + .cm-editor { height: 30px !important; min-height: 30px !important; border-radius: 0 !important; - border-right: 0 ; - } + border-right: 0; + } } } -.tjdb-limit-offset-codehinter{ - .cm-editor{ + +.tjdb-limit-offset-codehinter { + .cm-editor { height: 30px !important; min-height: 30px !important; } @@ -1894,7 +1897,7 @@ $border-radius: 4px; margin-right: auto; p { - display: flex; + display: flex; align-items: center; span { From d5b3708de00c299de8690ad6e4de93f62116a459 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Thu, 20 Mar 2025 21:38:15 +0530 Subject: [PATCH 016/236] feat: Makes header and footer resizable --- .../AppBuilder/AppCanvas/Grid/gridUtils.js | 21 +++ .../Inspector/Components/Form.jsx | 19 --- .../AppBuilder/WidgetManager/widgets/form.js | 7 + .../Form/Components/HorizontalSlot.jsx | 78 ++++++++++ frontend/src/AppBuilder/Widgets/Form/Form.jsx | 137 ++++++++---------- .../src/AppBuilder/Widgets/Form/form.scss | 45 ++++++ .../src/AppBuilder/_hooks/useActiveSlot.js | 46 ++++++ frontend/src/AppBuilder/_hooks/useMoveable.js | 135 +++++++++++++++++ .../src/Editor/WidgetManager/configs/form.js | 7 + .../apps/services/widget-config/form.js | 7 + 10 files changed, 408 insertions(+), 94 deletions(-) create mode 100644 frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx create mode 100644 frontend/src/AppBuilder/_hooks/useActiveSlot.js create mode 100644 frontend/src/AppBuilder/_hooks/useMoveable.js diff --git a/frontend/src/AppBuilder/AppCanvas/Grid/gridUtils.js b/frontend/src/AppBuilder/AppCanvas/Grid/gridUtils.js index da179bc11d..b18dd9d311 100644 --- a/frontend/src/AppBuilder/AppCanvas/Grid/gridUtils.js +++ b/frontend/src/AppBuilder/AppCanvas/Grid/gridUtils.js @@ -415,6 +415,27 @@ export function hideGridLines() { document.getElementById('real-canvas')?.classList.add('hide-grid'); } +export function showGridLinesOnSlot(slotId) { + var canvasElm = document.getElementById(`canvas-${slotId}`); + + canvasElm.classList.remove('hide-grid'); + canvasElm.classList.add('show-grid'); + + document.getElementById('real-canvas')?.classList.add('hide-grid'); + document.getElementById('real-canvas')?.classList.remove('show-grid'); +} + +export function hideGridLinesOnSlot(slotId) { + var canvasElm = document.getElementById(`canvas-${slotId}`); + + + canvasElm.classList.remove('show-grid'); + canvasElm.classList.add('hide-grid'); + + document.getElementById('real-canvas')?.classList.remove('hide-grid'); + document.getElementById('real-canvas')?.classList.add('show-grid'); +} + // Track previously active elements for efficient cleanup let previousActiveWidgets = null; let previousActiveCanvas = null; diff --git a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx index b39924854e..e0178ddbeb 100644 --- a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx +++ b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx @@ -168,25 +168,6 @@ export const baseComponentProperties = ( }); } - items.push({ - title: `${i18next.t('widget.common.general', 'General')}`, - isOpen: true, - children: ( - <> - {renderElement( - component, - componentMeta, - layoutPropertyChanged, - dataQueries, - 'tooltip', - 'general', - currentState, - allComponents - )} - - ), - }); - items.push({ title: `${i18next.t('widget.common.devices', 'Devices')}`, isOpen: true, diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/form.js b/frontend/src/AppBuilder/WidgetManager/widgets/form.js index 2d8eb7f0a8..c5194822b6 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/form.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/form.js @@ -294,6 +294,13 @@ export const formConfig = { defaultValue: false, }, }, + tooltip: { + type: 'code', + displayName: 'Tooltip', + validation: { schema: { type: 'string' } }, + section: 'additionalActions', + placeholder: 'Enter tooltip text', + }, }, events: { onSubmit: { displayName: 'On submit' }, diff --git a/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx b/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx new file mode 100644 index 0000000000..0e15e4a058 --- /dev/null +++ b/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx @@ -0,0 +1,78 @@ +import React, { useEffect } from 'react'; +import { Container as SubContainer } from '@/AppBuilder/AppCanvas/Container'; +import { showGridLinesOnSlot, hideGridLinesOnSlot } from '@/AppBuilder/AppCanvas/Grid/gridUtils'; +import { useResizable } from '@/AppBuilder/_hooks/useMoveable'; + +export const HorizontalSlot = React.memo( + ({ + id, + height = 0, + width, + darkMode, + isDisabled, + isActive, + slotName = 'header', // 'header' or 'footer' + slotStyle = {}, + onResize + }) => { + const parsedHeight = parseInt(height, 10); + + const { getRootProps, getHandleProps, getResizeState } = useResizable({ + initialHeight: parsedHeight, + initialWidth: '100%', // Now respects parent's width + minHeight: 40, + maxHeight: 400, + maxWidth: '100%', + stepHeight: 10, // Height will change in steps of 10px + onResize: () => {}, + onDragEnd: (values) => { + onResize(values); + }, + isReverseVerticalDrag: slotName === 'footer', // Reverse dragging for Footer + }); + + const { height: resizedHeight, isDragging } = getResizeState(); + + + + useEffect(() => { + if (isDragging) { + showGridLinesOnSlot(id); + } else { + hideGridLinesOnSlot(id); + } + }, [isDragging, id]); + + const canvasHeight = parseInt(resizedHeight, 10) / 10; + + return ( +
+
+ +
+
+ + {isDisabled && ( +
{}} + onDrop={(e) => e.stopPropagation()} + /> + )} +
+ ); + } +); diff --git a/frontend/src/AppBuilder/Widgets/Form/Form.jsx b/frontend/src/AppBuilder/Widgets/Form/Form.jsx index afeb4cf844..ffa2373a96 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Form.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Form.jsx @@ -14,6 +14,9 @@ import { CONTAINER_FORM_CANVAS_PADDING, SUBCONTAINER_CANVAS_BORDER_WIDTH, } from '@/AppBuilder/AppCanvas/appCanvasConstants'; +import { HorizontalSlot } from './Components/HorizontalSlot'; +import { useActiveSlot } from '@/AppBuilder/_hooks/useActiveSlot'; + import './form.scss'; const getCanvasHeight = (height) => { @@ -35,6 +38,7 @@ export const Form = function Form(props) { properties, resetComponent = () => {}, dataCy, + onComponentClick, } = props; const childComponents = useStore((state) => state.getChildComponents(id), shallow); const { @@ -46,16 +50,7 @@ export const Form = function Form(props) { footerBackgroundColor, headerBackgroundColor, } = styles; - const { - buttonToSubmit, - loadingState, - advanced, - JSONSchema, - showHeader = false, - showFooter = false, - visibility, - disabledState, - } = properties; + const { buttonToSubmit, advanced, JSONSchema, showHeader = false, showFooter = false } = properties; const { isDisabled, isVisible, isLoading } = useExposeState( properties.loadingState, properties.visibility, @@ -76,16 +71,6 @@ export const Form = function Form(props) { flexDirection: 'column', }; - const formHeader = { - flexShrink: 0, - paddingBottom: '3px', - paddingTop: '7px', - paddingLeft: `${CONTAINER_FORM_CANVAS_PADDING}px`, - paddingRight: `${CONTAINER_FORM_CANVAS_PADDING}px`, - backgroundColor: - ['#fff', '#ffffffff'].includes(headerBackgroundColor) && darkMode ? '#1F2837' : headerBackgroundColor, - }; - const formContent = { overflow: 'hidden auto', display: 'flex', @@ -96,13 +81,6 @@ export const Form = function Form(props) { paddingRight: `${CONTAINER_FORM_CANVAS_PADDING}px`, }; - const formFooter = { - flexShrink: 0, - padding: `${CONTAINER_FORM_CANVAS_PADDING}px`, - backgroundColor: - ['#fff', '#ffffffff'].includes(footerBackgroundColor) && darkMode ? '#1F2837' : footerBackgroundColor, - }; - const parentRef = useRef(null); const childDataRef = useRef({}); @@ -110,7 +88,6 @@ export const Form = function Form(props) { const [isValid, setValidation] = useState(true); const [uiComponents, setUIComponents] = useState([]); const mounted = useMounted(); - const canvasHeaderHeight = getCanvasHeight(headerHeight) / 10; const canvasFooterHeight = getCanvasHeight(footerHeight) / 10; useEffect(() => { @@ -287,6 +264,38 @@ export const Form = function Form(props) { setChildrenData(childDataRef.current); }; + const activeSlot = useActiveSlot(id); // Track the active slot for this widget + const setComponentProperty = useStore((state) => state.setComponentProperty, shallow); + const updateHeaderSizeInStore = ({ newHeight }) => { + const heightInPx = `${parseInt(newHeight, 10)}px`; + console.log('newHeight', newHeight); + setComponentProperty(id, `headerHeight`, heightInPx, 'properties', 'value', false); + }; + + const updateFooterSizeInStore = ({ newHeight }) => { + const heightInPx = `${parseInt(newHeight, 10)}px`; + console.log('newHeight', newHeight); + setComponentProperty(id, `footerHeight`, heightInPx, 'properties', 'value', false); + }; + const formFooter = { + flexShrink: 0, + paddingTop: '3px', + paddingBottom: '7px', + paddingLeft: `${CONTAINER_FORM_CANVAS_PADDING}px`, + paddingRight: `${CONTAINER_FORM_CANVAS_PADDING}px`, + backgroundColor: + ['#fff', '#ffffffff'].includes(footerBackgroundColor) && darkMode ? '#1F2837' : footerBackgroundColor, + }; + const formHeader = { + flexShrink: 0, + paddingBottom: '3px', + paddingTop: '7px', + paddingLeft: `${CONTAINER_FORM_CANVAS_PADDING}px`, + paddingRight: `${CONTAINER_FORM_CANVAS_PADDING}px`, + backgroundColor: + ['#fff', '#ffffffff'].includes(headerBackgroundColor) && darkMode ? '#1F2837' : headerBackgroundColor, + }; + return (
{showHeader && ( -
- - {isDisabled && ( -
{}} - onDrop={(e) => e.stopPropagation()} - /> - )} -
+ )} +
{isLoading ? (
@@ -382,30 +381,18 @@ export const Form = function Form(props) { )}
{showFooter && ( -
- - {isDisabled && ( - + )} ); diff --git a/frontend/src/AppBuilder/Widgets/Form/form.scss b/frontend/src/AppBuilder/Widgets/Form/form.scss index 530e837eb2..1758e1d0d1 100644 --- a/frontend/src/AppBuilder/Widgets/Form/form.scss +++ b/frontend/src/AppBuilder/Widgets/Form/form.scss @@ -1,3 +1,7 @@ +.jet-form-body { + background-color: inherit; +} + .wj-form-header { position: relative; &::after { @@ -38,3 +42,44 @@ box-sizing: content-box; padding: 4px 0; } + +.resizable-slot { + position: relative; + height: auto; + box-shadow: 0 0 0 1px transparent; /* Acts as a border */ + transition: box-shadow 0.15s ease-in-out; + + &:hover { + box-shadow: 0 0 0 1px var(--border-weak); + } + + &.active { + box-shadow: 0 0 0 1px var(--border-accent-strong); + } + + .resize-handle { + position: absolute; + bottom: -4px; + left: 50%; /* Center horizontally */ + transform: translateX(-50%); /* Ensure proper centering */ + width: 24px; + height: 8px; + border-radius: 4px; + background-color: var(--background-accent-strong); + cursor: ns-resize; + z-index: 1; + visibility: hidden; + transition: visibility 0.15s ease-in-out; + } + + &.active .resize-handle { + visibility: visible; + } +} +.only-bottom { +} + +.jet-form-footer .resize-handle { + top: -4px; + bottom: unset; +} diff --git a/frontend/src/AppBuilder/_hooks/useActiveSlot.js b/frontend/src/AppBuilder/_hooks/useActiveSlot.js new file mode 100644 index 0000000000..bc3269a7ca --- /dev/null +++ b/frontend/src/AppBuilder/_hooks/useActiveSlot.js @@ -0,0 +1,46 @@ +import { useState, useEffect } from 'react'; +import useStore from '@/AppBuilder/_stores/store'; +import { shallow } from 'zustand/shallow'; + +const useIsWidgetSelected = (id) => { + // Get selected components from store using shallow comparison + const selectedComponents = useStore((state) => state.selectedComponents, shallow); + + // Check if the only selected component is the provided `id` + return selectedComponents.length === 1 && selectedComponents[0] === id; +}; + + +export const useActiveSlot = (widgetId) => { + const [activeSlot, setActiveSlot] = useState(''); // Default to widget ID + const isSelected = useIsWidgetSelected(widgetId); // Check if widget is selected + useEffect(() => { + const handleClick = (event) => { + let target = event.target; + + // Traverse up to find a slot with an id + while (target && target !== document.body) { + if (target.id && target.id.startsWith('canvas-')) { + const slotId = target.id.replace(/^canvas-/, ''); // ✅ Strip "canvas-" + setActiveSlot(slotId); + return; + } + target = target.parentElement; + } + + // If no slot is found, reset to widget ID + setActiveSlot(widgetId); + }; + + // Attach single click if the widget is selected, otherwise listen for double-click + const eventType = isSelected ? 'click' : 'dblclick'; + + document.addEventListener(eventType, handleClick); + + return () => { + document.removeEventListener(eventType, handleClick); + }; + }, [widgetId, isSelected]); // Re-run when widgetId or selection state changes + + return activeSlot; +}; diff --git a/frontend/src/AppBuilder/_hooks/useMoveable.js b/frontend/src/AppBuilder/_hooks/useMoveable.js new file mode 100644 index 0000000000..ea2687e473 --- /dev/null +++ b/frontend/src/AppBuilder/_hooks/useMoveable.js @@ -0,0 +1,135 @@ +import { useRef, useState } from 'react'; + +const defaultProps = { + minHeight: 50, + maxHeight: 600, + minWidth: 50, + maxWidth: 600, + lockHorizontal: false, + lockVertical: false, + stepHeight: 10, // Default step size for height + stepWidth: 10, // Default step size for width + onResize: null, + onDragStart: null, + onDragEnd: null, + isReverseVerticalDrag: false, +}; + +export const useResizable = (options = {}) => { + const props = { ...defaultProps, ...options }; + const parentRef = useRef(null); + const [isDragging, setIsDragging] = useState(false); // ✅ Track dragging state + + const [height, setHeight] = useState( + typeof props.initialHeight === 'string' ? props.initialHeight : `${props.initialHeight || 200}px` + ); + const [width, setWidth] = useState( + typeof props.initialWidth === 'string' ? props.initialWidth : `${props.initialWidth || 200}px` + ); + + const getRootProps = () => ({ + ref: parentRef, + style: { height, width }, + }); + + const getResizeState = () => ({ + height, + width, + isDragging, + }); + + const getHandleProps = () => { + const handleMouseDown = (e) => { + // Prevent right-click drag activation (button === 2) + if (e.button === 2) return; + + if (!parentRef.current) return; + e.stopPropagation(); + e.preventDefault(); + const startHeight = parseInt(parentRef.current.clientHeight); + const startWidth = parseInt(parentRef.current.clientWidth); + const parentWidth = parentRef.current.parentElement ? parentRef.current.parentElement.clientWidth : startWidth; + const startY = e.clientY; + const startX = e.clientX; + const isPercentage = typeof props.initialWidth === 'string' && props.initialWidth.includes('%'); + + setIsDragging(true); // ✅ Set dragging state to true + + if (props.onDragStart) { + props.onDragStart({ newHeight: startHeight, newWidth: startWidth }); + } + + const handleMouseMove = (moveEvent) => { + moveEvent.stopPropagation(); + moveEvent.preventDefault(); + let newHeight = startHeight; + let newWidth = startWidth; + + if (!props.lockVertical) { + const deltaY = props.isReverseVerticalDrag ? startY - moveEvent.clientY : moveEvent.clientY - startY; + newHeight = startHeight + deltaY; + newHeight = Math.max(props.minHeight, Math.min(props.maxHeight, newHeight)); + newHeight = Math.round(newHeight / props.stepHeight) * props.stepHeight; // Snap to stepHeight + } + + if (!props.lockHorizontal) { + newWidth = startWidth + (moveEvent.clientX - startX); + newWidth = Math.max(props.minWidth, Math.min(props.maxWidth, newWidth)); + newWidth = Math.round(newWidth / props.stepWidth) * props.stepWidth; // Snap to stepWidth + + if (isPercentage) { + newWidth = (newWidth / parentWidth) * 100; // Convert to percentage + newWidth = `${newWidth.toFixed(2)}%`; + } else { + newWidth = `${newWidth}px`; + } + } + + setHeight(`${newHeight}px`); + setWidth(newWidth); + + if (parentRef.current) { + parentRef.current.style.height = `${newHeight}px`; + parentRef.current.style.width = newWidth; + } + + if (props.onResize) { + props.onResize({ + newHeight, + newWidth, + heightDiff: newHeight - startHeight, + widthDiff: isPercentage + ? parseInt(newWidth) - (startWidth / parentWidth) * 100 + : parseInt(newWidth) - startWidth, + }); + } + }; + + const handleMouseUp = () => { + setIsDragging(false); // ✅ Set dragging state to false + + document.removeEventListener('mousemove', handleMouseMove); + document.removeEventListener('mouseup', handleMouseUp); + + if (props.onDragEnd) { + // Get the updated height and width from the DOM instead of relying on state + const finalHeight = parentRef.current ? parseInt(parentRef.current.clientHeight) : parseInt(height); + const finalWidth = parentRef.current ? parseInt(parentRef.current.clientWidth) : parseInt(width); + + props.onDragEnd({ newHeight: finalHeight, newWidth: finalWidth }); + } + }; + + document.addEventListener('mousemove', handleMouseMove); + document.addEventListener('mouseup', handleMouseUp); + }; + + return { + onMouseDown: handleMouseDown, + }; + }; + + return { rootRef: parentRef, getRootProps, getHandleProps, getResizeState }; +}; + +export default useResizable; diff --git a/frontend/src/Editor/WidgetManager/configs/form.js b/frontend/src/Editor/WidgetManager/configs/form.js index 2d8eb7f0a8..c5194822b6 100644 --- a/frontend/src/Editor/WidgetManager/configs/form.js +++ b/frontend/src/Editor/WidgetManager/configs/form.js @@ -294,6 +294,13 @@ export const formConfig = { defaultValue: false, }, }, + tooltip: { + type: 'code', + displayName: 'Tooltip', + validation: { schema: { type: 'string' } }, + section: 'additionalActions', + placeholder: 'Enter tooltip text', + }, }, events: { onSubmit: { displayName: 'On submit' }, diff --git a/server/src/modules/apps/services/widget-config/form.js b/server/src/modules/apps/services/widget-config/form.js index 2d8eb7f0a8..c5194822b6 100644 --- a/server/src/modules/apps/services/widget-config/form.js +++ b/server/src/modules/apps/services/widget-config/form.js @@ -294,6 +294,13 @@ export const formConfig = { defaultValue: false, }, }, + tooltip: { + type: 'code', + displayName: 'Tooltip', + validation: { schema: { type: 'string' } }, + section: 'additionalActions', + placeholder: 'Enter tooltip text', + }, }, events: { onSubmit: { displayName: 'On submit' }, From ce130241f0884acf3c78d52a5effc0b6f68a003e Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Fri, 21 Mar 2025 12:48:33 +0530 Subject: [PATCH 017/236] fix --- frontend/src/Editor/Components/verticalDivider.jsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/frontend/src/Editor/Components/verticalDivider.jsx b/frontend/src/Editor/Components/verticalDivider.jsx index ed9f2d9bfd..5dcb402bf7 100644 --- a/frontend/src/Editor/Components/verticalDivider.jsx +++ b/frontend/src/Editor/Components/verticalDivider.jsx @@ -2,14 +2,13 @@ import React from 'react'; export const VerticalDivider = function Divider({ styles, height, width, dataCy, darkMode, properties }) { const { dividerColor, boxShadow, dividerStyle } = styles; - const { visibility } = properties; const color = dividerColor === '' || ['#000', '#000000'].includes(dividerColor) ? (darkMode ? '#fff' : '#000') : dividerColor; return (
From 6a125e4248e24e6f1cfca9dba4120d53e6afcf6f Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Fri, 21 Mar 2025 12:56:31 +0530 Subject: [PATCH 018/236] fix --- .../Components/{verticalDivider.jsx => VerticalDivider.jsx} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename frontend/src/Editor/Components/{verticalDivider.jsx => VerticalDivider.jsx} (100%) diff --git a/frontend/src/Editor/Components/verticalDivider.jsx b/frontend/src/Editor/Components/VerticalDivider.jsx similarity index 100% rename from frontend/src/Editor/Components/verticalDivider.jsx rename to frontend/src/Editor/Components/VerticalDivider.jsx From c461c04c3d363de350ac58ff96a0d51521d427be Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Mon, 24 Mar 2025 13:46:23 +0530 Subject: [PATCH 019/236] Update names --- frontend/src/AppBuilder/WidgetManager/widgets/divider.js | 4 ++-- .../src/AppBuilder/WidgetManager/widgets/verticalDivider.js | 2 +- frontend/src/Editor/WidgetManager/configs/divider.js | 4 ++-- frontend/src/Editor/WidgetManager/configs/verticalDivider.js | 2 +- server/src/modules/apps/services/widget-config/divider.js | 4 ++-- .../modules/apps/services/widget-config/verticalDivider.js | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/divider.js b/frontend/src/AppBuilder/WidgetManager/widgets/divider.js index 6c4478ef55..121ca0faac 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/divider.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/divider.js @@ -1,6 +1,6 @@ export const dividerConfig = { - name: 'Divider', - displayName: 'Divider', + name: 'HorizontalDivider', + displayName: 'Horizontal divider', description: 'Separator between components', component: 'Divider', defaultSize: { diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js b/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js index 3e0d1cf740..cd3881883f 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js @@ -1,6 +1,6 @@ export const verticalDividerConfig = { name: 'VerticalDivider', - displayName: 'Vertical Divider', + displayName: 'Vertical divider', description: 'Vertical line separator', component: 'VerticalDivider', defaultSize: { diff --git a/frontend/src/Editor/WidgetManager/configs/divider.js b/frontend/src/Editor/WidgetManager/configs/divider.js index 6c4478ef55..2682691102 100644 --- a/frontend/src/Editor/WidgetManager/configs/divider.js +++ b/frontend/src/Editor/WidgetManager/configs/divider.js @@ -1,6 +1,6 @@ export const dividerConfig = { - name: 'Divider', - displayName: 'Divider', + name: 'HorizontalDivider', + displayName: 'Horizontal Divider', description: 'Separator between components', component: 'Divider', defaultSize: { diff --git a/frontend/src/Editor/WidgetManager/configs/verticalDivider.js b/frontend/src/Editor/WidgetManager/configs/verticalDivider.js index 3e0d1cf740..cd3881883f 100644 --- a/frontend/src/Editor/WidgetManager/configs/verticalDivider.js +++ b/frontend/src/Editor/WidgetManager/configs/verticalDivider.js @@ -1,6 +1,6 @@ export const verticalDividerConfig = { name: 'VerticalDivider', - displayName: 'Vertical Divider', + displayName: 'Vertical divider', description: 'Vertical line separator', component: 'VerticalDivider', defaultSize: { diff --git a/server/src/modules/apps/services/widget-config/divider.js b/server/src/modules/apps/services/widget-config/divider.js index 2e53f6d8e0..5bd4f4d607 100644 --- a/server/src/modules/apps/services/widget-config/divider.js +++ b/server/src/modules/apps/services/widget-config/divider.js @@ -1,6 +1,6 @@ export const dividerConfig = { - name: 'Divider', - displayName: 'Divider', + name: 'HorizontalDivider', + displayName: 'Horizontal Divider', description: 'Separator between components', component: 'Divider', defaultSize: { diff --git a/server/src/modules/apps/services/widget-config/verticalDivider.js b/server/src/modules/apps/services/widget-config/verticalDivider.js index 3e0d1cf740..cd3881883f 100644 --- a/server/src/modules/apps/services/widget-config/verticalDivider.js +++ b/server/src/modules/apps/services/widget-config/verticalDivider.js @@ -1,6 +1,6 @@ export const verticalDividerConfig = { name: 'VerticalDivider', - displayName: 'Vertical Divider', + displayName: 'Vertical divider', description: 'Vertical line separator', component: 'VerticalDivider', defaultSize: { From 390445d5e1461f84c5eae5826a6c8904c73663bb Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Tue, 25 Mar 2025 00:07:27 +0530 Subject: [PATCH 020/236] revert submodule commit --- frontend/ee | 2 +- server/ee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/ee b/frontend/ee index 1cd7afea26..715a830c7a 160000 --- a/frontend/ee +++ b/frontend/ee @@ -1 +1 @@ -Subproject commit 1cd7afea262f3b72de08da83e544911571fc05b9 +Subproject commit 715a830c7a8d75efc7f77106292d9e4499005b69 diff --git a/server/ee b/server/ee index e2db6a5fa9..0eefbb71a1 160000 --- a/server/ee +++ b/server/ee @@ -1 +1 @@ -Subproject commit e2db6a5fa9f64a9795136b2874c8041dede4b480 +Subproject commit 0eefbb71a1d5288f49641af5efaaab25970f27d1 From 4e59ad56a09cb4c0a011f3800fed961337fc9c20 Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Tue, 25 Mar 2025 01:29:01 +0530 Subject: [PATCH 021/236] fix divider ui feedback --- .../WidgetManager/widgets/divider.js | 24 ++++++------- frontend/src/Editor/Components/Divider.jsx | 35 +++++++++++-------- .../src/Editor/Components/VerticalDivider.jsx | 9 ++--- .../Editor/WidgetManager/configs/divider.js | 24 ++++++------- .../apps/services/widget-config/divider.js | 24 ++++++------- 5 files changed, 59 insertions(+), 57 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/divider.js b/frontend/src/AppBuilder/WidgetManager/widgets/divider.js index 121ca0faac..f813b847e8 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/divider.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/divider.js @@ -47,6 +47,18 @@ export const dividerConfig = { }, accordian: 'Divider', }, + dividerStyle: { + type: 'switch', + displayName: 'Style', + validation: { + schema: { type: 'string' }, + }, + options: [ + { displayName: 'Solid', value: 'solid' }, + { displayName: 'Dashed', value: 'dashed' }, + ], + accordian: 'Divider', + }, labelAlignment: { type: 'switch', displayName: 'Label alignment', @@ -61,18 +73,6 @@ export const dividerConfig = { accordian: 'Divider', isFxNotRequired: true, }, - dividerStyle: { - type: 'switch', - displayName: 'Style', - validation: { - schema: { type: 'string' }, - }, - options: [ - { displayName: 'Solid', value: 'solid' }, - { displayName: 'Dashed', value: 'dashed' }, - ], - accordian: 'Divider', - }, labelColor: { type: 'color', displayName: 'Label Color', diff --git a/frontend/src/Editor/Components/Divider.jsx b/frontend/src/Editor/Components/Divider.jsx index 18a57ccaee..c5cd06447c 100644 --- a/frontend/src/Editor/Components/Divider.jsx +++ b/frontend/src/Editor/Components/Divider.jsx @@ -1,14 +1,15 @@ import React from 'react'; export const Divider = function Divider({ dataCy, height, width, darkMode, styles, properties }) { - const { labelAlignment, labelColor, dividerColor, boxShadow, dividerStyle } = styles; + const { labelAlignment, labelColor, dividerColor, boxShadow, dividerStyle, padding } = styles; const { label, visibility } = properties; const color = dividerColor === '' || ['#000', '#000000'].includes(dividerColor) ? (darkMode ? '#fff' : '#000') : dividerColor; const dividerLineStyle = { - width, + width: '100%', padding: '0rem', + boxShadow, ...(dividerStyle === 'dashed' ? { height: 0, // No height for dashed, use border instead @@ -21,22 +22,28 @@ export const Divider = function Divider({ dataCy, height, width, darkMode, style borderTop: 'none', }), }; + + const labelStyles = { + color: labelColor, + boxShadow, + fontSize: '11px', + fontWeight: '500', + lineHeight: '16px', + }; + // If no label, render the original divider if (!label) { return (
-
+
); } @@ -46,18 +53,16 @@ export const Divider = function Divider({ dataCy, height, width, darkMode, style
{labelAlignment === 'left' && ( <> - {label} + {label}
)} @@ -72,7 +77,7 @@ export const Divider = function Divider({ dataCy, height, width, darkMode, style }} >
- {label} + {label}
)} @@ -80,7 +85,7 @@ export const Divider = function Divider({ dataCy, height, width, darkMode, style {labelAlignment === 'right' && ( <>
- {label} + {label} )}
diff --git a/frontend/src/Editor/Components/VerticalDivider.jsx b/frontend/src/Editor/Components/VerticalDivider.jsx index 5dcb402bf7..b763e95457 100644 --- a/frontend/src/Editor/Components/VerticalDivider.jsx +++ b/frontend/src/Editor/Components/VerticalDivider.jsx @@ -7,20 +7,17 @@ export const VerticalDivider = function Divider({ styles, height, width, dataCy, return (
-
diff --git a/frontend/src/Editor/WidgetManager/configs/divider.js b/frontend/src/Editor/WidgetManager/configs/divider.js index 2682691102..82bb38da6f 100644 --- a/frontend/src/Editor/WidgetManager/configs/divider.js +++ b/frontend/src/Editor/WidgetManager/configs/divider.js @@ -47,6 +47,18 @@ export const dividerConfig = { }, accordian: 'Divider', }, + dividerStyle: { + type: 'switch', + displayName: 'Style', + validation: { + schema: { type: 'string' }, + }, + options: [ + { displayName: 'Solid', value: 'solid' }, + { displayName: 'Dashed', value: 'dashed' }, + ], + accordian: 'Divider', + }, labelAlignment: { type: 'switch', displayName: 'Label alignment', @@ -61,18 +73,6 @@ export const dividerConfig = { accordian: 'Divider', isFxNotRequired: true, }, - dividerStyle: { - type: 'switch', - displayName: 'Style', - validation: { - schema: { type: 'string' }, - }, - options: [ - { displayName: 'Solid', value: 'solid' }, - { displayName: 'Dashed', value: 'dashed' }, - ], - accordian: 'Divider', - }, labelColor: { type: 'color', displayName: 'Label Color', diff --git a/server/src/modules/apps/services/widget-config/divider.js b/server/src/modules/apps/services/widget-config/divider.js index 5bd4f4d607..4500b89ad3 100644 --- a/server/src/modules/apps/services/widget-config/divider.js +++ b/server/src/modules/apps/services/widget-config/divider.js @@ -47,6 +47,18 @@ export const dividerConfig = { }, accordian: 'Divider', }, + dividerStyle: { + type: 'switch', + displayName: 'Style', + validation: { + schema: { type: 'string' }, + }, + options: [ + { displayName: 'Solid', value: 'solid' }, + { displayName: 'Dashed', value: 'dashed' }, + ], + accordian: 'Divider', + }, labelAlignment: { type: 'switch', displayName: 'Label alignment', @@ -61,18 +73,6 @@ export const dividerConfig = { accordian: 'Divider', isFxNotRequired: true, }, - dividerStyle: { - type: 'switch', - displayName: 'Style', - validation: { - schema: { type: 'string' }, - }, - options: [ - { displayName: 'Solid', value: 'solid' }, - { displayName: 'Dashed', value: 'dashed' }, - ], - accordian: 'Divider', - }, labelColor: { type: 'color', displayName: 'Label Color', From e6a019e004d45c37bfc444487f6d7699478fa28c Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Tue, 25 Mar 2025 14:09:03 +0530 Subject: [PATCH 022/236] Update divider gap --- frontend/src/Editor/Components/Divider.jsx | 10 ++++++++-- .../src/Editor/Components/VerticalDivider.jsx | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/frontend/src/Editor/Components/Divider.jsx b/frontend/src/Editor/Components/Divider.jsx index c5cd06447c..349c6f0ddc 100644 --- a/frontend/src/Editor/Components/Divider.jsx +++ b/frontend/src/Editor/Components/Divider.jsx @@ -1,5 +1,8 @@ import React from 'react'; +const DASH_WIDTH = 4; +const DASH_GAP = 4; + export const Divider = function Divider({ dataCy, height, width, darkMode, styles, properties }) { const { labelAlignment, labelColor, dividerColor, boxShadow, dividerStyle, padding } = styles; const { label, visibility } = properties; @@ -12,9 +15,12 @@ export const Divider = function Divider({ dataCy, height, width, darkMode, style boxShadow, ...(dividerStyle === 'dashed' ? { - height: 0, // No height for dashed, use border instead - borderTop: `1px dashed ${color}`, + backgroundImage: `linear-gradient(to right, ${color} ${DASH_WIDTH}px, transparent ${DASH_GAP}px)`, + backgroundSize: `${DASH_WIDTH + DASH_GAP}px 1px`, + backgroundRepeat: 'repeat-x', backgroundColor: 'transparent', + borderTop: 'none', + height: '1px', } : { height: '1px', diff --git a/frontend/src/Editor/Components/VerticalDivider.jsx b/frontend/src/Editor/Components/VerticalDivider.jsx index b763e95457..76042c8908 100644 --- a/frontend/src/Editor/Components/VerticalDivider.jsx +++ b/frontend/src/Editor/Components/VerticalDivider.jsx @@ -1,4 +1,6 @@ import React from 'react'; +const DASH_WIDTH = 4; +const DASH_GAP = 4; export const VerticalDivider = function Divider({ styles, height, width, dataCy, darkMode, properties }) { const { dividerColor, boxShadow, dividerStyle } = styles; @@ -15,8 +17,18 @@ export const VerticalDivider = function Divider({ styles, height, width, dataCy, style={{ height: '100%', width: '1px', - backgroundColor: dividerStyle === 'solid' ? color : 'transparent', - borderLeft: dividerStyle === 'dashed' ? `1px dashed ${color}` : 'none', + ...(dividerStyle === 'dashed' + ? { + backgroundColor: 'transparent', + backgroundImage: `linear-gradient(to bottom, ${color} ${DASH_WIDTH}px, transparent ${DASH_GAP}px)`, + backgroundSize: `1px ${DASH_WIDTH + DASH_GAP}px`, + backgroundRepeat: 'repeat-y', + border: 'none', + } + : { + backgroundColor: dividerStyle === 'solid' ? color : 'transparent', + border: 'none', + }), padding: '0rem', boxShadow, }} From 7a50c41103128ef312406d5b78e510528acada0d Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Tue, 25 Mar 2025 21:52:37 +0530 Subject: [PATCH 023/236] Fixes interaction bugs with slot resizing --- .../Form/Components/HorizontalSlot.jsx | 15 ++++--- frontend/src/AppBuilder/Widgets/Form/Form.jsx | 10 +++-- .../src/AppBuilder/Widgets/Form/form.scss | 25 ++++++++++- .../src/AppBuilder/_hooks/useActiveSlot.js | 41 ++++++++++++++++--- 4 files changed, 75 insertions(+), 16 deletions(-) diff --git a/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx b/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx index 0e15e4a058..e892dc4f9f 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx @@ -13,15 +13,16 @@ export const HorizontalSlot = React.memo( isActive, slotName = 'header', // 'header' or 'footer' slotStyle = {}, - onResize + onResize, + maxHeight, }) => { const parsedHeight = parseInt(height, 10); const { getRootProps, getHandleProps, getResizeState } = useResizable({ initialHeight: parsedHeight, initialWidth: '100%', // Now respects parent's width - minHeight: 40, - maxHeight: 400, + minHeight: 10, + maxHeight: maxHeight || 400, maxWidth: '100%', stepHeight: 10, // Height will change in steps of 10px onResize: () => {}, @@ -33,8 +34,6 @@ export const HorizontalSlot = React.memo( const { height: resizedHeight, isDragging } = getResizeState(); - - useEffect(() => { if (isDragging) { showGridLinesOnSlot(id); @@ -47,7 +46,10 @@ export const HorizontalSlot = React.memo( return (
-
+
diff --git a/frontend/src/AppBuilder/Widgets/Form/Form.jsx b/frontend/src/AppBuilder/Widgets/Form/Form.jsx index ffa2373a96..1328fc195d 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Form.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Form.jsx @@ -268,21 +268,24 @@ export const Form = function Form(props) { const setComponentProperty = useStore((state) => state.setComponentProperty, shallow); const updateHeaderSizeInStore = ({ newHeight }) => { const heightInPx = `${parseInt(newHeight, 10)}px`; - console.log('newHeight', newHeight); setComponentProperty(id, `headerHeight`, heightInPx, 'properties', 'value', false); }; const updateFooterSizeInStore = ({ newHeight }) => { const heightInPx = `${parseInt(newHeight, 10)}px`; - console.log('newHeight', newHeight); setComponentProperty(id, `footerHeight`, heightInPx, 'properties', 'value', false); }; + + // debugger; + const headerMaxHeight = parseInt(height, 10) - parseInt(footerHeight, 10) - 100 - 10; + const footerMaxHeight = parseInt(height, 10) - parseInt(headerHeight, 10) - 100 - 10; const formFooter = { flexShrink: 0, paddingTop: '3px', paddingBottom: '7px', paddingLeft: `${CONTAINER_FORM_CANVAS_PADDING}px`, paddingRight: `${CONTAINER_FORM_CANVAS_PADDING}px`, + maxHeight: `${footerMaxHeight}px`, backgroundColor: ['#fff', '#ffffffff'].includes(footerBackgroundColor) && darkMode ? '#1F2837' : footerBackgroundColor, }; @@ -292,13 +295,14 @@ export const Form = function Form(props) { paddingTop: '7px', paddingLeft: `${CONTAINER_FORM_CANVAS_PADDING}px`, paddingRight: `${CONTAINER_FORM_CANVAS_PADDING}px`, + maxHeight: `${headerMaxHeight}px`, backgroundColor: ['#fff', '#ffffffff'].includes(headerBackgroundColor) && darkMode ? '#1F2837' : headerBackgroundColor, }; return (
{ export const useActiveSlot = (widgetId) => { const [activeSlot, setActiveSlot] = useState(''); // Default to widget ID const isSelected = useIsWidgetSelected(widgetId); // Check if widget is selected + useEffect(() => { - const handleClick = (event) => { + if (!isSelected) { + setActiveSlot(''); + } + }, [isSelected]); + + useEffect(() => { + const handleDoubleClick = (event) => { let target = event.target; // Traverse up to find a slot with an id @@ -31,16 +38,40 @@ export const useActiveSlot = (widgetId) => { // If no slot is found, reset to widget ID setActiveSlot(widgetId); }; + const handleSingleClick = (event) => { + let target = event.target; + + // Traverse up to find a valid main slot (not header/footer) + while (target && target !== document.body) { + if ( + target.id && + target.id.startsWith('canvas-') && + !target.id.endsWith('-header') && + !target.id.endsWith('-footer') + ) { + const slotId = target.id.replace(/^canvas-/, ''); // Strip "canvas-" + setActiveSlot(slotId); + return; + } + target = target.parentElement; + } + + // If no main slot is found, fallback to widget ID + setActiveSlot(widgetId); + }; // Attach single click if the widget is selected, otherwise listen for double-click - const eventType = isSelected ? 'click' : 'dblclick'; + // const eventType = isSelected ? 'click' : 'dblclick'; + const eventType = 'dblclick'; - document.addEventListener(eventType, handleClick); + document.addEventListener(eventType, handleDoubleClick); + document.addEventListener('click', handleSingleClick); return () => { - document.removeEventListener(eventType, handleClick); + document.removeEventListener(eventType, handleDoubleClick); + document.removeEventListener('click', handleSingleClick); }; - }, [widgetId, isSelected]); // Re-run when widgetId or selection state changes + }, [widgetId]); // Re-run when widgetId or selection state changes return activeSlot; }; From 5c037048934714425c1b645a8b1785d745d6f65e Mon Sep 17 00:00:00 2001 From: Shaurya Sharma Date: Wed, 26 Mar 2025 04:41:00 +0530 Subject: [PATCH 024/236] Server side query support added --- frontend/ee | 2 +- .../CodeEditor/MultiLineCodeEditor.jsx | 34 ++++++++++++++++- .../src/AppBuilder/CodeEditor/PreviewBox.jsx | 9 ++++- .../CodeEditor/SingleLineCodeEditor.jsx | 38 +++++++++++++++++-- frontend/src/AppBuilder/CodeEditor/utils.js | 11 ++++++ frontend/webpack.config.js | 2 +- server/ee | 2 +- .../data-queries/interfaces/IUtilService.ts | 3 +- .../src/modules/data-queries/util.service.ts | 31 +++++++++++---- .../data-sources/interfaces/IUtilService.ts | 2 +- server/src/modules/data-sources/module.ts | 2 + .../src/modules/data-sources/util.service.ts | 22 +++++++---- .../modules/licensing/configs/LicenseBase.ts | 12 ++++++ .../modules/licensing/constants/PlanTerms.ts | 1 + .../src/modules/licensing/constants/index.ts | 1 + server/src/modules/licensing/helper.ts | 3 ++ .../src/modules/licensing/interfaces/terms.ts | 1 + .../organization-constants/constants/index.ts | 1 + .../src/modules/organization-users/module.ts | 4 +- server/src/modules/users/module.ts | 26 ++++++++++++- 20 files changed, 176 insertions(+), 31 deletions(-) diff --git a/frontend/ee b/frontend/ee index d93ee7e131..715a830c7a 160000 --- a/frontend/ee +++ b/frontend/ee @@ -1 +1 @@ -Subproject commit d93ee7e1318f044ef2327671b8b257648071453d +Subproject commit 715a830c7a8d75efc7f77106292d9e4499005b69 diff --git a/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx b/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx index f95baaa328..b447df7efd 100644 --- a/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx +++ b/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx @@ -7,6 +7,7 @@ import { keymap } from '@codemirror/view'; import { completionKeymap, acceptCompletion, autocompletion, completionStatus } from '@codemirror/autocomplete'; import { python } from '@codemirror/lang-python'; import { sql } from '@codemirror/lang-sql'; +import _ from 'lodash'; import { sass, sassCompletionSource } from '@codemirror/lang-sass'; import { okaidia } from '@uiw/codemirror-theme-okaidia'; import { githubLight } from '@uiw/codemirror-theme-github'; @@ -21,6 +22,7 @@ import useStore from '@/AppBuilder/_stores/store'; import { shallow } from 'zustand/shallow'; import { search, searchKeymap, searchPanelOpen } from '@codemirror/search'; import { handleSearchPanel, SearchBtn } from './SearchBox'; +import { isInsideParent } from './utils'; const langSupport = Object.freeze({ javascript: javascript(), @@ -51,8 +53,17 @@ const MultiLineCodeEditor = (props) => { renderCopilot, } = props; const replaceIdsWithName = useStore((state) => state.replaceIdsWithName, shallow); + const wrapperRef = useRef(null); const getSuggestions = useStore((state) => state.getSuggestions, shallow); + const license = useStore((state) => state.license, shallow); + const isLicenseValid = + !_.get(license, 'featureAccess.licenseStatus.isExpired', true) && + _.get(license, 'featureAccess.licenseStatus.isLicenseValid', false); const isInsideQueryPane = !!document.querySelector('.code-hinter-wrapper')?.closest('.query-details'); + const isInsideQueryManager = useMemo( + () => isInsideParent(wrapperRef?.current, 'query-manager'), + [wrapperRef.current] + ); const context = useContext(CodeHinterContext); @@ -100,9 +111,27 @@ const MultiLineCodeEditor = (props) => { const hints = getSuggestions(); + const serverHints = []; + + if (isInsideQueryManager && isLicenseValid) { + hints?.appHints?.forEach((appHint) => { + if (appHint?.hint?.startsWith('globals.currentUser')) { + const key = appHint?.hint?.replace('globals.currentUser', 'globals.server.currentUser'); + serverHints.push({ + hint: key, + type: appHint?.type, + }); + } + }); + } + const allHints = { + ...hints, + appHints: [...hints.appHints, ...serverHints], + }; + let JSLangHints = []; if (lang === 'javascript') { - JSLangHints = Object.keys(hints['jsHints']) + JSLangHints = Object.keys(allHints['jsHints']) .map((key) => { return hints['jsHints'][key]['methods'].map((hint) => ({ hint: hint, @@ -120,7 +149,7 @@ const MultiLineCodeEditor = (props) => { }); } - const appHints = hints['appHints']; + const appHints = allHints['appHints']; let autoSuggestionList = appHints.filter((suggestion) => { return suggestion.hint.includes(nearestSubstring); @@ -229,6 +258,7 @@ const MultiLineCodeEditor = (props) => {
diff --git a/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx b/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx index 2429973c25..89626cf820 100644 --- a/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx +++ b/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx @@ -96,6 +96,7 @@ export const PreviewBox = ({ const [largeDataset, setLargeDataset] = useState(false); const globals = useStore((state) => state.getAllExposedValues().constants || {}, shallow); const secrets = useStore((state) => state.getSecrets(), shallow); + const globalServerConstantsRegex = /.*\{\{.*globals\.server\..*\}\}.*/; const getPreviewContent = (content, type) => { if (content === undefined || content === null) return currentValue; @@ -118,11 +119,11 @@ export const PreviewBox = ({ let previewContent = resolvedValue; let isGlobalConstant = currentValue && currentValue.includes('{{constants.'); let isSecretConstant = currentValue && currentValue.includes('{{secrets.'); + const isServerConstant = currentValue && currentValue.match(globalServerConstantsRegex); let invalidConstants = null; let undefinedError = null; if (isGlobalConstant || isSecretConstant) { invalidConstants = verifyConstant(currentValue, globals, secrets); - console.log('invalidConstants', invalidConstants); } if (invalidConstants?.length) { undefinedError = { type: 'Invalid constants' }; @@ -222,6 +223,7 @@ export const PreviewBox = ({ isWorkspaceVariable={isWorkspaceVariable} isSecretConstant={isSecretConstant || false} isLargeDataset={largeDataset} + isServerConstant={isServerConstant} /> copyToClipboard(error ? error?.value : content)} @@ -240,6 +242,7 @@ const RenderResolvedValue = ({ withValidation, isWorkspaceVariable, isSecretConstant = false, + isServerConstant = false, isLargeDataset, }) => { const computeCoersionPreview = (resolvedValue, coersionData) => { @@ -264,7 +267,9 @@ const RenderResolvedValue = ({ }` : previewType; - const previewContent = isSecretConstant + const previewContent = isServerConstant + ? 'Server constants would be resolved at runtime' + : isSecretConstant ? 'Values of secret constants are hidden' : !withValidation ? resolvedValue diff --git a/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx b/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx index 1243f26f43..74ed22a4f2 100644 --- a/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx +++ b/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx @@ -3,7 +3,7 @@ import React, { useContext, useEffect, useMemo, useRef, useState } from 'react'; import { PreviewBox } from './PreviewBox'; import { ToolTip } from '@/Editor/Inspector/Elements/Components/ToolTip'; import { useTranslation } from 'react-i18next'; -import { camelCase, isEmpty, noop } from 'lodash'; +import { camelCase, isEmpty, noop, get } from 'lodash'; import CodeMirror from '@uiw/react-codemirror'; import { javascript } from '@codemirror/lang-javascript'; import { autocompletion, completionKeymap, completionStatus, acceptCompletion } from '@codemirror/autocomplete'; @@ -12,7 +12,7 @@ import { keymap } from '@codemirror/view'; import FxButton from '../CodeBuilder/Elements/FxButton'; import cx from 'classnames'; import { DynamicFxTypeRenderer } from './DynamicFxTypeRenderer'; -import { resolveReferences } from './utils'; +import { isInsideParent, resolveReferences } from './utils'; import { okaidia } from '@uiw/codemirror-theme-okaidia'; import { githubLight } from '@uiw/codemirror-theme-github'; import { getAutocompletion } from './autocompleteExtensionConfig'; @@ -136,6 +136,7 @@ const SingleLineCodeEditor = ({ componentName, fieldMeta = {}, componentId, ...r componentName={componentName} setShowPreview={setShowPreview} showPreview={showPreview} + wrapperRef={wrapperRef} {...restProps} />
@@ -168,10 +169,39 @@ const EditorInput = ({ previewRef, setShowPreview, onInputChange, + wrapperRef, }) => { + const license = useStore((state) => state.license, shallow); + + const isLicenseValid = + !get(license, 'featureAccess.licenseStatus.isExpired', true) && + get(license, 'featureAccess.licenseStatus.isLicenseValid', false); + const getSuggestions = useStore((state) => state.getSuggestions, shallow); + const isInsideQueryManager = useMemo( + () => isInsideParent(wrapperRef?.current, 'query-manager'), + [wrapperRef.current] + ); function autoCompleteExtensionConfig(context) { const hints = getSuggestions(); + const serverHints = []; + + if (isInsideQueryManager && isLicenseValid) { + hints?.appHints?.forEach((appHint) => { + if (appHint?.hint?.startsWith('globals.currentUser')) { + const key = appHint?.hint?.replace('globals.currentUser', 'globals.server.currentUser'); + serverHints.push({ + hint: key, + type: appHint?.type, + }); + } + }); + } + const allHints = { + ...hints, + appHints: [...hints.appHints, ...serverHints], + }; + let word = context.matchBefore(/\w*/); const totalReferences = (context.state.doc.toString().match(/{{/g) || []).length; @@ -202,7 +232,7 @@ const EditorInput = ({ queryInput = '{{' + currentWord + '}}'; } - let completions = getAutocompletion(queryInput, validationType, hints, totalReferences, originalQueryInput); + let completions = getAutocompletion(queryInput, validationType, allHints, totalReferences, originalQueryInput); return { from: word.from, @@ -212,7 +242,7 @@ const EditorInput = ({ } // eslint-disable-next-line react-hooks/exhaustive-deps - const overRideFunction = React.useCallback((context) => autoCompleteExtensionConfig(context), []); + const overRideFunction = React.useCallback((context) => autoCompleteExtensionConfig(context), [isInsideQueryManager]); const autoCompleteConfig = autocompletion({ override: [overRideFunction], diff --git a/frontend/src/AppBuilder/CodeEditor/utils.js b/frontend/src/AppBuilder/CodeEditor/utils.js index 03473a629f..5149ece110 100644 --- a/frontend/src/AppBuilder/CodeEditor/utils.js +++ b/frontend/src/AppBuilder/CodeEditor/utils.js @@ -30,6 +30,17 @@ function traverseAST(node, callback) { } } +export const isInsideParent = (element, className) => { + while (element) { + if (element.classList?.contains(className)) { + console.log('element.classList', element.classList); + return true; + } + element = element.parentElement; + } + return false; +}; + function getMethods(type) { const arrayMethods = Object.getOwnPropertyNames(Array.prototype).filter( (p) => typeof Array.prototype[p] === 'function' diff --git a/frontend/webpack.config.js b/frontend/webpack.config.js index 92712693b3..7621dc993d 100644 --- a/frontend/webpack.config.js +++ b/frontend/webpack.config.js @@ -122,7 +122,7 @@ module.exports = { '@cloud/modules': emptyModulePath, }, }, - devtool: environment === 'development' ? 'eval-source-map' : 'hidden-source-map', + devtool: 'source-map', module: { rules: [ { diff --git a/server/ee b/server/ee index 1da04eef69..003d8503fa 160000 --- a/server/ee +++ b/server/ee @@ -1 +1 @@ -Subproject commit 1da04eef696345ce9f35d42af92e5d6de992cd85 +Subproject commit 003d8503fa94f149d209e42198e934b1fb56e0bc diff --git a/server/src/modules/data-queries/interfaces/IUtilService.ts b/server/src/modules/data-queries/interfaces/IUtilService.ts index 738108d75d..2c390313df 100644 --- a/server/src/modules/data-queries/interfaces/IUtilService.ts +++ b/server/src/modules/data-queries/interfaces/IUtilService.ts @@ -22,7 +22,8 @@ export interface IDataQueriesUtilService { dataQuery: any, queryOptions: object, organization_id: string, - environmentId?: string + environmentId?: string, + userId?: string ): Promise<{ service: any; sourceOptions: object; diff --git a/server/src/modules/data-queries/util.service.ts b/server/src/modules/data-queries/util.service.ts index 889b39046d..08efbaa42b 100644 --- a/server/src/modules/data-queries/util.service.ts +++ b/server/src/modules/data-queries/util.service.ts @@ -82,6 +82,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { organizationId, environmentId ); + const userId = user ? user.id : null; dataSource.options = dataSourceOptions.options; let { sourceOptions, parsedQueryOptions, service } = await this.fetchServiceAndParsedParams( @@ -89,7 +90,8 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { dataQuery, queryOptions, organizationId, - environmentId + environmentId, + userId ); queryStatus.setOptions(parsedQueryOptions); @@ -217,7 +219,8 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { dataQuery, queryOptions, organizationId, - environmentId + environmentId, + userId )); queryStatus.setOptions(parsedQueryOptions); result = await service.run( @@ -291,18 +294,27 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { } } - async fetchServiceAndParsedParams(dataSource, dataQuery, queryOptions, organization_id, environmentId = undefined) { + async fetchServiceAndParsedParams( + dataSource, + dataQuery, + queryOptions, + organization_id, + environmentId = undefined, + userId = undefined + ) { const sourceOptions = await this.dataSourceUtilService.parseSourceOptions( dataSource.options, organization_id, - environmentId + environmentId, + userId ); const parsedQueryOptions = await this.parseQueryOptions( dataQuery.options, queryOptions, organization_id, - environmentId + environmentId, + userId ); const service = await this.pluginsSelectorService.getService(dataSource.pluginId, dataSource.kind); @@ -368,7 +380,8 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { object: any, options: object, organization_id: string, - environmentId?: string + environmentId?: string, + userId?: string ): Promise { const stack: any[] = [{ obj: object, key: null, parent: null }]; @@ -406,12 +419,14 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { // b: Handle {{constants.}} or {{secrets.}} if ( (typeof resolvedValue === 'string' && resolvedValue.includes('{{constants.')) || - resolvedValue.includes('{{secrets.') + resolvedValue.includes('{{secrets.') || + resolvedValue.includes('{{globals.server.') ) { const resolvingConstant = await this.dataSourceUtilService.resolveConstants( resolvedValue, organization_id, - environmentId + environmentId, + userId ); resolvedValue = resolvingConstant; if (parent && key !== null) { diff --git a/server/src/modules/data-sources/interfaces/IUtilService.ts b/server/src/modules/data-sources/interfaces/IUtilService.ts index f8db416617..8c72b78ddf 100644 --- a/server/src/modules/data-sources/interfaces/IUtilService.ts +++ b/server/src/modules/data-sources/interfaces/IUtilService.ts @@ -34,7 +34,7 @@ export interface IDataSourcesUtilService { parseOptionsForOauthDataSource(options: Array, resetSecureData?: boolean): Promise>; - resolveConstants(value: string, organizationId: string, environmentId: string): Promise; + resolveConstants(value: string, organizationId: string, environmentId: string, userId?: string): Promise; resolveKeyValuePair(element: any, organizationId: string, environmentId: string): Promise; diff --git a/server/src/modules/data-sources/module.ts b/server/src/modules/data-sources/module.ts index 27072f6d2c..0a17074118 100644 --- a/server/src/modules/data-sources/module.ts +++ b/server/src/modules/data-sources/module.ts @@ -10,6 +10,7 @@ import { InstanceSettingsModule } from '@modules/instance-settings/module'; import { VersionRepository } from '@modules/versions/repository'; import { AppsRepository } from '@modules/apps/repository'; import { TooljetDbModule } from '@modules/tooljet-db/module'; +import { UsersModule } from '@modules/users/module'; export class DataSourcesModule { static async register(configs?: { IS_GET_CONTEXT: boolean }): Promise { @@ -28,6 +29,7 @@ export class DataSourcesModule { await OrganizationConstantModule.register(configs), await InstanceSettingsModule.register(configs), await TooljetDbModule.register(configs), + await UsersModule.register(configs), ], providers: [ DataSourcesService, diff --git a/server/src/modules/data-sources/util.service.ts b/server/src/modules/data-sources/util.service.ts index b4329dd4c5..8c89662f9f 100644 --- a/server/src/modules/data-sources/util.service.ts +++ b/server/src/modules/data-sources/util.service.ts @@ -302,8 +302,9 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { return dataSource; } - async resolveConstants(str: string, organizationId: string, environmentId: string): Promise { + async resolveConstants(str: string, organizationId: string, environmentId: string, userId?: string): Promise { const regex = /\{\{(constants|secrets)\.(.*?)\}\}/g; + const matches = Array.from(str.matchAll(regex)); if (matches.length === 0) return str; @@ -353,7 +354,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { } async resolveValue(value, organization_id, environment_id) { - const constantMatcher = /{{constants|secrets\..+?}}/g; + const constantMatcher = /{{constants|secrets|globals.server\..+?}}/g; if (typeof value === 'string' && constantMatcher.test(value)) { return await this.resolveConstants(value, organization_id, environment_id); @@ -371,7 +372,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { const parsedOptions = JSON.parse(JSON.stringify(options)); // need to match if currentOption is a contant, {{constants.psql_db} - const constantMatcher = /{{constants|secrets\..+?}}/g; + const constantMatcher = /{{constants|secrets|globals.server\..+?}}/g; for (const key of Object.keys(parsedOptions)) { let currentOption = parsedOptions[key]?.['value']; @@ -590,10 +591,15 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { return options; } - async parseSourceOptions(options: any, organizationId: string, environmentId: string): Promise { + async parseSourceOptions( + options: any, + organizationId: string, + environmentId: string, + userId?: string + ): Promise { // For adhoc queries such as REST API queries, source options will be null if (!options) return {}; - const constantMatcher = /\{\{(constants|secrets)\..*?\}\}/g; + const constantMatcher = /\{\{(constants|secrets|globals.server)\..*?\}\}/g; for (const key of Object.keys(options)) { const currentOption = options[key]?.['value']; @@ -609,7 +615,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { constantMatcher.lastIndex = 0; if (constantMatcher.test(inner)) { - const resolved = await this.resolveConstants(inner, organizationId, environmentId); + const resolved = await this.resolveConstants(inner, organizationId, environmentId, userId); curr[j] = resolved; } } @@ -618,7 +624,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { } if (constantMatcher.test(currentOption)) { - const resolved = await this.resolveConstants(currentOption, organizationId, environmentId); + const resolved = await this.resolveConstants(currentOption, organizationId, environmentId, userId); options[key]['value'] = resolved; } } @@ -633,7 +639,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { const value = await this.credentialService.getValue(credentialId); if (value.includes('{{constants') || value.includes('{{secrets')) { - const resolved = await this.resolveConstants(value, organizationId, environmentId); + const resolved = await this.resolveConstants(value, organizationId, environmentId, userId); parsedOptions[key] = resolved; continue; } else { diff --git a/server/src/modules/licensing/configs/LicenseBase.ts b/server/src/modules/licensing/configs/LicenseBase.ts index 6f7764addd..8b616a8d21 100644 --- a/server/src/modules/licensing/configs/LicenseBase.ts +++ b/server/src/modules/licensing/configs/LicenseBase.ts @@ -15,6 +15,7 @@ export default class LicenseBase { private _isCustomStyling: boolean; private _isWhiteLabelling: boolean; private _isCustomThemes: boolean; + private _isServerSideGlobal: boolean; private _isMultiEnvironment: boolean; private _isMultiPlayerEdit: boolean; private _isComments: boolean; @@ -49,6 +50,7 @@ export default class LicenseBase { this._isCustomStyling = true; this._isWhiteLabelling = true; this._isCustomThemes = true; + this._isServerSideGlobal = true; this._isLicenseValid = true; this._isMultiEnvironment = true; this._isAi = true; @@ -88,6 +90,7 @@ export default class LicenseBase { this._isCustomStyling = this.getFeatureValue('customStyling'); this._isWhiteLabelling = this.getFeatureValue('whiteLabelling'); this._isCustomThemes = this.getFeatureValue('customThemes'); + this._isServerSideGlobal = this.getFeatureValue('serverSideGlobal'); this._isMultiEnvironment = this.getFeatureValue('multiEnvironment'); this._isMultiPlayerEdit = this.getFeatureValue('multiPlayerEdit'); this._isComments = this.getFeatureValue('comments'); @@ -256,6 +259,13 @@ export default class LicenseBase { return this._isCustomThemes; } + public get serverSideGlobal(): boolean { + if (this.IsBasicPlan) { + return !!BASIC_PLAN_TERMS.features?.serverSideGlobal; + } + return this._isServerSideGlobal; + } + public get multiPlayerEdit(): boolean { if (this.IsBasicPlan) { return !!BASIC_PLAN_TERMS.features?.multiPlayerEdit; @@ -298,6 +308,7 @@ export default class LicenseBase { customStyling: this.customStyling, whiteLabelling: this.whiteLabelling, customThemes: this.customThemes, + serverSideGlobal: this.serverSideGlobal, multiEnvironment: this.multiEnvironment, multiPlayerEdit: this.multiPlayerEdit, gitSync: this.gitSync, @@ -326,6 +337,7 @@ export default class LicenseBase { samlEnabled: this.saml, customStylingEnabled: this.customStyling, customThemesEnabled: this.customThemes, + serverSideGlobalEnabled: this.serverSideGlobal, multiEnvironmentEnabled: this.multiEnvironment, multiPlayerEditEnabled: this.multiPlayerEdit, commentsEnabled: this.comments, diff --git a/server/src/modules/licensing/constants/PlanTerms.ts b/server/src/modules/licensing/constants/PlanTerms.ts index 0eb05cfe6c..c896a1aa46 100644 --- a/server/src/modules/licensing/constants/PlanTerms.ts +++ b/server/src/modules/licensing/constants/PlanTerms.ts @@ -25,6 +25,7 @@ export const BASIC_PLAN_TERMS: Partial = { gitSync: false, comments: false, customThemes: false, + serverSideGlobal: false, ai: true, }, domains: [], diff --git a/server/src/modules/licensing/constants/index.ts b/server/src/modules/licensing/constants/index.ts index 49c7428a84..f5bcf3bd14 100644 --- a/server/src/modules/licensing/constants/index.ts +++ b/server/src/modules/licensing/constants/index.ts @@ -104,6 +104,7 @@ export enum LICENSE_FIELD { CUSTOM_STYLE = 'customStylingEnabled', WHITE_LABEL = 'whitelabellingEnabled', CUSTOM_THEMES = 'customThemeEnabled', + SERVER_SIDE_GLOBAL = 'serverSideGlobalEnabled', AUDIT_LOGS = 'auditLogsEnabled', MAX_DURATION_FOR_AUDIT_LOGS = 'maxDaysForAuditLogs', MULTI_ENVIRONMENT = 'multiEnvironmentEnabled', diff --git a/server/src/modules/licensing/helper.ts b/server/src/modules/licensing/helper.ts index a9ffdc3305..fb6a10bf4e 100644 --- a/server/src/modules/licensing/helper.ts +++ b/server/src/modules/licensing/helper.ts @@ -59,6 +59,9 @@ export function getLicenseFieldValue(type: LICENSE_FIELD, licenseInstance: Licen case LICENSE_FIELD.CUSTOM_THEMES: return licenseInstance.customThemes; + // case LICENSE_FIELD.SERVER_SIDE_GLOBAL: + // return licenseInstance.serverSideGlobal; + case LICENSE_FIELD.AUDIT_LOGS: return licenseInstance.auditLogs; diff --git a/server/src/modules/licensing/interfaces/terms.ts b/server/src/modules/licensing/interfaces/terms.ts index 5be1902aef..c7cbb86690 100644 --- a/server/src/modules/licensing/interfaces/terms.ts +++ b/server/src/modules/licensing/interfaces/terms.ts @@ -27,6 +27,7 @@ export interface Terms { gitSync?: boolean; comments?: boolean; customThemes?: boolean; + serverSideGlobal?: boolean; ai?: boolean; }; type?: LICENSE_TYPE; diff --git a/server/src/modules/organization-constants/constants/index.ts b/server/src/modules/organization-constants/constants/index.ts index edd867b913..7ed5e37bca 100644 --- a/server/src/modules/organization-constants/constants/index.ts +++ b/server/src/modules/organization-constants/constants/index.ts @@ -1,6 +1,7 @@ export enum OrganizationConstantType { GLOBAL = 'Global', SECRET = 'Secret', + SERVER = 'Server', } export enum FEATURE_KEY { diff --git a/server/src/modules/organization-users/module.ts b/server/src/modules/organization-users/module.ts index 174c1b8a92..3ebec059aa 100644 --- a/server/src/modules/organization-users/module.ts +++ b/server/src/modules/organization-users/module.ts @@ -20,7 +20,9 @@ export class OrganizationUsersModule { const { OrganizationUsersController } = await import( `${await getImportPath(IS_GET_CONTEXT)}/organization-users/controller` ); - const { OrganizationUsersService } = await import(`${await getImportPath(IS_GET_CONTEXT)}/organization-users/service`); + const { OrganizationUsersService } = await import( + `${await getImportPath(IS_GET_CONTEXT)}/organization-users/service` + ); const { OrganizationUsersUtilService } = await import( `${await getImportPath(IS_GET_CONTEXT)}/organization-users/util.service` ); diff --git a/server/src/modules/users/module.ts b/server/src/modules/users/module.ts index bd91972dba..965856b0d8 100644 --- a/server/src/modules/users/module.ts +++ b/server/src/modules/users/module.ts @@ -3,6 +3,15 @@ import { DynamicModule } from '@nestjs/common'; import { UserRepository } from './repository'; import { SessionModule } from '@modules/session/module'; import { FeatureAbilityFactory } from './ability'; +import { SessionUtilService } from '@modules/session/util.service'; +import { OrganizationRepository } from '@modules/organizations/repository'; +import { GroupPermissionsRepository } from '@modules/group-permissions/repository'; +import { OrganizationUsersRepository } from '@modules/organization-users/repository'; +import { MetadataUtilService } from '@modules/meta/util.service'; +import { RolesRepository } from '@modules/roles/repository'; +import { EncryptionService } from '@modules/encryption/service'; +import { JwtService } from '@nestjs/jwt'; +import { LicenseCountsService } from '@modules/licensing/services/count.service'; export class UsersModule { static async register(configs?: { IS_GET_CONTEXT: boolean }): Promise { @@ -15,7 +24,22 @@ export class UsersModule { module: UsersModule, imports: [await SessionModule.register(configs)], controllers: [UsersController], - providers: [UsersService, UserRepository, UsersUtilService, FeatureAbilityFactory], + providers: [ + UsersService, + UserRepository, + UsersUtilService, + FeatureAbilityFactory, + SessionUtilService, + OrganizationRepository, + OrganizationUsersRepository, + GroupPermissionsRepository, + MetadataUtilService, + RolesRepository, + EncryptionService, + JwtService, + LicenseCountsService, + ], + exports: [UsersUtilService, UserRepository], }; } } From b40b37f5c3835aab55b4c512fd88afec12682a1b Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Wed, 26 Mar 2025 11:45:12 +0530 Subject: [PATCH 025/236] add padding --- .../WidgetManager/widgets/buttonGroup.js | 14 ++++++++++++++ .../AppBuilder/WidgetManager/widgets/checkbox.js | 15 +++++++++++++++ .../WidgetManager/widgets/colorPicker.js | 14 ++++++++++++++ .../src/AppBuilder/WidgetManager/widgets/icon.js | 15 +++++++++++++++ .../WidgetManager/widgets/rangeslider.js | 14 ++++++++++++++ .../WidgetManager/widgets/starrating.js | 14 ++++++++++++++ .../src/AppBuilder/WidgetManager/widgets/tags.js | 14 ++++++++++++++ .../WidgetManager/widgets/toggleswitchv2.js | 15 +++++++++++++++ .../Editor/WidgetManager/configs/buttonGroup.js | 14 ++++++++++++++ .../src/Editor/WidgetManager/configs/checkbox.js | 15 +++++++++++++++ .../Editor/WidgetManager/configs/colorPicker.js | 14 ++++++++++++++ frontend/src/Editor/WidgetManager/configs/icon.js | 15 +++++++++++++++ .../Editor/WidgetManager/configs/rangeslider.js | 14 ++++++++++++++ .../Editor/WidgetManager/configs/starrating.js | 14 ++++++++++++++ frontend/src/Editor/WidgetManager/configs/tags.js | 14 ++++++++++++++ .../WidgetManager/configs/toggleswitchv2.js | 15 +++++++++++++++ .../apps/services/widget-config/buttonGroup.js | 14 ++++++++++++++ .../apps/services/widget-config/checkbox.js | 15 +++++++++++++++ .../apps/services/widget-config/colorPicker.js | 14 ++++++++++++++ .../modules/apps/services/widget-config/icon.js | 15 +++++++++++++++ .../apps/services/widget-config/rangeslider.js | 14 ++++++++++++++ .../apps/services/widget-config/starrating.js | 14 ++++++++++++++ .../modules/apps/services/widget-config/tags.js | 14 ++++++++++++++ .../apps/services/widget-config/toggleswitchv2.js | 15 +++++++++++++++ 24 files changed, 345 insertions(+) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/buttonGroup.js b/frontend/src/AppBuilder/WidgetManager/widgets/buttonGroup.js index c0fa889dd5..d7f479624b 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/buttonGroup.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/buttonGroup.js @@ -123,6 +123,19 @@ export const buttonGroupConfig = { defaultValue: '#007bff', }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { selected: [1], @@ -148,6 +161,7 @@ export const buttonGroupConfig = { disabledState: { value: '{{false}}' }, selectedTextColor: { value: '#FFFFFF' }, selectedBackgroundColor: { value: '#4368E3' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/checkbox.js b/frontend/src/AppBuilder/WidgetManager/widgets/checkbox.js index c9b6424020..9f991be251 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/checkbox.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/checkbox.js @@ -126,6 +126,20 @@ export const checkboxConfig = { ], accordian: 'label', }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'switch', + }, }, exposedVariables: { value: false, @@ -189,6 +203,7 @@ export const checkboxConfig = { handleColor: { value: '#FFFFFF' }, alignment: { value: 'right' }, boxShadow: { value: '0px 0px 0px 0px #00000090' }, + padding: { value: 'default' }, }, validation: { mandatory: { value: '{{false}}' }, diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/colorPicker.js b/frontend/src/AppBuilder/WidgetManager/widgets/colorPicker.js index b2fddd7e4c..6d93508891 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/colorPicker.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/colorPicker.js @@ -26,6 +26,19 @@ export const colorPickerConfig = { }, styles: { visibility: { type: 'toggle', displayName: 'Visibility' }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { selectedColorHex: '#000000', @@ -45,6 +58,7 @@ export const colorPickerConfig = { events: [], styles: { visibility: { value: '{{true}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/icon.js b/frontend/src/AppBuilder/WidgetManager/widgets/icon.js index aea06c976c..8c0b0880e4 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/icon.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/icon.js @@ -78,6 +78,20 @@ export const iconConfig = { }, accordian: 'Icon', }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'Icon', + }, }, exposedVariables: {}, actions: [ @@ -116,6 +130,7 @@ export const iconConfig = { styles: { iconColor: { value: '#000' }, iconAlign: { value: 'center' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/rangeslider.js b/frontend/src/AppBuilder/WidgetManager/widgets/rangeslider.js index 151dca3384..541ed95209 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/rangeslider.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/rangeslider.js @@ -84,6 +84,19 @@ export const rangeSliderConfig = { defaultValue: true, }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { value: null, @@ -111,6 +124,7 @@ export const rangeSliderConfig = { handleColor: { value: '' }, trackColor: { value: '' }, visibility: { value: '{{true}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/starrating.js b/frontend/src/AppBuilder/WidgetManager/widgets/starrating.js index 01240d0369..d6caf8013c 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/starrating.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/starrating.js @@ -89,6 +89,19 @@ export const starratingConfig = { defaultValue: false, }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { value: 0, @@ -112,6 +125,7 @@ export const starratingConfig = { labelColor: { value: '' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/tags.js b/frontend/src/AppBuilder/WidgetManager/widgets/tags.js index 8af289b23a..6479eeaad0 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/tags.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/tags.js @@ -38,6 +38,19 @@ export const tagsConfig = { defaultValue: true, }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: {}, definition: { @@ -54,6 +67,7 @@ export const tagsConfig = { events: [], styles: { visibility: { value: '{{true}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/toggleswitchv2.js b/frontend/src/AppBuilder/WidgetManager/widgets/toggleswitchv2.js index 6753fbb50d..6f61a7645d 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/toggleswitchv2.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/toggleswitchv2.js @@ -126,6 +126,20 @@ export const toggleSwitchV2Config = { validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] } }, accordian: 'switch', }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'switch', + }, }, exposedVariables: { value: false, @@ -187,6 +201,7 @@ export const toggleSwitchV2Config = { handleColor: { value: '#FFFFFF' }, alignment: { value: 'right' }, boxShadow: { value: '0px 0px 0px 0px #00000090' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/Editor/WidgetManager/configs/buttonGroup.js b/frontend/src/Editor/WidgetManager/configs/buttonGroup.js index 65b7e77807..4a1d5ff218 100644 --- a/frontend/src/Editor/WidgetManager/configs/buttonGroup.js +++ b/frontend/src/Editor/WidgetManager/configs/buttonGroup.js @@ -123,6 +123,19 @@ export const buttonGroupConfig = { defaultValue: '#007bff', }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { selected: [1], @@ -148,6 +161,7 @@ export const buttonGroupConfig = { disabledState: { value: '{{false}}' }, selectedTextColor: { value: '' }, selectedBackgroundColor: { value: '' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/Editor/WidgetManager/configs/checkbox.js b/frontend/src/Editor/WidgetManager/configs/checkbox.js index c9b6424020..9f991be251 100644 --- a/frontend/src/Editor/WidgetManager/configs/checkbox.js +++ b/frontend/src/Editor/WidgetManager/configs/checkbox.js @@ -126,6 +126,20 @@ export const checkboxConfig = { ], accordian: 'label', }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'switch', + }, }, exposedVariables: { value: false, @@ -189,6 +203,7 @@ export const checkboxConfig = { handleColor: { value: '#FFFFFF' }, alignment: { value: 'right' }, boxShadow: { value: '0px 0px 0px 0px #00000090' }, + padding: { value: 'default' }, }, validation: { mandatory: { value: '{{false}}' }, diff --git a/frontend/src/Editor/WidgetManager/configs/colorPicker.js b/frontend/src/Editor/WidgetManager/configs/colorPicker.js index b2fddd7e4c..6d93508891 100644 --- a/frontend/src/Editor/WidgetManager/configs/colorPicker.js +++ b/frontend/src/Editor/WidgetManager/configs/colorPicker.js @@ -26,6 +26,19 @@ export const colorPickerConfig = { }, styles: { visibility: { type: 'toggle', displayName: 'Visibility' }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { selectedColorHex: '#000000', @@ -45,6 +58,7 @@ export const colorPickerConfig = { events: [], styles: { visibility: { value: '{{true}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/Editor/WidgetManager/configs/icon.js b/frontend/src/Editor/WidgetManager/configs/icon.js index aea06c976c..8c0b0880e4 100644 --- a/frontend/src/Editor/WidgetManager/configs/icon.js +++ b/frontend/src/Editor/WidgetManager/configs/icon.js @@ -78,6 +78,20 @@ export const iconConfig = { }, accordian: 'Icon', }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'Icon', + }, }, exposedVariables: {}, actions: [ @@ -116,6 +130,7 @@ export const iconConfig = { styles: { iconColor: { value: '#000' }, iconAlign: { value: 'center' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/Editor/WidgetManager/configs/rangeslider.js b/frontend/src/Editor/WidgetManager/configs/rangeslider.js index 151dca3384..541ed95209 100644 --- a/frontend/src/Editor/WidgetManager/configs/rangeslider.js +++ b/frontend/src/Editor/WidgetManager/configs/rangeslider.js @@ -84,6 +84,19 @@ export const rangeSliderConfig = { defaultValue: true, }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { value: null, @@ -111,6 +124,7 @@ export const rangeSliderConfig = { handleColor: { value: '' }, trackColor: { value: '' }, visibility: { value: '{{true}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/Editor/WidgetManager/configs/starrating.js b/frontend/src/Editor/WidgetManager/configs/starrating.js index 01240d0369..d6caf8013c 100644 --- a/frontend/src/Editor/WidgetManager/configs/starrating.js +++ b/frontend/src/Editor/WidgetManager/configs/starrating.js @@ -89,6 +89,19 @@ export const starratingConfig = { defaultValue: false, }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { value: 0, @@ -112,6 +125,7 @@ export const starratingConfig = { labelColor: { value: '' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/Editor/WidgetManager/configs/tags.js b/frontend/src/Editor/WidgetManager/configs/tags.js index 8af289b23a..6479eeaad0 100644 --- a/frontend/src/Editor/WidgetManager/configs/tags.js +++ b/frontend/src/Editor/WidgetManager/configs/tags.js @@ -38,6 +38,19 @@ export const tagsConfig = { defaultValue: true, }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: {}, definition: { @@ -54,6 +67,7 @@ export const tagsConfig = { events: [], styles: { visibility: { value: '{{true}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/frontend/src/Editor/WidgetManager/configs/toggleswitchv2.js b/frontend/src/Editor/WidgetManager/configs/toggleswitchv2.js index 6753fbb50d..6f61a7645d 100644 --- a/frontend/src/Editor/WidgetManager/configs/toggleswitchv2.js +++ b/frontend/src/Editor/WidgetManager/configs/toggleswitchv2.js @@ -126,6 +126,20 @@ export const toggleSwitchV2Config = { validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] } }, accordian: 'switch', }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'switch', + }, }, exposedVariables: { value: false, @@ -187,6 +201,7 @@ export const toggleSwitchV2Config = { handleColor: { value: '#FFFFFF' }, alignment: { value: 'right' }, boxShadow: { value: '0px 0px 0px 0px #00000090' }, + padding: { value: 'default' }, }, }, }; diff --git a/server/src/modules/apps/services/widget-config/buttonGroup.js b/server/src/modules/apps/services/widget-config/buttonGroup.js index c0fa889dd5..d7f479624b 100644 --- a/server/src/modules/apps/services/widget-config/buttonGroup.js +++ b/server/src/modules/apps/services/widget-config/buttonGroup.js @@ -123,6 +123,19 @@ export const buttonGroupConfig = { defaultValue: '#007bff', }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { selected: [1], @@ -148,6 +161,7 @@ export const buttonGroupConfig = { disabledState: { value: '{{false}}' }, selectedTextColor: { value: '#FFFFFF' }, selectedBackgroundColor: { value: '#4368E3' }, + padding: { value: 'default' }, }, }, }; diff --git a/server/src/modules/apps/services/widget-config/checkbox.js b/server/src/modules/apps/services/widget-config/checkbox.js index c9b6424020..9f991be251 100644 --- a/server/src/modules/apps/services/widget-config/checkbox.js +++ b/server/src/modules/apps/services/widget-config/checkbox.js @@ -126,6 +126,20 @@ export const checkboxConfig = { ], accordian: 'label', }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'switch', + }, }, exposedVariables: { value: false, @@ -189,6 +203,7 @@ export const checkboxConfig = { handleColor: { value: '#FFFFFF' }, alignment: { value: 'right' }, boxShadow: { value: '0px 0px 0px 0px #00000090' }, + padding: { value: 'default' }, }, validation: { mandatory: { value: '{{false}}' }, diff --git a/server/src/modules/apps/services/widget-config/colorPicker.js b/server/src/modules/apps/services/widget-config/colorPicker.js index b2fddd7e4c..6d93508891 100644 --- a/server/src/modules/apps/services/widget-config/colorPicker.js +++ b/server/src/modules/apps/services/widget-config/colorPicker.js @@ -26,6 +26,19 @@ export const colorPickerConfig = { }, styles: { visibility: { type: 'toggle', displayName: 'Visibility' }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { selectedColorHex: '#000000', @@ -45,6 +58,7 @@ export const colorPickerConfig = { events: [], styles: { visibility: { value: '{{true}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/server/src/modules/apps/services/widget-config/icon.js b/server/src/modules/apps/services/widget-config/icon.js index aea06c976c..8c0b0880e4 100644 --- a/server/src/modules/apps/services/widget-config/icon.js +++ b/server/src/modules/apps/services/widget-config/icon.js @@ -78,6 +78,20 @@ export const iconConfig = { }, accordian: 'Icon', }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'Icon', + }, }, exposedVariables: {}, actions: [ @@ -116,6 +130,7 @@ export const iconConfig = { styles: { iconColor: { value: '#000' }, iconAlign: { value: 'center' }, + padding: { value: 'default' }, }, }, }; diff --git a/server/src/modules/apps/services/widget-config/rangeslider.js b/server/src/modules/apps/services/widget-config/rangeslider.js index 151dca3384..541ed95209 100644 --- a/server/src/modules/apps/services/widget-config/rangeslider.js +++ b/server/src/modules/apps/services/widget-config/rangeslider.js @@ -84,6 +84,19 @@ export const rangeSliderConfig = { defaultValue: true, }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { value: null, @@ -111,6 +124,7 @@ export const rangeSliderConfig = { handleColor: { value: '' }, trackColor: { value: '' }, visibility: { value: '{{true}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/server/src/modules/apps/services/widget-config/starrating.js b/server/src/modules/apps/services/widget-config/starrating.js index 01240d0369..d6caf8013c 100644 --- a/server/src/modules/apps/services/widget-config/starrating.js +++ b/server/src/modules/apps/services/widget-config/starrating.js @@ -89,6 +89,19 @@ export const starratingConfig = { defaultValue: false, }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: { value: 0, @@ -112,6 +125,7 @@ export const starratingConfig = { labelColor: { value: '' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/server/src/modules/apps/services/widget-config/tags.js b/server/src/modules/apps/services/widget-config/tags.js index 8af289b23a..6479eeaad0 100644 --- a/server/src/modules/apps/services/widget-config/tags.js +++ b/server/src/modules/apps/services/widget-config/tags.js @@ -38,6 +38,19 @@ export const tagsConfig = { defaultValue: true, }, }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + }, }, exposedVariables: {}, definition: { @@ -54,6 +67,7 @@ export const tagsConfig = { events: [], styles: { visibility: { value: '{{true}}' }, + padding: { value: 'default' }, }, }, }; diff --git a/server/src/modules/apps/services/widget-config/toggleswitchv2.js b/server/src/modules/apps/services/widget-config/toggleswitchv2.js index 6753fbb50d..6f61a7645d 100644 --- a/server/src/modules/apps/services/widget-config/toggleswitchv2.js +++ b/server/src/modules/apps/services/widget-config/toggleswitchv2.js @@ -126,6 +126,20 @@ export const toggleSwitchV2Config = { validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] } }, accordian: 'switch', }, + padding: { + type: 'switch', + displayName: 'Padding', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: 'default', + }, + isFxNotRequired: true, + options: [ + { displayName: 'Default', value: 'default' }, + { displayName: 'None', value: 'none' }, + ], + accordian: 'switch', + }, }, exposedVariables: { value: false, @@ -187,6 +201,7 @@ export const toggleSwitchV2Config = { handleColor: { value: '#FFFFFF' }, alignment: { value: 'right' }, boxShadow: { value: '0px 0px 0px 0px #00000090' }, + padding: { value: 'default' }, }, }, }; From f2dd8343a056a6664938a7f6fd7bd55f43a2605d Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Wed, 26 Mar 2025 15:00:54 +0530 Subject: [PATCH 026/236] Adjust height for Icon and color picker widget --- frontend/src/Editor/Components/ColorPicker.jsx | 4 ++-- frontend/src/Editor/Components/Icon.jsx | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/Editor/Components/ColorPicker.jsx b/frontend/src/Editor/Components/ColorPicker.jsx index 58282490f1..fb5be51f5e 100644 --- a/frontend/src/Editor/Components/ColorPicker.jsx +++ b/frontend/src/Editor/Components/ColorPicker.jsx @@ -161,8 +161,8 @@ export const ColorPicker = function ({ : { display: 'none' }; return ( -
-
+
+
setShowColorPicker(true)} diff --git a/frontend/src/Editor/Components/Icon.jsx b/frontend/src/Editor/Components/Icon.jsx index 289e9d1194..8ebb400aed 100644 --- a/frontend/src/Editor/Components/Icon.jsx +++ b/frontend/src/Editor/Components/Icon.jsx @@ -84,7 +84,7 @@ export const Icon = ({
) : (
{ From 9be24dc2c20e78c672c2856aa9ae40646037f145 Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Thu, 27 Mar 2025 11:43:04 +0530 Subject: [PATCH 027/236] Add horiizontal icon and migration --- .../icons/widgets/horizontalDivider.jsx | 22 ++++++ .../assets/images/icons/widgets/index.jsx | 9 +-- ...MoveVisibilityDisabledStatesDividerLink.ts | 69 +++++++++++++++++++ .../services/app-import-export.service.ts | 37 +++++----- 4 files changed, 114 insertions(+), 23 deletions(-) create mode 100644 frontend/assets/images/icons/widgets/horizontalDivider.jsx create mode 100644 server/data-migrations/1743053824028-MoveVisibilityDisabledStatesDividerLink.ts diff --git a/frontend/assets/images/icons/widgets/horizontalDivider.jsx b/frontend/assets/images/icons/widgets/horizontalDivider.jsx new file mode 100644 index 0000000000..6f843ae57a --- /dev/null +++ b/frontend/assets/images/icons/widgets/horizontalDivider.jsx @@ -0,0 +1,22 @@ +import React from 'react'; + +const HorizontalDivider = ({ fill = '#D7DBDF', width = 24, className = '', viewBox = '0 0 49 48' }) => ( + + + + + + + + + + + +); + +export default HorizontalDivider; diff --git a/frontend/assets/images/icons/widgets/index.jsx b/frontend/assets/images/icons/widgets/index.jsx index 7ecb678d1b..ee1fed9afb 100644 --- a/frontend/assets/images/icons/widgets/index.jsx +++ b/frontend/assets/images/icons/widgets/index.jsx @@ -13,8 +13,6 @@ import Customcomponent from './customcomponent.jsx'; import Datepicker from './datepicker.jsx'; import DateTimePickerV2 from './datetimepickerV2.jsx'; import Daterangepicker from './daterangepicker.jsx'; -import Divider from './divider.jsx'; -import DividerHorizondal from './dividerhorizontal.jsx'; import Downstatistics from './downstatistics.jsx'; import Dropdown from './dropdown.jsx'; import Filepicker from './filepicker.jsx'; @@ -59,6 +57,7 @@ import Upstatistics from './upstatistics.jsx'; import Verticaldivider from './verticaldivider.jsx'; import TimePicker from './timepicker.jsx'; import DatepickerV2 from './datepickerv2.jsx'; +import HorizontalDivider from './horizontalDivider.jsx'; const WidgetIcon = (props) => { switch (props.name) { @@ -101,10 +100,8 @@ const WidgetIcon = (props) => { return ; case 'daterangepicker': return ; - case 'divider': - return ; - case 'divider-horizondal': - return ; + case 'horizontaldivider': + return ; case 'downstatistics': return ; case 'dropdown': diff --git a/server/data-migrations/1743053824028-MoveVisibilityDisabledStatesDividerLink.ts b/server/data-migrations/1743053824028-MoveVisibilityDisabledStatesDividerLink.ts new file mode 100644 index 0000000000..2a019f0881 --- /dev/null +++ b/server/data-migrations/1743053824028-MoveVisibilityDisabledStatesDividerLink.ts @@ -0,0 +1,69 @@ +import { Component } from '@entities/component.entity'; +import { processDataInBatches } from '@helpers/migration.helper'; +import { EntityManager, MigrationInterface, QueryRunner } from 'typeorm'; + +export class MoveVisibilityDisabledStatesDividerLink1743053824028 implements MigrationInterface { + + public async up(queryRunner: QueryRunner): Promise { + const componentTypes = ['Divider', 'VerticalDivider', 'Link']; + const batchSize = 100; + const entityManager = queryRunner.manager; + + for (const componentType of componentTypes) { + await processDataInBatches( + entityManager, + async (entityManager: EntityManager) => { + return await entityManager.find(Component, { + where: { type: componentType }, + order: { createdAt: 'ASC' }, + }); + }, + async (entityManager: EntityManager, components: Component[]) => { + await this.processUpdates(entityManager, components); + }, + batchSize + ); + } + } + + private async processUpdates(entityManager, components) { + for (const component of components) { + const properties = component.properties; + const styles = component.styles; + const general = component.general; + const generalStyles = component.generalStyles; + const validation = component.validation; + + if (styles.visibility) { + properties.visibility = styles.visibility; + delete styles.visibility; + } + + if (styles.disabledState) { + properties.disabledState = styles.disabledState; + delete styles.disabledState; + } + + if (general?.tooltip) { + properties.tooltip = general?.tooltip; + delete general?.tooltip; + } + + if (generalStyles?.boxShadow) { + styles.boxShadow = generalStyles?.boxShadow; + delete generalStyles?.boxShadow; + } + + await entityManager.update(Component, component.id, { + properties, + styles, + general, + generalStyles, + validation, + }); + } + } + public async down(queryRunner: QueryRunner): Promise { + } + +} diff --git a/server/src/modules/apps/services/app-import-export.service.ts b/server/src/modules/apps/services/app-import-export.service.ts index c80b0ea653..69f1442f5b 100644 --- a/server/src/modules/apps/services/app-import-export.service.ts +++ b/server/src/modules/apps/services/app-import-export.service.ts @@ -51,7 +51,7 @@ type DefaultDataSourceName = | 'tooljetdbdefault' | 'workflowsdefault'; -type NewRevampedComponent = 'Text' | 'TextInput' | 'PasswordInput' | 'NumberInput' | 'Table' | 'Button' | 'Checkbox'; +type NewRevampedComponent = 'Text' | 'TextInput' | 'PasswordInput' | 'NumberInput' | 'Table' | 'Button' | 'Checkbox' | 'Divider' | 'VerticalDivider' | 'Link'; const DefaultDataSourceNames: DefaultDataSourceName[] = [ 'restapidefault', @@ -69,6 +69,9 @@ const NewRevampedComponents: NewRevampedComponent[] = [ 'Table', 'Checkbox', 'Button', + 'Divider', + 'VerticalDivider', + 'Link', ]; @Injectable() @@ -79,7 +82,7 @@ export class AppImportExportService { protected appEnvironmentUtilService: AppEnvironmentUtilService, protected readonly entityManager: EntityManager, protected componentsService: ComponentsService - ) {} + ) { } async export(user: User, id: string, searchParams: any = {}): Promise<{ appV2: App }> { // https://github.com/typeorm/typeorm/issues/3857 @@ -181,13 +184,13 @@ export class AppImportExportService { const components = pages.length > 0 ? await manager - .createQueryBuilder(Component, 'components') - .leftJoinAndSelect('components.layouts', 'layouts') - .where('components.pageId IN(:...pageId)', { - pageId: pages.map((v) => v.id), - }) - .orderBy('components.created_at', 'ASC') - .getMany() + .createQueryBuilder(Component, 'components') + .leftJoinAndSelect('components.layouts', 'layouts') + .where('components.pageId IN(:...pageId)', { + pageId: pages.map((v) => v.id), + }) + .orderBy('components.created_at', 'ASC') + .getMany() : []; const events = await manager @@ -1056,10 +1059,10 @@ export class AppImportExportService { const options = importingDataSource.kind === 'tooljetdb' ? this.replaceTooljetDbTableIds( - importingQuery.options, - externalResourceMappings['tooljet_database'], - organizationId - ) + importingQuery.options, + externalResourceMappings['tooljet_database'], + organizationId + ) : importingQuery.options; const newQuery = manager.create(DataQuery, { @@ -1626,10 +1629,10 @@ export class AppImportExportService { options: dataSourceId == defaultDataSourceIds['tooljetdb'] ? this.replaceTooljetDbTableIds( - query.options, - externalResourceMappings['tooljet_database'], - user.organizationId - ) + query.options, + externalResourceMappings['tooljet_database'], + user.organizationId + ) : query.options, }); await manager.save(newQuery); From f53366ec19ff4e59df828dbb66fd3f51ba8ca81a Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Thu, 27 Mar 2025 11:56:28 +0530 Subject: [PATCH 028/236] fix --- .../1743053824028-MoveVisibilityDisabledStatesDividerLink.ts | 5 ----- 1 file changed, 5 deletions(-) diff --git a/server/data-migrations/1743053824028-MoveVisibilityDisabledStatesDividerLink.ts b/server/data-migrations/1743053824028-MoveVisibilityDisabledStatesDividerLink.ts index 2a019f0881..21ff07dc0c 100644 --- a/server/data-migrations/1743053824028-MoveVisibilityDisabledStatesDividerLink.ts +++ b/server/data-migrations/1743053824028-MoveVisibilityDisabledStatesDividerLink.ts @@ -39,11 +39,6 @@ export class MoveVisibilityDisabledStatesDividerLink1743053824028 implements Mig delete styles.visibility; } - if (styles.disabledState) { - properties.disabledState = styles.disabledState; - delete styles.disabledState; - } - if (general?.tooltip) { properties.tooltip = general?.tooltip; delete general?.tooltip; From d962755142266c317ad2230d470b7fdd10c9fbf3 Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Thu, 27 Mar 2025 13:59:48 +0530 Subject: [PATCH 029/236] Fix dropdown and multiselect menuPlacement in modals when menus don't have bottom space --- frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx | 2 ++ frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx | 2 ++ 2 files changed, 4 insertions(+) diff --git a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx index a01ed895e0..a1d15ad44a 100644 --- a/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx +++ b/frontend/src/Editor/Components/DropdownV2/DropdownV2.jsx @@ -469,6 +469,8 @@ export const DropdownV2 = ({ menuPlacement="auto" onMenuOpen={() => fireEvent('onFocus')} onMenuClose={() => fireEvent('onBlur')} + // This is not setting minheight, required to help calculate menuPlacement by providing fixed height upfront before rendering (required in the case of modal) + minMenuHeight={300} />
diff --git a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx index 6ef45e84d9..855703dfe3 100644 --- a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx +++ b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx @@ -513,6 +513,8 @@ export const MultiselectV2 = ({ fireEvent={() => fireEvent('onSelect')} menuPlacement="auto" menuPortalTarget={document.body} + // This is not setting minheight, required to help calculate menuPlacement by providing fixed height upfront before rendering (required in the case of modal) + minMenuHeight={300} />
From a0992217d176069d5451d82f4c80cf607d6b1117 Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Fri, 28 Mar 2025 13:20:24 +0530 Subject: [PATCH 030/236] make default width 1 grid --- .../src/AppBuilder/WidgetManager/widgets/verticalDivider.js | 2 +- frontend/src/Editor/WidgetManager/configs/verticalDivider.js | 2 +- .../src/modules/apps/services/widget-config/verticalDivider.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js b/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js index cd3881883f..34d9029e3a 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/verticalDivider.js @@ -4,7 +4,7 @@ export const verticalDividerConfig = { description: 'Vertical line separator', component: 'VerticalDivider', defaultSize: { - width: 2, + width: 1, height: 100, }, others: { diff --git a/frontend/src/Editor/WidgetManager/configs/verticalDivider.js b/frontend/src/Editor/WidgetManager/configs/verticalDivider.js index cd3881883f..34d9029e3a 100644 --- a/frontend/src/Editor/WidgetManager/configs/verticalDivider.js +++ b/frontend/src/Editor/WidgetManager/configs/verticalDivider.js @@ -4,7 +4,7 @@ export const verticalDividerConfig = { description: 'Vertical line separator', component: 'VerticalDivider', defaultSize: { - width: 2, + width: 1, height: 100, }, others: { diff --git a/server/src/modules/apps/services/widget-config/verticalDivider.js b/server/src/modules/apps/services/widget-config/verticalDivider.js index cd3881883f..34d9029e3a 100644 --- a/server/src/modules/apps/services/widget-config/verticalDivider.js +++ b/server/src/modules/apps/services/widget-config/verticalDivider.js @@ -4,7 +4,7 @@ export const verticalDividerConfig = { description: 'Vertical line separator', component: 'VerticalDivider', defaultSize: { - width: 2, + width: 1, height: 100, }, others: { From 86355f6f9bb3a921f35b6470c8356fd309a41849 Mon Sep 17 00:00:00 2001 From: Johnson Cherian Date: Fri, 28 Mar 2025 16:45:54 +0530 Subject: [PATCH 031/236] chore: Adds new design for form, container default children (#12239) Co-authored-by: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> --- .../WidgetManager/widgets/container.js | 18 +- .../AppBuilder/WidgetManager/widgets/form.js | 266 +++++------------- .../Widgets/Container/Container.jsx | 3 +- frontend/src/AppBuilder/Widgets/Form/Form.jsx | 21 +- .../src/AppBuilder/Widgets/Form/form.scss | 8 +- .../Editor/WidgetManager/configs/container.js | 18 +- .../src/Editor/WidgetManager/configs/form.js | 266 +++++------------- .../apps/services/widget-config/container.js | 20 +- .../apps/services/widget-config/form.js | 266 +++++------------- 9 files changed, 252 insertions(+), 634 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/container.js b/frontend/src/AppBuilder/WidgetManager/widgets/container.js index 37a895f553..d1670b8a93 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/container.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/container.js @@ -3,7 +3,7 @@ export const containerConfig = { displayName: 'Container', description: 'Group components', defaultSize: { - width: 5, + width: 10, height: 200, }, component: 'Container', @@ -47,10 +47,16 @@ export const containerConfig = { defaultValue: true, }, }, + headerHeight: { + type: 'numberInput', + displayName: 'Header height', + validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, + }, }, defaultChildren: [ { componentName: 'Text', + slotName: 'header', layout: { top: 20, left: 1, @@ -97,15 +103,6 @@ export const containerConfig = { }, accordian: 'container', }, - headerHeight: { - type: 'numberInput', - displayName: 'Height', - validation: { - schema: { type: 'number' }, - defaultValue: 80, - }, - accordian: 'header', - }, borderRadius: { type: 'numberInput', displayName: 'Border', @@ -157,6 +154,7 @@ export const containerConfig = { loadingState: { value: `{{false}}` }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, + headerHeight: { value: `{{80}}` }, }, events: [], styles: { diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/form.js b/frontend/src/AppBuilder/WidgetManager/widgets/form.js index c5194822b6..f28044d52c 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/form.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/form.js @@ -4,7 +4,7 @@ export const formConfig = { description: 'Wrapper for multiple components', defaultSize: { width: 13, - height: 480, + height: 450, }, defaultChildren: [ { @@ -19,7 +19,7 @@ export const formConfig = { accessorKey: 'text', styles: ['fontWeight', 'textSize', 'textColor'], defaultValue: { - text: 'Form title', + text: 'Form', textSize: 20, textColor: '#000', }, @@ -34,203 +34,83 @@ export const formConfig = { }, properties: ['text'], defaultValue: { - text: 'Button2', + text: 'Submit', padding: 'none', }, }, - { - componentName: 'Text', - layout: { - top: 40, - left: 10, - height: 30, - width: 17, - }, - properties: ['text'], - styles: [ - 'textSize', - 'fontWeight', - 'fontStyle', - 'textColor', - 'isScrollRequired', - 'lineHeight', - 'textIndent', - 'textAlign', - 'verticalAlignment', - 'decoration', - 'transformation', - 'letterSpacing', - 'wordSpacing', - 'fontVariant', - 'backgroundColor', - 'borderColor', - 'borderRadius', - 'boxShadow', - 'padding', - ], - defaultValue: { - text: 'User Details', - fontWeight: 'bold', - textSize: 18, - textColor: '#000', - backgroundColor: '#fff00000', - textAlign: 'left', - decoration: 'none', - transformation: 'none', - fontStyle: 'normal', - lineHeight: 1.5, - textIndent: '0', - letterSpacing: '0', - wordSpacing: '0', - fontVariant: 'normal', - verticalAlignment: 'top', - padding: 'default', - boxShadow: '0px 0px 0px 0px #00000090', - borderRadius: '0', - isScrollRequired: 'enabled', - }, - }, - { - componentName: 'Text', - layout: { - top: 90, - left: 10, - height: 30, - }, - properties: ['text'], - styles: [ - 'textSize', - 'fontWeight', - 'fontStyle', - 'textColor', - 'isScrollRequired', - 'lineHeight', - 'textIndent', - 'textAlign', - 'verticalAlignment', - 'decoration', - 'transformation', - 'letterSpacing', - 'wordSpacing', - 'fontVariant', - 'backgroundColor', - 'borderColor', - 'borderRadius', - 'boxShadow', - 'padding', - ], - defaultValue: { - text: 'Name', - fontWeight: 'normal', - textSize: 14, - textColor: '#000', - backgroundColor: '#fff00000', - textAlign: 'left', - decoration: 'none', - transformation: 'none', - fontStyle: 'normal', - lineHeight: 1.5, - textIndent: '0', - letterSpacing: '0', - wordSpacing: '0', - fontVariant: 'normal', - verticalAlignment: 'top', - padding: 'default', - boxShadow: '0px 0px 0px 0px #00000090', - borderRadius: '0', - isScrollRequired: 'enabled', - }, - }, - { - componentName: 'Text', - layout: { - top: 160, - left: 10, - height: 30, - }, - properties: ['text'], - styles: [ - 'textSize', - 'fontWeight', - 'fontStyle', - 'textColor', - 'isScrollRequired', - 'lineHeight', - 'textIndent', - 'textAlign', - 'verticalAlignment', - 'decoration', - 'transformation', - 'letterSpacing', - 'wordSpacing', - 'fontVariant', - 'backgroundColor', - 'borderColor', - 'borderRadius', - 'boxShadow', - 'padding', - ], - defaultValue: { - text: 'Age', - fontWeight: 'normal', - textSize: 14, - textColor: '#000', - backgroundColor: '#fff00000', - textAlign: 'left', - decoration: 'none', - transformation: 'none', - fontStyle: 'normal', - lineHeight: 1.5, - textIndent: '0', - letterSpacing: '0', - wordSpacing: '0', - fontVariant: 'normal', - verticalAlignment: 'top', - padding: 'default', - boxShadow: '0px 0px 0px 0px #00000090', - borderRadius: '0', - isScrollRequired: 'enabled', - }, - }, { componentName: 'TextInput', layout: { - top: 120, - left: 10, - height: 30, - width: 25, + top: 20, + left: 5, + height: 40, + width: 31, }, properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto', 'padding'], defaultValue: { placeholder: 'Enter your name', - label: '', + label: 'Name', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', }, }, { componentName: 'NumberInput', layout: { - top: 190, - left: 10, - height: 30, - width: 25, + top: 80, + left: 5, + height: 40, + width: 31, }, - properties: ['value', 'label'], + properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto', 'padding'], defaultValue: { - value: 24, - label: '', + placeholder: 'Age', + label: 'Age', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', }, }, { - componentName: 'Button', + componentName: 'TextInput', layout: { - top: 240, - left: 10, - height: 30, - width: 10, + top: 140, + left: 5, + height: 40, + width: 31, }, - properties: ['text'], + properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto', 'padding'], defaultValue: { - text: 'Submit', + placeholder: 'Tomy', + label: 'Pet name', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', + }, + }, + { + componentName: 'TextInput', + layout: { + top: 200, + left: 5, + height: 40, + width: 31, + }, + properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto'], + defaultValue: { + label: 'Favorite color?', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', }, }, ], @@ -276,6 +156,16 @@ export const formConfig = { }, showHeader: { type: 'toggle', displayName: 'Header' }, showFooter: { type: 'toggle', displayName: 'Footer' }, + headerHeight: { + type: 'numberInput', + displayName: 'Header height', + validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, + }, + footerHeight: { + type: 'numberInput', + displayName: 'Footer height', + validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, + }, visibility: { type: 'toggle', displayName: 'Visibility', @@ -323,22 +213,6 @@ export const formConfig = { defaultValue: '#ffffffff', }, }, - headerHeight: { - type: 'code', - displayName: 'Header height', - validation: { - schema: { type: 'string' }, - defaultValue: '80px', - }, - }, - footerHeight: { - type: 'code', - displayName: 'Footer height', - validation: { - schema: { type: 'string' }, - defaultValue: '80px', - }, - }, backgroundColor: { type: 'color', displayName: 'Background color', @@ -410,18 +284,18 @@ export const formConfig = { value: "{{ {title: 'User registration form', properties: {firstname: {type: 'textinput',value: 'Maria',label:'First name', validation:{maxLength:6}, styles: {backgroundColor: '#f6f5ff',textColor: 'black'},},lastname:{type: 'textinput',value: 'Doe', label:'Last name', styles: {backgroundColor: '#f6f5ff',textColor: 'black'},},age:{type:'number', label:'Age'},}, submitButton: {value: 'Submit', styles: {backgroundColor: '#3a433b',borderColor:'#595959'}}} }}", }, - showHeader: { value: '{{false}}' }, - showFooter: { value: '{{false}}' }, + showHeader: { value: '{{true}}' }, + showFooter: { value: '{{true}}' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, + headerHeight: { value: 60 }, + footerHeight: { value: 60 }, }, events: [], styles: { backgroundColor: { value: '#fff' }, borderRadius: { value: '0' }, borderColor: { value: '#fff' }, - headerHeight: { value: '60px' }, - footerHeight: { value: '60px' }, }, }, }; diff --git a/frontend/src/AppBuilder/Widgets/Container/Container.jsx b/frontend/src/AppBuilder/Widgets/Container/Container.jsx index 4978427370..a706d29069 100644 --- a/frontend/src/AppBuilder/Widgets/Container/Container.jsx +++ b/frontend/src/AppBuilder/Widgets/Container/Container.jsx @@ -33,7 +33,8 @@ export const Container = ({ shallow ); - const { borderRadius, borderColor, boxShadow, headerHeight = 80 } = styles; + const { borderRadius, borderColor, boxShadow } = styles; + const { headerHeight = 80 } = properties; const contentBgColor = useMemo(() => { return { backgroundColor: diff --git a/frontend/src/AppBuilder/Widgets/Form/Form.jsx b/frontend/src/AppBuilder/Widgets/Form/Form.jsx index 1328fc195d..d918a1a2b5 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Form.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Form.jsx @@ -41,16 +41,16 @@ export const Form = function Form(props) { onComponentClick, } = props; const childComponents = useStore((state) => state.getChildComponents(id), shallow); + const { borderRadius, borderColor, boxShadow, footerBackgroundColor, headerBackgroundColor } = styles; const { - borderRadius, - borderColor, - boxShadow, - headerHeight, - footerHeight, - footerBackgroundColor, - headerBackgroundColor, - } = styles; - const { buttonToSubmit, advanced, JSONSchema, showHeader = false, showFooter = false } = properties; + buttonToSubmit, + advanced, + JSONSchema, + showHeader = false, + showFooter = false, + headerHeight = 80, + footerHeight = 80, + } = properties; const { isDisabled, isVisible, isLoading } = useExposeState( properties.loadingState, properties.visibility, @@ -88,7 +88,8 @@ export const Form = function Form(props) { const [isValid, setValidation] = useState(true); const [uiComponents, setUIComponents] = useState([]); const mounted = useMounted(); - const canvasFooterHeight = getCanvasHeight(footerHeight) / 10; + const canvasHeaderHeight = headerHeight / 10; + const canvasFooterHeight = footerHeight / 10; useEffect(() => { const exposedVariables = { diff --git a/frontend/src/AppBuilder/Widgets/Form/form.scss b/frontend/src/AppBuilder/Widgets/Form/form.scss index e1e694d7c0..766b309a7f 100644 --- a/frontend/src/AppBuilder/Widgets/Form/form.scss +++ b/frontend/src/AppBuilder/Widgets/Form/form.scss @@ -10,8 +10,8 @@ content: ""; position: absolute; bottom: 0; - left: -7px; - right: -7px; + left: -2px; + right: -2px; height: 1px; background-color: var(--border-weak); } @@ -23,8 +23,8 @@ content: ""; position: absolute; top: 0; - left: -7px; - right: -7px; + left: -2px; + right: -2px; height: 1px; background-color: var(--border-weak); } diff --git a/frontend/src/Editor/WidgetManager/configs/container.js b/frontend/src/Editor/WidgetManager/configs/container.js index 37a895f553..d1670b8a93 100644 --- a/frontend/src/Editor/WidgetManager/configs/container.js +++ b/frontend/src/Editor/WidgetManager/configs/container.js @@ -3,7 +3,7 @@ export const containerConfig = { displayName: 'Container', description: 'Group components', defaultSize: { - width: 5, + width: 10, height: 200, }, component: 'Container', @@ -47,10 +47,16 @@ export const containerConfig = { defaultValue: true, }, }, + headerHeight: { + type: 'numberInput', + displayName: 'Header height', + validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, + }, }, defaultChildren: [ { componentName: 'Text', + slotName: 'header', layout: { top: 20, left: 1, @@ -97,15 +103,6 @@ export const containerConfig = { }, accordian: 'container', }, - headerHeight: { - type: 'numberInput', - displayName: 'Height', - validation: { - schema: { type: 'number' }, - defaultValue: 80, - }, - accordian: 'header', - }, borderRadius: { type: 'numberInput', displayName: 'Border', @@ -157,6 +154,7 @@ export const containerConfig = { loadingState: { value: `{{false}}` }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, + headerHeight: { value: `{{80}}` }, }, events: [], styles: { diff --git a/frontend/src/Editor/WidgetManager/configs/form.js b/frontend/src/Editor/WidgetManager/configs/form.js index c5194822b6..f28044d52c 100644 --- a/frontend/src/Editor/WidgetManager/configs/form.js +++ b/frontend/src/Editor/WidgetManager/configs/form.js @@ -4,7 +4,7 @@ export const formConfig = { description: 'Wrapper for multiple components', defaultSize: { width: 13, - height: 480, + height: 450, }, defaultChildren: [ { @@ -19,7 +19,7 @@ export const formConfig = { accessorKey: 'text', styles: ['fontWeight', 'textSize', 'textColor'], defaultValue: { - text: 'Form title', + text: 'Form', textSize: 20, textColor: '#000', }, @@ -34,203 +34,83 @@ export const formConfig = { }, properties: ['text'], defaultValue: { - text: 'Button2', + text: 'Submit', padding: 'none', }, }, - { - componentName: 'Text', - layout: { - top: 40, - left: 10, - height: 30, - width: 17, - }, - properties: ['text'], - styles: [ - 'textSize', - 'fontWeight', - 'fontStyle', - 'textColor', - 'isScrollRequired', - 'lineHeight', - 'textIndent', - 'textAlign', - 'verticalAlignment', - 'decoration', - 'transformation', - 'letterSpacing', - 'wordSpacing', - 'fontVariant', - 'backgroundColor', - 'borderColor', - 'borderRadius', - 'boxShadow', - 'padding', - ], - defaultValue: { - text: 'User Details', - fontWeight: 'bold', - textSize: 18, - textColor: '#000', - backgroundColor: '#fff00000', - textAlign: 'left', - decoration: 'none', - transformation: 'none', - fontStyle: 'normal', - lineHeight: 1.5, - textIndent: '0', - letterSpacing: '0', - wordSpacing: '0', - fontVariant: 'normal', - verticalAlignment: 'top', - padding: 'default', - boxShadow: '0px 0px 0px 0px #00000090', - borderRadius: '0', - isScrollRequired: 'enabled', - }, - }, - { - componentName: 'Text', - layout: { - top: 90, - left: 10, - height: 30, - }, - properties: ['text'], - styles: [ - 'textSize', - 'fontWeight', - 'fontStyle', - 'textColor', - 'isScrollRequired', - 'lineHeight', - 'textIndent', - 'textAlign', - 'verticalAlignment', - 'decoration', - 'transformation', - 'letterSpacing', - 'wordSpacing', - 'fontVariant', - 'backgroundColor', - 'borderColor', - 'borderRadius', - 'boxShadow', - 'padding', - ], - defaultValue: { - text: 'Name', - fontWeight: 'normal', - textSize: 14, - textColor: '#000', - backgroundColor: '#fff00000', - textAlign: 'left', - decoration: 'none', - transformation: 'none', - fontStyle: 'normal', - lineHeight: 1.5, - textIndent: '0', - letterSpacing: '0', - wordSpacing: '0', - fontVariant: 'normal', - verticalAlignment: 'top', - padding: 'default', - boxShadow: '0px 0px 0px 0px #00000090', - borderRadius: '0', - isScrollRequired: 'enabled', - }, - }, - { - componentName: 'Text', - layout: { - top: 160, - left: 10, - height: 30, - }, - properties: ['text'], - styles: [ - 'textSize', - 'fontWeight', - 'fontStyle', - 'textColor', - 'isScrollRequired', - 'lineHeight', - 'textIndent', - 'textAlign', - 'verticalAlignment', - 'decoration', - 'transformation', - 'letterSpacing', - 'wordSpacing', - 'fontVariant', - 'backgroundColor', - 'borderColor', - 'borderRadius', - 'boxShadow', - 'padding', - ], - defaultValue: { - text: 'Age', - fontWeight: 'normal', - textSize: 14, - textColor: '#000', - backgroundColor: '#fff00000', - textAlign: 'left', - decoration: 'none', - transformation: 'none', - fontStyle: 'normal', - lineHeight: 1.5, - textIndent: '0', - letterSpacing: '0', - wordSpacing: '0', - fontVariant: 'normal', - verticalAlignment: 'top', - padding: 'default', - boxShadow: '0px 0px 0px 0px #00000090', - borderRadius: '0', - isScrollRequired: 'enabled', - }, - }, { componentName: 'TextInput', layout: { - top: 120, - left: 10, - height: 30, - width: 25, + top: 20, + left: 5, + height: 40, + width: 31, }, properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto', 'padding'], defaultValue: { placeholder: 'Enter your name', - label: '', + label: 'Name', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', }, }, { componentName: 'NumberInput', layout: { - top: 190, - left: 10, - height: 30, - width: 25, + top: 80, + left: 5, + height: 40, + width: 31, }, - properties: ['value', 'label'], + properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto', 'padding'], defaultValue: { - value: 24, - label: '', + placeholder: 'Age', + label: 'Age', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', }, }, { - componentName: 'Button', + componentName: 'TextInput', layout: { - top: 240, - left: 10, - height: 30, - width: 10, + top: 140, + left: 5, + height: 40, + width: 31, }, - properties: ['text'], + properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto', 'padding'], defaultValue: { - text: 'Submit', + placeholder: 'Tomy', + label: 'Pet name', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', + }, + }, + { + componentName: 'TextInput', + layout: { + top: 200, + left: 5, + height: 40, + width: 31, + }, + properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto'], + defaultValue: { + label: 'Favorite color?', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', }, }, ], @@ -276,6 +156,16 @@ export const formConfig = { }, showHeader: { type: 'toggle', displayName: 'Header' }, showFooter: { type: 'toggle', displayName: 'Footer' }, + headerHeight: { + type: 'numberInput', + displayName: 'Header height', + validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, + }, + footerHeight: { + type: 'numberInput', + displayName: 'Footer height', + validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, + }, visibility: { type: 'toggle', displayName: 'Visibility', @@ -323,22 +213,6 @@ export const formConfig = { defaultValue: '#ffffffff', }, }, - headerHeight: { - type: 'code', - displayName: 'Header height', - validation: { - schema: { type: 'string' }, - defaultValue: '80px', - }, - }, - footerHeight: { - type: 'code', - displayName: 'Footer height', - validation: { - schema: { type: 'string' }, - defaultValue: '80px', - }, - }, backgroundColor: { type: 'color', displayName: 'Background color', @@ -410,18 +284,18 @@ export const formConfig = { value: "{{ {title: 'User registration form', properties: {firstname: {type: 'textinput',value: 'Maria',label:'First name', validation:{maxLength:6}, styles: {backgroundColor: '#f6f5ff',textColor: 'black'},},lastname:{type: 'textinput',value: 'Doe', label:'Last name', styles: {backgroundColor: '#f6f5ff',textColor: 'black'},},age:{type:'number', label:'Age'},}, submitButton: {value: 'Submit', styles: {backgroundColor: '#3a433b',borderColor:'#595959'}}} }}", }, - showHeader: { value: '{{false}}' }, - showFooter: { value: '{{false}}' }, + showHeader: { value: '{{true}}' }, + showFooter: { value: '{{true}}' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, + headerHeight: { value: 60 }, + footerHeight: { value: 60 }, }, events: [], styles: { backgroundColor: { value: '#fff' }, borderRadius: { value: '0' }, borderColor: { value: '#fff' }, - headerHeight: { value: '60px' }, - footerHeight: { value: '60px' }, }, }, }; diff --git a/server/src/modules/apps/services/widget-config/container.js b/server/src/modules/apps/services/widget-config/container.js index ec1d5174b0..d1670b8a93 100644 --- a/server/src/modules/apps/services/widget-config/container.js +++ b/server/src/modules/apps/services/widget-config/container.js @@ -3,7 +3,7 @@ export const containerConfig = { displayName: 'Container', description: 'Group components', defaultSize: { - width: 5, + width: 10, height: 200, }, component: 'Container', @@ -47,10 +47,16 @@ export const containerConfig = { defaultValue: true, }, }, + headerHeight: { + type: 'numberInput', + displayName: 'Header height', + validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, + }, }, defaultChildren: [ { componentName: 'Text', + slotName: 'header', layout: { top: 20, left: 1, @@ -97,15 +103,6 @@ export const containerConfig = { }, accordian: 'container', }, - headerHeight: { - type: 'numberInput', - displayName: 'Height', - validation: { - schema: { type: 'number' }, - defaultValue: 80, - }, - accordian: 'header', - }, borderRadius: { type: 'numberInput', displayName: 'Border', @@ -153,10 +150,11 @@ export const containerConfig = { showOnMobile: { value: '{{false}}' }, }, properties: { - showHeader: {value: `{{true}}`}, + showHeader: { value: `{{true}}` }, loadingState: { value: `{{false}}` }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, + headerHeight: { value: `{{80}}` }, }, events: [], styles: { diff --git a/server/src/modules/apps/services/widget-config/form.js b/server/src/modules/apps/services/widget-config/form.js index c5194822b6..f28044d52c 100644 --- a/server/src/modules/apps/services/widget-config/form.js +++ b/server/src/modules/apps/services/widget-config/form.js @@ -4,7 +4,7 @@ export const formConfig = { description: 'Wrapper for multiple components', defaultSize: { width: 13, - height: 480, + height: 450, }, defaultChildren: [ { @@ -19,7 +19,7 @@ export const formConfig = { accessorKey: 'text', styles: ['fontWeight', 'textSize', 'textColor'], defaultValue: { - text: 'Form title', + text: 'Form', textSize: 20, textColor: '#000', }, @@ -34,203 +34,83 @@ export const formConfig = { }, properties: ['text'], defaultValue: { - text: 'Button2', + text: 'Submit', padding: 'none', }, }, - { - componentName: 'Text', - layout: { - top: 40, - left: 10, - height: 30, - width: 17, - }, - properties: ['text'], - styles: [ - 'textSize', - 'fontWeight', - 'fontStyle', - 'textColor', - 'isScrollRequired', - 'lineHeight', - 'textIndent', - 'textAlign', - 'verticalAlignment', - 'decoration', - 'transformation', - 'letterSpacing', - 'wordSpacing', - 'fontVariant', - 'backgroundColor', - 'borderColor', - 'borderRadius', - 'boxShadow', - 'padding', - ], - defaultValue: { - text: 'User Details', - fontWeight: 'bold', - textSize: 18, - textColor: '#000', - backgroundColor: '#fff00000', - textAlign: 'left', - decoration: 'none', - transformation: 'none', - fontStyle: 'normal', - lineHeight: 1.5, - textIndent: '0', - letterSpacing: '0', - wordSpacing: '0', - fontVariant: 'normal', - verticalAlignment: 'top', - padding: 'default', - boxShadow: '0px 0px 0px 0px #00000090', - borderRadius: '0', - isScrollRequired: 'enabled', - }, - }, - { - componentName: 'Text', - layout: { - top: 90, - left: 10, - height: 30, - }, - properties: ['text'], - styles: [ - 'textSize', - 'fontWeight', - 'fontStyle', - 'textColor', - 'isScrollRequired', - 'lineHeight', - 'textIndent', - 'textAlign', - 'verticalAlignment', - 'decoration', - 'transformation', - 'letterSpacing', - 'wordSpacing', - 'fontVariant', - 'backgroundColor', - 'borderColor', - 'borderRadius', - 'boxShadow', - 'padding', - ], - defaultValue: { - text: 'Name', - fontWeight: 'normal', - textSize: 14, - textColor: '#000', - backgroundColor: '#fff00000', - textAlign: 'left', - decoration: 'none', - transformation: 'none', - fontStyle: 'normal', - lineHeight: 1.5, - textIndent: '0', - letterSpacing: '0', - wordSpacing: '0', - fontVariant: 'normal', - verticalAlignment: 'top', - padding: 'default', - boxShadow: '0px 0px 0px 0px #00000090', - borderRadius: '0', - isScrollRequired: 'enabled', - }, - }, - { - componentName: 'Text', - layout: { - top: 160, - left: 10, - height: 30, - }, - properties: ['text'], - styles: [ - 'textSize', - 'fontWeight', - 'fontStyle', - 'textColor', - 'isScrollRequired', - 'lineHeight', - 'textIndent', - 'textAlign', - 'verticalAlignment', - 'decoration', - 'transformation', - 'letterSpacing', - 'wordSpacing', - 'fontVariant', - 'backgroundColor', - 'borderColor', - 'borderRadius', - 'boxShadow', - 'padding', - ], - defaultValue: { - text: 'Age', - fontWeight: 'normal', - textSize: 14, - textColor: '#000', - backgroundColor: '#fff00000', - textAlign: 'left', - decoration: 'none', - transformation: 'none', - fontStyle: 'normal', - lineHeight: 1.5, - textIndent: '0', - letterSpacing: '0', - wordSpacing: '0', - fontVariant: 'normal', - verticalAlignment: 'top', - padding: 'default', - boxShadow: '0px 0px 0px 0px #00000090', - borderRadius: '0', - isScrollRequired: 'enabled', - }, - }, { componentName: 'TextInput', layout: { - top: 120, - left: 10, - height: 30, - width: 25, + top: 20, + left: 5, + height: 40, + width: 31, }, properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto', 'padding'], defaultValue: { placeholder: 'Enter your name', - label: '', + label: 'Name', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', }, }, { componentName: 'NumberInput', layout: { - top: 190, - left: 10, - height: 30, - width: 25, + top: 80, + left: 5, + height: 40, + width: 31, }, - properties: ['value', 'label'], + properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto', 'padding'], defaultValue: { - value: 24, - label: '', + placeholder: 'Age', + label: 'Age', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', }, }, { - componentName: 'Button', + componentName: 'TextInput', layout: { - top: 240, - left: 10, - height: 30, - width: 10, + top: 140, + left: 5, + height: 40, + width: 31, }, - properties: ['text'], + properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto', 'padding'], defaultValue: { - text: 'Submit', + placeholder: 'Tomy', + label: 'Pet name', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', + }, + }, + { + componentName: 'TextInput', + layout: { + top: 200, + left: 5, + height: 40, + width: 31, + }, + properties: ['placeholder', 'label'], + styles: ['alignment', 'width', 'auto'], + defaultValue: { + label: 'Favorite color?', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', }, }, ], @@ -276,6 +156,16 @@ export const formConfig = { }, showHeader: { type: 'toggle', displayName: 'Header' }, showFooter: { type: 'toggle', displayName: 'Footer' }, + headerHeight: { + type: 'numberInput', + displayName: 'Header height', + validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, + }, + footerHeight: { + type: 'numberInput', + displayName: 'Footer height', + validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, + }, visibility: { type: 'toggle', displayName: 'Visibility', @@ -323,22 +213,6 @@ export const formConfig = { defaultValue: '#ffffffff', }, }, - headerHeight: { - type: 'code', - displayName: 'Header height', - validation: { - schema: { type: 'string' }, - defaultValue: '80px', - }, - }, - footerHeight: { - type: 'code', - displayName: 'Footer height', - validation: { - schema: { type: 'string' }, - defaultValue: '80px', - }, - }, backgroundColor: { type: 'color', displayName: 'Background color', @@ -410,18 +284,18 @@ export const formConfig = { value: "{{ {title: 'User registration form', properties: {firstname: {type: 'textinput',value: 'Maria',label:'First name', validation:{maxLength:6}, styles: {backgroundColor: '#f6f5ff',textColor: 'black'},},lastname:{type: 'textinput',value: 'Doe', label:'Last name', styles: {backgroundColor: '#f6f5ff',textColor: 'black'},},age:{type:'number', label:'Age'},}, submitButton: {value: 'Submit', styles: {backgroundColor: '#3a433b',borderColor:'#595959'}}} }}", }, - showHeader: { value: '{{false}}' }, - showFooter: { value: '{{false}}' }, + showHeader: { value: '{{true}}' }, + showFooter: { value: '{{true}}' }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, + headerHeight: { value: 60 }, + footerHeight: { value: 60 }, }, events: [], styles: { backgroundColor: { value: '#fff' }, borderRadius: { value: '0' }, borderColor: { value: '#fff' }, - headerHeight: { value: '60px' }, - footerHeight: { value: '60px' }, }, }, }; From 7384a96c6e0155ddba47d957ff458de3fe07fee0 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Fri, 28 Mar 2025 16:55:15 +0530 Subject: [PATCH 032/236] Adds default height for body --- .../AppBuilder/WidgetManager/widgets/form.js | 27 +++------- frontend/src/AppBuilder/Widgets/Form/Form.jsx | 17 +++--- .../src/AppBuilder/Widgets/Form/FormUtils.js | 20 +++++++ .../src/Editor/WidgetManager/configs/form.js | 27 +++------- .../apps/services/widget-config/form.js | 52 +++++++++++++++++-- 5 files changed, 88 insertions(+), 55 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/form.js b/frontend/src/AppBuilder/WidgetManager/widgets/form.js index f28044d52c..e5996062fb 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/form.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/form.js @@ -47,11 +47,12 @@ export const formConfig = { width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto', 'padding'], + styles: ['alignment', 'width', 'auto', 'padding', 'direction'], defaultValue: { placeholder: 'Enter your name', label: 'Name', width: '{{60}}', + direction: 'left', alignment: 'side', auto: '{{false}}', padding: 'default', @@ -66,11 +67,12 @@ export const formConfig = { width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto', 'padding'], + styles: ['alignment', 'width', 'auto', 'padding', 'direction'], defaultValue: { placeholder: 'Age', label: 'Age', width: '{{60}}', + direction: 'left', alignment: 'side', auto: '{{false}}', padding: 'default', @@ -85,30 +87,13 @@ export const formConfig = { width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto', 'padding'], + styles: ['alignment', 'width', 'auto', 'padding', 'direction'], defaultValue: { placeholder: 'Tomy', label: 'Pet name', width: '{{60}}', alignment: 'side', - auto: '{{false}}', - padding: 'default', - }, - }, - { - componentName: 'TextInput', - layout: { - top: 200, - left: 5, - height: 40, - width: 31, - }, - properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto'], - defaultValue: { - label: 'Favorite color?', - width: '{{60}}', - alignment: 'side', + direction: 'left', auto: '{{false}}', padding: 'default', }, diff --git a/frontend/src/AppBuilder/Widgets/Form/Form.jsx b/frontend/src/AppBuilder/Widgets/Form/Form.jsx index d918a1a2b5..eb09a1ad4d 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Form.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Form.jsx @@ -2,7 +2,7 @@ import React, { useRef, useState, useEffect } from 'react'; import { Container as SubContainer } from '@/AppBuilder/AppCanvas/Container'; // eslint-disable-next-line import/no-unresolved import _, { debounce, omit } from 'lodash'; -import { generateUIComponents } from './FormUtils'; +import { generateUIComponents, getBodyHeight } from './FormUtils'; import { useMounted } from '@/_hooks/use-mount'; import { onComponentClick, removeFunctionObjects } from '@/_helpers/appUtils'; import { deepClone } from '@/_helpers/utilities/utils.helpers'; @@ -19,11 +19,6 @@ import { useActiveSlot } from '@/AppBuilder/_hooks/useActiveSlot'; import './form.scss'; -const getCanvasHeight = (height) => { - const parsedHeight = height.includes('px') ? parseInt(height, 10) : height; - return Math.ceil(parsedHeight); -}; - export const Form = function Form(props) { const { id, @@ -60,6 +55,9 @@ export const Form = function Form(props) { ); const backgroundColor = ['#fff', '#ffffffff'].includes(styles.backgroundColor) && darkMode ? '#232E3C' : styles.backgroundColor; + + const computedFormBodyHeight = getBodyHeight(height, showHeader, showFooter, headerHeight, footerHeight); + const computedStyles = { backgroundColor, borderRadius: borderRadius ? parseFloat(borderRadius) : 0, @@ -336,10 +334,13 @@ export const Form = function Form(props) { ) : (
{!advanced && ( -
+
{ if (/^(true|false)$/i.test(input) == true) return JSON.parse(input); return true; }; + +export const getBodyHeight = (height, showHeader, showFooter, headerHeight = 60, footerHeight = 60) => { + let modalHeight = height ? parseInt(height, 10) : 0; + let parsedHeaderHeight = showHeader ? parseInt(headerHeight, 10) : 0; + let parsedFooterHeight = showFooter ? parseInt(footerHeight, 10) : 0; + + if (showHeader) { + // 10 is header padding + modalHeight = modalHeight - parsedHeaderHeight - 10; + } + if (showFooter) { + // 14 is footer padding + modalHeight = modalHeight - parsedFooterHeight - 14; + } + + const rounded = Math.ceil(modalHeight / 10) * 10; + + console.log('rounded', rounded) + return `${Math.max(rounded - 20, 40)}px`; +}; diff --git a/frontend/src/Editor/WidgetManager/configs/form.js b/frontend/src/Editor/WidgetManager/configs/form.js index f28044d52c..e5996062fb 100644 --- a/frontend/src/Editor/WidgetManager/configs/form.js +++ b/frontend/src/Editor/WidgetManager/configs/form.js @@ -47,11 +47,12 @@ export const formConfig = { width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto', 'padding'], + styles: ['alignment', 'width', 'auto', 'padding', 'direction'], defaultValue: { placeholder: 'Enter your name', label: 'Name', width: '{{60}}', + direction: 'left', alignment: 'side', auto: '{{false}}', padding: 'default', @@ -66,11 +67,12 @@ export const formConfig = { width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto', 'padding'], + styles: ['alignment', 'width', 'auto', 'padding', 'direction'], defaultValue: { placeholder: 'Age', label: 'Age', width: '{{60}}', + direction: 'left', alignment: 'side', auto: '{{false}}', padding: 'default', @@ -85,30 +87,13 @@ export const formConfig = { width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto', 'padding'], + styles: ['alignment', 'width', 'auto', 'padding', 'direction'], defaultValue: { placeholder: 'Tomy', label: 'Pet name', width: '{{60}}', alignment: 'side', - auto: '{{false}}', - padding: 'default', - }, - }, - { - componentName: 'TextInput', - layout: { - top: 200, - left: 5, - height: 40, - width: 31, - }, - properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto'], - defaultValue: { - label: 'Favorite color?', - width: '{{60}}', - alignment: 'side', + direction: 'left', auto: '{{false}}', padding: 'default', }, diff --git a/server/src/modules/apps/services/widget-config/form.js b/server/src/modules/apps/services/widget-config/form.js index f28044d52c..d46c637849 100644 --- a/server/src/modules/apps/services/widget-config/form.js +++ b/server/src/modules/apps/services/widget-config/form.js @@ -47,11 +47,12 @@ export const formConfig = { width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto', 'padding'], + styles: ['alignment', 'width', 'auto', 'padding', 'direction'], defaultValue: { placeholder: 'Enter your name', label: 'Name', width: '{{60}}', + direction: 'left', alignment: 'side', auto: '{{false}}', padding: 'default', @@ -66,11 +67,12 @@ export const formConfig = { width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto', 'padding'], + styles: ['alignment', 'width', 'auto', 'padding', 'direction'], defaultValue: { placeholder: 'Age', label: 'Age', width: '{{60}}', + direction: 'left', alignment: 'side', auto: '{{false}}', padding: 'default', @@ -85,32 +87,72 @@ export const formConfig = { width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto', 'padding'], + styles: ['alignment', 'width', 'auto', 'padding', 'direction'], defaultValue: { placeholder: 'Tomy', label: 'Pet name', width: '{{60}}', alignment: 'side', + direction: 'left', auto: '{{false}}', padding: 'default', }, }, { - componentName: 'TextInput', + componentName: 'Text', layout: { top: 200, left: 5, + height: 30, + width: 10, + }, + properties: ['text'], + accessorKey: 'text', + styles: ['fontWeight', 'textSize', 'textColor', 'direction'], + defaultValue: { + text: 'Who are you', + textSize: 12, + direction: 'left', + textColor: '#000', + }, + }, + { + componentName: 'TextArea', + layout: { + top: 200, + left: 14, + height: 80, + width: 22, + }, + properties: ['placeholder', 'value'], + styles: ['alignment', 'width', 'auto', 'padding', 'visibility'], + defaultValue: { + placeholder: 'Tomy', + value: 'Pet name', + width: '{{60}}', + alignment: 'side', + auto: '{{false}}', + padding: 'default', + visibility: '{{true}}', + }, + }, + { + componentName: 'MultiselectV2', + layout: { + top: 400, + left: 5, height: 40, width: 31, }, properties: ['placeholder', 'label'], - styles: ['alignment', 'width', 'auto'], + styles: ['alignment', 'width', 'auto', 'direction'], defaultValue: { label: 'Favorite color?', width: '{{60}}', alignment: 'side', auto: '{{false}}', padding: 'default', + direction: 'left', }, }, ], From 3b5c6a148610a705ea2a976e15fe006abafe2fc5 Mon Sep 17 00:00:00 2001 From: Shaurya Sharma Date: Wed, 2 Apr 2025 02:11:13 +0530 Subject: [PATCH 033/236] Minor fixes and code adjustments --- .../CodeEditor/MultiLineCodeEditor.jsx | 19 ++--------- .../src/AppBuilder/CodeEditor/PreviewBox.jsx | 6 +++- .../CodeEditor/SingleLineCodeEditor.jsx | 19 ++--------- .../_stores/slices/codeHinterSlice.js | 18 ++++++++++ frontend/webpack.config.js | 2 +- server/ee | 2 +- server/src/modules/licensing/helper.ts | 4 +-- server/src/modules/organizations/module.ts | 1 + server/src/modules/users/module.ts | 33 +++++-------------- 9 files changed, 41 insertions(+), 63 deletions(-) diff --git a/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx b/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx index b447df7efd..ef5a5dbd7d 100644 --- a/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx +++ b/frontend/src/AppBuilder/CodeEditor/MultiLineCodeEditor.jsx @@ -55,10 +55,8 @@ const MultiLineCodeEditor = (props) => { const replaceIdsWithName = useStore((state) => state.replaceIdsWithName, shallow); const wrapperRef = useRef(null); const getSuggestions = useStore((state) => state.getSuggestions, shallow); - const license = useStore((state) => state.license, shallow); - const isLicenseValid = - !_.get(license, 'featureAccess.licenseStatus.isExpired', true) && - _.get(license, 'featureAccess.licenseStatus.isLicenseValid', false); + const getServerSideGlobalSuggestions = useStore((state) => state.getServerSideGlobalSuggestions, shallow); + const isInsideQueryPane = !!document.querySelector('.code-hinter-wrapper')?.closest('.query-details'); const isInsideQueryManager = useMemo( () => isInsideParent(wrapperRef?.current, 'query-manager'), @@ -111,19 +109,8 @@ const MultiLineCodeEditor = (props) => { const hints = getSuggestions(); - const serverHints = []; + const serverHints = getServerSideGlobalSuggestions(isInsideQueryManager); - if (isInsideQueryManager && isLicenseValid) { - hints?.appHints?.forEach((appHint) => { - if (appHint?.hint?.startsWith('globals.currentUser')) { - const key = appHint?.hint?.replace('globals.currentUser', 'globals.server.currentUser'); - serverHints.push({ - hint: key, - type: appHint?.type, - }); - } - }); - } const allHints = { ...hints, appHints: [...hints.appHints, ...serverHints], diff --git a/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx b/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx index 89626cf820..bc8411752a 100644 --- a/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx +++ b/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx @@ -198,7 +198,11 @@ export const PreviewBox = ({ const errValue = ifCoersionErrorHasCircularDependency(_resolveValue); setError({ - message: isSecretError ? 'secrets cannot be used in apps' : _error, + message: isServerConstant + ? 'Server side variables cannot be used in apps' + : isSecretError + ? 'secrets cannot be used in apps' + : _error, value: isSecretError ? 'Undefined' : jsErrorType === 'Invalid' diff --git a/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx b/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx index 74ed22a4f2..e0d0203fd2 100644 --- a/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx +++ b/frontend/src/AppBuilder/CodeEditor/SingleLineCodeEditor.jsx @@ -171,11 +171,7 @@ const EditorInput = ({ onInputChange, wrapperRef, }) => { - const license = useStore((state) => state.license, shallow); - - const isLicenseValid = - !get(license, 'featureAccess.licenseStatus.isExpired', true) && - get(license, 'featureAccess.licenseStatus.isLicenseValid', false); + const getServerSideGlobalSuggestions = useStore((state) => state.getServerSideGlobalSuggestions, shallow); const getSuggestions = useStore((state) => state.getSuggestions, shallow); const isInsideQueryManager = useMemo( @@ -184,19 +180,8 @@ const EditorInput = ({ ); function autoCompleteExtensionConfig(context) { const hints = getSuggestions(); - const serverHints = []; + const serverHints = getServerSideGlobalSuggestions(isInsideQueryManager); - if (isInsideQueryManager && isLicenseValid) { - hints?.appHints?.forEach((appHint) => { - if (appHint?.hint?.startsWith('globals.currentUser')) { - const key = appHint?.hint?.replace('globals.currentUser', 'globals.server.currentUser'); - serverHints.push({ - hint: key, - type: appHint?.type, - }); - } - }); - } const allHints = { ...hints, appHints: [...hints.appHints, ...serverHints], diff --git a/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js b/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js index 953d253709..5933a727f1 100644 --- a/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js +++ b/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js @@ -36,4 +36,22 @@ export const createCodeHinterSlice = (set, get) => ({ setSuggestions({ appHints: suggestionList, jsHints: jsHints }); }, getSuggestions: () => get().suggestions, + getServerSideGlobalSuggestions: (isInsideQueryManager) => { + const isServerSideGlobalEnabled = !!get()?.license?.featureAccess?.serverSideGlobal; + const serverHints = []; + const hints = get().getSuggestions(); + if (isInsideQueryManager && isServerSideGlobalEnabled) { + hints?.appHints?.forEach((appHint) => { + if (appHint?.hint?.startsWith('globals.currentUser')) { + const key = appHint?.hint?.replace('globals.currentUser', 'globals.server.currentUser'); + serverHints.push({ + hint: key, + type: appHint?.type, + }); + } + }); + } + + return serverHints; + }, }); diff --git a/frontend/webpack.config.js b/frontend/webpack.config.js index 7621dc993d..986c7011b1 100644 --- a/frontend/webpack.config.js +++ b/frontend/webpack.config.js @@ -122,7 +122,7 @@ module.exports = { '@cloud/modules': emptyModulePath, }, }, - devtool: 'source-map', + devtool: environment === 'development' ? 'source-map' : 'hidden-source-map', module: { rules: [ { diff --git a/server/ee b/server/ee index 003d8503fa..7701ae87d3 160000 --- a/server/ee +++ b/server/ee @@ -1 +1 @@ -Subproject commit 003d8503fa94f149d209e42198e934b1fb56e0bc +Subproject commit 7701ae87d3698f1acc42b26bf6144507bf7beb0d diff --git a/server/src/modules/licensing/helper.ts b/server/src/modules/licensing/helper.ts index fb6a10bf4e..0a8bc949b5 100644 --- a/server/src/modules/licensing/helper.ts +++ b/server/src/modules/licensing/helper.ts @@ -59,8 +59,8 @@ export function getLicenseFieldValue(type: LICENSE_FIELD, licenseInstance: Licen case LICENSE_FIELD.CUSTOM_THEMES: return licenseInstance.customThemes; - // case LICENSE_FIELD.SERVER_SIDE_GLOBAL: - // return licenseInstance.serverSideGlobal; + case LICENSE_FIELD.SERVER_SIDE_GLOBAL: + return licenseInstance.serverSideGlobal; case LICENSE_FIELD.AUDIT_LOGS: return licenseInstance.auditLogs; diff --git a/server/src/modules/organizations/module.ts b/server/src/modules/organizations/module.ts index b7432d5e4c..c455f68d38 100644 --- a/server/src/modules/organizations/module.ts +++ b/server/src/modules/organizations/module.ts @@ -16,6 +16,7 @@ export class OrganizationsModule { imports: [await InstanceSettingsModule.register(configs)], controllers: [OrganizationsController], providers: [OrganizationsService, OrganizationRepository, FeatureAbilityFactory, AppEnvironmentUtilService], + exports: [OrganizationRepository], }; } } diff --git a/server/src/modules/users/module.ts b/server/src/modules/users/module.ts index 965856b0d8..753484e802 100644 --- a/server/src/modules/users/module.ts +++ b/server/src/modules/users/module.ts @@ -3,15 +3,8 @@ import { DynamicModule } from '@nestjs/common'; import { UserRepository } from './repository'; import { SessionModule } from '@modules/session/module'; import { FeatureAbilityFactory } from './ability'; -import { SessionUtilService } from '@modules/session/util.service'; -import { OrganizationRepository } from '@modules/organizations/repository'; -import { GroupPermissionsRepository } from '@modules/group-permissions/repository'; -import { OrganizationUsersRepository } from '@modules/organization-users/repository'; -import { MetadataUtilService } from '@modules/meta/util.service'; -import { RolesRepository } from '@modules/roles/repository'; -import { EncryptionService } from '@modules/encryption/service'; -import { JwtService } from '@nestjs/jwt'; -import { LicenseCountsService } from '@modules/licensing/services/count.service'; +import { OrganizationsModule } from '@modules/organizations/module'; +import { MetaModule } from '@modules/meta/module'; export class UsersModule { static async register(configs?: { IS_GET_CONTEXT: boolean }): Promise { @@ -22,23 +15,13 @@ export class UsersModule { return { module: UsersModule, - imports: [await SessionModule.register(configs)], - controllers: [UsersController], - providers: [ - UsersService, - UserRepository, - UsersUtilService, - FeatureAbilityFactory, - SessionUtilService, - OrganizationRepository, - OrganizationUsersRepository, - GroupPermissionsRepository, - MetadataUtilService, - RolesRepository, - EncryptionService, - JwtService, - LicenseCountsService, + imports: [ + await SessionModule.register(configs), + await OrganizationsModule.register(configs), + await MetaModule.register(configs), ], + controllers: [UsersController], + providers: [UsersService, UserRepository, UsersUtilService, FeatureAbilityFactory], exports: [UsersUtilService, UserRepository], }; } From 9632939beaa26c3ab8ce6f862e139d0df867efcd Mon Sep 17 00:00:00 2001 From: Shaurya Sharma Date: Wed, 2 Apr 2025 03:23:34 +0530 Subject: [PATCH 034/236] Minor changes --- server/ee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/ee b/server/ee index 7701ae87d3..26c75a6d49 160000 --- a/server/ee +++ b/server/ee @@ -1 +1 @@ -Subproject commit 7701ae87d3698f1acc42b26bf6144507bf7beb0d +Subproject commit 26c75a6d49101e500074f9dde5b1bec99a4093bd From a3db2ab3d5e54f14d2f9db7a0d6ebd91a70b135a Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Wed, 2 Apr 2025 20:39:26 +0530 Subject: [PATCH 035/236] Hides header footer height --- .../src/AppBuilder/WidgetManager/widgets/form.js | 4 +++- .../Widgets/Form/Components/HorizontalSlot.jsx | 5 ++++- frontend/src/AppBuilder/Widgets/Form/Form.jsx | 15 ++++++++------- frontend/src/AppBuilder/Widgets/Form/form.scss | 6 +++--- frontend/src/Editor/WidgetManager/configs/form.js | 4 +++- .../modules/apps/services/widget-config/form.js | 4 +++- 6 files changed, 24 insertions(+), 14 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/form.js b/frontend/src/AppBuilder/WidgetManager/widgets/form.js index e5996062fb..0ef410b908 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/form.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/form.js @@ -20,7 +20,7 @@ export const formConfig = { styles: ['fontWeight', 'textSize', 'textColor'], defaultValue: { text: 'Form', - textSize: 20, + textSize: 16, textColor: '#000', }, }, @@ -144,11 +144,13 @@ export const formConfig = { headerHeight: { type: 'numberInput', displayName: 'Header height', + isHidden: true, validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, }, footerHeight: { type: 'numberInput', displayName: 'Footer height', + isHidden: true, validation: { schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, defaultValue: 80 }, }, visibility: { diff --git a/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx b/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx index e892dc4f9f..ad58c835ca 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx @@ -14,6 +14,7 @@ export const HorizontalSlot = React.memo( slotName = 'header', // 'header' or 'footer' slotStyle = {}, onResize, + isEditing, maxHeight, }) => { const parsedHeight = parseInt(height, 10); @@ -47,7 +48,9 @@ export const HorizontalSlot = React.memo( return (
state.setComponentProperty, shallow); const updateHeaderSizeInStore = ({ newHeight }) => { - const heightInPx = `${parseInt(newHeight, 10)}px`; - setComponentProperty(id, `headerHeight`, heightInPx, 'properties', 'value', false); + const _height = parseInt(newHeight, 10); + setComponentProperty(id, `headerHeight`, _height, 'properties', 'value', false); }; const updateFooterSizeInStore = ({ newHeight }) => { - const heightInPx = `${parseInt(newHeight, 10)}px`; - setComponentProperty(id, `footerHeight`, heightInPx, 'properties', 'value', false); + const _height = parseInt(newHeight, 10); + setComponentProperty(id, `footerHeight`, _height, 'properties', 'value', false); }; - // debugger; + const mode = useStore((state) => state.currentMode, shallow); + const isEditing = mode === 'edit'; const headerMaxHeight = parseInt(height, 10) - parseInt(footerHeight, 10) - 100 - 10; const footerMaxHeight = parseInt(height, 10) - parseInt(headerHeight, 10) - 100 - 10; const formFooter = { @@ -315,7 +316,7 @@ export const Form = function Form(props) { Date: Thu, 3 Apr 2025 12:20:12 +0530 Subject: [PATCH 036/236] Fixes border color --- frontend/src/AppBuilder/Widgets/Form/form.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/AppBuilder/Widgets/Form/form.scss b/frontend/src/AppBuilder/Widgets/Form/form.scss index 6756ec51ed..e012f0a075 100644 --- a/frontend/src/AppBuilder/Widgets/Form/form.scss +++ b/frontend/src/AppBuilder/Widgets/Form/form.scss @@ -56,7 +56,7 @@ box-shadow: 0 0 0 1px var(--border-weak); } - &is-editing.active { + &.is-editing.active { box-shadow: 0 0 0 1px var(--border-accent-weak); } From 86625c01a06b853288641dc2bd5c18224b0c8885 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Thu, 3 Apr 2025 12:41:31 +0530 Subject: [PATCH 037/236] Fixes border radius --- frontend/src/AppBuilder/Widgets/Form/Form.jsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/src/AppBuilder/Widgets/Form/Form.jsx b/frontend/src/AppBuilder/Widgets/Form/Form.jsx index 5370bc6a55..8c015fefc1 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Form.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Form.jsx @@ -57,6 +57,7 @@ export const Form = function Form(props) { ['#fff', '#ffffffff'].includes(styles.backgroundColor) && darkMode ? '#232E3C' : styles.backgroundColor; const computedFormBodyHeight = getBodyHeight(height, showHeader, showFooter, headerHeight, footerHeight); + const computedBorderRadius = `${borderRadius ? parseFloat(borderRadius) : 0}px`; const computedStyles = { backgroundColor, @@ -67,6 +68,7 @@ export const Form = function Form(props) { position: 'relative', boxShadow, flexDirection: 'column', + clipPath: `inset(0 round ${computedBorderRadius})`, }; const formContent = { From abde48b5e0ba23b71eaea4b6f42ecead17affba2 Mon Sep 17 00:00:00 2001 From: Shaurya Sharma Date: Fri, 4 Apr 2025 00:27:59 +0530 Subject: [PATCH 038/236] Resolved comments --- .../data-queries/interfaces/IUtilService.ts | 10 ++++++++-- server/src/modules/data-queries/util.service.ts | 15 +++++++-------- .../data-sources/interfaces/IUtilService.ts | 2 +- server/src/modules/data-sources/module.ts | 2 ++ server/src/modules/data-sources/util.service.ts | 15 +++++---------- 5 files changed, 23 insertions(+), 21 deletions(-) diff --git a/server/src/modules/data-queries/interfaces/IUtilService.ts b/server/src/modules/data-queries/interfaces/IUtilService.ts index 2c390313df..f070380b54 100644 --- a/server/src/modules/data-queries/interfaces/IUtilService.ts +++ b/server/src/modules/data-queries/interfaces/IUtilService.ts @@ -23,7 +23,7 @@ export interface IDataQueriesUtilService { queryOptions: object, organization_id: string, environmentId?: string, - userId?: string + user?: User ): Promise<{ service: any; sourceOptions: object; @@ -32,5 +32,11 @@ export interface IDataQueriesUtilService { setCookiesBackToClient(response: Response, responseHeaders: any): void; - parseQueryOptions(object: any, options: object, organization_id: string, environmentId?: string): Promise; + parseQueryOptions( + object: any, + options: object, + organization_id: string, + environmentId?: string, + user?: User + ): Promise; } diff --git a/server/src/modules/data-queries/util.service.ts b/server/src/modules/data-queries/util.service.ts index 08efbaa42b..f99fb84718 100644 --- a/server/src/modules/data-queries/util.service.ts +++ b/server/src/modules/data-queries/util.service.ts @@ -82,7 +82,6 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { organizationId, environmentId ); - const userId = user ? user.id : null; dataSource.options = dataSourceOptions.options; let { sourceOptions, parsedQueryOptions, service } = await this.fetchServiceAndParsedParams( @@ -91,7 +90,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { queryOptions, organizationId, environmentId, - userId + user ); queryStatus.setOptions(parsedQueryOptions); @@ -220,7 +219,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { queryOptions, organizationId, environmentId, - userId + user )); queryStatus.setOptions(parsedQueryOptions); result = await service.run( @@ -300,13 +299,13 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { queryOptions, organization_id, environmentId = undefined, - userId = undefined + user = undefined ) { const sourceOptions = await this.dataSourceUtilService.parseSourceOptions( dataSource.options, organization_id, environmentId, - userId + user ); const parsedQueryOptions = await this.parseQueryOptions( @@ -314,7 +313,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { queryOptions, organization_id, environmentId, - userId + user ); const service = await this.pluginsSelectorService.getService(dataSource.pluginId, dataSource.kind); @@ -381,7 +380,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { options: object, organization_id: string, environmentId?: string, - userId?: string + user?: User ): Promise { const stack: any[] = [{ obj: object, key: null, parent: null }]; @@ -426,7 +425,7 @@ export class DataQueriesUtilService implements IDataQueriesUtilService { resolvedValue, organization_id, environmentId, - userId + user ); resolvedValue = resolvingConstant; if (parent && key !== null) { diff --git a/server/src/modules/data-sources/interfaces/IUtilService.ts b/server/src/modules/data-sources/interfaces/IUtilService.ts index 8c72b78ddf..1539d73019 100644 --- a/server/src/modules/data-sources/interfaces/IUtilService.ts +++ b/server/src/modules/data-sources/interfaces/IUtilService.ts @@ -34,7 +34,7 @@ export interface IDataSourcesUtilService { parseOptionsForOauthDataSource(options: Array, resetSecureData?: boolean): Promise>; - resolveConstants(value: string, organizationId: string, environmentId: string, userId?: string): Promise; + resolveConstants(value: string, organizationId: string, environmentId: string, user?: User): Promise; resolveKeyValuePair(element: any, organizationId: string, environmentId: string): Promise; diff --git a/server/src/modules/data-sources/module.ts b/server/src/modules/data-sources/module.ts index 0a17074118..f9d774ba78 100644 --- a/server/src/modules/data-sources/module.ts +++ b/server/src/modules/data-sources/module.ts @@ -11,6 +11,7 @@ import { VersionRepository } from '@modules/versions/repository'; import { AppsRepository } from '@modules/apps/repository'; import { TooljetDbModule } from '@modules/tooljet-db/module'; import { UsersModule } from '@modules/users/module'; +import { SessionModule } from '@modules/session/module'; export class DataSourcesModule { static async register(configs?: { IS_GET_CONTEXT: boolean }): Promise { @@ -30,6 +31,7 @@ export class DataSourcesModule { await InstanceSettingsModule.register(configs), await TooljetDbModule.register(configs), await UsersModule.register(configs), + await SessionModule.register(configs), ], providers: [ DataSourcesService, diff --git a/server/src/modules/data-sources/util.service.ts b/server/src/modules/data-sources/util.service.ts index 8c89662f9f..28d5719ad1 100644 --- a/server/src/modules/data-sources/util.service.ts +++ b/server/src/modules/data-sources/util.service.ts @@ -302,7 +302,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { return dataSource; } - async resolveConstants(str: string, organizationId: string, environmentId: string, userId?: string): Promise { + async resolveConstants(str: string, organizationId: string, environmentId: string, user?: User): Promise { const regex = /\{\{(constants|secrets)\.(.*?)\}\}/g; const matches = Array.from(str.matchAll(regex)); @@ -591,12 +591,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { return options; } - async parseSourceOptions( - options: any, - organizationId: string, - environmentId: string, - userId?: string - ): Promise { + async parseSourceOptions(options: any, organizationId: string, environmentId: string, user?: User): Promise { // For adhoc queries such as REST API queries, source options will be null if (!options) return {}; const constantMatcher = /\{\{(constants|secrets|globals.server)\..*?\}\}/g; @@ -615,7 +610,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { constantMatcher.lastIndex = 0; if (constantMatcher.test(inner)) { - const resolved = await this.resolveConstants(inner, organizationId, environmentId, userId); + const resolved = await this.resolveConstants(inner, organizationId, environmentId, user); curr[j] = resolved; } } @@ -624,7 +619,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { } if (constantMatcher.test(currentOption)) { - const resolved = await this.resolveConstants(currentOption, organizationId, environmentId, userId); + const resolved = await this.resolveConstants(currentOption, organizationId, environmentId, user); options[key]['value'] = resolved; } } @@ -639,7 +634,7 @@ export class DataSourcesUtilService implements IDataSourcesUtilService { const value = await this.credentialService.getValue(credentialId); if (value.includes('{{constants') || value.includes('{{secrets')) { - const resolved = await this.resolveConstants(value, organizationId, environmentId, userId); + const resolved = await this.resolveConstants(value, organizationId, environmentId, user); parsedOptions[key] = resolved; continue; } else { From a0a1480594d085ef4c70d53579407d2b6528f59e Mon Sep 17 00:00:00 2001 From: Shaurya Sharma Date: Fri, 4 Apr 2025 00:47:28 +0530 Subject: [PATCH 039/236] Unnecessary code removed --- server/src/modules/data-sources/module.ts | 2 -- server/src/modules/organizations/module.ts | 1 - server/src/modules/users/module.ts | 9 +-------- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/server/src/modules/data-sources/module.ts b/server/src/modules/data-sources/module.ts index f9d774ba78..e247ddba38 100644 --- a/server/src/modules/data-sources/module.ts +++ b/server/src/modules/data-sources/module.ts @@ -10,7 +10,6 @@ import { InstanceSettingsModule } from '@modules/instance-settings/module'; import { VersionRepository } from '@modules/versions/repository'; import { AppsRepository } from '@modules/apps/repository'; import { TooljetDbModule } from '@modules/tooljet-db/module'; -import { UsersModule } from '@modules/users/module'; import { SessionModule } from '@modules/session/module'; export class DataSourcesModule { @@ -30,7 +29,6 @@ export class DataSourcesModule { await OrganizationConstantModule.register(configs), await InstanceSettingsModule.register(configs), await TooljetDbModule.register(configs), - await UsersModule.register(configs), await SessionModule.register(configs), ], providers: [ diff --git a/server/src/modules/organizations/module.ts b/server/src/modules/organizations/module.ts index c455f68d38..b7432d5e4c 100644 --- a/server/src/modules/organizations/module.ts +++ b/server/src/modules/organizations/module.ts @@ -16,7 +16,6 @@ export class OrganizationsModule { imports: [await InstanceSettingsModule.register(configs)], controllers: [OrganizationsController], providers: [OrganizationsService, OrganizationRepository, FeatureAbilityFactory, AppEnvironmentUtilService], - exports: [OrganizationRepository], }; } } diff --git a/server/src/modules/users/module.ts b/server/src/modules/users/module.ts index 753484e802..bd91972dba 100644 --- a/server/src/modules/users/module.ts +++ b/server/src/modules/users/module.ts @@ -3,8 +3,6 @@ import { DynamicModule } from '@nestjs/common'; import { UserRepository } from './repository'; import { SessionModule } from '@modules/session/module'; import { FeatureAbilityFactory } from './ability'; -import { OrganizationsModule } from '@modules/organizations/module'; -import { MetaModule } from '@modules/meta/module'; export class UsersModule { static async register(configs?: { IS_GET_CONTEXT: boolean }): Promise { @@ -15,14 +13,9 @@ export class UsersModule { return { module: UsersModule, - imports: [ - await SessionModule.register(configs), - await OrganizationsModule.register(configs), - await MetaModule.register(configs), - ], + imports: [await SessionModule.register(configs)], controllers: [UsersController], providers: [UsersService, UserRepository, UsersUtilService, FeatureAbilityFactory], - exports: [UsersUtilService, UserRepository], }; } } From 73f630668a91b146c15f5764da5312f0dd152b2d Mon Sep 17 00:00:00 2001 From: Shaurya Sharma Date: Fri, 4 Apr 2025 01:23:58 +0530 Subject: [PATCH 040/236] Minor bug fixes --- frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx | 2 +- frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx b/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx index bc8411752a..3ca9261a4b 100644 --- a/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx +++ b/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx @@ -96,7 +96,7 @@ export const PreviewBox = ({ const [largeDataset, setLargeDataset] = useState(false); const globals = useStore((state) => state.getAllExposedValues().constants || {}, shallow); const secrets = useStore((state) => state.getSecrets(), shallow); - const globalServerConstantsRegex = /.*\{\{.*globals\.server\..*\}\}.*/; + const globalServerConstantsRegex = /^\{\{.*globals\.server.*\}\}$/; const getPreviewContent = (content, type) => { if (content === undefined || content === null) return currentValue; diff --git a/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js b/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js index 5933a727f1..7f73632524 100644 --- a/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js +++ b/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js @@ -40,10 +40,16 @@ export const createCodeHinterSlice = (set, get) => ({ const isServerSideGlobalEnabled = !!get()?.license?.featureAccess?.serverSideGlobal; const serverHints = []; const hints = get().getSuggestions(); + console.log('isServerSideGlobalEnabled', isServerSideGlobalEnabled, 'isInsideQueryManager', isInsideQueryManager); if (isInsideQueryManager && isServerSideGlobalEnabled) { + serverHints.push({ hint: 'globals.server', type: 'Object' }); hints?.appHints?.forEach((appHint) => { if (appHint?.hint?.startsWith('globals.currentUser')) { const key = appHint?.hint?.replace('globals.currentUser', 'globals.server.currentUser'); + console.log({ + hint: key, + type: appHint?.type, + }); serverHints.push({ hint: key, type: appHint?.type, From 2481bda0c83147dc8b9f2918c43b6e402988deb6 Mon Sep 17 00:00:00 2001 From: Shaurya Sharma Date: Fri, 4 Apr 2025 01:27:41 +0530 Subject: [PATCH 041/236] Comments removed --- frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js b/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js index 7f73632524..854cba49da 100644 --- a/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js +++ b/frontend/src/AppBuilder/_stores/slices/codeHinterSlice.js @@ -40,7 +40,6 @@ export const createCodeHinterSlice = (set, get) => ({ const isServerSideGlobalEnabled = !!get()?.license?.featureAccess?.serverSideGlobal; const serverHints = []; const hints = get().getSuggestions(); - console.log('isServerSideGlobalEnabled', isServerSideGlobalEnabled, 'isInsideQueryManager', isInsideQueryManager); if (isInsideQueryManager && isServerSideGlobalEnabled) { serverHints.push({ hint: 'globals.server', type: 'Object' }); hints?.appHints?.forEach((appHint) => { From ab762c44f63b4fd0ca85d3137304970252b1ea9b Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Fri, 4 Apr 2025 15:28:05 +0530 Subject: [PATCH 042/236] added box shadow --- frontend/src/AppBuilder/WidgetManager/widgets/icon.js | 10 ++++++++++ frontend/src/Editor/Components/Icon.jsx | 4 ++-- frontend/src/Editor/WidgetManager/configs/icon.js | 10 ++++++++++ .../1737039401111-UpdateVisibilityFrIconComponent.ts | 8 +++++++- .../src/modules/apps/services/widget-config/icon.js | 11 ++++++++++- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/icon.js b/frontend/src/AppBuilder/WidgetManager/widgets/icon.js index 8c0b0880e4..40dc8185dd 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/icon.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/icon.js @@ -92,6 +92,15 @@ export const iconConfig = { ], accordian: 'Icon', }, + boxShadow: { + type: 'boxShadow', + displayName: 'Box shadow', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: '0px 0px 0px 0px #00000040', + }, + accordian: 'Icon', + }, }, exposedVariables: {}, actions: [ @@ -131,6 +140,7 @@ export const iconConfig = { iconColor: { value: '#000' }, iconAlign: { value: 'center' }, padding: { value: 'default' }, + boxShadow: { value: '0px 0px 0px 0px #00000040' }, }, }, }; diff --git a/frontend/src/Editor/Components/Icon.jsx b/frontend/src/Editor/Components/Icon.jsx index 8ebb400aed..1758e41be3 100644 --- a/frontend/src/Editor/Components/Icon.jsx +++ b/frontend/src/Editor/Components/Icon.jsx @@ -17,7 +17,7 @@ export const Icon = ({ }) => { const isInitialRender = useRef(true); const { icon, loadingState, disabledState } = properties; - const { iconAlign, iconColor } = styles; + const { iconAlign, iconColor, boxShadow } = styles; // eslint-disable-next-line import/namespace const IconElement = Icons[icon]; @@ -87,7 +87,7 @@ export const Icon = ({ className={cx('icon-widget h-100', { 'd-none': !visibility }, { 'cursor-pointer': false })} data-cy={dataCy} data-disabled={isDisabled} - style={{ textAlign: iconAlign }} + style={{ textAlign: iconAlign, boxShadow }} onMouseEnter={(event) => { event.stopPropagation(); fireEvent('onHover'); diff --git a/frontend/src/Editor/WidgetManager/configs/icon.js b/frontend/src/Editor/WidgetManager/configs/icon.js index 8c0b0880e4..40dc8185dd 100644 --- a/frontend/src/Editor/WidgetManager/configs/icon.js +++ b/frontend/src/Editor/WidgetManager/configs/icon.js @@ -92,6 +92,15 @@ export const iconConfig = { ], accordian: 'Icon', }, + boxShadow: { + type: 'boxShadow', + displayName: 'Box shadow', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: '0px 0px 0px 0px #00000040', + }, + accordian: 'Icon', + }, }, exposedVariables: {}, actions: [ @@ -131,6 +140,7 @@ export const iconConfig = { iconColor: { value: '#000' }, iconAlign: { value: 'center' }, padding: { value: 'default' }, + boxShadow: { value: '0px 0px 0px 0px #00000040' }, }, }, }; diff --git a/server/data-migrations/1737039401111-UpdateVisibilityFrIconComponent.ts b/server/data-migrations/1737039401111-UpdateVisibilityFrIconComponent.ts index 77ce0a232d..26a04fcf3b 100644 --- a/server/data-migrations/1737039401111-UpdateVisibilityFrIconComponent.ts +++ b/server/data-migrations/1737039401111-UpdateVisibilityFrIconComponent.ts @@ -30,6 +30,7 @@ export class UpdateVisibilityFrIconComponent1737039401111 implements MigrationIn const properties = component.properties; const styles = component.styles; const general = component.general; + const generalStyles = component.generalStyles; if (styles.visibility) { properties.visibility = styles.visibility; @@ -41,6 +42,11 @@ export class UpdateVisibilityFrIconComponent1737039401111 implements MigrationIn delete general?.tooltip; } + if (generalStyles?.boxShadow) { + styles.boxShadow = generalStyles?.boxShadow; + delete generalStyles?.boxShadow; + } + await entityManager.update(Component, component.id, { properties, styles, @@ -49,5 +55,5 @@ export class UpdateVisibilityFrIconComponent1737039401111 implements MigrationIn } } - public async down(queryRunner: QueryRunner): Promise {} + public async down(queryRunner: QueryRunner): Promise { } } diff --git a/server/src/modules/apps/services/widget-config/icon.js b/server/src/modules/apps/services/widget-config/icon.js index 8c0b0880e4..6e2035c7dd 100644 --- a/server/src/modules/apps/services/widget-config/icon.js +++ b/server/src/modules/apps/services/widget-config/icon.js @@ -92,6 +92,15 @@ export const iconConfig = { ], accordian: 'Icon', }, + boxShadow: { + type: 'boxShadow', + displayName: 'Box shadow', + validation: { + schema: { type: 'union', schemas: [{ type: 'string' }, { type: 'number' }] }, + defaultValue: '0px 0px 0px 0px #00000040', + }, + accordian: 'Icon', + }, }, exposedVariables: {}, actions: [ @@ -131,6 +140,6 @@ export const iconConfig = { iconColor: { value: '#000' }, iconAlign: { value: 'center' }, padding: { value: 'default' }, - }, + boxShadow: { value: '0px 0px 0px 0px #00000040' }, }, }; From c9a70058d34588962b425119d32d54bbf2e43aad Mon Sep 17 00:00:00 2001 From: Shaurya Sharma Date: Fri, 4 Apr 2025 15:39:02 +0530 Subject: [PATCH 043/236] Minor bug fixes --- frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx b/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx index 3ca9261a4b..90bc53d2b7 100644 --- a/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx +++ b/frontend/src/AppBuilder/CodeEditor/PreviewBox.jsx @@ -199,7 +199,7 @@ export const PreviewBox = ({ setError({ message: isServerConstant - ? 'Server side variables cannot be used in apps' + ? 'Server variables cannot be used in apps' : isSecretError ? 'secrets cannot be used in apps' : _error, @@ -249,6 +249,8 @@ const RenderResolvedValue = ({ isServerConstant = false, isLargeDataset, }) => { + const isServerSideGlobalEnabled = useStore((state) => !!state?.license?.featureAccess?.serverSideGlobal, shallow); + const computeCoersionPreview = (resolvedValue, coersionData) => { if (coersionData?.typeBeforeCoercion === coersionData?.typeAfterCoercion) return resolvedValue; @@ -272,7 +274,9 @@ const RenderResolvedValue = ({ : previewType; const previewContent = isServerConstant - ? 'Server constants would be resolved at runtime' + ? isServerSideGlobalEnabled + ? 'Server variables would be resolved at runtime' + : 'Server variables are only available in paid plans' : isSecretConstant ? 'Values of secret constants are hidden' : !withValidation From f9f3f841111a61edb9a2a2211229237df7bf5d5d Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Fri, 4 Apr 2025 16:07:19 +0530 Subject: [PATCH 044/236] Changes resize handle size --- .../AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx | 6 +++++- frontend/src/AppBuilder/Widgets/Form/Form.jsx | 8 +++----- frontend/src/AppBuilder/Widgets/Form/form.scss | 4 +++- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx b/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx index ad58c835ca..86a5c58b14 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Components/HorizontalSlot.jsx @@ -45,6 +45,10 @@ export const HorizontalSlot = React.memo( const canvasHeight = parseInt(resizedHeight, 10) / 10; + const resizeStyle = { + backgroundColor: darkMode ? '#1F2837' : '#fff', + }; + return (
-
+
{isDisabled && ( diff --git a/frontend/src/AppBuilder/Widgets/Form/Form.jsx b/frontend/src/AppBuilder/Widgets/Form/Form.jsx index 8c015fefc1..7e536f5e1f 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Form.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Form.jsx @@ -88,8 +88,6 @@ export const Form = function Form(props) { const [isValid, setValidation] = useState(true); const [uiComponents, setUIComponents] = useState([]); const mounted = useMounted(); - const canvasHeaderHeight = headerHeight / 10; - const canvasFooterHeight = footerHeight / 10; useEffect(() => { const exposedVariables = { @@ -318,7 +316,7 @@ export const Form = function Form(props) { )} -
+
{isLoading ? (
@@ -393,7 +391,7 @@ export const Form = function Form(props) { Date: Mon, 7 Apr 2025 13:05:09 +0530 Subject: [PATCH 045/236] fix link QA bugs --- frontend/src/Editor/Components/Link/Link.jsx | 18 +++++++++++++----- frontend/src/Editor/Components/Link/link.scss | 18 ++++++++++++++---- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/frontend/src/Editor/Components/Link/Link.jsx b/frontend/src/Editor/Components/Link/Link.jsx index 0b33686278..b15c582818 100644 --- a/frontend/src/Editor/Components/Link/Link.jsx +++ b/frontend/src/Editor/Components/Link/Link.jsx @@ -19,8 +19,7 @@ export const Link = ({ height, properties, styles, fireEvent, setExposedVariable const computedStyles = { display: 'flex', alignItems: verticalAlignment === 'top' ? 'flex-start' : verticalAlignment === 'center' ? 'center' : 'flex-end', - justifyContent: - horizontalAlignment === 'left' ? 'flex-start' : horizontalAlignment === 'center' ? 'center' : 'flex-end', + textAlign: horizontalAlignment === 'left' ? 'left' : horizontalAlignment === 'center' ? 'center' : 'right', height: '100%', width: '100%', boxShadow, @@ -113,10 +112,19 @@ export const Link = ({ height, properties, styles, fireEvent, setExposedVariable onMouseOver={() => { fireEvent('onHover'); }} - style={{ color: textColor, fontSize: textSize, cursor: isDisabled ? 'not-allowed' : 'pointer' }} + style={{ width: '100%' }} ref={clickRef} > - + {iconVisibility && ( )} - {linkTextState} + {linkTextState}
diff --git a/frontend/src/Editor/Components/Link/link.scss b/frontend/src/Editor/Components/Link/link.scss index a92f19829f..20b375025f 100644 --- a/frontend/src/Editor/Components/Link/link.scss +++ b/frontend/src/Editor/Components/Link/link.scss @@ -1,8 +1,18 @@ .link-widget { a { - text-underline-offset: 32%; // Adds space between text and underline - &:hover { - color: var(--link-hover-color) !important; - } + text-decoration: none !important; + pointer-events: none; + cursor: none !important; + + .link-text { + pointer-events: all; + text-underline-offset: 32%; // Adds space between text and underline + cursor: pointer; + &:hover { + text-decoration: underline; + text-decoration-color: var(--link-hover-color) !important; + color: var(--link-hover-color) !important; + } } + } } From be01a024f253893cdbb44bed88b6103641ea028d Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Mon, 7 Apr 2025 13:11:44 +0530 Subject: [PATCH 046/236] fix --- frontend/src/Editor/Components/Link/Link.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/Editor/Components/Link/Link.jsx b/frontend/src/Editor/Components/Link/Link.jsx index b15c582818..3a5744df8e 100644 --- a/frontend/src/Editor/Components/Link/Link.jsx +++ b/frontend/src/Editor/Components/Link/Link.jsx @@ -123,6 +123,7 @@ export const Link = ({ height, properties, styles, fireEvent, setExposedVariable justifyContent: horizontalAlignment === 'left' ? 'flex-start' : horizontalAlignment === 'center' ? 'center' : 'flex-end', color: textColor, + paddingBottom: verticalAlignment === 'bottom' ? '1px' : '0px', }} > {iconVisibility && ( From 4ba13541ba6f4a1f103d76e88e3b3d2931e292b1 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Mon, 7 Apr 2025 20:04:20 +0530 Subject: [PATCH 047/236] fix: Fixes widgets on old modal grid getting stuck --- frontend/src/AppBuilder/AppCanvas/Grid/Grid.jsx | 2 +- frontend/src/AppBuilder/Widgets/Modal.jsx | 2 +- frontend/src/AppBuilder/Widgets/ModalV2/Components/Modal.jsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/src/AppBuilder/AppCanvas/Grid/Grid.jsx b/frontend/src/AppBuilder/AppCanvas/Grid/Grid.jsx index 174c68b475..016b4c03a3 100644 --- a/frontend/src/AppBuilder/AppCanvas/Grid/Grid.jsx +++ b/frontend/src/AppBuilder/AppCanvas/Grid/Grid.jsx @@ -942,7 +942,7 @@ export default function Grid({ gridWidth, currentLayout }) { const isParentModal = isParentNewModal || isParentLegacyModal || isParentModalSlot; if (isParentModal) { - const modalContainer = e.target.closest('.tj-modal-widget-content'); + const modalContainer = e.target.closest('.tj-modal--container'); const mainCanvas = document.getElementById('real-canvas'); const mainRect = mainCanvas.getBoundingClientRect(); diff --git a/frontend/src/AppBuilder/Widgets/Modal.jsx b/frontend/src/AppBuilder/Widgets/Modal.jsx index 128c98aed2..04e2668441 100644 --- a/frontend/src/AppBuilder/Widgets/Modal.jsx +++ b/frontend/src/AppBuilder/Widgets/Modal.jsx @@ -239,7 +239,7 @@ export const Modal = function Modal({ { return ( { e.preventDefault(); From df7208fae94003565a8ba964f629354c03ccbe74 Mon Sep 17 00:00:00 2001 From: Nakul Nagargade Date: Tue, 8 Apr 2025 03:34:21 +0530 Subject: [PATCH 048/236] Fix default widget height in ModalV2 --- frontend/src/AppBuilder/WidgetManager/widgets/modalV2.js | 6 +++--- frontend/src/Editor/WidgetManager/configs/modalV2.js | 6 +++--- server/src/modules/apps/services/widget-config/modalV2.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/modalV2.js b/frontend/src/AppBuilder/WidgetManager/widgets/modalV2.js index e7e96c4398..a3c89acf93 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/modalV2.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/modalV2.js @@ -5,7 +5,7 @@ export const modalV2Config = { component: 'ModalV2', defaultSize: { width: 10, - height: 34, + height: 40, }, others: { showOnDesktop: { type: 'toggle', displayName: 'Show on desktop' }, @@ -137,7 +137,7 @@ export const modalV2Config = { layout: { top: 24, left: 22, - height: 36, + height: 40, }, displayName: 'ModalFooterCancel', properties: ['text'], @@ -154,7 +154,7 @@ export const modalV2Config = { layout: { top: 24, left: 32, - height: 36, + height: 40, }, displayName: 'ModalFooterConfirm', properties: ['text'], diff --git a/frontend/src/Editor/WidgetManager/configs/modalV2.js b/frontend/src/Editor/WidgetManager/configs/modalV2.js index e7e96c4398..a3c89acf93 100644 --- a/frontend/src/Editor/WidgetManager/configs/modalV2.js +++ b/frontend/src/Editor/WidgetManager/configs/modalV2.js @@ -5,7 +5,7 @@ export const modalV2Config = { component: 'ModalV2', defaultSize: { width: 10, - height: 34, + height: 40, }, others: { showOnDesktop: { type: 'toggle', displayName: 'Show on desktop' }, @@ -137,7 +137,7 @@ export const modalV2Config = { layout: { top: 24, left: 22, - height: 36, + height: 40, }, displayName: 'ModalFooterCancel', properties: ['text'], @@ -154,7 +154,7 @@ export const modalV2Config = { layout: { top: 24, left: 32, - height: 36, + height: 40, }, displayName: 'ModalFooterConfirm', properties: ['text'], diff --git a/server/src/modules/apps/services/widget-config/modalV2.js b/server/src/modules/apps/services/widget-config/modalV2.js index e7e96c4398..a3c89acf93 100644 --- a/server/src/modules/apps/services/widget-config/modalV2.js +++ b/server/src/modules/apps/services/widget-config/modalV2.js @@ -5,7 +5,7 @@ export const modalV2Config = { component: 'ModalV2', defaultSize: { width: 10, - height: 34, + height: 40, }, others: { showOnDesktop: { type: 'toggle', displayName: 'Show on desktop' }, @@ -137,7 +137,7 @@ export const modalV2Config = { layout: { top: 24, left: 22, - height: 36, + height: 40, }, displayName: 'ModalFooterCancel', properties: ['text'], @@ -154,7 +154,7 @@ export const modalV2Config = { layout: { top: 24, left: 32, - height: 36, + height: 40, }, displayName: 'ModalFooterConfirm', properties: ['text'], From 917ea827478b557db23664a0a0bba2265041c9b1 Mon Sep 17 00:00:00 2001 From: johnsoncherian Date: Tue, 8 Apr 2025 13:18:06 +0530 Subject: [PATCH 049/236] chore: initial release branch commit --- .version | 2 +- frontend/ee | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.version b/.version index 19811903a7..30291cba22 100644 --- a/.version +++ b/.version @@ -1 +1 @@ -3.8.0 +3.10.0 diff --git a/frontend/ee b/frontend/ee index 96d68bb980..4b950ed3d0 160000 --- a/frontend/ee +++ b/frontend/ee @@ -1 +1 @@ -Subproject commit 96d68bb9801411de58e6ec62c9d0e84bba631fdd +Subproject commit 4b950ed3d0ba15edddf217936e9c9ae1ca3cf11a From 623487e7e0b31b8831bd5c497520e6ae27d185e4 Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Tue, 8 Apr 2025 13:53:31 +0530 Subject: [PATCH 050/236] fix: Update container header for old data to false --- .../Inspector/Components/Form.jsx | 36 ++++++------- .../WidgetManager/widgets/container.js | 4 +- .../Editor/WidgetManager/configs/container.js | 4 +- ...097765065-UpdateContainerHeaderProperty.ts | 50 +++++++++++++++++++ .../apps/services/widget-config/container.js | 4 +- 5 files changed, 74 insertions(+), 24 deletions(-) create mode 100644 server/migrations/1744097765065-UpdateContainerHeaderProperty.ts diff --git a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx index b39924854e..b6d7033b49 100644 --- a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx +++ b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx @@ -110,24 +110,6 @@ export const baseComponentProperties = ( }); } - items.push({ - title: 'Additional actions', - isOpen: true, - children: additionalActions?.map((property) => - renderElement( - component, - componentMeta, - paramUpdated, - dataQueries, - property, - 'properties', - currentState, - allComponents, - darkMode - ) - ), - }); - if (events.length > 0) { items.push({ title: `${i18next.t('widget.common.events', 'Events')}`, @@ -149,6 +131,24 @@ export const baseComponentProperties = ( }); } + items.push({ + title: 'Additional actions', + isOpen: true, + children: additionalActions?.map((property) => + renderElement( + component, + componentMeta, + paramUpdated, + dataQueries, + property, + 'properties', + currentState, + allComponents, + darkMode + ) + ), + }); + if (validations.length > 0) { items.push({ title: `${i18next.t('widget.common.validation', 'Validation')}`, diff --git a/frontend/src/AppBuilder/WidgetManager/widgets/container.js b/frontend/src/AppBuilder/WidgetManager/widgets/container.js index 424b9a801d..04eb035abf 100644 --- a/frontend/src/AppBuilder/WidgetManager/widgets/container.js +++ b/frontend/src/AppBuilder/WidgetManager/widgets/container.js @@ -44,7 +44,7 @@ export const containerConfig = { displayName: 'Show header', validation: { schema: { type: 'boolean' }, - defaultValue: false, + defaultValue: true, }, }, }, @@ -154,7 +154,7 @@ export const containerConfig = { showOnMobile: { value: '{{false}}' }, }, properties: { - showHeader: { value: `{{false}}` }, + showHeader: { value: `{{true}}` }, loadingState: { value: `{{false}}` }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/frontend/src/Editor/WidgetManager/configs/container.js b/frontend/src/Editor/WidgetManager/configs/container.js index 424b9a801d..04eb035abf 100644 --- a/frontend/src/Editor/WidgetManager/configs/container.js +++ b/frontend/src/Editor/WidgetManager/configs/container.js @@ -44,7 +44,7 @@ export const containerConfig = { displayName: 'Show header', validation: { schema: { type: 'boolean' }, - defaultValue: false, + defaultValue: true, }, }, }, @@ -154,7 +154,7 @@ export const containerConfig = { showOnMobile: { value: '{{false}}' }, }, properties: { - showHeader: { value: `{{false}}` }, + showHeader: { value: `{{true}}` }, loadingState: { value: `{{false}}` }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, diff --git a/server/migrations/1744097765065-UpdateContainerHeaderProperty.ts b/server/migrations/1744097765065-UpdateContainerHeaderProperty.ts new file mode 100644 index 0000000000..1e7dd95b9e --- /dev/null +++ b/server/migrations/1744097765065-UpdateContainerHeaderProperty.ts @@ -0,0 +1,50 @@ +import { Component } from 'src/entities/component.entity'; + +import { processDataInBatches } from '@helpers/migration.helper'; +import { EntityManager, MigrationInterface, QueryRunner } from 'typeorm'; + +export class UpdateContainerHeaderProperty1744097765065 implements MigrationInterface { + public async up(queryRunner: QueryRunner): Promise { + const componentTypes = ['Container']; + const batchSize = 100; + const entityManager = queryRunner.manager; + + for (const componentType of componentTypes) { + await processDataInBatches( + entityManager, + async (entityManager: EntityManager) => { + return await entityManager.find(Component, { + where: { type: componentType }, + order: { createdAt: 'ASC' }, + }); + }, + async (entityManager: EntityManager, components: Component[]) => { + await this.processUpdates(entityManager, components); + }, + batchSize + ); + } + } + + private async processUpdates(entityManager: EntityManager, components: Component[]) { + for (const component of components) { + const properties = component.properties; + const styles = component.styles; + const general = component.general; + + // Update showHeader property to false for old instances + if (!properties.showHeader) { + properties.showHeader = { value: '{{false}}' }; + } + + // Update the modal component with the modified properties + await entityManager.update(Component, component.id, { + properties, + styles, + general, + }); + } + } + + public async down(queryRunner: QueryRunner): Promise {} +} diff --git a/server/src/modules/apps/services/widget-config/container.js b/server/src/modules/apps/services/widget-config/container.js index 424b9a801d..04eb035abf 100644 --- a/server/src/modules/apps/services/widget-config/container.js +++ b/server/src/modules/apps/services/widget-config/container.js @@ -44,7 +44,7 @@ export const containerConfig = { displayName: 'Show header', validation: { schema: { type: 'boolean' }, - defaultValue: false, + defaultValue: true, }, }, }, @@ -154,7 +154,7 @@ export const containerConfig = { showOnMobile: { value: '{{false}}' }, }, properties: { - showHeader: { value: `{{false}}` }, + showHeader: { value: `{{true}}` }, loadingState: { value: `{{false}}` }, visibility: { value: '{{true}}' }, disabledState: { value: '{{false}}' }, From 0fc495536f5d2d0a1aec1cda85cbdf1732d3874f Mon Sep 17 00:00:00 2001 From: Nithin David Thomas <1277421+nithindavid@users.noreply.github.com> Date: Wed, 9 Apr 2025 13:49:23 +0530 Subject: [PATCH 051/236] fix: Hides header footer options when custom schema is turned on --- .../RightSideBar/Inspector/Components/Form.jsx | 14 ++++++++++++++ frontend/src/AppBuilder/Widgets/Form/Form.jsx | 4 ++-- frontend/src/AppBuilder/Widgets/Form/form.scss | 13 +++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx index b39924854e..740691b5d3 100644 --- a/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx +++ b/frontend/src/AppBuilder/RightSideBar/Inspector/Components/Form.jsx @@ -40,6 +40,7 @@ export const Form = ({ const { id } = component; const newOptions = [{ name: 'None', value: 'none' }]; + Object.entries(allComponents).forEach(([componentId, _component]) => { const validParent = _component.component.parent === id || @@ -52,6 +53,19 @@ export const Form = ({ tempComponentMeta.properties.buttonToSubmit.options = newOptions; + // Hide header footer if custom schema is turned on + + if (component.component.definition.properties.advanced.value === '{{true}}') { + component.component.properties.showHeader = { + ...component.component.properties.headerHeight, + isHidden: true, + }; + component.component.properties.showFooter = { + ...component.component.properties.headerHeight, + isHidden: true, + }; + } + const accordionItems = baseComponentProperties( properties, events, diff --git a/frontend/src/AppBuilder/Widgets/Form/Form.jsx b/frontend/src/AppBuilder/Widgets/Form/Form.jsx index afeb4cf844..a5dbd2a865 100644 --- a/frontend/src/AppBuilder/Widgets/Form/Form.jsx +++ b/frontend/src/AppBuilder/Widgets/Form/Form.jsx @@ -299,7 +299,7 @@ export const Form = function Form(props) { if (e.target.className === 'real-canvas') onComponentClick(id, component); }} //Hack, should find a better solution - to prevent losing z index+1 when container element is clicked > - {showHeader && ( + {!advanced && showHeader && (
)}
- {showFooter && ( + {!advanced && showFooter && (
Date: Wed, 9 Apr 2025 14:15:46 +0530 Subject: [PATCH 052/236] Removed the extra space in bottom of query manager. --- .../src/AppBuilder/QueryManager/Components/QueryManagerBody.jsx | 1 - 1 file changed, 1 deletion(-) diff --git a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerBody.jsx b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerBody.jsx index 9e6737f41c..244d8e53cf 100644 --- a/frontend/src/AppBuilder/QueryManager/Components/QueryManagerBody.jsx +++ b/frontend/src/AppBuilder/QueryManager/Components/QueryManagerBody.jsx @@ -381,7 +381,6 @@ export const BaseQueryManagerBody = ({ darkMode, activeTab, renderCopilot = () = {activeTab === 1 && renderQueryElement()} {activeTab === 2 && renderTransformation()} {activeTab === 3 && renderQueryOptions()} -
)} From f565449d884a66f235c8692d384f656cb3db00cd Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Wed, 9 Apr 2025 22:53:57 +0530 Subject: [PATCH 053/236] Fix: Filter dropdown not opening when you click on label. --- .../NewTable/_components/Header/Header.jsx | 2 +- .../Header/_components/Filter/Filter.jsx | 3 ++- .../Header/_components/Filter/FilterRow.jsx | 25 ++++++++++++++++++- frontend/src/_ui/Select/SelectComponent.jsx | 5 ++++ 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/frontend/src/AppBuilder/Widgets/NewTable/_components/Header/Header.jsx b/frontend/src/AppBuilder/Widgets/NewTable/_components/Header/Header.jsx index 9e9a6f656f..1331889870 100644 --- a/frontend/src/AppBuilder/Widgets/NewTable/_components/Header/Header.jsx +++ b/frontend/src/AppBuilder/Widgets/NewTable/_components/Header/Header.jsx @@ -117,7 +117,7 @@ export const Header = memo(
{showFilter && ( - + )} ); diff --git a/frontend/src/AppBuilder/Widgets/NewTable/_components/Header/_components/Filter/Filter.jsx b/frontend/src/AppBuilder/Widgets/NewTable/_components/Header/_components/Filter/Filter.jsx index 905142fc59..7b1a3cdca6 100644 --- a/frontend/src/AppBuilder/Widgets/NewTable/_components/Header/_components/Filter/Filter.jsx +++ b/frontend/src/AppBuilder/Widgets/NewTable/_components/Header/_components/Filter/Filter.jsx @@ -6,7 +6,7 @@ import { FilterFooter } from './FilterFooter'; import { FilterHeader } from './FilterHeader'; import { debounce, isEqual } from 'lodash'; -export const Filter = memo(({ table, darkMode, setFilters, setShowFilter }) => { +export const Filter = memo(({ id, table, darkMode, setFilters, setShowFilter }) => { const { t } = useTranslation(); const [localFilters, setLocalFilters] = useState(table.getState().columnFilters); @@ -142,6 +142,7 @@ export const Filter = memo(({ table, darkMode, setFilters, setShowFilter }) => {
{localFilters.map((filter, index) => ( { + ({ id, filter, index, columns, darkMode, onColumnChange, onOperationChange, onValueChange, onRemove }) => { const { t } = useTranslation(); + const isDragging = useStore((state) => state.draggingComponentId === id); const selectStyles = (width) => { return { @@ -15,6 +18,10 @@ export const FilterRow = memo( menuList: (base) => ({ ...base, }), + menu: (base) => ({ + ...base, + display: isDragging ? 'none' : 'block', + }), }; }; @@ -29,11 +36,13 @@ export const FilterRow = memo( value={filter.id} search={true} onChange={(value) => onColumnChange(index, value)} + components={{ ValueContainer: CustomValueContainer }} placeholder={t('globals.select', 'Select') + '...'} className={`${darkMode ? 'select-search-dark' : 'select-search'} mb-0`} styles={selectStyles('100%')} useCustomStyles={true} darkMode={darkMode} + openMenuOnFocus={true} />
@@ -42,11 +51,13 @@ export const FilterRow = memo( value={filter.value.condition} search={true} onChange={(value) => onOperationChange(index, value)} + components={{ ValueContainer: CustomValueContainer }} className={`${darkMode ? 'select-search-dark' : 'select-search'}`} placeholder={t('globals.select', 'Select') + '...'} styles={selectStyles('100%')} useCustomStyles={true} darkMode={darkMode} + openMenuOnFocus={true} />
@@ -74,3 +85,15 @@ export const FilterRow = memo( ); } ); + +const CustomValueContainer = (props) => { + const handleClick = (e) => { + if (props.selectProps?.selectRef?.current) { + props.selectProps.selectRef.current.focus(); + } + if (props.innerProps?.onMouseDown) { + props.innerProps.onMouseDown(e); + } + }; + return ; +}; diff --git a/frontend/src/_ui/Select/SelectComponent.jsx b/frontend/src/_ui/Select/SelectComponent.jsx index 6675b090e3..2d62352000 100644 --- a/frontend/src/_ui/Select/SelectComponent.jsx +++ b/frontend/src/_ui/Select/SelectComponent.jsx @@ -4,6 +4,7 @@ import Select from 'react-select'; import defaultStyles from './styles'; export const SelectComponent = ({ options = [], value, onChange, closeMenuOnSelect, darkMode, ...restProps }) => { + const selectRef = React.useRef(null); const isDarkMode = darkMode ?? localStorage.getItem('darkMode') === 'true'; const { isMulti = false, @@ -22,6 +23,7 @@ export const SelectComponent = ({ options = [], value, onChange, closeMenuOnSele useCustomStyles = false, isDisabled = false, borderRadius, + openMenuOnFocus = false, } = restProps; const customStyles = useCustomStyles ? styles : defaultStyles(isDarkMode, width, height, styles, borderRadius); @@ -56,6 +58,8 @@ export const SelectComponent = ({ options = [], value, onChange, closeMenuOnSele return ( { - setIsMenuOpen(true); - fireEvent('onFocus'); - }} - onMenuClose={() => { - setIsMenuOpen(false); - fireEvent('onBlur'); - }} onKeyDown={(e) => { - if (e.key === 'Enter' && !isMenuOpen) { + if (e.key === 'Enter' && !isMenuOpen && !isDropdownLoading) { setIsMenuOpen(true); + fireEvent('onFocus'); e.preventDefault(); } if (e.key === 'Escape' && isMenuOpen) { setIsMenuOpen(false); + fireEvent('onBlur'); e.preventDefault(); } }} From 662f9c3aabae4bbb398d15a225ce472945163084 Mon Sep 17 00:00:00 2001 From: devanshu052000 Date: Thu, 10 Apr 2025 22:13:15 +0530 Subject: [PATCH 056/236] Fixed interactions in Multiselect --- .../MultiselectV2/CustomValueContainer.jsx | 2 +- .../MultiselectV2/MultiselectV2.jsx | 46 ++++++++----------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/frontend/src/Editor/Components/MultiselectV2/CustomValueContainer.jsx b/frontend/src/Editor/Components/MultiselectV2/CustomValueContainer.jsx index 2901abc106..9eb11ea4c6 100644 --- a/frontend/src/Editor/Components/MultiselectV2/CustomValueContainer.jsx +++ b/frontend/src/Editor/Components/MultiselectV2/CustomValueContainer.jsx @@ -42,7 +42,7 @@ const CustomValueContainer = ({ children, ...props }) => { {/* Rendering children except Placeholder component to preserve the default behavior of react-select like focus handling */} {React.Children.map(children, (child) => { - if (child.type !== Placeholder) { + if (child?.type !== Placeholder) { return child; } })} diff --git a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx index 7d5109edee..63eec271f2 100644 --- a/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx +++ b/frontend/src/Editor/Components/MultiselectV2/MultiselectV2.jsx @@ -12,7 +12,6 @@ import Label from '@/_ui/Label'; const tinycolor = require('tinycolor2'); import { CustomDropdownIndicator, CustomClearIndicator } from '../DropdownV2/DropdownV2'; import { getInputBackgroundColor, getInputBorderColor, getInputFocusedColor, sortArray } from '../DropdownV2/utils'; -import useStore from '@/AppBuilder/_stores/store'; export const MultiselectV2 = ({ id, @@ -77,8 +76,6 @@ export const MultiselectV2 = ({ const [searchInputValue, setSearchInputValue] = useState(''); const _height = padding === 'default' ? `${height}px` : `${height + 4}px`; const [userInteracted, setUserInteracted] = useState(false); - const currentMode = useStore((state) => state.currentMode); - const isEditor = currentMode === 'edit'; const [isMultiselectOpen, setIsMultiselectOpen] = useState(false); useEffect(() => { @@ -270,26 +267,29 @@ export const MultiselectV2 = ({ fireEvent('onSearchTextChanged'); } }; - const handleClickOutside = (event) => { + const handleClickOutsideSelect = (event) => { let menu = document.getElementById(`dropdown-multiselect-widget-custom-menu-list-${id}`); if ( + isMultiselectOpen && multiselectRef.current && !multiselectRef.current.contains(event.target) && menu && !menu.contains(event.target) ) { - if (isMultiselectOpen) { - fireEvent('onBlur'); - setIsMultiselectOpen(false); - setSearchInputValue(''); - } + setIsMultiselectOpen(false); + fireEvent('onBlur'); } }; - const handleClickInEditor = (e) => { - if (e.target.className.includes('clear-indicator') || isMultiselectOpen) return; - e.stopPropagation(); - selectRef.current?.onControlMouseDown(e); + const handleClickInsideSelect = () => { + if (isMultiSelectDisabled || isMultiSelectLoading) return; + if (isMultiselectOpen) { + setIsMultiselectOpen(false); + fireEvent('onBlur'); + } else { + setIsMultiselectOpen(true); + fireEvent('onFocus'); + } }; const setInputValue = (values) => { @@ -304,11 +304,11 @@ export const MultiselectV2 = ({ }; useEffect(() => { - document.addEventListener('mousedown', handleClickOutside, { capture: true }); + document.addEventListener('mousedown', handleClickOutsideSelect, { capture: true }); return () => { - document.removeEventListener('mousedown', handleClickOutside, { capture: true }); + document.removeEventListener('mousedown', handleClickOutsideSelect, { capture: true }); }; - }, [isMultiselectOpen]); + }, [isMultiselectOpen, componentName]); // Handle Select all logic useEffect(() => { @@ -468,7 +468,7 @@ export const MultiselectV2 = ({ _width={_width} top={'1px'} /> -
+
- onInputChange(e.currentTarget.value, { - action: 'input-change', - }) - } - onMouseDown={(e) => { - e.stopPropagation(); - e.target.focus(); - }} - onTouchEnd={(e) => { - e.stopPropagation(); - e.target.focus(); - }} - onFocus={onMenuInputFocus} - placeholder="Search" - className="dropdown-multiselect-widget-search-box" - /> -
+ {showSearchInput && ( +
+ + + + + onInputChange(e.currentTarget.value, { + action: 'input-change', + }) + } + onMouseDown={(e) => { + e.stopPropagation(); + e.target.focus(); + }} + onTouchEnd={(e) => { + e.stopPropagation(); + e.target.focus(); + }} + onFocus={onMenuInputFocus} + placeholder="Search" + className="dropdown-multiselect-widget-search-box" + /> +
+ )} {showAllOption && !optionsLoadingState && (