From 6fcc4ae6a256b30f9b29785965e2e16b32c4b90f Mon Sep 17 00:00:00 2001 From: Aditya Toshniwal Date: Fri, 8 Nov 2024 15:48:24 +0530 Subject: [PATCH] More fixes for issues found while testing query tool pagination changes. #1780 --- .github/workflows/run-python-tests-pg.yml | 33 ++++++++----------- .../browser/templates/browser/js/messages.js | 1 + web/pgadmin/static/js/validators.js | 5 ++- .../components/sections/ResultSetToolbar.jsx | 12 +++---- 4 files changed, 25 insertions(+), 26 deletions(-) diff --git a/.github/workflows/run-python-tests-pg.yml b/.github/workflows/run-python-tests-pg.yml index 1e3e41c0d..fd7166e12 100644 --- a/.github/workflows/run-python-tests-pg.yml +++ b/.github/workflows/run-python-tests-pg.yml @@ -62,7 +62,7 @@ jobs: ECHO Running %INSTALLER_EXE%... %INSTALLER_EXE% --prefix C:\PostgreSQL\${{ matrix.pgver }} --datadir C:\PostgreSQL\${{ matrix.pgver }}\data --serverport 59${{ matrix.pgver }} --superpassword postgres --install_runtimes 0 --mode unattended --unattendedmodeui none --disable-components pgAdmin,stackbuilder --enable-components server,commandlinetools" choco install -y mitkerberos - + REM Ignore error 3010 (reboot required) IF %ERRORLEVEL% EQU 3010 cmd /c "exit /b 0" shell: cmd @@ -92,12 +92,12 @@ jobs: sudo sed -i "s/port = 543[0-9]/port = 59${{ matrix.pgver }}/g" /etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf sudo sed -i "s/#shared_preload_libraries = ''/shared_preload_libraries = '\$libdir\/plugin_debugger'/g" /etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf sudo su - postgres -c "/usr/lib/postgresql/${{ matrix.pgver }}/bin/postgres -D /var/lib/postgresql/${{ matrix.pgver }}/main -c config_file=/etc/postgresql/${{ matrix.pgver }}/main/postgresql.conf &" - + until sudo runuser -l postgres -c "pg_isready -p 59${{ matrix.pgver }}" 2>/dev/null; do >&2 echo "Postgres is unavailable - sleeping for 2 seconds" sleep 2 done - + psql -U postgres -p 59${{ matrix.pgver }} -c 'CREATE EXTENSION pgagent;' psql -U postgres -p 59${{ matrix.pgver }} -c 'CREATE EXTENSION pldbgapi;' @@ -107,18 +107,13 @@ jobs: echo local all all trust > /opt/homebrew/var/postgresql@${{ matrix.pgver }}/pg_hba.conf sed -i '' "s/#port = 543[0-9]/port = 59${{ matrix.pgver }}/g" /opt/homebrew/var/postgresql@${{ matrix.pgver }}/postgresql.conf brew services restart postgresql@${{ matrix.pgver }} - + until /opt/homebrew/opt/postgresql@${{ matrix.pgver }}/bin/pg_isready -p 59${{ matrix.pgver }} 2>/dev/null; do >&2 echo "Postgres is unavailable - sleeping for 2 seconds" sleep 2 done - - psql postgres -p 59${{ matrix.pgver }} -c 'CREATE ROLE postgres SUPERUSER LOGIN;' -# Pin the python version to v3.12 till pgAdmin supports latest versions. - - uses: actions/setup-python@v5 - with: - python-version: '3.12' + psql postgres -p 59${{ matrix.pgver }} -c 'CREATE ROLE postgres SUPERUSER LOGIN;' - name: Install Python dependencies on Linux and macOS if: ${{ matrix.os == 'macos-latest' || matrix.os == 'ubuntu-latest' }} @@ -140,21 +135,21 @@ jobs: run: | cat < web/config_local.py from config import * - + # Debug mode DEBUG = True - + # App mode SERVER_MODE = False - + # Log CONSOLE_LOG_LEVEL = DEBUG FILE_LOG_LEVEL = DEBUG - + DEFAULT_SERVER = '127.0.0.1' - + UPGRADE_CHECK_ENABLED = False - + LOG_FILE = "$(pwd)/var/pgadmin4.log" SESSION_DB_PATH = "$(pwd)/var/sessions" STORAGE_DIR = "$(pwd)/var/storage" @@ -162,7 +157,7 @@ jobs: TEST_SQLITE_PATH = "$(pwd)/var/pgadmin4.db" AZURE_CREDENTIAL_CACHE_DIR = "$(pwd)/var/azurecredentialcache" EOF - + cat < web/regression/test_config.json { "pgAdmin4_login_credentials": { @@ -211,7 +206,7 @@ jobs: if: ${{ matrix.os == 'windows-latest' }} run: | FOR /f "delims=" %%D IN ('python -c "import os; print(os.getcwd().replace('\\', '\\\\'))"') DO SET WORKING_DIR=%%D - + > web\config_local.py ( @echo.from config import * @echo. @@ -236,7 +231,7 @@ jobs: @echo.TEST_SQLITE_PATH = "%WORKING_DIR%\\var\\test_pgadmin4.db" @echo.AZURE_CREDENTIAL_CACHE_DIR = "%WORKING_DIR%\\var\\azurecredentialcache" ) - + > web\regression\test_config.json ( @echo.{ @echo. "pgAdmin4_login_credentials": { diff --git a/web/pgadmin/browser/templates/browser/js/messages.js b/web/pgadmin/browser/templates/browser/js/messages.js index 445bad3e1..14513f9e3 100644 --- a/web/pgadmin/browser/templates/browser/js/messages.js +++ b/web/pgadmin/browser/templates/browser/js/messages.js @@ -26,6 +26,7 @@ define( 'SQL_NO_CHANGE': gettext('Nothing changed'), 'MUST_BE_INT' : gettext("'%s' must be an integer."), 'MUST_BE_NUM' : gettext("'%s' must be a numeric."), + 'INVALID_MIN_MAX' : gettext("Min and Max values are not valid"), 'MUST_GR_EQ' : gettext("'%s' must be greater than or equal to %s."), 'MUST_LESS_EQ' : gettext("'%s' must be less than or equal to %s."), 'CANNOT_BE_EMPTY': gettext("'%s' cannot be empty."), diff --git a/web/pgadmin/static/js/validators.js b/web/pgadmin/static/js/validators.js index c9f1bb71b..2dc1cde43 100644 --- a/web/pgadmin/static/js/validators.js +++ b/web/pgadmin/static/js/validators.js @@ -15,7 +15,10 @@ import pgAdmin from 'sources/pgadmin'; export function minMaxValidator(label, value, minValue, maxValue) { if((_.isUndefined(value) || _.isNull(value) || String(value) === '')) return null; - if (!_.isUndefined(minValue) && (value < minValue || value === '-')) { + + if(isNaN(minValue) || isNaN(maxValue)) { + return pgAdmin.Browser.messages.INVALID_MIN_MAX; + } else if (!_.isUndefined(minValue) && (value < minValue || value === '-')) { return sprintf(pgAdmin.Browser.messages.MUST_GR_EQ, label, minValue); } else if (!_.isUndefined(maxValue) && value > maxValue) { return sprintf(pgAdmin.Browser.messages.MUST_LESS_EQ, label, maxValue); diff --git a/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSetToolbar.jsx b/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSetToolbar.jsx index 046f34bc7..558b57c82 100644 --- a/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSetToolbar.jsx +++ b/web/pgadmin/tools/sqleditor/static/js/components/sections/ResultSetToolbar.jsx @@ -153,17 +153,17 @@ function PaginationInputs({pagination, totalRowCount, clearSelection}) { setErrorInputs((prev)=>{ let errors = {...prev}; - if(minMaxValidator('', inputs.pageNo, 1, inputs.pageCount) || isEmptyString(inputs.pageNo)) { + if(minMaxValidator('', parseInt(inputs.pageNo), 1, parseInt(inputs.pageCount)) || isEmptyString(inputs.pageNo)) { errors.pageNo = true; } else { errors.pageNo = false; } - if(minMaxValidator('', inputs.from, 1, inputs.to) || isEmptyString(inputs.from)) { + if(minMaxValidator('', parseInt(inputs.from), 1, parseInt(inputs.to)) || isEmptyString(inputs.from)) { errors.from = true; } else { errors.from = false; } - if(minMaxValidator('', inputs.to, 1, totalRowCount) || isEmptyString(inputs.to)) { + if(minMaxValidator('', parseInt(inputs.to), 1, totalRowCount) || isEmptyString(inputs.to)) { errors.to = true; } else { errors.to = false; @@ -233,8 +233,8 @@ function PaginationInputs({pagination, totalRowCount, clearSelection}) { {gettext('of')} {pagination.page_count}
 
- goToPage(1)} icon={}/> - goToPage(pagination.page_no-1)} icon={}/> + goToPage(1)} icon={}/> + goToPage(pagination.page_no-1)} icon={}/> goToPage(pagination.page_no+1)} icon={}/> goToPage(pagination.page_count)} icon={} /> @@ -423,7 +423,7 @@ export function ResultSetToolbar({query, canEdit, totalRowCount, pagination, all } { - allRowsSelect == 'PAGE' && ( + allRowsSelect == 'PAGE' && totalRowCount > pagination.page_size && (
{gettext('All rows on this page are selected.')}