-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PM-14990] Add password prompt for ssh key import (#12105)
* Add password prompt for ssh key import * Remove empty line * Convert to switch statement
- Loading branch information
Showing
5 changed files
with
147 additions
and
30 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
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,3 +1,4 @@ | ||
export * from "./import-error-dialog.component"; | ||
export * from "./import-success-dialog.component"; | ||
export * from "./file-password-prompt.component"; | ||
export * from "./sshkey-password-prompt.component"; |
31 changes: 31 additions & 0 deletions
31
libs/importer/src/components/dialog/sshkey-password-prompt.component.html
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,31 @@ | ||
<form [formGroup]="formGroup" [bitSubmit]="submit"> | ||
<bit-dialog> | ||
<span bitDialogTitle> | ||
{{ "enterSshKeyPassword" | i18n }} | ||
</span> | ||
|
||
<div bitDialogContent> | ||
{{ "enterSshKeyPasswordDesc" | i18n }} | ||
<bit-form-field class="tw-mt-6"> | ||
<bit-label>{{ "confirmSshKeyPassword" | i18n }}</bit-label> | ||
<input | ||
bitInput | ||
type="password" | ||
formControlName="sshKeyPassword" | ||
appAutofocus | ||
appInputVerbatim | ||
/> | ||
<button type="button" bitSuffix bitIconButton bitPasswordInputToggle></button> | ||
</bit-form-field> | ||
</div> | ||
|
||
<ng-container bitDialogFooter> | ||
<button bitButton buttonType="primary" type="submit"> | ||
<span>{{ "importSshKey" | i18n }}</span> | ||
</button> | ||
<button bitButton bitDialogClose buttonType="secondary" type="button"> | ||
<span>{{ "cancel" | i18n }}</span> | ||
</button> | ||
</ng-container> | ||
</bit-dialog> | ||
</form> |
46 changes: 46 additions & 0 deletions
46
libs/importer/src/components/dialog/sshkey-password-prompt.component.ts
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,46 @@ | ||
import { DialogRef } from "@angular/cdk/dialog"; | ||
import { CommonModule } from "@angular/common"; | ||
import { Component } from "@angular/core"; | ||
import { FormBuilder, ReactiveFormsModule, Validators } from "@angular/forms"; | ||
|
||
import { JslibModule } from "@bitwarden/angular/jslib.module"; | ||
import { | ||
AsyncActionsModule, | ||
ButtonModule, | ||
DialogModule, | ||
FormFieldModule, | ||
IconButtonModule, | ||
} from "@bitwarden/components"; | ||
|
||
@Component({ | ||
templateUrl: "sshkey-password-prompt.component.html", | ||
standalone: true, | ||
imports: [ | ||
CommonModule, | ||
JslibModule, | ||
DialogModule, | ||
FormFieldModule, | ||
AsyncActionsModule, | ||
ButtonModule, | ||
IconButtonModule, | ||
ReactiveFormsModule, | ||
], | ||
}) | ||
export class SshKeyPasswordPromptComponent { | ||
protected formGroup = this.formBuilder.group({ | ||
sshKeyPassword: ["", Validators.required], | ||
}); | ||
|
||
constructor( | ||
public dialogRef: DialogRef, | ||
protected formBuilder: FormBuilder, | ||
) {} | ||
|
||
submit = () => { | ||
this.formGroup.markAsTouched(); | ||
if (!this.formGroup.valid) { | ||
return; | ||
} | ||
this.dialogRef.close(this.formGroup.value.sshKeyPassword); | ||
}; | ||
} |