Xiao-zhen-Liu commented on code in PR #4161:
URL: https://github.com/apache/texera/pull/4161#discussion_r2699506517
##########
frontend/src/app/dashboard/component/user/share-access/share-access.component.ts:
##########
@@ -76,6 +76,17 @@ export class ShareAccessComponent implements OnInit,
OnDestroy {
this.currentEmail = this.userService.getCurrentUser()?.email;
}
+ get hasWriteAccess(): boolean {
Review Comment:
There is an existing `writeAccess` variable that is still used by other
components. All other usages of the old variable should be replaced with
`hasWriteAccess` to avoid stale states in other places.
##########
frontend/src/app/dashboard/component/user/share-access/share-access.component.ts:
##########
@@ -238,6 +249,57 @@ export class ShareAccessComponent implements OnInit,
OnDestroy {
});
}
+ public changeAccessLevel(email: string, newPrivilege: string): void {
+ const isOwnAccess = email === this.currentEmail;
+ const currentUserAccess = this.accessList.find(entry => entry.email ===
email);
+ const isDowngrade = currentUserAccess?.privilege === Privilege.WRITE &&
newPrivilege === "READ";
+
+ if (isOwnAccess && isDowngrade) {
+ const modal: NzModalRef = this.modalService.create({
+ nzTitle: "Downgrade Your Access",
+ nzContent: `Are you sure you want to change your own access to READ?
You will no longer be able to edit this ${this.type} or manage access.`,
+ nzFooter: [
+ {
+ label: "Cancel",
+ onClick: () => {
+ modal.close();
+ this.ngOnInit();
+ },
+ },
+ {
+ label: "Confirm",
+ type: "primary",
+ danger: true,
+ onClick: () => {
+ this.doChangeAccessLevel(email, newPrivilege);
+ modal.close();
+ },
+ },
+ ],
+ });
+ } else {
+ this.doChangeAccessLevel(email, newPrivilege);
+ }
+ }
+
+ private doChangeAccessLevel(email: string, newPrivilege: string): void {
Review Comment:
The name is awkward. Consider something like `applyAccessLevelChange`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]