Skip to content

fix: aibutton placeholder header #2499

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/components/ComponentsProvider/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ export class Registry<Entities extends RegistryEntities = {}> {
return this.entities[id];
}

has<Id extends keyof Entities>(id: Id): boolean {
const entity = this.entities[id];
return entity && entity.name !== 'EmptyPlaceholder';
}

register<Id extends string, T>(id: Id, entity: T): Registry<Entities & {[key in Id]: T}> {
this.entities[id] = entity;

Expand All @@ -31,4 +36,5 @@ type ComponentType<T> =
export interface ComponentsRegistryTemplate<T extends Registry, Entities = NonNullable<T['type']>> {
set<Id extends keyof Entities>(id: Id, entity: ComponentType<Entities[Id]>): this;
get<Id extends keyof Entities>(id: Id): ComponentType<Entities[Id]>;
has<Id extends keyof Entities>(id: Id): boolean;
}
5 changes: 2 additions & 3 deletions src/containers/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ function Header() {
const isAddClusterAvailable =
useAddClusterFeatureAvailable() && uiFactory.onAddCluster !== undefined;

const AIAssistantButton = componentsRegistry.get('AIAssistantButton');

const breadcrumbItems = React.useMemo(() => {
let options = {...pageBreadcrumbsOptions, singleClusterMode};

Expand Down Expand Up @@ -79,7 +77,8 @@ function Header() {
);
}

if (AIAssistantButton) {
if (componentsRegistry.has('AIAssistantButton')) {
const AIAssistantButton = componentsRegistry.get('AIAssistantButton');
elements.push(<AIAssistantButton key="ai-assistant" />);
}

Expand Down
Loading