From d49ec24c08940f2c3001fd00aa5650607c9a7a16 Mon Sep 17 00:00:00 2001 From: Anagh Hegde Date: Mon, 7 Oct 2024 16:23:09 +0530 Subject: [PATCH 1/3] chore: create pg_trm extension for the GIN index creation (#36722) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description Due to the size limit on the BTree index we are creating GIN index for a permission group. To support this we need to create a pg_trm extension. ## Automation /ok-to-test tags="@tag.Sanity" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: d62be8f46ad45b1190bf5c014c0a8ea0c50cf284 > Cypress dashboard. > Tags: `@tag.Sanity` > Spec: >
Mon, 07 Oct 2024 10:46:39 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [ ] No ## Summary by CodeRabbit - **New Features** - Enhanced database initialization by adding the creation of the `pg_trgm` extension for PostgreSQL, improving text search capabilities. - **Bug Fixes** - Ensured the extension is created only if it does not already exist, preventing unnecessary errors during setup. --- deploy/docker/fs/opt/appsmith/pg-utils.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/deploy/docker/fs/opt/appsmith/pg-utils.sh b/deploy/docker/fs/opt/appsmith/pg-utils.sh index 1c962655111..175deb9a174 100755 --- a/deploy/docker/fs/opt/appsmith/pg-utils.sh +++ b/deploy/docker/fs/opt/appsmith/pg-utils.sh @@ -127,11 +127,16 @@ init_pg_db() { echo "Schema 'appsmith' does not exist. Creating schema..." psql -h "$PG_DB_HOST" -p "$PG_DB_PORT" -U postgres -d "$PG_DB_NAME" -c "CREATE SCHEMA appsmith;" fi - USER=$PG_DB_USER SCHEMA="appsmith" DB=$PG_DB_NAME HOST=$PG_DB_HOST PORT=$PG_DB_PORT grant_permissions_for_schema + + echo "Creating pg_trgm extension..." + psql -h "$PG_DB_HOST" -p "$PG_DB_PORT" -U postgres -d "$PG_DB_NAME" -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" else echo "Remote PostgreSQL detected, running as current user." PGPASSWORD=$PG_DB_PASSWORD psql -h "$PG_DB_HOST" -p "$PG_DB_PORT" -U "$PG_DB_USER" -d "$PG_DB_NAME" -c "CREATE SCHEMA IF NOT EXISTS appsmith;" + + echo "Creating pg_trgm extension..." + psql -h "$PG_DB_HOST" -p "$PG_DB_PORT" -U "$PG_DB_USER" -d "$PG_DB_NAME" -c "CREATE EXTENSION IF NOT EXISTS pg_trgm;" fi # Check if the schema creation was successful From d15eea3e1ed5cf2b3c0b9314248cf4318e9a66c5 Mon Sep 17 00:00:00 2001 From: Rahul Barwal Date: Mon, 7 Oct 2024 17:22:02 +0530 Subject: [PATCH 2/3] fix: widget icon in Connect To options in oneclick binding menu (#36703) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This pull request fixes the issue with the widget icon not displaying correctly in the Connect To options. The `useConnectToOptions` function now correctly retrieves the widget config for the current widget and uses the `iconSVG` property from the config to display the widget icon. Fixes #`Issue Number` _or_ Fixes https://github.com/appsmithorg/appsmith/issues/36353 > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="@tag.All" ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: 80a63553ab8f1d77695d3261095a90acdb4b5a4d > Cypress dashboard. > Tags: `@tag.All` > Spec: >
Mon, 07 Oct 2024 09:25:24 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No ## Summary by CodeRabbit - **New Features** - Enhanced datasource selection validation by ensuring images associated with queried items are present and valid. - Improved icon retrieval for connectable widgets in the dropdown, allowing for more accurate icon displays based on widget types. - **Bug Fixes** - Fixed icon rendering issues in dropdown options to ensure the correct icons are displayed. --------- Co-authored-by: Jacques Ikot --- .../ClientSide/OneClickBinding/spec_utility.ts | 17 ++++++++++++++++- .../useSource/useConnectToOptions.tsx | 5 ++++- .../OtherFields/Field/Dropdown/useDropdown.tsx | 5 ++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/spec_utility.ts b/app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/spec_utility.ts index 91b52c0d116..ba218d46f17 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/spec_utility.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/OneClickBinding/spec_utility.ts @@ -12,7 +12,22 @@ export class OneClickBinding { column: Record = {}, ) { agHelper.GetNClick(oneClickBindingLocator.datasourceDropdownSelector); - + agHelper.GetElement("[role='menu']").then(($menu) => { + if ( + $menu.find(oneClickBindingLocator.datasourceQuerySelector()).length > 0 + ) { + cy.wrap($menu) + .find(oneClickBindingLocator.datasourceQuerySelector()) + .should("have.length.greaterThan", 0) + .each(($item) => { + cy.wrap($item) + .find("img") + .should(($img) => { + expect($img).to.have.attr("src").and.not.be.empty; + }); + }); + } + }); expandLoadMoreOptions(); agHelper.AssertElementAbsence(oneClickBindingLocator.connectData); diff --git a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx index 9b638540209..ceedd1fda2b 100644 --- a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx +++ b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/CommonControls/DatasourceDropdown/useSource/useConnectToOptions.tsx @@ -227,6 +227,9 @@ function useConnectToOptions(props: ConnectToOptionsProps) { // This is the path we bind to the sourceData field Ex: `{{Table1.selectedRow}}` const { widgetBindPath } = getOneClickBindingConnectableWidgetConfig(currWidget); + const iconSVG = + WidgetFactory.getConfig(currWidget.type)?.iconSVG || + currWidget.iconSVG; return { id: widgetId, @@ -237,7 +240,7 @@ function useConnectToOptions(props: ConnectToOptionsProps) { ), diff --git a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/WidgetSpecificControls/OtherFields/Field/Dropdown/useDropdown.tsx b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/WidgetSpecificControls/OtherFields/Field/Dropdown/useDropdown.tsx index efac989bf96..e5143135f27 100644 --- a/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/WidgetSpecificControls/OtherFields/Field/Dropdown/useDropdown.tsx +++ b/app/client/src/components/editorComponents/WidgetQueryGeneratorForm/WidgetSpecificControls/OtherFields/Field/Dropdown/useDropdown.tsx @@ -81,12 +81,15 @@ export function useDropdown(props: OneClickDropdownFieldProps) { if (getOneClickBindingConnectableWidgetConfig) { const { message, widgetBindPath } = getOneClickBindingConnectableWidgetConfig(currWidget); + const iconSVG = + WidgetFactory.getConfig(currWidget.type)?.iconSVG || + currWidget.iconSVG; return { id: currWidgetId, value: widgetBindPath, label: currWidget.widgetName, - icon: , + icon: , data: { widgetType: currWidget.type, widgetName: currWidget.widgetName, From 22ccab07d45d433eae6d514e2dba88e32d90b9c2 Mon Sep 17 00:00:00 2001 From: Abhijeet <41686026+abhvsn@users.noreply.github.com> Date: Tue, 8 Oct 2024 07:53:58 +0530 Subject: [PATCH 3/3] chore: Create appsmith postgres DB to be used by internal processes (#36670) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description With the migration to postgres as Appsmith's persistent database we wanted to have central DB to be consumed by internal services. Currently all the services try to create the same DB and may end up in a race condition, so we are moving this task to `entrypoint.sh`. Steps: 1. Initialise data directory for pg 2. Run the upgrade migration if necessary 3. Start the pg server 4. Create `appsmith` db with postgres user 5. Stop the pg server /test Sanity ### :mag: Cypress test results > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: > Commit: e3840764acb3088233bf6552d74721abb00518a6 > Cypress dashboard. > Tags: `@tag.Sanity` > Spec: >
Mon, 07 Oct 2024 09:31:39 UTC ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No ## Summary by CodeRabbit - **New Features** - Improved database initialization logic for the Appsmith application. - Automatically creates the Appsmith database if it does not already exist during startup. - **Bug Fixes** - Enhanced robustness of the database setup process with existence checks before creation. --- deploy/docker/fs/opt/appsmith/entrypoint.sh | 29 +++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/deploy/docker/fs/opt/appsmith/entrypoint.sh b/deploy/docker/fs/opt/appsmith/entrypoint.sh index 5e42418d92a..685c0b8fd0a 100644 --- a/deploy/docker/fs/opt/appsmith/entrypoint.sh +++ b/deploy/docker/fs/opt/appsmith/entrypoint.sh @@ -6,6 +6,7 @@ tlog "Running as: $(id)" stacks_path=/appsmith-stacks +export APPSMITH_PG_DATABASE="appsmith" export SUPERVISORD_CONF_TARGET="$TMP/supervisor-conf.d/" # export for use in supervisord.conf export MONGODB_TMP_KEY_PATH="$TMP/mongodb-key" # export for use in supervisor process mongodb.conf @@ -432,6 +433,7 @@ init_postgres() { tlog "Initializing local Postgres data folder" su postgres -c "env PATH='$PATH' initdb -D $POSTGRES_DB_PATH" fi + create_appsmith_pg_db "$POSTGRES_DB_PATH" else runEmbeddedPostgres=0 fi @@ -453,6 +455,33 @@ safe_init_postgres() { fi } +# Method to create a appsmith database in the postgres +# Args: +# POSTGRES_DB_PATH (string): Path to the postgres data directory +# Returns: +# None +# Example: +# create_appsmith_pg_db "/appsmith-stacks/data/postgres/main" +create_appsmith_pg_db() { + POSTGRES_DB_PATH=$1 + # Start the postgres , wait for it to be ready and create a appsmith db + su postgres -c "env PATH='$PATH' pg_ctl -D $POSTGRES_DB_PATH -l $POSTGRES_DB_PATH/logfile start" + echo "Waiting for Postgres to start" + until su postgres -c "env PATH='$PATH' pg_isready -d postgres"; do + tlog "Waiting for Postgres to be ready..." + sleep 1 + done + # Check if the appsmith DB is present + DB_EXISTS=$(su postgres -c "env PATH='$PATH' psql -tAc \"SELECT 1 FROM pg_database WHERE datname='${APPSMITH_PG_DATABASE}'\"") + + if [[ "$DB_EXISTS" != "1" ]]; then + su postgres -c "env PATH='$PATH' psql -c \"CREATE DATABASE ${APPSMITH_PG_DATABASE}\"" + else + echo "Database ${APPSMITH_PG_DATABASE} already exists." + fi + su postgres -c "env PATH='$PATH' pg_ctl -D $POSTGRES_DB_PATH stop" +} + setup_caddy() { if [[ "$APPSMITH_RATE_LIMIT" == "disabled" ]]; then export _APPSMITH_CADDY="/opt/caddy/caddy_vanilla"