feat(console): rehauled navigation for instances including breadcrumb (#10283)

This PR significantly improves user navigation by introducing a new
instance-level navigation bar. This new bar, positioned above the
existing organization navigation, provides quick access to key sections:
Home, Organizations, Actions, and Settings.

Additionally, the breadcrumb component has been refined for more
consistent behavior, reintroducing intuitive breadcrumb buttons to
easily navigate up the hierarchy. These changes also include design
improvements for a cleaner and more streamlined appearance across the
interface.

<img width="423" height="138" alt="Screenshot 2025-07-17 at 14 55 46"
src="https://github.com/user-attachments/assets/ba9e40a1-1077-4cb6-8735-ac7ab637abe7"
/>
<img width="562" height="132" alt="Screenshot 2025-07-17 at 14 56 41"
src="https://github.com/user-attachments/assets/d85dc673-0df8-4677-9d2b-dc031dde42c3"
/>
<img width="545" height="254" alt="Screenshot 2025-07-17 at 14 56 10"
src="https://github.com/user-attachments/assets/eaf10117-079e-4181-8dbb-60c89b24556a"
/>
<img width="689" height="261" alt="Screenshot 2025-07-17 at 14 56 20"
src="https://github.com/user-attachments/assets/510ad550-1d9a-4c6a-8af1-66cb0b23619c"
/>

---------

Co-authored-by: conblem <[email protected]>
Co-authored-by: Stefan Benz <[email protected]>
Co-authored-by: Florian Forster <[email protected]>
This commit is contained in:
Max Peintner
2025-08-28 11:23:14 +02:00
committed by GitHub
co-authored by conblem Stefan Benz Florian Forster
parent cccba3f8f3
commit f963ea9f86
117 changed files with 3286 additions and 2360 deletions
@@ -0,0 +1,212 @@
import { computed, Injectable, signal } from '@angular/core';
import { GrpcService } from './grpc.service';
import { injectQuery, mutationOptions, QueryClient, queryOptions, skipToken } from '@tanstack/angular-query-experimental';
import { MessageInitShape } from '@bufbuild/protobuf';
import { ListOrganizationsRequestSchema, ListOrganizationsResponse } from '@zitadel/proto/zitadel/org/v2/org_service_pb';
import { NewMgmtService } from './new-mgmt.service';
import { OrgInterceptorProvider } from './interceptors/org.interceptor';
import { NewAdminService } from './new-admin.service';
import { SetUpOrgRequestSchema } from '@zitadel/proto/zitadel/admin_pb';
import { TranslateService } from '@ngx-translate/core';
import { lastValueFrom } from 'rxjs';
import { first } from 'rxjs/operators';
import { StorageKey, StorageLocation, StorageService } from './storage.service';
import { UserService } from './user.service';
@Injectable({
providedIn: 'root',
})
export class NewOrganizationService {
constructor(
private readonly grpcService: GrpcService,
private readonly newMgtmService: NewMgmtService,
private readonly newAdminService: NewAdminService,
private readonly orgInterceptorProvider: OrgInterceptorProvider,
private readonly queryClient: QueryClient,
private readonly translate: TranslateService,
private readonly storage: StorageService,
private readonly userService: UserService,
) {}
private readonly orgIdSignal = signal<string | undefined>(
this.storage.getItem(StorageKey.organizationId, StorageLocation.session) ??
this.storage.getItem(StorageKey.organizationId, StorageLocation.local) ??
undefined,
);
public readonly orgId = this.orgIdSignal.asReadonly();
public getOrgId() {
return computed(() => {
const orgId = this.orgIdSignal();
if (orgId === undefined) {
throw new Error('No organization ID set');
}
return orgId;
});
}
public async setOrgId(orgId?: string) {
const organization = await this.queryClient.fetchQuery(this.organizationByIdQueryOptions(orgId ?? this.getOrgId()()));
if (organization) {
this.storage.setItem(StorageKey.organizationId, orgId, StorageLocation.session);
this.storage.setItem(StorageKey.organizationId, orgId, StorageLocation.local);
this.orgIdSignal.set(orgId);
} else {
throw new Error('request organization not found');
}
return organization;
}
public organizationByIdQueryOptions(organizationId?: string) {
const req = {
query: {
limit: 1,
},
queries: [
{
query: {
case: 'idQuery' as const,
value: {
id: organizationId?.toString(),
},
},
},
],
};
return queryOptions({
queryKey: [this.userService.userId(), 'organization', 'listOrganizations', req],
queryFn: organizationId
? () => this.listOrganizations(req).then((resp) => resp.result.find(Boolean) ?? null)
: skipToken,
});
}
public activeOrganizationQuery() {
return injectQuery(() => this.organizationByIdQueryOptions(this.orgId()));
}
public listOrganizationsQueryOptions(req?: MessageInitShape<typeof ListOrganizationsRequestSchema>) {
return queryOptions({
queryKey: this.listOrganizationsQueryKey(req),
queryFn: () => this.listOrganizations(req ?? {}),
});
}
public listOrganizationsQueryKey(req?: MessageInitShape<typeof ListOrganizationsRequestSchema>) {
if (!req) {
return [this.userService.userId(), 'organization', 'listOrganizations'];
}
// needed because angular query isn't able to serialize a bigint key
const query = req.query ? { ...req.query, offset: req.query.offset ? Number(req.query.offset) : undefined } : undefined;
const queryKey = {
...req,
...(query ? { query } : {}),
};
return [this.userService.userId(), 'organization', 'listOrganizations', queryKey];
}
public listOrganizations(
req: MessageInitShape<typeof ListOrganizationsRequestSchema>,
signal?: AbortSignal,
): Promise<ListOrganizationsResponse> {
return this.grpcService.organizationNew.listOrganizations(req, { signal });
}
private async getDefaultOrganization() {
let resp = await this.listOrganizations({
query: {
limit: 1,
},
queries: [
{
query: {
case: 'defaultQuery',
value: {},
},
},
],
});
return resp.result.find(Boolean) ?? null;
}
private invalidateAllOrganizationQueries() {
return this.queryClient.invalidateQueries({
queryKey: this.listOrganizationsQueryOptions().queryKey,
});
}
public renameOrgMutationOptions = () =>
mutationOptions({
mutationKey: ['renameOrg'],
mutationFn: (name: string) => this.newMgtmService.updateOrg({ name }),
onSettled: () => this.invalidateAllOrganizationQueries(),
});
public deleteOrgMutationOptions = () =>
mutationOptions({
mutationKey: ['deleteOrg'],
mutationFn: async () => {
// Before we remove the org we get the current default org
// we have to query before the current org is removed
const defaultOrg = await this.getDefaultOrganization();
if (!defaultOrg) {
const error$ = this.translate.get('ORG.TOAST.DEFAULTORGOTFOUND').pipe(first());
throw { message: await lastValueFrom(error$) };
}
const resp = await this.newMgtmService.removeOrg();
await new Promise((resolve) => setTimeout(resolve, 1000));
// We change active org to default org as
// current org was deleted to avoid Organization doesn't exist
await this.setOrgId(defaultOrg.id);
return resp;
},
onSettled: async () => {
const orgId = this.orgInterceptorProvider.getOrgId();
if (orgId) {
this.queryClient.removeQueries({
queryKey: this.organizationByIdQueryOptions(orgId).queryKey,
});
}
await this.invalidateAllOrganizationQueries();
},
});
public reactivateOrgMutationOptions = () =>
mutationOptions({
mutationKey: ['reactivateOrg'],
mutationFn: () => this.newMgtmService.reactivateOrg(),
onSettled: () => this.invalidateAllOrganizationQueries(),
});
public deactivateOrgMutationOptions = () =>
mutationOptions({
mutationKey: ['deactivateOrg'],
mutationFn: () => this.newMgtmService.deactivateOrg(),
onSettled: () => this.invalidateAllOrganizationQueries(),
});
public setupOrgMutationOptions = () =>
mutationOptions({
mutationKey: ['setupOrg'],
mutationFn: (req: MessageInitShape<typeof SetUpOrgRequestSchema>) => this.newAdminService.setupOrg(req),
onSettled: async () => {
await this.invalidateAllOrganizationQueries();
},
});
public addOrgMutationOptions = () =>
mutationOptions({
mutationKey: ['addOrg'],
mutationFn: (name: string) => this.newMgtmService.addOrg(name),
onSettled: async () => {
await this.invalidateAllOrganizationQueries();
},
});
}