From 0206eea0d1aada7380ce822b535fe4b1b4abec7d Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 2 Aug 2024 15:27:01 +0800 Subject: [PATCH 1/5] added new flag to indicate self managed extension, few ui improvements, ability to preview listing --- addon/components/extension-card.hbs | 5 ++++ addon/components/extension-card.js | 3 +- addon/components/extension-form.hbs | 8 ++++- addon/components/extension-form.js | 30 +++++++++++++++++++ addon/components/modals/extension-details.hbs | 2 +- addon/models/registry-extension.js | 2 ++ composer.json | 2 +- extension.json | 2 +- package.json | 2 +- ...ed_column_to_registry_extensions_table.php | 28 +++++++++++++++++ server/src/Models/RegistryExtension.php | 11 +++++++ server/src/Models/RegistryExtensionBundle.php | 4 +-- 12 files changed, 91 insertions(+), 8 deletions(-) create mode 100644 server/migrations/2024_08_02_072214_add_self_managed_column_to_registry_extensions_table.php diff --git a/addon/components/extension-card.hbs b/addon/components/extension-card.hbs index 87f18af..234631f 100644 --- a/addon/components/extension-card.hbs +++ b/addon/components/extension-card.hbs @@ -6,6 +6,11 @@
{{@extension.name}}
{{n-a @extension.description}}
+ {{#if @extension.payment_required}} + {{format-currency @extension.price @extension.currency}} + {{else}} + Free + {{/if}}
{{yield @extension}} diff --git a/addon/components/extension-card.js b/addon/components/extension-card.js index 7ca0c49..a34fb37 100644 --- a/addon/components/extension-card.js +++ b/addon/components/extension-card.js @@ -40,9 +40,10 @@ export default class ExtensionCardComponent extends Component { @action onClick(options = {}) { const installChannel = `install.${this.currentUser.companyId}.${this.extension.id}`; + const isAuthor = this.extension.is_author === true; const isAlreadyPurchased = this.extension.is_purchased === true; const isAlreadyInstalled = this.extension.is_installed === true; - const isPaymentRequired = this.extension.payment_required === true && isAlreadyPurchased === false; + const isPaymentRequired = !isAuthor && this.extension.payment_required === true && isAlreadyPurchased === false; if (typeof this.args.onClick === 'function') { this.args.onClick(this.extension); diff --git a/addon/components/extension-form.hbs b/addon/components/extension-form.hbs index 3a368bf..0169588 100644 --- a/addon/components/extension-form.hbs +++ b/addon/components/extension-form.hbs @@ -101,7 +101,13 @@ {{/if}} - +
Website
{{this.extension.website_url}} diff --git a/addon/models/registry-extension.js b/addon/models/registry-extension.js index f42b62e..8c18edc 100644 --- a/addon/models/registry-extension.js +++ b/addon/models/registry-extension.js @@ -63,8 +63,10 @@ export default class RegistryExtensionModel extends Model { @attr('array') languages; @attr('object') meta; @attr('boolean') core_service; + @attr('boolean') self_managed; @attr('boolean') is_purchased; @attr('boolean') is_installed; + @attr('boolean') is_author; @attr('string', { defaultValue: 'pending' }) status; /** @dates */ diff --git a/composer.json b/composer.json index 8fdc025..b55517e 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "fleetbase/registry-bridge", - "version": "0.0.11", + "version": "0.0.12", "description": "Internal Bridge between Fleetbase API and Extensions Registry", "keywords": [ "fleetbase-extension", diff --git a/extension.json b/extension.json index b7f7a57..1077ba6 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "Registry Bridge", - "version": "0.0.11", + "version": "0.0.12", "description": "Internal Bridge between Fleetbase API and Extensions Registry", "repository": "https://github.com/fleetbase/registry-bridge", "license": "AGPL-3.0-or-later", diff --git a/package.json b/package.json index d464f52..a3525e0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@fleetbase/registry-bridge-engine", - "version": "0.0.11", + "version": "0.0.12", "description": "Internal Bridge between Fleetbase API and Extensions Registry", "fleetbase": { "route": "extensions" diff --git a/server/migrations/2024_08_02_072214_add_self_managed_column_to_registry_extensions_table.php b/server/migrations/2024_08_02_072214_add_self_managed_column_to_registry_extensions_table.php new file mode 100644 index 0000000..488516d --- /dev/null +++ b/server/migrations/2024_08_02_072214_add_self_managed_column_to_registry_extensions_table.php @@ -0,0 +1,28 @@ +boolean('self_managed')->after('subtitle')->default(0); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('registry_extensions', function (Blueprint $table) { + $table->dropColumn('self_managed'); + }); + } +}; diff --git a/server/src/Models/RegistryExtension.php b/server/src/Models/RegistryExtension.php index 63893f2..c9bb933 100644 --- a/server/src/Models/RegistryExtension.php +++ b/server/src/Models/RegistryExtension.php @@ -57,6 +57,7 @@ class RegistryExtension extends Model 'stripe_product_id', 'name', 'subtitle', + 'self_managed', 'payment_required', 'price', 'sale_price', @@ -90,6 +91,7 @@ class RegistryExtension extends Model * The attributes that should be cast to native types. */ protected $casts = [ + 'self_managed' => 'boolean', 'payment_required' => 'boolean', 'on_sale' => 'boolean', 'subscription_required' => 'boolean', @@ -121,6 +123,7 @@ class RegistryExtension extends Model 'publisher_name', 'is_purchased', 'is_installed', + 'is_author', ]; /** @@ -413,6 +416,14 @@ public function getPublisherNameAttribute(): ?string return data_get($this, 'company.name'); } + /** + * Determines if the current company session is the author of the extension. + */ + public function getIsAuthorAttribute(): bool + { + return $this->company_uuid === session('company'); + } + /** * Finds a RegistryExtension by package name in the associated currentBundle. * diff --git a/server/src/Models/RegistryExtensionBundle.php b/server/src/Models/RegistryExtensionBundle.php index 8a4dcd9..d76832c 100644 --- a/server/src/Models/RegistryExtensionBundle.php +++ b/server/src/Models/RegistryExtensionBundle.php @@ -688,7 +688,7 @@ public function runInstallerProgress(): void ]); // minimal latency - usleep(500 * rand(2, 4)); + usleep(50 * rand(1, 3)); } } } @@ -708,7 +708,7 @@ public function runUninstallerProgress(): void ]); // minimal latency - usleep(500 * rand(2, 4)); + usleep(50 * rand(1, 3)); } } } From 8b715aff4b75e6b56ae2aa6ac612257bd440a899 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Fri, 2 Aug 2024 15:49:14 +0800 Subject: [PATCH 2/5] added self managed flag and details to ui --- addon/components/extension-form.hbs | 14 ++++++++++- addon/components/extension-form.js | 7 +++--- addon/components/modals/extension-details.hbs | 23 +++++++++++++------ translations/en-us.yaml | 14 ++++++++++- 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/addon/components/extension-form.hbs b/addon/components/extension-form.hbs index 0169588..a4be355 100644 --- a/addon/components/extension-form.hbs +++ b/addon/components/extension-form.hbs @@ -69,7 +69,6 @@ + + + + {{t "registry-bridge.developers.extensions.extension-form.self-managed"}} + +

+ {{t "registry-bridge.developers.extensions.extension-form.self-managed-help-text"}} +

+
diff --git a/addon/components/extension-form.js b/addon/components/extension-form.js index 8fc094f..6dd80d1 100644 --- a/addon/components/extension-form.js +++ b/addon/components/extension-form.js @@ -19,8 +19,8 @@ export default class ExtensionFormComponent extends Component { type: 'link', size: 'xs', text: 'Preview Listing', - onClick: this.previewListing - } + onClick: this.previewListing, + }, ]; acceptedImageTypes = ['image/jpeg', 'image/png', 'image/gif']; acceptedBundleTypes = [ @@ -142,10 +142,9 @@ export default class ExtensionFormComponent extends Component { modalHeaderClass: 'flb--extension-modal-header', acceptButtonText: isPaymentRequired ? `Purchase for ${formatCurrency(extension.price, extension.currency)}` : isAlreadyInstalled ? 'Installed' : 'Install', acceptButtonIcon: isPaymentRequired ? 'credit-card' : isAlreadyInstalled ? 'check' : 'download', - acceptButtonDisabled: isAlreadyInstalled, + acceptButtonDisabled: true, acceptButtonScheme: isPaymentRequired ? 'success' : 'primary', declineButtonText: 'Done', - acceptButtonDisabled: true, extension, ...options, }); diff --git a/addon/components/modals/extension-details.hbs b/addon/components/modals/extension-details.hbs index 193ac39..b7de2cc 100644 --- a/addon/components/modals/extension-details.hbs +++ b/addon/components/modals/extension-details.hbs @@ -2,7 +2,7 @@