Skip to content
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

feat: add action menu extension #576

Closed
wants to merge 3 commits into from
Closed
Changes from 1 commit
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
Next Next commit
add toolbar ext
add toolbar ext

add toolbar ext

Signed-off-by: ashutosh16 <[email protected]>
ashutosh16 committed Aug 22, 2024
commit 6e4cffc85a5b575d00cabc78a0ac311160c8b020
9 changes: 7 additions & 2 deletions src/components/top-bar/top-bar.tsx
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@ export interface Toolbar {
breadcrumbs?: { title: string | React.ReactNode, path?: string; }[];
tools?: React.ReactNode;
actionMenu?: ActionMenu;
toolBarExtensions?: React.ReactNode[];
}

export interface TopBarProps extends React.Props<any> {
@@ -85,22 +86,26 @@ const renderBreadcrumbs = (breadcrumbs: { title: string | React.ReactNode, path?
</div>
);

const renderActionMenu = (actionMenu: ActionMenu) => (
const renderActionMenu = (actionMenu: ActionMenu, toolBarExts: React.ReactNode[]) => (
<div>
{actionMenu.items.map((item, i) => (
<button disabled={!!item.disabled} qe-id={item.qeId} className='argo-button argo-button--base' onClick={() => item.action()} style={{marginRight: 2}} key={i}>
{item.iconClassName && (<i className={item.iconClassName} style={{marginLeft: '-5px', marginRight: '5px'}}/>)}
{item.title}
</button>
))}
{toolBarExts && toolBarExts.map((ext, index) => (
<React.Fragment key={index}>{ext}</React.Fragment>
))}
</div>
);

const renderToolbar = (toolbar: Toolbar) => (
<div className='top-bar row' key='tool-bar'>
<div className='columns small-9 top-bar__left-side'>
{toolbar.actionMenu && renderActionMenu(toolbar.actionMenu)}
{toolbar.actionMenu && renderActionMenu(toolbar.actionMenu, toolbar.toolBarExtensions)}
</div>

<div className='columns small-3 top-bar__right-side'>
{toolbar.filter && renderFilter(toolbar.filter)}
{toolbar.tools}