Skip to content

Commit f2c967b

Browse files
authored
fix: aibutton placeholder header (#2499)
1 parent 81dbbf8 commit f2c967b

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/components/ComponentsProvider/registry.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export class Registry<Entities extends RegistryEntities = {}> {
1616
return this.entities[id];
1717
}
1818

19+
has<Id extends keyof Entities>(id: Id): boolean {
20+
const entity = this.entities[id];
21+
return entity && entity.name !== 'EmptyPlaceholder';
22+
}
23+
1924
register<Id extends string, T>(id: Id, entity: T): Registry<Entities & {[key in Id]: T}> {
2025
this.entities[id] = entity;
2126

@@ -31,4 +36,5 @@ type ComponentType<T> =
3136
export interface ComponentsRegistryTemplate<T extends Registry, Entities = NonNullable<T['type']>> {
3237
set<Id extends keyof Entities>(id: Id, entity: ComponentType<Entities[Id]>): this;
3338
get<Id extends keyof Entities>(id: Id): ComponentType<Entities[Id]>;
39+
has<Id extends keyof Entities>(id: Id): boolean;
3440
}

src/containers/Header/Header.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ function Header() {
3939
const isAddClusterAvailable =
4040
useAddClusterFeatureAvailable() && uiFactory.onAddCluster !== undefined;
4141

42-
const AIAssistantButton = componentsRegistry.get('AIAssistantButton');
43-
4442
const breadcrumbItems = React.useMemo(() => {
4543
let options = {...pageBreadcrumbsOptions, singleClusterMode};
4644

@@ -79,7 +77,8 @@ function Header() {
7977
);
8078
}
8179

82-
if (AIAssistantButton) {
80+
if (componentsRegistry.has('AIAssistantButton')) {
81+
const AIAssistantButton = componentsRegistry.get('AIAssistantButton');
8382
elements.push(<AIAssistantButton key="ai-assistant" />);
8483
}
8584

0 commit comments

Comments
 (0)