Skip to content

Commit

Permalink
Add NavigationBar contributions extension points
Browse files Browse the repository at this point in the history
  • Loading branch information
wpiers committed Jun 4, 2024
1 parent 4d798fc commit 83cc7a0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ export {
export { type NavigationBarIconProps, type NavigationBarMenuProps } from './navigationBar/NavigationBar.types';
export {
navigationBarIconExtensionPoint,
navigationBarLeftContributionExtensionPoint,
navigationBarMenuExtensionPoint,
navigationBarRightContributionExtensionPoint,
} from './navigationBar/NavigationBarExtensionPoints';
export { routerExtensionPoint } from './router/RouterExtensionPoints';
export { projectActionButtonMenuItemExtensionPoint } from './views/project-browser/list-projects-area/ProjectActionButtonExtensionPoints';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Contributors:
* Obeo - initial API and implementation
*******************************************************************************/
import { useComponent } from '@eclipse-sirius/sirius-components-core';
import { useComponent, useComponents } from '@eclipse-sirius/sirius-components-core';
import AppBar from '@material-ui/core/AppBar';
import IconButton from '@material-ui/core/IconButton';
import Link from '@material-ui/core/Link';
Expand All @@ -19,7 +19,12 @@ import Tooltip from '@material-ui/core/Tooltip';
import { emphasize, makeStyles } from '@material-ui/core/styles';
import { Link as RouterLink } from 'react-router-dom';
import { NavigationBarProps } from './NavigationBar.types';
import { navigationBarIconExtensionPoint, navigationBarMenuExtensionPoint } from './NavigationBarExtensionPoints';
import {
navigationBarIconExtensionPoint,
navigationBarLeftContributionExtensionPoint,
navigationBarMenuExtensionPoint,
navigationBarRightContributionExtensionPoint,
} from './NavigationBarExtensionPoints';

const useNavigationBarStyles = makeStyles((theme) => ({
navbar: {
Expand Down Expand Up @@ -64,6 +69,8 @@ export const NavigationBar = ({ children }: NavigationBarProps) => {

const { Component: Icon } = useComponent(navigationBarIconExtensionPoint);
const { Component: Menu } = useComponent(navigationBarMenuExtensionPoint);
const leftContributions = useComponents(navigationBarLeftContributionExtensionPoint);
const rightContributions = useComponents(navigationBarRightContributionExtensionPoint);

return (
<div className={classes.navbar}>
Expand All @@ -78,9 +85,15 @@ export const NavigationBar = ({ children }: NavigationBarProps) => {
</IconButton>
</Link>
</Tooltip>
{leftContributions.map(({ Component: LeftContribution }, index) => (
<LeftContribution key={index} />
))}
</div>
{children}
<div className={classes.right}>
{rightContributions.map(({ Component: RightContribution }, index) => (
<RightContribution key={index} />
))}
<Menu />
</div>
</Toolbar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,7 @@ export interface NavigationBarProps {
export interface NavigationBarIconProps {}

export interface NavigationBarMenuProps {}

export interface NavigationBarLeftContributionProps {}

export interface NavigationBarRightContributionProps {}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
import { ComponentExtensionPoint } from '@eclipse-sirius/sirius-components-core';
import { SiriusIcon } from '../core/SiriusIcon';
import { Help } from './Help';
import { NavigationBarIconProps, NavigationBarMenuProps } from './NavigationBar.types';
import {
NavigationBarIconProps,
NavigationBarLeftContributionProps,
NavigationBarMenuProps,
NavigationBarRightContributionProps,
} from './NavigationBar.types';

const NavigationBarIcon = ({}: NavigationBarIconProps) => <SiriusIcon fontSize="large" />;
const NavigationBarMenu = ({}: NavigationBarMenuProps) => <Help />;
Expand All @@ -28,3 +33,15 @@ export const navigationBarMenuExtensionPoint: ComponentExtensionPoint<Navigation
identifier: 'navigationBar#menu',
FallbackComponent: NavigationBarMenu,
};

export const navigationBarLeftContributionExtensionPoint: ComponentExtensionPoint<NavigationBarLeftContributionProps> =
{
identifier: 'navigationBar#leftContributions',
FallbackComponent: () => null,
};

export const navigationBarRightContributionExtensionPoint: ComponentExtensionPoint<NavigationBarRightContributionProps> =
{
identifier: 'navigationBar#rightContributions',
FallbackComponent: () => null,
};

0 comments on commit 83cc7a0

Please sign in to comment.