mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-15 10:25:11 +00:00
feat(console): delete org (#4837)
Co-authored-by: Livio Spring <[email protected]>
This commit is contained in:
co-authored by
Livio Spring
parent
0530f19d94
commit
85a0bb0523
@@ -3,6 +3,7 @@ import { Component, Input, ViewChild } from '@angular/core';
|
||||
import { MatSort, Sort } from '@angular/material/sort';
|
||||
import { MatTableDataSource } from '@angular/material/table';
|
||||
import { Router } from '@angular/router';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { Timestamp } from 'google-protobuf/google/protobuf/timestamp_pb';
|
||||
import { BehaviorSubject, catchError, finalize, from, map, Observable, of, Subject, switchMap, take, takeUntil } from 'rxjs';
|
||||
import { Org, OrgFieldName, OrgQuery, OrgState } from 'src/app/proto/generated/zitadel/org_pb';
|
||||
@@ -56,6 +57,7 @@ export class OrgTableComponent {
|
||||
private router: Router,
|
||||
private toast: ToastService,
|
||||
private _liveAnnouncer: LiveAnnouncer,
|
||||
private translate: TranslateService,
|
||||
) {
|
||||
this.requestOrgs$.next({ limit: this.initialLimit, offset: 0, queries: this.searchQueries });
|
||||
this.authService.getActiveOrg().then((org) => (this.activeOrg = org));
|
||||
@@ -134,8 +136,14 @@ export class OrgTableComponent {
|
||||
}
|
||||
|
||||
public setAndNavigateToOrg(org: Org.AsObject): void {
|
||||
this.authService.setActiveOrg(org);
|
||||
this.router.navigate(['/org']);
|
||||
if (org.state !== OrgState.ORG_STATE_REMOVED) {
|
||||
this.authService.setActiveOrg(org);
|
||||
this.router.navigate(['/org']);
|
||||
} else {
|
||||
this.translate.get('ORG.TOAST.ORG_WAS_DELETED').subscribe((data) => {
|
||||
this.toast.showInfo(data);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public changePage(): void {
|
||||
|
||||
@@ -28,6 +28,10 @@
|
||||
<button data-e2e="rename" mat-menu-item (click)="renameOrg()">
|
||||
{{ 'ORG.PAGES.RENAME.ACTION' | translate }}
|
||||
</button>
|
||||
|
||||
<button data-e2e="delete" mat-menu-item (click)="deleteOrg()">
|
||||
{{ 'ORG.PAGES.DELETE' | translate }}
|
||||
</button>
|
||||
</ng-container>
|
||||
<cnsl-contributors
|
||||
topContributors
|
||||
|
||||
@@ -126,6 +126,44 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
public deleteOrg(): void {
|
||||
const mgmtUserData = {
|
||||
confirmKey: 'ACTIONS.DELETE',
|
||||
cancelKey: 'ACTIONS.CANCEL',
|
||||
titleKey: 'ORG.DIALOG.DELETE.TITLE',
|
||||
warnSectionKey: 'ORG.DIALOG.DELETE.DESCRIPTION',
|
||||
hintKey: 'ORG.DIALOG.DELETE.TYPENAME',
|
||||
hintParam: 'ORG.DIALOG.DELETE.DESCRIPTION',
|
||||
confirmationKey: 'ORG.DIALOG.DELETE.ORGNAME',
|
||||
confirmation: this.org?.name,
|
||||
};
|
||||
|
||||
if (this.org) {
|
||||
let dialogRef;
|
||||
|
||||
dialogRef = this.dialog.open(WarnDialogComponent, {
|
||||
data: mgmtUserData,
|
||||
width: '400px',
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe((resp) => {
|
||||
if (resp) {
|
||||
this.mgmtService
|
||||
.removeOrg()
|
||||
.then(() => {
|
||||
setTimeout(() => {
|
||||
this.router.navigate(['/orgs']);
|
||||
}, 1000);
|
||||
this.toast.showInfo('ORG.TOAST.DELETED', true);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async getData(): Promise<void> {
|
||||
this.mgmtService
|
||||
.getMyOrg()
|
||||
|
||||
@@ -312,6 +312,7 @@ import {
|
||||
RemoveOrgMemberResponse,
|
||||
RemoveOrgMetadataRequest,
|
||||
RemoveOrgMetadataResponse,
|
||||
RemoveOrgRequest,
|
||||
RemovePersonalAccessTokenRequest,
|
||||
RemovePersonalAccessTokenResponse,
|
||||
RemoveProjectGrantMemberRequest,
|
||||
@@ -1469,6 +1470,11 @@ export class ManagementService {
|
||||
return this.grpcService.mgmt.removeUser(req, null).then((resp) => resp.toObject());
|
||||
}
|
||||
|
||||
public removeOrg(): Promise<RemoveUserResponse.AsObject> {
|
||||
const req = new RemoveOrgRequest();
|
||||
return this.grpcService.mgmt.removeOrg(req, null).then((resp) => resp.toObject());
|
||||
}
|
||||
|
||||
public listProjectMembers(
|
||||
projectId: string,
|
||||
limit: number,
|
||||
|
||||
Reference in New Issue
Block a user