1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-28 14:13:22 +00:00
Files
browser/src/popup/vault/share.component.ts
Matt Gibson 0cd6efd67f Move share from edit to view. Fix animations (#1497)
* Move share from edit to view. Fix animations

Editing and Sharing a cipher simultaneously results in lost edits. Move
share button to the view page to resolve this confusion.

Previous routing caused the share form to be animated again on
submition, resulting in a stuttering page load. This method correctly
animates all transitions with the concession that the share page
always takes you back to the view page. This is not necessarily the current
behavior, but it is the most likely behavior in the current scheme

* Update jslib reference
2020-12-17 11:06:31 -06:00

53 lines
1.9 KiB
TypeScript

import { Location } from '@angular/common';
import { Component } from '@angular/core';
import {
ActivatedRoute,
Router,
} from '@angular/router';
import { CipherService } from 'jslib/abstractions/cipher.service';
import { CollectionService } from 'jslib/abstractions/collection.service';
import { I18nService } from 'jslib/abstractions/i18n.service';
import { PlatformUtilsService } from 'jslib/abstractions/platformUtils.service';
import { UserService } from 'jslib/abstractions/user.service';
import { ShareComponent as BaseShareComponent } from 'jslib/angular/components/share.component';
@Component({
selector: 'app-vault-share',
templateUrl: 'share.component.html',
})
export class ShareComponent extends BaseShareComponent {
constructor(collectionService: CollectionService, platformUtilsService: PlatformUtilsService,
i18nService: I18nService, userService: UserService,
cipherService: CipherService, private route: ActivatedRoute,
private location: Location, private router: Router) {
super(collectionService, platformUtilsService, i18nService, userService, cipherService);
}
async ngOnInit() {
this.onSharedCipher.subscribe(() => {
this.router.navigate(['view-cipher', { cipherId: this.cipherId }]);
});
const queryParamsSub = this.route.queryParams.subscribe(async (params) => {
this.cipherId = params.cipherId;
await this.load();
if (queryParamsSub != null) {
queryParamsSub.unsubscribe();
}
});
}
async submit(): Promise<boolean> {
const success = await super.submit();
if (success) {
this.cancel();
}
return success;
}
cancel() {
this.router.navigate(['/view-cipher'], { replaceUrl: true, queryParams: { cipherId: this.cipher.id } });
}
}