From 349833573fd2dd4d412197f6f4ab23a13f5e1843 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 8 Sep 2022 04:51:08 +0000 Subject: [PATCH 01/23] region environment variables --- .env | 3 +++ Dockerfile | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.env b/.env index 227ea10676..5b688cf87e 100644 --- a/.env +++ b/.env @@ -81,6 +81,9 @@ _APP_USAGE_DATABASE_INTERVAL=15 _APP_USAGE_STATS=enabled _APP_LOGGING_PROVIDER= _APP_LOGGING_CONFIG= +_APP_REGION_DEFAULT=default +_APP_REGIIONS=default +_APP_REGION_DISABLED= DOCKERHUB_PULL_USERNAME= DOCKERHUB_PULL_PASSWORD= DOCKERHUB_PULL_EMAIL= \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index a7cae38502..97fb51eb0e 100755 --- a/Dockerfile +++ b/Dockerfile @@ -255,7 +255,10 @@ ENV _APP_SERVER=swoole \ _APP_MAINTENANCE_RETENTION_ABUSE=86400 \ _APP_MAINTENANCE_INTERVAL=86400 \ _APP_LOGGING_PROVIDER= \ - _APP_LOGGING_CONFIG= + _APP_LOGGING_CONFIG= \ + _APP_REGIONS=default \ + _APP_REGION_DEFAULT=default \ + _APP_REGION_DISABLED= RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone From fafef03512c8292586b493dfc8f93caf962d8c5b Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 8 Sep 2022 04:53:46 +0000 Subject: [PATCH 02/23] region attribute on project --- app/config/collections.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/config/collections.php b/app/config/collections.php index 633e2c33b9..102c8706ac 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -523,6 +523,17 @@ $collections = [ 'array' => false, 'filters' => [], ], + [ + '$id' => ID::custom('region'), + 'type' => Database::VAR_STRING, + 'format' => '', + 'size' => 128, + 'signed' => true, + 'required' => false, + 'default' => null, + 'array' => false, + 'filters' => [], + ], [ '$id' => ID::custom('description'), 'type' => Database::VAR_STRING, From 119344031a7d2240cd10cf8203ff22c889085acd Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 8 Sep 2022 05:04:16 +0000 Subject: [PATCH 03/23] region on endpoint --- app/controllers/api/projects.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/projects.php b/app/controllers/api/projects.php index 8dec0ba0cb..adc1e9007e 100644 --- a/app/controllers/api/projects.php +++ b/app/controllers/api/projects.php @@ -58,6 +58,7 @@ App::post('/v1/projects') ->param('projectId', '', new CustomId(), 'Unique Id. Choose your own unique ID or pass the string "unique()" to auto generate it. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can\'t start with a special char. Max length is 36 chars.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') ->param('teamId', '', new UID(), 'Team unique ID.') + ->param('region', '', new Whitelist([App::getEnv('_APP_REGIONS', [])]), 'Project URL.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) @@ -70,7 +71,7 @@ App::post('/v1/projects') ->inject('response') ->inject('dbForConsole') ->inject('dbForProject') - ->action(function (string $projectId, string $name, string $teamId, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole, Database $dbForProject) { + ->action(function (string $projectId, string $name, string $teamId, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole, Database $dbForProject) { $team = $dbForConsole->getDocument('teams', $teamId); @@ -102,6 +103,7 @@ App::post('/v1/projects') 'name' => $name, 'teamInternalId' => $team->getInternalId(), 'teamId' => $team->getId(), + 'region' => $region, 'description' => $description, 'logo' => $logo, 'url' => $url, @@ -364,6 +366,7 @@ App::patch('/v1/projects/:projectId') ->label('sdk.response.model', Response::MODEL_PROJECT) ->param('projectId', '', new UID(), 'Project unique ID.') ->param('name', null, new Text(128), 'Project name. Max length: 128 chars.') + ->param('region', '', new Whitelist([App::getEnv('_APP_REGIONS', [])]), 'Project URL.', true) ->param('description', '', new Text(256), 'Project description. Max length: 256 chars.', true) ->param('logo', '', new Text(1024), 'Project logo.', true) ->param('url', '', new URL(), 'Project URL.', true) @@ -375,7 +378,7 @@ App::patch('/v1/projects/:projectId') ->param('legalTaxId', '', new Text(256), 'Project legal tax ID. Max length: 256 chars.', true) ->inject('response') ->inject('dbForConsole') - ->action(function (string $projectId, string $name, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole) { + ->action(function (string $projectId, string $name, string $region, string $description, string $logo, string $url, string $legalName, string $legalCountry, string $legalState, string $legalCity, string $legalAddress, string $legalTaxId, Response $response, Database $dbForConsole) { $project = $dbForConsole->getDocument('projects', $projectId); @@ -385,6 +388,7 @@ App::patch('/v1/projects/:projectId') $project = $dbForConsole->updateDocument('projects', $project->getId(), $project ->setAttribute('name', $name) + ->setAttribute('region', $region) ->setAttribute('description', $description) ->setAttribute('logo', $logo) ->setAttribute('url', $url) From 8450a0c213e861df3412c0ca223ff62ef68c57e7 Mon Sep 17 00:00:00 2001 From: Damodar Lohani Date: Thu, 8 Sep 2022 05:24:46 +0000 Subject: [PATCH 04/23] region in UI --- .env | 2 +- Dockerfile | 2 +- app/controllers/web/console.php | 6 ++++++ app/views/console/comps/header.phtml | 16 ++++++++++++++++ 4 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.env b/.env index 5b688cf87e..951b3cf562 100644 --- a/.env +++ b/.env @@ -83,7 +83,7 @@ _APP_LOGGING_PROVIDER= _APP_LOGGING_CONFIG= _APP_REGION_DEFAULT=default _APP_REGIIONS=default -_APP_REGION_DISABLED= +_APP_REGIONS_DISABLED= DOCKERHUB_PULL_USERNAME= DOCKERHUB_PULL_PASSWORD= DOCKERHUB_PULL_EMAIL= \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 97fb51eb0e..339c80e063 100755 --- a/Dockerfile +++ b/Dockerfile @@ -258,7 +258,7 @@ ENV _APP_SERVER=swoole \ _APP_LOGGING_CONFIG= \ _APP_REGIONS=default \ _APP_REGION_DEFAULT=default \ - _APP_REGION_DISABLED= + _APP_REGIONS_DISABLED= RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone diff --git a/app/controllers/web/console.php b/app/controllers/web/console.php index 864ed535f2..3617024722 100644 --- a/app/controllers/web/console.php +++ b/app/controllers/web/console.php @@ -28,6 +28,12 @@ App::shutdown() $header = new View(__DIR__ . '/../../views/console/comps/header.phtml'); $footer = new View(__DIR__ . '/../../views/console/comps/footer.phtml'); + $header + ->setParam('regions', App::getEnv('_APP_REGIONS', [])) + ->setParam('disabledRegions', App::getEnv('_APP_REGIONS_DISABLED', [])) + ->setParam('defaultRegion', App::getEnv('_APP_REGION_DEFAULT', 'default')) + ; + $footer ->setParam('home', App::getEnv('_APP_HOME', '')) ->setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN')) diff --git a/app/views/console/comps/header.phtml b/app/views/console/comps/header.phtml index 09fe421c79..6e56c7c357 100644 --- a/app/views/console/comps/header.phtml +++ b/app/views/console/comps/header.phtml @@ -1,3 +1,8 @@ +getParam('regions', []); +$disabledRegions = $this->getParam('disabledRegions', []); +$defaultRegion = $this->getParam('defaultRegion', []); +?>