mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-30 22:41:33 +01:00
[SM-1292] Add secret view dialog (#9445)
* Add secret view dialog * Use secret view dialog
This commit is contained in:
parent
d30b947dd7
commit
769d67af39
@ -8354,5 +8354,8 @@
|
|||||||
},
|
},
|
||||||
"verified": {
|
"verified": {
|
||||||
"message": "Verified"
|
"message": "Verified"
|
||||||
|
},
|
||||||
|
"viewSecret": {
|
||||||
|
"message": "View secret"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,7 @@
|
|||||||
(deleteSecretsEvent)="openDeleteSecret($event)"
|
(deleteSecretsEvent)="openDeleteSecret($event)"
|
||||||
(newSecretEvent)="openNewSecretDialog()"
|
(newSecretEvent)="openNewSecretDialog()"
|
||||||
(editSecretEvent)="openEditSecret($event)"
|
(editSecretEvent)="openEditSecret($event)"
|
||||||
|
(viewSecretEvent)="openViewSecret($event)"
|
||||||
(copySecretNameEvent)="copySecretName($event)"
|
(copySecretNameEvent)="copySecretName($event)"
|
||||||
(copySecretValueEvent)="copySecretValue($event)"
|
(copySecretValueEvent)="copySecretValue($event)"
|
||||||
(copySecretUuidEvent)="copySecretUuid($event)"
|
(copySecretUuidEvent)="copySecretUuid($event)"
|
||||||
|
@ -41,6 +41,10 @@ import {
|
|||||||
SecretDialogComponent,
|
SecretDialogComponent,
|
||||||
SecretOperation,
|
SecretOperation,
|
||||||
} from "../secrets/dialog/secret-dialog.component";
|
} from "../secrets/dialog/secret-dialog.component";
|
||||||
|
import {
|
||||||
|
SecretViewDialogComponent,
|
||||||
|
SecretViewDialogParams,
|
||||||
|
} from "../secrets/dialog/secret-view-dialog.component";
|
||||||
import { SecretService } from "../secrets/secret.service";
|
import { SecretService } from "../secrets/secret.service";
|
||||||
import {
|
import {
|
||||||
ServiceAccountDialogComponent,
|
ServiceAccountDialogComponent,
|
||||||
@ -277,6 +281,15 @@ export class OverviewComponent implements OnInit, OnDestroy {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openViewSecret(secretId: string) {
|
||||||
|
this.dialogService.open<unknown, SecretViewDialogParams>(SecretViewDialogComponent, {
|
||||||
|
data: {
|
||||||
|
organizationId: this.organizationId,
|
||||||
|
secretId: secretId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
openDeleteSecret(event: SecretListView[]) {
|
openDeleteSecret(event: SecretListView[]) {
|
||||||
this.dialogService.open<unknown, SecretDeleteOperation>(SecretDeleteDialogComponent, {
|
this.dialogService.open<unknown, SecretDeleteOperation>(SecretDeleteDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
(deleteSecretsEvent)="openDeleteSecret($event)"
|
(deleteSecretsEvent)="openDeleteSecret($event)"
|
||||||
(newSecretEvent)="openNewSecretDialog()"
|
(newSecretEvent)="openNewSecretDialog()"
|
||||||
(editSecretEvent)="openEditSecret($event)"
|
(editSecretEvent)="openEditSecret($event)"
|
||||||
|
(viewSecretEvent)="openViewSecret($event)"
|
||||||
(copySecretNameEvent)="copySecretName($event)"
|
(copySecretNameEvent)="copySecretName($event)"
|
||||||
(copySecretValueEvent)="copySecretValue($event)"
|
(copySecretValueEvent)="copySecretValue($event)"
|
||||||
(copySecretUuidEvent)="copySecretUuid($event)"
|
(copySecretUuidEvent)="copySecretUuid($event)"
|
||||||
|
@ -19,6 +19,10 @@ import {
|
|||||||
SecretDialogComponent,
|
SecretDialogComponent,
|
||||||
SecretOperation,
|
SecretOperation,
|
||||||
} from "../../secrets/dialog/secret-dialog.component";
|
} from "../../secrets/dialog/secret-dialog.component";
|
||||||
|
import {
|
||||||
|
SecretViewDialogComponent,
|
||||||
|
SecretViewDialogParams,
|
||||||
|
} from "../../secrets/dialog/secret-view-dialog.component";
|
||||||
import { SecretService } from "../../secrets/secret.service";
|
import { SecretService } from "../../secrets/secret.service";
|
||||||
import { SecretsListComponent } from "../../shared/secrets-list.component";
|
import { SecretsListComponent } from "../../shared/secrets-list.component";
|
||||||
import { ProjectService } from "../project.service";
|
import { ProjectService } from "../project.service";
|
||||||
@ -88,6 +92,15 @@ export class ProjectSecretsComponent {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openViewSecret(secretId: string) {
|
||||||
|
this.dialogService.open<unknown, SecretViewDialogParams>(SecretViewDialogComponent, {
|
||||||
|
data: {
|
||||||
|
organizationId: this.organizationId,
|
||||||
|
secretId: secretId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
openDeleteSecret(event: SecretListView[]) {
|
openDeleteSecret(event: SecretListView[]) {
|
||||||
this.dialogService.open<unknown, SecretDeleteOperation>(SecretDeleteDialogComponent, {
|
this.dialogService.open<unknown, SecretDeleteOperation>(SecretDeleteDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
<form [formGroup]="formGroup">
|
||||||
|
<bit-dialog
|
||||||
|
dialogSize="large"
|
||||||
|
[loading]="loading"
|
||||||
|
[title]="'viewSecret' | i18n"
|
||||||
|
[subtitle]="formGroup.get('name').value"
|
||||||
|
>
|
||||||
|
<ng-container bitDialogContent class="tw-relative">
|
||||||
|
<div class="tw-flex tw-gap-4 tw-pt-4">
|
||||||
|
<bit-form-field class="tw-w-1/3">
|
||||||
|
<bit-label>{{ "name" | i18n }}</bit-label>
|
||||||
|
<input appAutofocus formControlName="name" bitInput />
|
||||||
|
</bit-form-field>
|
||||||
|
<bit-form-field class="tw-w-full">
|
||||||
|
<bit-label>{{ "value" | i18n }}</bit-label>
|
||||||
|
<textarea bitInput rows="4" formControlName="value"></textarea>
|
||||||
|
</bit-form-field>
|
||||||
|
</div>
|
||||||
|
<bit-form-field>
|
||||||
|
<bit-label>{{ "notes" | i18n }}</bit-label>
|
||||||
|
<textarea bitInput rows="4" formControlName="notes"></textarea>
|
||||||
|
</bit-form-field>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container bitDialogFooter>
|
||||||
|
<button type="button" bitButton buttonType="primary" bitFormButton bitDialogClose>
|
||||||
|
{{ "close" | i18n }}
|
||||||
|
</button>
|
||||||
|
</ng-container>
|
||||||
|
</bit-dialog>
|
||||||
|
</form>
|
@ -0,0 +1,39 @@
|
|||||||
|
import { DIALOG_DATA } from "@angular/cdk/dialog";
|
||||||
|
import { Component, Inject, OnInit } from "@angular/core";
|
||||||
|
import { FormControl, FormGroup } from "@angular/forms";
|
||||||
|
|
||||||
|
import { SecretService } from "../secret.service";
|
||||||
|
|
||||||
|
export interface SecretViewDialogParams {
|
||||||
|
organizationId: string;
|
||||||
|
secretId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Component({
|
||||||
|
templateUrl: "./secret-view-dialog.component.html",
|
||||||
|
})
|
||||||
|
export class SecretViewDialogComponent implements OnInit {
|
||||||
|
protected loading = true;
|
||||||
|
protected formGroup = new FormGroup({
|
||||||
|
name: new FormControl(""),
|
||||||
|
value: new FormControl(""),
|
||||||
|
notes: new FormControl(""),
|
||||||
|
});
|
||||||
|
|
||||||
|
constructor(
|
||||||
|
private secretService: SecretService,
|
||||||
|
@Inject(DIALOG_DATA) private params: SecretViewDialogParams,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
async ngOnInit() {
|
||||||
|
this.loading = true;
|
||||||
|
const secret = await this.secretService.getBySecretId(this.params.secretId);
|
||||||
|
this.formGroup.setValue({
|
||||||
|
name: secret.name,
|
||||||
|
value: secret.value,
|
||||||
|
notes: secret.note,
|
||||||
|
});
|
||||||
|
this.formGroup.disable();
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
}
|
@ -10,6 +10,7 @@
|
|||||||
(deleteSecretsEvent)="openDeleteSecret($event)"
|
(deleteSecretsEvent)="openDeleteSecret($event)"
|
||||||
(newSecretEvent)="openNewSecretDialog()"
|
(newSecretEvent)="openNewSecretDialog()"
|
||||||
(editSecretEvent)="openEditSecret($event)"
|
(editSecretEvent)="openEditSecret($event)"
|
||||||
|
(viewSecretEvent)="openViewSecret($event)"
|
||||||
(copySecretNameEvent)="copySecretName($event)"
|
(copySecretNameEvent)="copySecretName($event)"
|
||||||
(copySecretValueEvent)="copySecretValue($event)"
|
(copySecretValueEvent)="copySecretValue($event)"
|
||||||
(copySecretUuidEvent)="copySecretUuid($event)"
|
(copySecretUuidEvent)="copySecretUuid($event)"
|
||||||
|
@ -20,6 +20,10 @@ import {
|
|||||||
SecretDialogComponent,
|
SecretDialogComponent,
|
||||||
SecretOperation,
|
SecretOperation,
|
||||||
} from "./dialog/secret-dialog.component";
|
} from "./dialog/secret-dialog.component";
|
||||||
|
import {
|
||||||
|
SecretViewDialogComponent,
|
||||||
|
SecretViewDialogParams,
|
||||||
|
} from "./dialog/secret-view-dialog.component";
|
||||||
import { SecretService } from "./secret.service";
|
import { SecretService } from "./secret.service";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -77,6 +81,15 @@ export class SecretsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
openViewSecret(secretId: string) {
|
||||||
|
this.dialogService.open<unknown, SecretViewDialogParams>(SecretViewDialogComponent, {
|
||||||
|
data: {
|
||||||
|
organizationId: this.organizationId,
|
||||||
|
secretId: secretId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
openDeleteSecret(event: SecretListView[]) {
|
openDeleteSecret(event: SecretListView[]) {
|
||||||
this.dialogService.open<unknown, SecretDeleteOperation>(SecretDeleteDialogComponent, {
|
this.dialogService.open<unknown, SecretDeleteOperation>(SecretDeleteDialogComponent, {
|
||||||
data: {
|
data: {
|
||||||
|
@ -4,12 +4,18 @@ import { SecretsManagerSharedModule } from "../shared/sm-shared.module";
|
|||||||
|
|
||||||
import { SecretDeleteDialogComponent } from "./dialog/secret-delete.component";
|
import { SecretDeleteDialogComponent } from "./dialog/secret-delete.component";
|
||||||
import { SecretDialogComponent } from "./dialog/secret-dialog.component";
|
import { SecretDialogComponent } from "./dialog/secret-dialog.component";
|
||||||
|
import { SecretViewDialogComponent } from "./dialog/secret-view-dialog.component";
|
||||||
import { SecretsRoutingModule } from "./secrets-routing.module";
|
import { SecretsRoutingModule } from "./secrets-routing.module";
|
||||||
import { SecretsComponent } from "./secrets.component";
|
import { SecretsComponent } from "./secrets.component";
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [SecretsManagerSharedModule, SecretsRoutingModule],
|
imports: [SecretsManagerSharedModule, SecretsRoutingModule],
|
||||||
declarations: [SecretDeleteDialogComponent, SecretDialogComponent, SecretsComponent],
|
declarations: [
|
||||||
|
SecretDeleteDialogComponent,
|
||||||
|
SecretDialogComponent,
|
||||||
|
SecretViewDialogComponent,
|
||||||
|
SecretsComponent,
|
||||||
|
],
|
||||||
providers: [],
|
providers: [],
|
||||||
})
|
})
|
||||||
export class SecretsModule {}
|
export class SecretsModule {}
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
<i class="bwi bwi-key tw-text-muted" aria-hidden="true"></i>
|
<i class="bwi bwi-key tw-text-muted" aria-hidden="true"></i>
|
||||||
<div>
|
<div>
|
||||||
<div *ngIf="!trash">
|
<div *ngIf="!trash">
|
||||||
<button type="button" bitLink (click)="editSecretEvent.emit(secret.id)">
|
<button type="button" bitLink (click)="editSecret(secret)">
|
||||||
{{ secret.name }}
|
{{ secret.name }}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
@ -118,7 +118,7 @@
|
|||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
bitMenuItem
|
bitMenuItem
|
||||||
(click)="editSecretEvent.emit(secret.id)"
|
(click)="editSecret(secret)"
|
||||||
*ngIf="secret.write && !trash"
|
*ngIf="secret.write && !trash"
|
||||||
>
|
>
|
||||||
<i class="bwi bwi-fw bwi-pencil" aria-hidden="true"></i>
|
<i class="bwi bwi-fw bwi-pencil" aria-hidden="true"></i>
|
||||||
|
@ -37,6 +37,7 @@ export class SecretsListComponent implements OnDestroy {
|
|||||||
@Input() trash: boolean;
|
@Input() trash: boolean;
|
||||||
|
|
||||||
@Output() editSecretEvent = new EventEmitter<string>();
|
@Output() editSecretEvent = new EventEmitter<string>();
|
||||||
|
@Output() viewSecretEvent = new EventEmitter<string>();
|
||||||
@Output() copySecretNameEvent = new EventEmitter<string>();
|
@Output() copySecretNameEvent = new EventEmitter<string>();
|
||||||
@Output() copySecretValueEvent = new EventEmitter<string>();
|
@Output() copySecretValueEvent = new EventEmitter<string>();
|
||||||
@Output() copySecretUuidEvent = new EventEmitter<string>();
|
@Output() copySecretUuidEvent = new EventEmitter<string>();
|
||||||
@ -116,6 +117,14 @@ export class SecretsListComponent implements OnDestroy {
|
|||||||
return aProjects[0]?.name.localeCompare(bProjects[0].name);
|
return aProjects[0]?.name.localeCompare(bProjects[0].name);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
protected editSecret(secret: SecretListView) {
|
||||||
|
if (secret.write) {
|
||||||
|
this.editSecretEvent.emit(secret.id);
|
||||||
|
} else {
|
||||||
|
this.viewSecretEvent.emit(secret.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Refactor to smart component and remove
|
* TODO: Refactor to smart component and remove
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user