-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from fleetbase/dev-v0.0.2
v0.0.2
- Loading branch information
Showing
22 changed files
with
648 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
}, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from '@fleetbase/registry-bridge-engine/controllers/developers/credentials'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
server/migrations/2024_07_18_151000_add_auth_token_column_to_registry_users_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); | ||
} | ||
}; |
Oops, something went wrong.