From a907c9df34efbaa2dc9ee2cb6457ecdf5b59ee8b Mon Sep 17 00:00:00 2001 From: Chirag Aggarwal Date: Sat, 21 Feb 2026 20:21:08 +0530 Subject: [PATCH] fixes --- app/config/collections/projects.php | 2 +- .../Platform/Modules/Badge/Http/Action.php | 10 +++++++++ .../Modules/Badge/Http/Functions/Get.php | 22 ++++++++----------- .../Platform/Modules/Badge/Http/Sites/Get.php | 22 ++++++++----------- .../Modules/Sites/Http/Sites/Update.php | 7 ++++++ src/Appwrite/Utopia/Response/Model/Site.php | 6 +++++ 6 files changed, 42 insertions(+), 27 deletions(-) diff --git a/app/config/collections/projects.php b/app/config/collections/projects.php index a366ba42f9..8262290f43 100644 --- a/app/config/collections/projects.php +++ b/app/config/collections/projects.php @@ -1120,7 +1120,7 @@ return [ 'format' => '', 'filters' => [], 'required' => false, - 'default' => true, + 'default' => false, 'array' => false, ], [ diff --git a/src/Appwrite/Platform/Modules/Badge/Http/Action.php b/src/Appwrite/Platform/Modules/Badge/Http/Action.php index 254d07e280..6e2152870c 100644 --- a/src/Appwrite/Platform/Modules/Badge/Http/Action.php +++ b/src/Appwrite/Platform/Modules/Badge/Http/Action.php @@ -10,6 +10,16 @@ abstract class Action extends UtopiaAction protected const LABEL_TEXT_X = 260; protected const TEXT_PADDING = 10; protected const FALLBACK_CHAR_WIDTH = 7; + protected const MESSAGE_WIDTHS = [ + 'not found' => 75, + 'disabled' => 75, + 'no deployment' => 112, + 'unknown' => 74, + 'ready' => 55, + 'building' => 70, + 'waiting' => 70, + 'failed' => 60, + ]; protected const COLOR_BRIGHTGREEN = '#4c1'; protected const COLOR_GREEN = '#97ca00'; protected const COLOR_YELLOW = '#dfb317'; diff --git a/src/Appwrite/Platform/Modules/Badge/Http/Functions/Get.php b/src/Appwrite/Platform/Modules/Badge/Http/Functions/Get.php index b5ae133d20..f6af376b34 100644 --- a/src/Appwrite/Platform/Modules/Badge/Http/Functions/Get.php +++ b/src/Appwrite/Platform/Modules/Badge/Http/Functions/Get.php @@ -6,23 +6,15 @@ use Appwrite\Platform\Modules\Badge\Http\Action; use Appwrite\Template\Template; use Appwrite\Utopia\Response; use Utopia\Database\Database; +use Utopia\Database\Document; +use Utopia\Database\Exception\NotFound as NotFoundException; use Utopia\Database\Validator\Authorization; -use Utopia\Validator\Text; +use Utopia\Database\Validator\UID; class Get extends Action { private const LABEL = 'appwrite functions'; private const LABEL_WIDTH = 137; - private const MESSAGE_WIDTHS = [ - 'not found' => 75, - 'disabled' => 75, - 'no deployment' => 112, - 'unknown' => 74, - 'ready' => 60, - 'building' => 76, - 'waiting' => 70, - 'failed' => 60, - ]; public static function getName(): string { @@ -40,7 +32,7 @@ class Get extends Action ->label('sdk.auth', []) ->label('sdk.namespace', 'badge') ->label('sdk.method', 'getFunction') - ->param('functionId', '', new Text(36), 'Function ID') + ->param('functionId', '', new UID(), 'Function ID') ->inject('response') ->inject('dbForProject') ->inject('authorization') @@ -49,7 +41,11 @@ class Get extends Action public function action(string $functionId, Response $response, Database $dbForProject, Authorization $authorization): void { - $function = $authorization->skip(fn () => $dbForProject->getDocument('functions', $functionId)); + try { + $function = $authorization->skip(fn () => $dbForProject->getDocument('functions', $functionId)); + } catch (NotFoundException) { + $function = new Document(); + } $label = self::LABEL; switch (true) { diff --git a/src/Appwrite/Platform/Modules/Badge/Http/Sites/Get.php b/src/Appwrite/Platform/Modules/Badge/Http/Sites/Get.php index c565cd0de1..fd4051cd01 100644 --- a/src/Appwrite/Platform/Modules/Badge/Http/Sites/Get.php +++ b/src/Appwrite/Platform/Modules/Badge/Http/Sites/Get.php @@ -6,23 +6,15 @@ use Appwrite\Platform\Modules\Badge\Http\Action; use Appwrite\Template\Template; use Appwrite\Utopia\Response; use Utopia\Database\Database; +use Utopia\Database\Document; +use Utopia\Database\Exception\NotFound as NotFoundException; use Utopia\Database\Validator\Authorization; -use Utopia\Validator\Text; +use Utopia\Database\Validator\UID; class Get extends Action { private const LABEL = 'appwrite sites'; private const LABEL_WIDTH = 110; - private const MESSAGE_WIDTHS = [ - 'not found' => 75, - 'disabled' => 75, - 'no deployment' => 112, - 'unknown' => 74, - 'ready' => 60, - 'building' => 76, - 'waiting' => 70, - 'failed' => 60, - ]; public static function getName(): string { @@ -40,7 +32,7 @@ class Get extends Action ->label('sdk.auth', []) ->label('sdk.namespace', 'badge') ->label('sdk.method', 'getSite') - ->param('siteId', '', new Text(36), 'Site ID') + ->param('siteId', '', new UID(), 'Site ID') ->inject('response') ->inject('dbForProject') ->inject('authorization') @@ -49,7 +41,11 @@ class Get extends Action public function action(string $siteId, Response $response, Database $dbForProject, Authorization $authorization): void { - $site = $authorization->skip(fn () => $dbForProject->getDocument('sites', $siteId)); + try { + $site = $authorization->skip(fn () => $dbForProject->getDocument('sites', $siteId)); + } catch (NotFoundException) { + $site = new Document(); + } $label = self::LABEL; switch (true) { diff --git a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php index a071ab8bbe..e7af7caccd 100644 --- a/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php +++ b/src/Appwrite/Platform/Modules/Sites/Http/Sites/Update.php @@ -75,6 +75,7 @@ class Update extends Base ->param('buildRuntime', '', new WhiteList(array_keys(Config::getParam('runtimes')), true), 'Runtime to use during build step.', true) ->param('adapter', '', new WhiteList(['static', 'ssr']), 'Framework adapter defining rendering strategy. Allowed values are: static, ssr', true) ->param('fallbackFile', '', new Text(255, 0), 'Fallback file for single page application sites.', true) + ->param('deploymentBadge', null, new Boolean(), 'Whether to display deployment badge for this site.', true) ->param('installationId', '', new Text(128, 0), 'Appwrite Installation ID for VCS (Version Control System) deployment.', true) ->param('providerRepositoryId', '', new Text(128, 0), 'Repository ID of the repo linked to the site.', true) ->param('providerBranch', '', new Text(128, 0), 'Production branch for the repo linked to the site.', true) @@ -111,6 +112,7 @@ class Update extends Base string $buildRuntime, string $adapter, string $fallbackFile, + ?bool $deploymentBadge, string $installationId, ?string $providerRepositoryId, string $providerBranch, @@ -161,6 +163,10 @@ class Update extends Base $framework = $site->getAttribute('framework'); } + if ($request->getPayload('deploymentBadge', null) === null) { + $deploymentBadge = $site->getAttribute('deploymentBadge', true); + } + $enabled ??= $site->getAttribute('enabled', true); $repositoryId = $site->getAttribute('repositoryId', ''); @@ -264,6 +270,7 @@ class Update extends Base 'buildRuntime' => $buildRuntime, 'adapter' => $adapter, 'fallbackFile' => $fallbackFile, + 'deploymentBadge' => $deploymentBadge, ]))); // Redeploy logic diff --git a/src/Appwrite/Utopia/Response/Model/Site.php b/src/Appwrite/Utopia/Response/Model/Site.php index e6e205909b..e0c62d47ac 100644 --- a/src/Appwrite/Utopia/Response/Model/Site.php +++ b/src/Appwrite/Utopia/Response/Model/Site.php @@ -185,6 +185,12 @@ class Site extends Model 'default' => null, 'example' => 'index.html', ]) + ->addRule('deploymentBadge', [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Whether to display the deployment badge in the site response.', + 'default' => true, + 'example' => false, + ]) ; }