Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
Signed-off-by: Yi Cai <[email protected]>
  • Loading branch information
ciiay committed Jan 29, 2025
1 parent 8bd40f1 commit fcc3659
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,41 @@ dynamicPlugins:
config:
layout:
position: above-main-content # above-main-content | below-main-content
- mountPoint: application/header/component
- mountPoint: global.header/component
importName: SearchComponent
config:
type: search
enabled: true
slot: header-start
priority: 100
- mountPoint: application/header/component
- mountPoint: global.header/component
importName: CreateDropdown
config:
type: dropdown_button
enabled: true
key: create
slot: header-start
priority: 90
- mountPoint: application/header/component
- mountPoint: global.header/component
importName: HeaderIconButton
config:
type: icon_button
enabled: true
slot: header-start
priority: 80
props:
icon: support
tooltip: 'Support'
- mountPoint: application/header/component
- mountPoint: global.header/component
importName: HeaderIconButton
config:
type: icon_button
enabled: true
slot: header-start
priority: 70
props:
icon: notifications
tooltip: 'Notifications'
- mountPoint: application/header/component
- mountPoint: global.header/component
importName: ProfileDropdown
config:
type: dropdown_button
enabled: true
key: profile
slot: header-end
priority: 0
8 changes: 1 addition & 7 deletions workspaces/global-header/plugins/global-header/dev/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ const defaultGlobalHeaderComponentsMountPoints: GlobalHeaderComponentMountPoint[
{
Component: SearchComponent,
config: {
enabled: true,
type: ComponentType.SEARCH,
slot: Slot.HEADER_START,
priority: 100, // the greater the number, the more to the left it will be
Expand All @@ -52,7 +51,6 @@ const defaultGlobalHeaderComponentsMountPoints: GlobalHeaderComponentMountPoint[
Component: CreateDropdown as React.ComponentType,
config: {
type: ComponentType.DROPDOWN_BUTTON,
enabled: true,
slot: Slot.HEADER_START,
priority: 90,
key: 'create',
Expand All @@ -62,7 +60,6 @@ const defaultGlobalHeaderComponentsMountPoints: GlobalHeaderComponentMountPoint[
Component: HeaderIconButton as React.ComponentType,
config: {
type: ComponentType.ICON_BUTTON,
enabled: true,
slot: Slot.HEADER_START,
priority: 80,
props: {
Expand All @@ -76,7 +73,6 @@ const defaultGlobalHeaderComponentsMountPoints: GlobalHeaderComponentMountPoint[
Component: HeaderIconButton as React.ComponentType,
config: {
type: ComponentType.ICON_BUTTON,
enabled: true,
slot: Slot.HEADER_START,
priority: 70,
props: {
Expand All @@ -91,7 +87,6 @@ const defaultGlobalHeaderComponentsMountPoints: GlobalHeaderComponentMountPoint[
Component: ProfileDropdown as React.ComponentType,
config: {
type: ComponentType.DROPDOWN_BUTTON,
enabled: true,
slot: Slot.HEADER_END,
priority: 0, // the greater the number, the more to the left it will be
key: 'profile',
Expand Down Expand Up @@ -166,8 +161,7 @@ const scalprumState: ScalprumState = {
api: {
dynamicRootConfig: {
mountPoints: {
'application/header/component':
defaultGlobalHeaderComponentsMountPoints,
'global.header/component': defaultGlobalHeaderComponentsMountPoints,
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ export const GlobalHeader = () => {
}

const filteredAndSorted = allGlobalHeaderMountPoints.filter(
component =>
component.config?.enabled !== false &&
(!component.config?.priority || component.config.priority > -1),
component => (component.config?.priority ?? 0) > -1,
);

filteredAndSorted.sort(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import { HeaderIcon } from './HeaderIcon';
import { Link } from 'react-router-dom';

/**
* @public
* Header Icon Button properties
* @public
*/
export interface HeaderIconButtonProps {
icon: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const SearchBar = (props: SearchBarProps) => {
let options: string[] = [];
if (results.length > 0) {
options = [
...results.slice(0, 5).map(result => result.document.title),
...results.map(result => result.document.title),
`${query?.term}`,
];
} else if (query?.term) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface ScalprumState {
api?: {
dynamicRootConfig?: {
mountPoints?: {
'application/header/component': GlobalHeaderComponentMountPoint[];
'global.header/component': GlobalHeaderComponentMountPoint[];
};
};
};
Expand All @@ -33,9 +33,7 @@ export const useGlobalHeaderMountPoints = ():
const scalprum = useScalprum<ScalprumState>();

const globalHeaderComponentsMountPoints =
scalprum?.api?.dynamicRootConfig?.mountPoints?.[
'application/header/component'
];
scalprum?.api?.dynamicRootConfig?.mountPoints?.['global.header/component'];

return globalHeaderComponentsMountPoints;
};
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ export enum ComponentType {
export interface GlobalHeaderComponentMountPointConfig {
type: ComponentType;
key?: string;
enabled?: boolean;
slot?: Slot;
priority?: number;
size?: 'small' | 'medium' | 'large';
Expand Down

0 comments on commit fcc3659

Please sign in to comment.