Skip to content

Commit

Permalink
Merge pull request #1 from fleetbase/dev-v0.0.2
Browse files Browse the repository at this point in the history
v0.0.2
  • Loading branch information
roncodes authored Jul 18, 2024
2 parents 83ec76b + 136a981 commit 6efdac2
Show file tree
Hide file tree
Showing 22 changed files with 648 additions and 79 deletions.
5 changes: 5 additions & 0 deletions addon/components/modals/create-registry-credentials.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<Modal::Default @modalIsOpened={{@modalIsOpened}} @options={{@options}} @confirm={{@onConfirm}} @decline={{@onDecline}}>
<div class="modal-body-container">
<InputGroup @name="Password" @helpText="You must authenticate using your password." @placeholder="Enter your password" @value={{@options.password}} @type="password" />
</div>
</Modal::Default>
106 changes: 106 additions & 0 deletions addon/controllers/developers/credentials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
import Controller from '@ember/controller';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';

export default class DevelopersCredentialsController extends Controller {
@service modalsManager;
@service notifications;
@service hostRouter;
@service fetch;

columns = [
{
label: 'Owner',
valuePath: 'user.name',
width: '15%',
},
{
label: 'Fleetbase Token',
valuePath: 'token',
cellComponent: 'click-to-copy',
width: '20%',
},
{
label: 'Registry Token',
valuePath: 'registry_token',
cellComponent: 'click-to-reveal',
cellComponentArgs: {
clickToCopy: true,
},
width: '25%',
},
{
label: 'Expiry',
valuePath: 'expires_at',
width: '15%',
},
{
label: 'Created',
valuePath: 'created_at',
width: '15%',
},
{
label: '',
cellComponent: 'table/cell/dropdown',
ddButtonText: false,
ddButtonIcon: 'ellipsis-h',
ddButtonIconPrefix: 'fas',
ddMenuLabel: 'Credential Actions',
cellClassNames: 'overflow-visible',
wrapperClass: 'flex items-center justify-end mx-2',
width: '10%',
align: 'right',
actions: [
{
label: 'Delete Credentials',
fn: this.deleteCredentials,
className: 'text-red-700 hover:text-red-800',
},
],
},
];

@action deleteCredentials(credentials) {
this.modalsManager.confirm({
title: 'Delete extension registry credentials?',
body: 'Are you sure you wish to delete these credentials? Once deleted any service or user using these credentials will loose access to the registry.',
confirm: async (modal) => {
modal.startLoading();

try {
await this.fetch.delete(`auth/registry-tokens/${credentials.uuid}`, {}, { namespace: '~registry/v1' });
this.notifications.success('Registry credentials deleted.');
return this.hostRouter.refresh();
} catch (error) {
this.notifications.serverError(error);
}
},
});
}

@action createCredentials() {
this.modalsManager.show('modals/create-registry-credentials', {
title: 'Create new registry credentials',
acceptButtonText: 'Create',
acceptButtonIcon: 'check',
password: null,
confirm: async (modal) => {
modal.startLoading();

const password = modal.getOption('password');
if (!password) {
this.notifications.warning('Password cannot be empty');
return modal.stopLoading();
}

try {
await this.fetch.post('auth/registry-tokens', { password }, { namespace: '~registry/v1' });
this.notifications.success('Registry credentials created.');
return this.hostRouter.refresh();
} catch (error) {
this.notifications.serverError(error);
}
},
});
}
}
9 changes: 8 additions & 1 deletion addon/routes/developers/credentials.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';

export default class DevelopersCredentialsRoute extends Route {}
export default class DevelopersCredentialsRoute extends Route {
@service fetch;

model() {
return this.fetch.get('auth/registry-tokens', {}, { namespace: '~registry/v1' });
}
}
1 change: 1 addition & 0 deletions addon/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<Layout::Sidebar::Item @route="console.extensions.developers.extensions" @icon="box-archive">Extensions</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.extensions.developers.analytics" @icon="chart-simple">Analytics</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.extensions.developers.payments" @icon="cash-register">Payments</Layout::Sidebar::Item>
<Layout::Sidebar::Item @route="console.extensions.developers.credentials" @icon="key">Credentials</Layout::Sidebar::Item>
</Layout::Sidebar::Panel>
<Spacer @height="200px" />
</EmberWormhole>
Expand Down
14 changes: 13 additions & 1 deletion addon/templates/developers/credentials.hbs
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
{{outlet}}
<Layout::Section::Header @title="Credentials">
<Button @type="primary" @icon="plus" @iconPrefix="fas" @text="Create new credentials" class="mr-2" @onClick={{this.createCredentials}} />
</Layout::Section::Header>

<Layout::Section::Body class="overflow-y-scroll h-full">
<Table
@rows={{@model}}
@columns={{this.columns}}
@selectable={{false}}
@canSelectAll={{false}}
@pagination={{false}}
/>
</Layout::Section::Body>
1 change: 1 addition & 0 deletions app/components/modals/create-registry-credentials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@fleetbase/registry-bridge-engine/components/modals/create-registry-credentials';
1 change: 1 addition & 0 deletions app/controllers/developers/credentials.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from '@fleetbase/registry-bridge-engine/controllers/developers/credentials';
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/registry-bridge",
"version": "0.0.1",
"version": "0.0.2",
"description": "Internal Bridge between Fleetbase API and Extensions Registry",
"keywords": [
"fleetbase-extension",
Expand Down
2 changes: 1 addition & 1 deletion extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Registry Bridge",
"version": "0.0.1",
"version": "0.0.2",
"description": "Internal Bridge between Fleetbase API and Extensions Registry",
"repository": "https://github.com/fleetbase/registry-bridge",
"license": "AGPL-3.0-or-later",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fleetbase/registry-bridge-engine",
"version": "0.0.1",
"version": "0.0.2",
"description": "Internal Bridge between Fleetbase API and Extensions Registry",
"fleetbase": {
"route": "extensions"
Expand Down
3 changes: 2 additions & 1 deletion server/config/registry-bridge.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
],
'extensions' => [
'preinstalled' => Utils::castBoolean(env('REGISTRY_PREINSTALLED_EXTENSIONS', false))
'preinstalled' => Utils::castBoolean(env('REGISTRY_PREINSTALLED_EXTENSIONS', false)),
'protected_prefixes' => explode(',', env('REGISTRY_PROTECTED_PREFIXES', '@fleetbase,fleetbase,@flb,@fleetbase-extension,@flb-extension'))
],
'facilitator_fee' => env('REGISTRY_FACILITATOR_FEE', 10)
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('registry_users', function (Blueprint $table) {
$table->string('registry_token')->nullable()->after('token');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('registry_users', function (Blueprint $table) {
$table->dropColumn('registry_token');
});
}
};
Loading

0 comments on commit 6efdac2

Please sign in to comment.