Skip to content

Commit

Permalink
[3563] Add NavigationBar extension points
Browse files Browse the repository at this point in the history
Bug: eclipse-sirius#3563
Signed-off-by: William Piers <[email protected]>
  • Loading branch information
wpiers committed Jun 6, 2024
1 parent 23812fe commit bd6836b
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- https://github.com/eclipse-sirius/sirius-web/issues/3447[#3447] [view] Add support for For construct in the operations DSL
- https://github.com/eclipse-sirius/sirius-web/issues/3550[#3550] [core] Add ExtensionRegistry merge strategy
- https://github.com/eclipse-sirius/sirius-web/issues/3557[#3550] [app] Add ProjectSettings tab extension point
- https://github.com/eclipse-sirius/sirius-web/issues/3557[#3563] [app] Improve NavigationBar extensibility

=== Improvements

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,17 @@ export {
httpOptionsConfigurersExtensionPoint,
webSocketOptionsConfigurersExtensionPoint,
} from './graphql/useCreateApolloClientExtensionPoints';
export { type NavigationBarIconProps, type NavigationBarMenuProps } from './navigationBar/NavigationBar.types';
export {
type NavigationBarIconProps,
type NavigationBarLeftContributionProps,
type NavigationBarMenuProps,
type NavigationBarRightContributionProps,
} 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 All @@ -31,9 +36,8 @@ const useNavigationBarStyles = makeStyles((theme) => ({
backgroundColor: theme.palette.navigationBar.border,
},
toolbar: {
display: 'flex',
flexDirection: 'row',
justifyContent: 'space-between',
display: 'grid',
gridTemplateColumns: '1fr min-content 1fr',
backgroundColor: theme.palette.navigationBar.background,
},
left: {
Expand Down Expand Up @@ -64,6 +68,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 +84,15 @@ export const NavigationBar = ({ children }: NavigationBarProps) => {
</IconButton>
</Link>
</Tooltip>
{leftContributions.map(({ Component: LeftContribution }, index) => (
<LeftContribution key={index} />
))}
</div>
{children}
<div>{children}</div>
<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 bd6836b

Please sign in to comment.