-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[PM-15999] - use new generator components in desktop app #12639
Merged
Merged
Changes from 8 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
8e87bc1
use new generator components in desktop app
jaasen-livefront 8864faa
add generator to export
jaasen-livefront e8952e2
add TODO comment
jaasen-livefront 170c8be
use app-specific component
jaasen-livefront a1fbe93
Merge branch 'main' into PM-15999
jaasen-livefront 9cf8d2f
use vault-owned generator component
jaasen-livefront 9cf10ee
use CipherFormGeneratorComponent
jaasen-livefront 8ee1836
rename to dialog component. reference ticket number in comment
jaasen-livefront 1ce63ae
use static method for opening dialog
jaasen-livefront File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
apps/desktop/src/vault/app/vault/credential-generator-dialog.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,38 @@ | ||
<bit-dialog #dialog dialogSize="large" background="alt"> | ||
<span bitDialogTitle>{{ "generator" | i18n }}</span> | ||
<ng-container bitDialogContent> | ||
<vault-cipher-form-generator | ||
[type]="data.type" | ||
(valueGenerated)="onCredentialGenerated($event)" | ||
/> | ||
<bit-item> | ||
<button | ||
type="button" | ||
bitLink | ||
linkType="primary" | ||
bit-item-content | ||
aria-haspopup="true" | ||
(click)="openHistoryDialog()" | ||
> | ||
{{ "generatorHistory" | i18n }} | ||
<i slot="end" class="bwi bwi-angle-right" aria-hidden="true"></i> | ||
</button> | ||
</bit-item> | ||
</ng-container> | ||
<ng-container bitDialogFooter> | ||
<div class="modal-footer"> | ||
<button | ||
type="button" | ||
class="primary" | ||
(click)="applyCredentials()" | ||
appA11yTitle="{{ 'select' | i18n }}" | ||
bitDialogClose | ||
> | ||
<i class="bwi bwi-lg bwi-fw bwi-check" aria-hidden="true"></i> | ||
</button> | ||
<button type="button" data-dismiss="modal" (click)="clearCredentials()" bitDialogClose> | ||
{{ "cancel" | i18n }} | ||
</button> | ||
</div> | ||
</ng-container> | ||
</bit-dialog> |
72 changes: 72 additions & 0 deletions
72
apps/desktop/src/vault/app/vault/credential-generator-dialog.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,72 @@ | ||
import { DIALOG_DATA } from "@angular/cdk/dialog"; | ||
import { CommonModule } from "@angular/common"; | ||
import { Component, Inject } from "@angular/core"; | ||
|
||
import { JslibModule } from "@bitwarden/angular/jslib.module"; | ||
import { | ||
ButtonModule, | ||
DialogModule, | ||
DialogService, | ||
ItemModule, | ||
LinkModule, | ||
} from "@bitwarden/components"; | ||
import { | ||
CredentialGeneratorHistoryDialogComponent, | ||
GeneratorModule, | ||
} from "@bitwarden/generator-components"; | ||
import { CipherFormGeneratorComponent } from "@bitwarden/vault"; | ||
|
||
export type CredentialGeneratorParams = { | ||
onCredentialGenerated: (value?: string) => void; | ||
type: "password" | "username"; | ||
}; | ||
|
||
export const openCredentialGeneratorDialog = ( | ||
dialogService: DialogService, | ||
data: CredentialGeneratorParams, | ||
) => { | ||
dialogService.open(CredentialGeneratorDialogComponent, { | ||
data, | ||
}); | ||
}; | ||
|
||
@Component({ | ||
standalone: true, | ||
selector: "credential-generator-dialog", | ||
templateUrl: "credential-generator-dialog.component.html", | ||
imports: [ | ||
CipherFormGeneratorComponent, | ||
CommonModule, | ||
DialogModule, | ||
ButtonModule, | ||
JslibModule, | ||
GeneratorModule, | ||
ItemModule, | ||
LinkModule, | ||
], | ||
}) | ||
export class CredentialGeneratorDialogComponent { | ||
credentialValue?: string; | ||
|
||
constructor( | ||
@Inject(DIALOG_DATA) protected data: CredentialGeneratorParams, | ||
private dialogService: DialogService, | ||
) {} | ||
|
||
applyCredentials = () => { | ||
this.data.onCredentialGenerated(this.credentialValue); | ||
}; | ||
|
||
clearCredentials = () => { | ||
this.data.onCredentialGenerated(); | ||
}; | ||
|
||
onCredentialGenerated = (value: string) => { | ||
this.credentialValue = value; | ||
}; | ||
|
||
openHistoryDialog = () => { | ||
// open history dialog | ||
this.dialogService.open(CredentialGeneratorHistoryDialogComponent); | ||
}; | ||
} |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we need this in the component
and then you reference the static method in the vault component like so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gbubemismith Gotcha! I was looking at a slightly different implementation. Should be gtg now.