feat(console): rename org (#4542)

* rename org

* add data-e2e

* e2e test

* restore state after

* use ngIf instead of hasrole directive and initialized regex

* rm h2 check

* Update e2e/cypress/e2e/organization/organizations.cy.ts

Co-authored-by: Elio Bischof <[email protected]>

* Update console/src/assets/i18n/de.json

Co-authored-by: Elio Bischof <[email protected]>

* Update console/src/assets/i18n/de.json

Co-authored-by: Elio Bischof <[email protected]>

* Update console/src/assets/i18n/en.json

Co-authored-by: Elio Bischof <[email protected]>

* change e2e test

* org param

* reintroduct org param

* use org query param

* org rename test

* no initial focus on button

* contain name

Co-authored-by: Elio Bischof <[email protected]>
This commit is contained in:
Max Peintner
2022-10-20 14:08:13 +02:00
committed by GitHub
co-authored by Elio Bischof
parent 2bfa51da1c
commit 6e89b7d0a1
16 changed files with 186 additions and 15 deletions
@@ -1,13 +1,14 @@
<cnsl-top-view
*ngIf="['org.write:' + org?.id, 'org.write$'] | hasRole as hasWrite$"
[hasBackButton]="false"
title="{{ org?.name }}"
[isActive]="org?.state === OrgState.ORG_STATE_ACTIVE"
[isInactive]="org?.state === OrgState.ORG_STATE_INACTIVE"
[hasContributors]="true"
stateTooltip="{{ 'ORG.STATE.' + org?.state | translate }}"
[hasActions]="['org.write:' + org?.id, 'org.write$'] | hasRole | async"
[hasActions]="hasWrite$ | async"
>
<ng-template topActions cnslHasRole [hasRole]="['org.write:' + org?.id, 'org.write$']">
<ng-container topActions *ngIf="hasWrite$ | async">
<button
mat-menu-item
*ngIf="org?.state === OrgState.ORG_STATE_ACTIVE"
@@ -23,7 +24,11 @@
>
{{ 'ORG.PAGES.REACTIVATE' | translate }}
</button>
</ng-template>
<button data-e2e="rename" mat-menu-item (click)="renameOrg()">
{{ 'ORG.PAGES.RENAME.ACTION' | translate }}
</button>
</ng-container>
<cnsl-contributors
topContributors
[totalResult]="totalMemberResult"
@@ -18,6 +18,7 @@ import { GrpcAuthService } from 'src/app/services/grpc-auth.service';
import { ManagementService } from 'src/app/services/mgmt.service';
import { ToastService } from 'src/app/services/toast.service';
import { Buffer } from 'buffer';
import { NameDialogComponent } from 'src/app/modules/name-dialog/name-dialog.component';
@Component({
selector: 'cnsl-org-detail',
@@ -44,7 +45,7 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
public InfoSectionType: any = InfoSectionType;
constructor(
auth: GrpcAuthService,
private auth: GrpcAuthService,
private dialog: MatDialog,
public mgmtService: ManagementService,
private toast: ToastService,
@@ -235,4 +236,49 @@ export class OrgDetailComponent implements OnInit, OnDestroy {
this.loadMetadata();
});
}
public renameOrg(): void {
const dialogRef = this.dialog.open(NameDialogComponent, {
data: {
name: this.org?.name,
titleKey: 'ORG.PAGES.RENAME.TITLE',
descKey: 'ORG.PAGES.RENAME.DESCRIPTION',
labelKey: 'ORG.PAGES.NAME',
},
width: '400px',
});
dialogRef.afterClosed().subscribe((name) => {
if (name) {
this.updateOrg(name);
}
});
}
public updateOrg(name: string): void {
if (this.org) {
this.mgmtService
.updateOrg(name)
.then(() => {
this.toast.showInfo('ORG.TOAST.UPDATED', true);
if (this.org) {
this.org.name = name;
}
this.mgmtService
.getMyOrg()
.then((resp) => {
if (resp.org) {
this.org = resp.org;
this.auth.setActiveOrg(resp.org);
}
})
.catch((error) => {
this.toast.showError(error);
});
})
.catch((error) => {
this.toast.showError(error);
});
}
}
}
+2
View File
@@ -19,6 +19,7 @@ import { InfoSectionModule } from 'src/app/modules/info-section/info-section.mod
import { InputModule } from 'src/app/modules/input/input.module';
import { MetaLayoutModule } from 'src/app/modules/meta-layout/meta-layout.module';
import { MetadataModule } from 'src/app/modules/metadata/metadata.module';
import { NameDialogModule } from 'src/app/modules/name-dialog/name-dialog.module';
import { SettingsGridModule } from 'src/app/modules/settings-grid/settings-grid.module';
import { SharedModule } from 'src/app/modules/shared/shared.module';
import { TopViewModule } from 'src/app/modules/top-view/top-view.module';
@@ -52,6 +53,7 @@ import { OrgRoutingModule } from './org-routing.module';
WarnDialogModule,
MemberCreateDialogModule,
MatMenuModule,
NameDialogModule,
ChangesModule,
MatProgressSpinnerModule,
MetadataModule,