Skip to content

Commit

Permalink
add actionmenut ext
Browse files Browse the repository at this point in the history
  • Loading branch information
ashutosh16 committed Aug 21, 2024
1 parent 7538083 commit 3e67e6d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {ApplicationsDetailsAppDropdown} from './application-details-app-dropdown
import {useSidebarTarget} from '../../../sidebar/sidebar';

import './application-details.scss';
import {ToolBarExtension, AppViewExtension, StatusPanelExtension} from '../../../shared/services/extensions-service';
import {TopBarExtension, AppViewExtension, StatusPanelExtension} from '../../../shared/services/extensions-service';

interface ApplicationDetailsState {
page: number;
Expand All @@ -44,8 +44,8 @@ interface ApplicationDetailsState {
extensionsMap?: {[key: string]: AppViewExtension};
statusExtensions?: StatusPanelExtension[];
statusExtensionsMap?: {[key: string]: StatusPanelExtension};
toolBarExtensions?: ToolBarExtension[];
toolBarExtensionsMap?: {[key: string]: ToolBarExtension};
TopBarExtensions?: TopBarExtension[];
TopBarExtensionsMap?: {[key: string]: TopBarExtension};
}

interface FilterInput {
Expand Down Expand Up @@ -95,10 +95,10 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{app
statusExtensions.forEach(ext => {
statusExtensionsMap[ext.id] = ext;
});
const toolBarExtensions = services.extensions.getToolBarExtensions();
const toolBarExtensionsMap: {[key: string]: ToolBarExtension} = {};
toolBarExtensions.forEach(ext => {
toolBarExtensionsMap[ext.id] = ext;
const TopBarExtensions = services.extensions.getTopBarExtensions();
const TopBarExtensionsMap: {[key: string]: TopBarExtension} = {};
TopBarExtensions.forEach(ext => {
TopBarExtensionsMap[ext.id] = ext;
});
this.state = {
page: 0,
Expand All @@ -111,8 +111,8 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{app
extensionsMap,
statusExtensions,
statusExtensionsMap,
toolBarExtensions,
toolBarExtensionsMap
TopBarExtensions,
TopBarExtensionsMap
};
if (typeof this.props.match.params.appnamespace === 'undefined') {
this.appNamespace = '';
Expand Down Expand Up @@ -576,8 +576,8 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{app
});

const activeExtension = this.state.statusExtensionsMap[this.selectedExtension];
const toolBarExtensions = services.extensions.getToolBarExtensions();
const toolBarExtensionsExt = this.state.toolBarExtensionsMap[this.selectedExtension];
const TopBarExtensions = services.extensions.getTopBarExtensions();
const TopBarExtensionsExt = this.state.TopBarExtensionsMap[this.selectedExtension];

return (
<div className={`application-details ${this.props.match.params.name}`}>
Expand All @@ -593,8 +593,8 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{app
actionMenu: {
items: [...this.getApplicationActionMenu(application, true)]
},
toolBarExtensions: toolBarExtensions.map(ext => (
<ToolBarExtensionView
actionMenuExtensions: TopBarExtensions.map(ext => (
<TopBarExtensionView
extension={ext}
key={ext.id}
application={application}
Expand Down Expand Up @@ -892,11 +892,11 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{app
{this.selectedExtension !== '' && activeExtension?.flyout && <activeExtension.flyout tree={tree} application={application} />}
</SlidingPanel>
<SlidingPanel
isMiddle={toolBarExtensionsExt?.isMiddle}
isNarrow={toolBarExtensionsExt?.isNarrow}
isShown={this.selectedExtension !== '' && toolBarExtensionsExt != null && toolBarExtensionsExt.flyout != null}
isMiddle={TopBarExtensionsExt?.isMiddle}
isNarrow={TopBarExtensionsExt?.isNarrow}
isShown={this.selectedExtension !== '' && TopBarExtensionsExt != null && TopBarExtensionsExt.flyout != null}
onClose={() => this.setExtensionPanelVisible('')}>
{this.selectedExtension !== '' && toolBarExtensionsExt?.flyout && <toolBarExtensionsExt.flyout tree={tree} application={application} />}
{this.selectedExtension !== '' && TopBarExtensionsExt?.flyout && <TopBarExtensionsExt.flyout tree={tree} application={application} />}
</SlidingPanel>
</Page>
</div>
Expand Down Expand Up @@ -1173,7 +1173,7 @@ const ExtensionView = (props: {extension: AppViewExtension; application: models.
return <extension.component application={application} tree={tree} />;
};

const ToolBarExtensionView = (props: {extension: ToolBarExtension; application: models.Application; tree: models.ApplicationTree; showExtension?: (id: string) => any}) => {
const TopBarExtensionView = (props: {extension: TopBarExtension; application: models.Application; tree: models.ApplicationTree; showExtension?: (id: string) => any}) => {
const {extension, application, tree, showExtension} = props;
return <extension.component key={extension.title} application={application} tree={tree} openFlyout={() => showExtension && showExtension(extension.id)} />;
};
26 changes: 13 additions & 13 deletions ui/src/app/shared/services/extensions-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const extensions = {
systemLevelExtensions: new Array<SystemLevelExtension>(),
appViewExtensions: new Array<AppViewExtension>(),
statusPanelExtensions: new Array<StatusPanelExtension>(),
toolBarExtensions: new Array<ToolBarExtension>()
TopBarExtensions: new Array<TopBarExtension>()
};

function registerResourceExtension(component: ExtensionComponent, group: string, kind: string, tabTitle: string, opts?: {icon: string}) {
Expand All @@ -27,8 +27,8 @@ function registerStatusPanelExtension(component: StatusPanelExtensionComponent,
extensions.statusPanelExtensions.push({component, flyout, title, id, isMiddle, isNarrow});
}

function registerToolBarExtension(component: ToolBarExtensionComponent, title: string, id: string, flyout?: ExtensionComponent, isMiddle = false, isNarrow = false) {
extensions.toolBarExtensions.push({component, flyout, title, id, isMiddle, isNarrow});
function registerTopBarExtension(component: TopBarExtensionComponent, title: string, id: string, flyout?: ExtensionComponent, isMiddle = false, isNarrow = false) {
extensions.TopBarExtensions.push({component, flyout, title, id, isMiddle, isNarrow});
}

let legacyInitialized = false;
Expand Down Expand Up @@ -75,9 +75,9 @@ export interface StatusPanelExtension {
isNarrow: boolean;
}

export interface ToolBarExtension {
component: ToolBarExtensionComponent;
flyout?: ToolBarExtensionFlyoutComponent;
export interface TopBarExtension {
component: TopBarExtensionComponent;
flyout?: TopBarExtensionFlyoutComponent;
title: string;
id: string;
isMiddle: boolean;
Expand All @@ -89,8 +89,8 @@ export type SystemExtensionComponent = React.ComponentType;
export type AppViewExtensionComponent = React.ComponentType<AppViewComponentProps>;
export type StatusPanelExtensionComponent = React.ComponentType<StatusPanelComponentProps>;
export type StatusPanelExtensionFlyoutComponent = React.ComponentType<StatusPanelFlyoutProps>;
export type ToolBarExtensionComponent = React.ComponentType<ToolBarExtensionComponentProps>;
export type ToolBarExtensionFlyoutComponent = React.ComponentType<ToolBarExtensionFlyoutProps>;
export type TopBarExtensionComponent = React.ComponentType<TopBarExtensionComponentProps>;
export type TopBarExtensionFlyoutComponent = React.ComponentType<TopBarExtensionFlyoutProps>;

export interface Extension {
component: ExtensionComponent;
Expand All @@ -112,7 +112,7 @@ export interface StatusPanelComponentProps {
openFlyout: () => any;
}

export interface ToolBarExtensionComponentProps {
export interface TopBarExtensionComponentProps {
application: Application;
tree: ApplicationTree;
openFlyout: () => any;
Expand All @@ -123,7 +123,7 @@ export interface StatusPanelFlyoutProps {
tree: ApplicationTree;
}

export interface ToolBarExtensionFlyoutProps {
export interface TopBarExtensionFlyoutProps {
application: Application;
tree: ApplicationTree;
}
Expand All @@ -146,8 +146,8 @@ export class ExtensionsService {
public getStatusPanelExtensions(): StatusPanelExtension[] {
return extensions.statusPanelExtensions.slice();
}
public getToolBarExtensions(): ToolBarExtension[] {
return extensions.toolBarExtensions.slice();
public getTopBarExtensions(): TopBarExtension[] {
return extensions.TopBarExtensions.slice();
}
}

Expand All @@ -159,6 +159,6 @@ export class ExtensionsService {
registerSystemLevelExtension,
registerAppViewExtension,
registerStatusPanelExtension,
registerToolBarExtension
registerTopBarExtension
};
})(window);

0 comments on commit 3e67e6d

Please sign in to comment.