-
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-16097] Separate copy buttons appearance setting (#12428)
--------- Co-authored-by: William Martin <[email protected]> (cherry picked from commit a4db527)
- Loading branch information
Showing
8 changed files
with
194 additions
and
50 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
162 changes: 113 additions & 49 deletions
162
...ser/src/vault/popup/components/vault-v2/item-copy-action/item-copy-actions.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
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
39 changes: 39 additions & 0 deletions
39
apps/browser/src/vault/popup/services/vault-popup-copy-buttons.service.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,39 @@ | ||
import { inject, Injectable } from "@angular/core"; | ||
import { map, Observable } from "rxjs"; | ||
|
||
import { | ||
GlobalStateProvider, | ||
KeyDefinition, | ||
VAULT_APPEARANCE, | ||
} from "@bitwarden/common/platform/state"; | ||
|
||
export type CopyButtonDisplayMode = "combined" | "quick"; | ||
|
||
const COPY_BUTTON = new KeyDefinition<CopyButtonDisplayMode>(VAULT_APPEARANCE, "copyButtons", { | ||
deserializer: (s) => s, | ||
}); | ||
|
||
/** | ||
* Settings service for vault copy button settings | ||
**/ | ||
@Injectable({ providedIn: "root" }) | ||
export class VaultPopupCopyButtonsService { | ||
private readonly DEFAULT_DISPLAY_MODE = "combined"; | ||
private state = inject(GlobalStateProvider).get(COPY_BUTTON); | ||
|
||
displayMode$: Observable<CopyButtonDisplayMode> = this.state.state$.pipe( | ||
map((state) => state ?? this.DEFAULT_DISPLAY_MODE), | ||
); | ||
|
||
async setDisplayMode(displayMode: CopyButtonDisplayMode) { | ||
await this.state.update(() => displayMode); | ||
} | ||
|
||
showQuickCopyActions$: Observable<boolean> = this.displayMode$.pipe( | ||
map((displayMode) => displayMode === "quick"), | ||
); | ||
|
||
async setShowQuickCopyActions(value: boolean) { | ||
await this.setDisplayMode(value ? "quick" : "combined"); | ||
} | ||
} |
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