Skip to content

Modular logistics and supply chain operating system (LSOS)

Added Manual Verify for Users [IAM], Added ability to Transfer Org Ownership and Leave Orgs, Added `recovery` command, fixes and patches

Ronald A. Richardsonf1ee8b0c9952
diff --git a/api/composer.json b/api/composer.json
index ec1c88a7..7fff07e7 100644
--- a/api/composer.json
+++ b/api/composer.json
@@ -9,9 +9,9 @@
"license": "AGPL-3.0-or-later",
"require": {
"php": "^8.0",
- "fleetbase/core-api": "^1.5.10",
- "fleetbase/fleetops-api": "^0.5.8",
- "fleetbase/registry-bridge": "^0.0.15",
+ "fleetbase/core-api": "^1.5.11",
+ "fleetbase/fleetops-api": "^0.5.9",
+ "fleetbase/registry-bridge": "^0.0.16",
"fleetbase/storefront-api": "^0.3.15",
"guzzlehttp/guzzle": "^7.0.1",
"laravel/framework": "^10.0",
diff --git a/api/composer.lock b/api/composer.lock
index aad46f3e..8e99ce04 100644
--- a/api/composer.lock
+++ b/api/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "8cd3991d254e9330f7523dcf62ab21ab",
+ "content-hash": "8e4e82d71a9b40574bb3de8f8141c988",
"packages": [
{
"name": "aws/aws-crt-php",
@@ -62,16 +62,16 @@
},
{
"name": "aws/aws-sdk-php",
- "version": "3.323.2",
+ "version": "3.323.3",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
- "reference": "030b93340f0e7d6fd20276037087d3eab8f16575"
+ "reference": "9dec2a6453bdb32b3abeb475fc63b46ba1cbd996"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/030b93340f0e7d6fd20276037087d3eab8f16575",
- "reference": "030b93340f0e7d6fd20276037087d3eab8f16575",
+ "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/9dec2a6453bdb32b3abeb475fc63b46ba1cbd996",
+ "reference": "9dec2a6453bdb32b3abeb475fc63b46ba1cbd996",
"shasum": ""
},
"require": {
@@ -154,9 +154,9 @@
"support": {
"forum": "https://forums.aws.amazon.com/forum.jspa?forumID=80",
"issues": "https://github.com/aws/aws-sdk-php/issues",
- "source": "https://github.com/aws/aws-sdk-php/tree/3.323.2"
+ "source": "https://github.com/aws/aws-sdk-php/tree/3.323.3"
},
- "time": "2024-10-07T18:11:24+00:00"
+ "time": "2024-10-08T18:05:47+00:00"
},
{
"name": "aws/aws-sdk-php-laravel",
@@ -1919,16 +1919,16 @@
},
{
"name": "dragonmantank/cron-expression",
- "version": "v3.3.3",
+ "version": "v3.4.0",
"source": {
"type": "git",
"url": "https://github.com/dragonmantank/cron-expression.git",
- "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a"
+ "reference": "8c784d071debd117328803d86b2097615b457500"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/adfb1f505deb6384dc8b39804c5065dd3c8c8c0a",
- "reference": "adfb1f505deb6384dc8b39804c5065dd3c8c8c0a",
+ "url": "https://api.github.com/repos/dragonmantank/cron-expression/zipball/8c784d071debd117328803d86b2097615b457500",
+ "reference": "8c784d071debd117328803d86b2097615b457500",
"shasum": ""
},
"require": {
@@ -1941,10 +1941,14 @@
"require-dev": {
"phpstan/extension-installer": "^1.0",
"phpstan/phpstan": "^1.0",
- "phpstan/phpstan-webmozart-assert": "^1.0",
"phpunit/phpunit": "^7.0|^8.0|^9.0"
},
"type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
"autoload": {
"psr-4": {
"Cron\\": "src/Cron/"
@@ -1968,7 +1972,7 @@
],
"support": {
"issues": "https://github.com/dragonmantank/cron-expression/issues",
- "source": "https://github.com/dragonmantank/cron-expression/tree/v3.3.3"
+ "source": "https://github.com/dragonmantank/cron-expression/tree/v3.4.0"
},
"funding": [
{
@@ -1976,7 +1980,7 @@
"type": "github"
}
],
- "time": "2023-08-10T19:36:49+00:00"
+ "time": "2024-10-09T13:47:03+00:00"
},
{
"name": "edamov/pushok",
@@ -2295,16 +2299,16 @@
},
{
"name": "fleetbase/core-api",
- "version": "1.5.10",
+ "version": "1.5.11",
"source": {
"type": "git",
"url": "https://github.com/fleetbase/core-api.git",
- "reference": "cd750f8a98f448f4b3caaad1fb8ada1dbcc17f7b"
+ "reference": "41b0068c18b00c7305cf920c245f35052d905cc4"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/fleetbase/core-api/zipball/cd750f8a98f448f4b3caaad1fb8ada1dbcc17f7b",
- "reference": "cd750f8a98f448f4b3caaad1fb8ada1dbcc17f7b",
+ "url": "https://api.github.com/repos/fleetbase/core-api/zipball/41b0068c18b00c7305cf920c245f35052d905cc4",
+ "reference": "41b0068c18b00c7305cf920c245f35052d905cc4",
"shasum": ""
},
"require": {
@@ -2387,29 +2391,29 @@
],
"support": {
"issues": "https://github.com/fleetbase/core-api/issues",
- "source": "https://github.com/fleetbase/core-api/tree/v1.5.10"
+ "source": "https://github.com/fleetbase/core-api/tree/v1.5.11"
},
- "time": "2024-10-08T12:15:58+00:00"
+ "time": "2024-10-09T16:24:17+00:00"
},
{
"name": "fleetbase/fleetops-api",
- "version": "0.5.8",
+ "version": "0.5.9",
"source": {
"type": "git",
"url": "https://github.com/fleetbase/fleetops.git",
- "reference": "09487c1c508c6c493af28f81786e0208d3005580"
+ "reference": "8a40f529dd5e65d971b21a560b0f1feb05cd7623"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/fleetbase/fleetops/zipball/09487c1c508c6c493af28f81786e0208d3005580",
- "reference": "09487c1c508c6c493af28f81786e0208d3005580",
+ "url": "https://api.github.com/repos/fleetbase/fleetops/zipball/8a40f529dd5e65d971b21a560b0f1feb05cd7623",
+ "reference": "8a40f529dd5e65d971b21a560b0f1feb05cd7623",
"shasum": ""
},
"require": {
"barryvdh/laravel-dompdf": "^2.0",
"brick/geo": "0.7.2",
"cknow/laravel-money": "^7.1",
- "fleetbase/core-api": "^1.5.9",
+ "fleetbase/core-api": "*",
"geocoder-php/google-maps-places-provider": "^1.4",
"giggsey/libphonenumber-for-php": "^8.13",
"league/geotools": "^1.1.0",
@@ -2476,9 +2480,9 @@
],
"support": {
"issues": "https://github.com/fleetbase/fleetops/issues",
- "source": "https://github.com/fleetbase/fleetops/tree/v0.5.8"
+ "source": "https://github.com/fleetbase/fleetops/tree/v0.5.9"
},
- "time": "2024-10-02T09:56:23+00:00"
+ "time": "2024-10-09T16:31:28+00:00"
},
{
"name": "fleetbase/laravel-mysql-spatial",
@@ -2548,16 +2552,16 @@
},
{
"name": "fleetbase/registry-bridge",
- "version": "0.0.15",
+ "version": "0.0.16",
"source": {
"type": "git",
"url": "https://github.com/fleetbase/registry-bridge.git",
- "reference": "2554590451be756460ef76dda73dcbd349879821"
+ "reference": "2f9a2533c0e18567bd66f463ef74bf48e4d84af1"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/fleetbase/registry-bridge/zipball/2554590451be756460ef76dda73dcbd349879821",
- "reference": "2554590451be756460ef76dda73dcbd349879821",
+ "url": "https://api.github.com/repos/fleetbase/registry-bridge/zipball/2f9a2533c0e18567bd66f463ef74bf48e4d84af1",
+ "reference": "2f9a2533c0e18567bd66f463ef74bf48e4d84af1",
"shasum": ""
},
"require": {
@@ -2624,9 +2628,9 @@
],
"support": {
"issues": "https://github.com/fleetbase/registry-bridge/issues",
- "source": "https://github.com/fleetbase/registry-bridge/tree/v0.0.15"
+ "source": "https://github.com/fleetbase/registry-bridge/tree/v0.0.16"
},
- "time": "2024-10-08T12:52:39+00:00"
+ "time": "2024-10-08T14:18:13+00:00"
},
{
"name": "fleetbase/storefront-api",
@@ -5666,16 +5670,16 @@
},
{
"name": "laravel/octane",
- "version": "v2.5.8",
+ "version": "v2.5.9",
"source": {
"type": "git",
"url": "https://github.com/laravel/octane.git",
- "reference": "ce37959546cf5e04df02aa41960f3ee816670b9b"
+ "reference": "d8d432eb1e51a8ab2575854963d94e70d4592e15"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/octane/zipball/ce37959546cf5e04df02aa41960f3ee816670b9b",
- "reference": "ce37959546cf5e04df02aa41960f3ee816670b9b",
+ "url": "https://api.github.com/repos/laravel/octane/zipball/d8d432eb1e51a8ab2575854963d94e70d4592e15",
+ "reference": "d8d432eb1e51a8ab2575854963d94e70d4592e15",
"shasum": ""
},
"require": {
@@ -5752,7 +5756,7 @@
"issues": "https://github.com/laravel/octane/issues",
"source": "https://github.com/laravel/octane"
},
- "time": "2024-10-01T21:03:50+00:00"
+ "time": "2024-10-06T21:09:20+00:00"
},
{
"name": "laravel/prompts",
@@ -7687,16 +7691,16 @@
},
{
"name": "nikic/php-parser",
- "version": "v5.3.0",
+ "version": "v5.3.1",
"source": {
"type": "git",
"url": "https://github.com/nikic/PHP-Parser.git",
- "reference": "3abf7425cd284141dc5d8d14a9ee444de3345d1a"
+ "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/3abf7425cd284141dc5d8d14a9ee444de3345d1a",
- "reference": "3abf7425cd284141dc5d8d14a9ee444de3345d1a",
+ "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/8eea230464783aa9671db8eea6f8c6ac5285794b",
+ "reference": "8eea230464783aa9671db8eea6f8c6ac5285794b",
"shasum": ""
},
"require": {
@@ -7739,9 +7743,9 @@
],
"support": {
"issues": "https://github.com/nikic/PHP-Parser/issues",
- "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.0"
+ "source": "https://github.com/nikic/PHP-Parser/tree/v5.3.1"
},
- "time": "2024-09-29T13:56:26+00:00"
+ "time": "2024-10-08T18:51:32+00:00"
},
{
"name": "nunomaduro/termwind",
@@ -15514,16 +15518,16 @@
},
{
"name": "laravel/sail",
- "version": "v1.34.0",
+ "version": "v1.35.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/sail.git",
- "reference": "511e9c95b0f3ee778dc9e11e242bcd2af8e002cd"
+ "reference": "992bc2d9e52174c79515967f30849d21daa334d8"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/laravel/sail/zipball/511e9c95b0f3ee778dc9e11e242bcd2af8e002cd",
- "reference": "511e9c95b0f3ee778dc9e11e242bcd2af8e002cd",
+ "url": "https://api.github.com/repos/laravel/sail/zipball/992bc2d9e52174c79515967f30849d21daa334d8",
+ "reference": "992bc2d9e52174c79515967f30849d21daa334d8",
"shasum": ""
},
"require": {
@@ -15573,7 +15577,7 @@
"issues": "https://github.com/laravel/sail/issues",
"source": "https://github.com/laravel/sail"
},
- "time": "2024-09-27T14:58:09+00:00"
+ "time": "2024-10-08T14:45:26+00:00"
},
{
"name": "mockery/mockery",
@@ -16318,16 +16322,16 @@
},
{
"name": "phpunit/phpunit",
- "version": "10.5.35",
+ "version": "10.5.36",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
- "reference": "7ac8b4e63f456046dcb4c9787da9382831a1874b"
+ "reference": "aa0a8ce701ea7ee314b0dfaa8970dc94f3f8c870"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/7ac8b4e63f456046dcb4c9787da9382831a1874b",
- "reference": "7ac8b4e63f456046dcb4c9787da9382831a1874b",
+ "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/aa0a8ce701ea7ee314b0dfaa8970dc94f3f8c870",
+ "reference": "aa0a8ce701ea7ee314b0dfaa8970dc94f3f8c870",
"shasum": ""
},
"require": {
@@ -16399,7 +16403,7 @@
"support": {
"issues": "https://github.com/sebastianbergmann/phpunit/issues",
"security": "https://github.com/sebastianbergmann/phpunit/security/policy",
- "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.35"
+ "source": "https://github.com/sebastianbergmann/phpunit/tree/10.5.36"
},
"funding": [
{
@@ -16415,7 +16419,7 @@
"type": "tidelift"
}
],
- "time": "2024-09-19T10:52:21+00:00"
+ "time": "2024-10-08T15:36:51+00:00"
},
{
"name": "sebastian/cli-parser",
diff --git a/console/app/components/modals/edit-organization.hbs b/console/app/components/modals/edit-organization.hbs
new file mode 100644
index 00000000..66b1b37b
--- /dev/null
+++ b/console/app/components/modals/edit-organization.hbs
@@ -0,0 +1,12 @@
+<Modal::Default @modalIsOpened={{@modalIsOpened}} @options={{@options}} @confirm={{@onConfirm}} @decline={{@onDecline}}>
+ <div class="modal-body-container pt-0i text-gray-900 dark:text-white">
+ <InputGroup @name="Organization name" @value={{@options.organization.name}} />
+ <InputGroup @name="Organization description" @value={{@options.organization.description}} />
+ <InputGroup @name="Organization phone number">
+ <PhoneInput @value={{@options.organization.phone}} @onInput={{fn (mut @options.organization.phone)}} class="form-input w-full" />
+ </InputGroup>
+ <InputGroup @name="Organization currency">
+ <CurrencySelect @value={{@options.organization.currency}} @onSelect={{fn (mut @options.organization.currency)}} @triggerClass="w-full form-select" />
+ </InputGroup>
+ </div>
+</Modal::Default>
\ No newline at end of file
diff --git a/console/app/components/modals/edit-organization.js b/console/app/components/modals/edit-organization.js
new file mode 100644
index 00000000..a2883b2b
--- /dev/null
+++ b/console/app/components/modals/edit-organization.js
@@ -0,0 +1,3 @@
+import Component from '@glimmer/component';
+
+export default class ModalsEditOrganizationComponent extends Component {}
diff --git a/console/app/components/modals/leave-organization.hbs b/console/app/components/modals/leave-organization.hbs
new file mode 100644
index 00000000..0298dcce
--- /dev/null
+++ b/console/app/components/modals/leave-organization.hbs
@@ -0,0 +1,43 @@
+<Modal::Default @modalIsOpened={{@modalIsOpened}} @options={{@options}} @confirm={{@onConfirm}} @decline={{@onDecline}}>
+ <div class="modal-body-container pt-0i text-gray-900 dark:text-white">
+ {{#if @options.isOwner}}
+ {{#if @options.hasOtherMembers}}
+ <p>
+ <div class="text-base mb-2">
+ As the owner of
+ <strong>{{@options.organization.name}}</strong>, leaving the organization requires you to nominate a new owner.
+ </div>
+ <div>Please select a member from the dropdown below to transfer ownership before you can proceed.</div>
+ </p>
+ <InputGroup @name="Select a New Owner" @wrapperClass="mt-2 mb-0i">
+ <Select
+ @options={{@options.organization.users}}
+ @value={{@options.newOwnerId}}
+ @onSelect={{@options.selectNewOwner}}
+ @optionLabel="name"
+ @optionValue="id"
+ @placeholder="Select a member"
+ />
+ </InputGroup>
+ {{else if @options.willBeDeleted}}
+ <p>
+ <div class="text-base mb-2">
+ You are the sole owner of
+ <strong>{{@options.organization.name}}</strong>.
+ </div>
+ <div>By leaving, the organization will be permanently deleted along with all its data.</div>
+ <div>Are you sure you want to proceed?</div>
+ </p>
+ <p class="mt-3"><em>This action cannot be undone.</em></p>
+ {{/if}}
+ {{else}}
+ <p>
+ <div class="text-base mb-2">
+ Are you sure you want to leave the organization
+ <strong>{{@options.organization.name}}</strong>?
+ </div>
+ <div>You will no longer have access to its resources and settings.</div>
+ </p>
+ {{/if}}
+ </div>
+</Modal::Default>
\ No newline at end of file
diff --git a/console/app/components/modals/leave-organization.js b/console/app/components/modals/leave-organization.js
new file mode 100644
index 00000000..78257e8f
--- /dev/null
+++ b/console/app/components/modals/leave-organization.js
@@ -0,0 +1,3 @@
+import Component from '@glimmer/component';
+
+export default class ModalsLeaveOrganizationComponent extends Component {}
diff --git a/console/app/controllers/console/account/organizations.js b/console/app/controllers/console/account/organizations.js
new file mode 100644
index 00000000..42217cd1
--- /dev/null
+++ b/console/app/controllers/console/account/organizations.js
@@ -0,0 +1,143 @@
+import Controller from '@ember/controller';
+import { inject as service } from '@ember/service';
+import { action } from '@ember/object';
+import { later } from '@ember/runloop';
+import { htmlSafe } from '@ember/template';
+
+export default class ConsoleAccountOrganizationsController extends Controller {
+ @service currentUser;
+ @service modalsManager;
+ @service crud;
+ @service notifications;
+ @service intl;
+ @service fetch;
+
+ @action async leaveOrganization (organization) {
+ const isOwner = this.currentUser.id === organization.owner_uuid;
+ const hasOtherMembers = organization.users_count > 1;
+ const willBeDeleted = isOwner && organization.users_count === 1;
+
+ if (hasOtherMembers) {
+ organization.loadUsers({ exclude: [this.currentUser.id] });
+ }
+
+ this.modalsManager.show('modals/leave-organization', {
+ title: isOwner ? (willBeDeleted ? 'Delete Organization' : 'Transfer Ownership and Leave') : 'Leave Organization',
+ acceptButtonText: isOwner ? (willBeDeleted ? 'Delete Organization' : 'Transfer Ownership and Leave') : 'Leave Organization',
+ acceptButtonScheme: 'danger',
+ acceptButtonIcon: isOwner ? (willBeDeleted ? 'trash' : 'person-walking-arrow-right') : 'person-walking-arrow-right',
+ acceptButtonDisabled: isOwner && hasOtherMembers,
+ isOwner,
+ hasOtherMembers,
+ willBeDeleted,
+ organization,
+ newOwnerId: null,
+ selectNewOwner: (newOwnerId) => {
+ this.modalsManager.setOption('newOwnerId', newOwnerId);
+ this.modalsManager.setOption('acceptButtonDisabled', false);
+ },
+ confirm: async modal => {
+ modal.startLoading();
+
+ if (isOwner) {
+ if (hasOtherMembers) {
+ const newOwnerId = this.modalsManager.getOption('newOwnerId');
+ try {
+ await organization.transferOwnership(newOwnerId, { leave: true });
+ } catch (error) {
+ this.notifications.serverError(error);
+ }
+ return modal.done();
+ }
+
+ if (willBeDeleted) {
+ try {
+ await organization.delete();
+ } catch (error) {
+ this.notifications.serverError(error);
+ }
+ return modal.done();
+ }
+ }
+
+ try {
+ await organization.leave();
+ } catch (error) {
+ this.notifications.serverError(error);
+ }
+
+ return modal.done();
+ },
+ });
+ }
+
+ @action switchOrganization (organization) {
+ this.modalsManager.confirm({
+ title: this.intl.t('console.switch-organization.modal-title', { organizationName: organization.name }),
+ body: this.intl.t('console.switch-organization.modal-body'),
+ acceptButtonText: this.intl.t('console.switch-organization.modal-accept-button-text'),
+ acceptButtonScheme: 'primary',
+ confirm: async modal => {
+ modal.startLoading();
+
+ try {
+ await this.fetch.post('auth/switch-organization', { next: organization.uuid });
+ this.fetch.flushRequestCache('auth/organizations');
+ this.notifications.success(this.intl.t('console.switch-organization.success-notification'));
+ return later(
+ this,
+ () => {
+ window.location.reload();
+ },
+ 900
+ );
+ } catch (error) {
+ modal.stopLoading();
+ return this.notifications.serverError(error);
+ }
+ },
+ });
+ }
+
+ @action deleteOrganization (organization) {
+ const isOwner = this.currentUser.id === organization.owner_uuid;
+
+ if (this.model.length === 1) {
+ return this.notifications.warning('Unable to delete your only organization.');
+ }
+
+ if (!isOwner) {
+ return this.notifications.warning('You do not have rights to delete this organization.');
+ }
+
+ this.crud.delete(organization, {
+ title: `Are you sure you want to delete the organization ${organization.name}?`,
+ body: htmlSafe(
+ `This action will permanently remove all data, including orders, members, and settings associated with the organization. <br /><br /><strong>This action cannot be undone.</strong>`
+ ),
+ acceptButtonText: 'Delete Organization',
+ acceptButtonScheme: 'danger',
+ acceptButtonIcon: 'trash',
+ confirm: () => {
+ modal.startLoading();
+
+ return organization.delete();
+ },
+ });
+ }
+
+ @action editOrganization (organization) {
+ this.modalsManager.show('modals/edit-organization', {
+ title: 'Edit Organization',
+ acceptButtonText: 'Save Changes',
+ acceptButtonIcon: 'save',
+ isOwner: this.currentUser.id === organization.owner_uuid,
+ organization,
+ confirm: (modal) => {
+ modal.startLoading();
+
+ return organization.save();
+ },
+ });
+ }
+}
diff --git a/console/app/instance-initializers/load-extensions.js b/console/app/instance-initializers/load-extensions.js
index 7bcb7f5c..b262162e 100644
--- a/console/app/instance-initializers/load-extensions.js
+++ b/console/app/instance-initializers/load-extensions.js
@@ -1,4 +1,4 @@
-export function initialize (application) {
+export function initialize(application) {
const universe = application.lookup('service:universe');
if (universe) {
universe.createRegistries(['@fleetbase/console', 'auth:login']);
diff --git a/console/app/models/company.js b/console/app/models/company.js
index af3368ec..c263c19f 100644
--- a/console/app/models/company.js
+++ b/console/app/models/company.js
@@ -1,5 +1,6 @@
import Model, { attr, belongsTo } from '@ember-data/model';
import { computed } from '@ember/object';
+import { getOwner } from '@ember/application';
import { format, formatDistanceToNow } from 'date-fns';
import autoSerialize from '../utils/auto-serialize';
@@ -34,41 +35,70 @@ export default class Company extends Model {
@attr('string') slug;
/** @dates */
+ @attr('date') joined_at;
@attr('date') deleted_at;
@attr('date') created_at;
@attr('date') updated_at;
/** @computed */
- @computed('phone_country_code', 'country') get phoneCountryCode() {
+ @computed('phone_country_code', 'country') get phoneCountryCode () {
return this.phone_country_code || this.country;
}
- @computed('updated_at') get updatedAgo() {
+ @computed('updated_at') get updatedAgo () {
return formatDistanceToNow(this.updated_at);
}
- @computed('updated_at') get updatedAt() {
+ @computed('updated_at') get updatedAt () {
return format(this.updated_at, 'PPP p');
}
- @computed('updated_at') get updatedAtShort() {
+ @computed('updated_at') get updatedAtShort () {
return format(this.updated_at, 'PP');
}
- @computed('created_at') get createdAgo() {
+ @computed('created_at') get createdAgo () {
return formatDistanceToNow(this.created_at);
}
- @computed('created_at') get createdAt() {
+ @computed('created_at') get createdAt () {
return format(this.created_at, 'PPP p');
}
- @computed('created_at') get createdAtShort() {
+ @computed('created_at') get createdAtShort () {
return format(this.created_at, 'PP');
}
/** @methods */
- toJSON() {
+ toJSON () {
return autoSerialize(this);
}
+
+ async transferOwnership (newOwner, params = {}) {
+ const owner = getOwner(this);
+ const fetch = owner.lookup('service:fetch');
+
+ return fetch.post('companies/transfer-ownership', { company: this.id, newOwner, ...params });
+ }
+
+ async leave (user = null, params = {}) {
+ const owner = getOwner(this);
+ const fetch = owner.lookup('service:fetch');
+
+ return fetch.post('companies/leave', { company: this.id, user, ...params });
+ }
+
+ async loadUsers (params = {}) {
+ const owner = getOwner(this);
+ const fetch = owner.lookup('service:fetch');
+
+ try {
+ const users = await fetch.get(`companies/${this.id}/users`, { ...params }, { normalizeToEmberData: true, normalizeModelType: 'user' });
+ this.set('users', users);
+ return users;
+ } catch (error) {
+ this.set('users', []);
+ return [];
+ }
+ }
}
diff --git a/console/app/models/user.js b/console/app/models/user.js
index 889b934f..860e91b8 100644
--- a/console/app/models/user.js
+++ b/console/app/models/user.js
@@ -69,6 +69,17 @@ export default class UserModel extends Model {
});
}
+ verify() {
+ const owner = getOwner(this);
+ const fetch = owner.lookup('service:fetch');
+
+ return fetch.patch(`users/verify/${this.id}`).then((response) => {
+ this.email_verified_at = response.email_verified_at;
+
+ return response;
+ });
+ }
+
removeFromCurrentCompany() {
const owner = getOwner(this);
const fetch = owner.lookup('service:fetch');
diff --git a/console/app/routes/application.js b/console/app/routes/application.js
index 1d932e56..d5c596c2 100644
--- a/console/app/routes/application.js
+++ b/console/app/routes/application.js
@@ -18,13 +18,12 @@ export default class ApplicationRoute extends Route {
@tracked defaultTheme;
/**
- * The application loading event.
- * Here will just run extension hooks.
+ * Handle the transition into the application.
*
* @memberof ApplicationRoute
*/
- @action loading (transition) {
- this.universe.callHooks('application:loading', this.session, this.router, transition);
+ @action willTransition(transition) {
+ this.universe.callHooks('application:will-transition', this.session, this.router, transition);
}
/**
@@ -38,6 +37,16 @@ export default class ApplicationRoute extends Route {
this.initializeLocale();
}
+ /**
+ * The application loading event.
+ * Here will just run extension hooks.
+ *
+ * @memberof ApplicationRoute
+ */
+ @action loading(transition) {
+ this.universe.callHooks('application:loading', this.session, this.router, transition);
+ }
+
/**
* Check the installation status of Fleetbase and transition user accordingly.
*
diff --git a/console/app/routes/console/account/organizations.js b/console/app/routes/console/account/organizations.js
new file mode 100644
index 00000000..947e9103
--- /dev/null
+++ b/console/app/routes/console/account/organizations.js
@@ -0,0 +1,10 @@
+import Route from '@ember/routing/route';
+import { inject as service } from '@ember/service';
+
+export default class ConsoleAccountOrganizationsRoute extends Route {
+ @service currentUser;
+
+ model() {
+ return this.currentUser.organizations;
+ }
+}
diff --git a/console/app/templates/console/account.hbs b/console/app/templates/console/account.hbs
index 540af9b2..2f4e68d0 100644
--- a/console/app/templates/console/account.hbs
+++ b/console/app/templates/console/account.hbs
@@ -3,6 +3,7 @@
<Layout::Sidebar::Panel @open={{true}} @title={{t "common.account"}}>
<Layout::Sidebar::Item @route="console.account.index" @icon="user">Profile</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.account.auth" @icon="key">Auth</Layout::Sidebar::Item>
+ <Layout::Sidebar::Item @route="console.account.organizations" @icon="building">Organizations</Layout::Sidebar::Item>
{{#each this.universe.accountMenuItems as |menuItem|}}
<Layout::Sidebar::Item @onClick={{fn this.universe.transitionMenuItem "console.account.virtual" menuItem}} @item={{menuItem}} @icon={{menuItem.icon}}>{{menuItem.title}}</Layout::Sidebar::Item>
{{/each}}
diff --git a/console/app/templates/console/account/organizations.hbs b/console/app/templates/console/account/organizations.hbs
new file mode 100644
index 00000000..67e03105
--- /dev/null
+++ b/console/app/templates/console/account/organizations.hbs
@@ -0,0 +1,34 @@
+{{page-title "Organizations"}}
+<Layout::Section::Header @title="Organizations" />
+
+<Layout::Section::Body class="overflow-y-scroll h-full">
+ <div class="container mx-auto h-screen">
+ <div class="max-w-3xl my-10 mx-auto space-y-6">
+ <ContentPanel @title="Your Organizations" @open={{true}} @pad={{true}} @panelBodyClass="bg-white dark:bg-gray-800">
+ <div class="space-y-2">
+ {{#each @model as |organization|}}
+ <div class="grid grid-cols-3 border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-900 rounded-lg px-3 py-2 items-center">
+ <div>
+ <div class="font-semibold">{{organization.name}}</div>
+ <div>Member Since: {{format-date organization.joined_at}}</div>
+ </div>
+ <div class="col-span-2 flex flex-row items-center justify-end space-x-2">
+ {{#let (eq organization.owner_uuid this.currentUser.id) as |isOwner|}}
+ <Button @type="danger" @size="xs" @icon="person-walking-arrow-right" @text="Leave" @onClick={{fn this.leaveOrganization organization}} />
+ {{#unless (eq this.currentUser.companyId organization.id)}}
+ <Button @size="xs" @icon="shuffle" @text="Switch" @onClick={{fn this.switchOrganization organization}} />
+ {{/unless}}
+ {{#if isOwner}}
+ <Button @size="xs" @icon="pencil" @text="Edit" @onClick={{fn this.editOrganization organization}} />
+ <Button @type="danger" @size="xs" @icon="trash" @text="Delete" @onClick={{fn this.deleteOrganization organization}} />
+ {{/if}}
+ {{/let}}
+ </div>
+ </div>
+ {{/each}}
+ </div>
+ </ContentPanel>
+ </div>
+ </div>
+ <Spacer @height="300px" />
+</Layout::Section::Body>
\ No newline at end of file
diff --git a/console/package.json b/console/package.json
index f3cfd87b..31d551ac 100644
--- a/console/package.json
+++ b/console/package.json
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/console",
- "version": "0.5.10",
+ "version": "0.5.11",
"private": true,
"description": "Modular logistics and supply chain operating system (LSOS)",
"repository": "https://github.com/fleetbase/fleetbase",
@@ -33,10 +33,10 @@
"@fleetbase/ember-core": "^0.2.21",
"@fleetbase/ember-ui": "^0.2.34",
"@fleetbase/fleetops-data": "^0.1.18",
- "@fleetbase/fleetops-engine": "^0.5.8",
- "@fleetbase/iam-engine": "^0.1.1",
+ "@fleetbase/fleetops-engine": "^0.5.9",
+ "@fleetbase/iam-engine": "^0.1.2",
"@fleetbase/leaflet-routing-machine": "^3.2.16",
- "@fleetbase/registry-bridge-engine": "^0.0.15",
+ "@fleetbase/registry-bridge-engine": "^0.0.16",
"@fleetbase/storefront-engine": "^0.3.15",
"@fortawesome/ember-fontawesome": "^2.0.0",
"ember-changeset": "^4.1.2",
diff --git a/console/pnpm-lock.yaml b/console/pnpm-lock.yaml
index b94b3076..2a879976 100644
--- a/console/pnpm-lock.yaml
+++ b/console/pnpm-lock.yaml
@@ -29,17 +29,17 @@ importers:
specifier: ^0.1.18
'@fleetbase/fleetops-engine':
- specifier: ^0.5.8
+ specifier: ^0.5.9
'@fleetbase/iam-engine':
- specifier: ^0.1.1
+ specifier: ^0.1.2
'@fleetbase/leaflet-routing-machine':
specifier: ^3.2.16
version: 3.2.16
'@fleetbase/registry-bridge-engine':
- specifier: ^0.0.15
+ specifier: ^0.0.16
'@fleetbase/storefront-engine':
specifier: ^0.3.15
@@ -1558,14 +1558,14 @@ packages:
resolution: {integrity: sha512-SBiL992igloYgEGMbUX65uW95nv8k32u2QSoqVm7HrWfhCwMEeHubEOA916otDkBalkHNSE6QgWigaJDMNnW4A==}
engines: {node: '>= 18'}
- '@fleetbase/[email protected]':
- resolution: {integrity: sha512-UCvj5lZlLEzD1bQnXedzaNnJcoKF1Y4qkfwTGd9+6eVZ6dymLnSLAyqVUhC0lPFt+UE2QkmZU8gieCcoh1Z2nQ==}
+ '@fleetbase/[email protected]':
+ resolution: {integrity: sha512-TGc2p4ZeY+w7PazEpx1jYI/hCajzVJav0GqqRAtCFHyKZ96AUir7Qdu5MTvEUp+yiilzn+GG0HjrvGctUQKnQA==}
engines: {node: '>= 18'}
peerDependencies:
ember-engines: ^0.9.0
- '@fleetbase/[email protected]':
- resolution: {integrity: sha512-T8OGEYyAMaSXPffE3VTBDUYhF61am1zBUIvLcl3DCjyWIfOoL7jM+Gmipsys7hRzsmGn4CaeOv4UG6duhSLsWA==}
+ '@fleetbase/[email protected]':
+ resolution: {integrity: sha512-+uaxdmIZBQOUUy6XsonN4LC2evZ0C1L7gdAx4uSC4uDy6uXUrRIvAmxN9eYshlOzc2vXTeL8hMdQo1NCyMEdoA==}
engines: {node: '>= 18'}
peerDependencies:
ember-engines: ^0.9.0
@@ -1577,8 +1577,8 @@ packages:
'@fleetbase/[email protected]':
resolution: {integrity: sha512-af0mKH3VKIGEfYEGXS9cedhgniwgkNwjC/Gp9ZEzXGTX2/13PyMdd1XOQTamaItPbh5x2uK2/n1BP0vIJ7ObEQ==}
- '@fleetbase/[email protected]':
- resolution: {integrity: sha512-muTFXgcNuJQXAF25gbUw1joqfFUWAbScASJPCN79IA2JXTTucJ/BAql1biK3mvykHkPC4sARE5j0uPkAUuhhQA==}
+ '@fleetbase/[email protected]':
+ resolution: {integrity: sha512-/AOmULGSPBI4gQYe4TjPee7b+g/rBCeaK1ORJevsKjP7VATE0ciL8c0rW2ZjosmPmk3+Tn5HB5i6M7MXEfv0YQ==}
engines: {node: '>= 18'}
peerDependencies:
ember-engines: ^0.9.0
@@ -10617,7 +10617,7 @@ snapshots:
- utf-8-validate
- webpack
dependencies:
'@babel/core': 7.25.7
@@ -10673,7 +10673,7 @@ snapshots:
- webpack-cli
- webpack-command
dependencies:
'@babel/core': 7.25.7
@@ -10727,7 +10727,7 @@ snapshots:
'@mapbox/polyline': 0.2.0
osrm-text-instructions: 0.13.4
dependencies:
'@babel/core': 7.25.7
diff --git a/console/router.map.js b/console/router.map.js
index 136b8077..bfcd2e51 100644
--- a/console/router.map.js
+++ b/console/router.map.js
@@ -30,6 +30,7 @@ Router.map(function () {
this.route('account', function () {
this.route('virtual', { path: '/:slug' });
this.route('auth');
+ this.route('organizations');
});
this.route('settings', function () {
this.route('virtual', { path: '/:slug' });
@@ -62,5 +63,4 @@ Router.map(function () {
});
});
this.route('catch', { path: '/*' });
-
});
diff --git a/console/tests/integration/components/modals/edit-organization-test.js b/console/tests/integration/components/modals/edit-organization-test.js
new file mode 100644
index 00000000..c30e0bbc
--- /dev/null
+++ b/console/tests/integration/components/modals/edit-organization-test.js
@@ -0,0 +1,26 @@
+import { module, test } from 'qunit';
+import { setupRenderingTest } from '@fleetbase/console/tests/helpers';
+import { render } from '@ember/test-helpers';
+import { hbs } from 'ember-cli-htmlbars';
+
+module('Integration | Component | modals/edit-organization', function (hooks) {
+ setupRenderingTest(hooks);
+
+ test('it renders', async function (assert) {
+ // Set any properties with this.set('myProperty', 'value');
+ // Handle any actions with this.set('myAction', function(val) { ... });
+
+ await render(hbs`<Modals::EditOrganization />`);
+
+ assert.dom().hasText('');
+
+ // Template block usage:
+ await render(hbs`
+ <Modals::EditOrganization>
+ template block text
+ </Modals::EditOrganization>
+ `);
+
+ assert.dom().hasText('template block text');
+ });
+});
diff --git a/console/tests/integration/components/modals/leave-organization-test.js b/console/tests/integration/components/modals/leave-organization-test.js
new file mode 100644
index 00000000..81fec47b
--- /dev/null
+++ b/console/tests/integration/components/modals/leave-organization-test.js
@@ -0,0 +1,26 @@
+import { module, test } from 'qunit';
+import { setupRenderingTest } from '@fleetbase/console/tests/helpers';
+import { render } from '@ember/test-helpers';
+import { hbs } from 'ember-cli-htmlbars';
+
+module('Integration | Component | modals/leave-organization', function (hooks) {
+ setupRenderingTest(hooks);
+
+ test('it renders', async function (assert) {
+ // Set any properties with this.set('myProperty', 'value');
+ // Handle any actions with this.set('myAction', function(val) { ... });
+
+ await render(hbs`<Modals::LeaveOrganization />`);
+
+ assert.dom().hasText('');
+
+ // Template block usage:
+ await render(hbs`
+ <Modals::LeaveOrganization>
+ template block text
+ </Modals::LeaveOrganization>
+ `);
+
+ assert.dom().hasText('template block text');
+ });
+});
diff --git a/console/tests/unit/controllers/console/account/organizations-test.js b/console/tests/unit/controllers/console/account/organizations-test.js
new file mode 100644
index 00000000..cadeeed2
--- /dev/null
+++ b/console/tests/unit/controllers/console/account/organizations-test.js
@@ -0,0 +1,12 @@
+import { module, test } from 'qunit';
+import { setupTest } from '@fleetbase/console/tests/helpers';
+
+module('Unit | Controller | console/account/organizations', function (hooks) {
+ setupTest(hooks);
+
+ // TODO: Replace this with your real tests.
+ test('it exists', function (assert) {
+ let controller = this.owner.lookup('controller:console/account/organizations');
+ assert.ok(controller);
+ });
+});
diff --git a/console/tests/unit/routes/console/account/organizations-test.js b/console/tests/unit/routes/console/account/organizations-test.js
new file mode 100644
index 00000000..78d72fe2
--- /dev/null
+++ b/console/tests/unit/routes/console/account/organizations-test.js
@@ -0,0 +1,11 @@
+import { module, test } from 'qunit';
+import { setupTest } from '@fleetbase/console/tests/helpers';
+
+module('Unit | Route | console/account/organizations', function (hooks) {
+ setupTest(hooks);
+
+ test('it exists', function (assert) {
+ let route = this.owner.lookup('route:console/account/organizations');
+ assert.ok(route);
+ });
+});
diff --git a/packages/core-api b/packages/core-api
index cd750f8a..41b0068c 160000
--- a/packages/core-api
+++ b/packages/core-api
@@ -1 +1 @@
-Subproject commit cd750f8a98f448f4b3caaad1fb8ada1dbcc17f7b
+Subproject commit 41b0068c18b00c7305cf920c245f35052d905cc4
diff --git a/packages/fleetops b/packages/fleetops
index 09487c1c..8a40f529 160000
--- a/packages/fleetops
+++ b/packages/fleetops
@@ -1 +1 @@
-Subproject commit 09487c1c508c6c493af28f81786e0208d3005580
+Subproject commit 8a40f529dd5e65d971b21a560b0f1feb05cd7623
diff --git a/packages/iam-engine b/packages/iam-engine
index 23dec1cd..030d25df 160000
--- a/packages/iam-engine
+++ b/packages/iam-engine
@@ -1 +1 @@
-Subproject commit 23dec1cda5c2f8a48d6ab6948a222997ae565081
+Subproject commit 030d25dfb6ebbe0bc1b1db14350ee58dc0187a58