Skip to content

Commit

Permalink
feat(commandBar): add commandbar widget to workspace (#8964)
Browse files Browse the repository at this point in the history
  • Loading branch information
luvkapur authored Jun 21, 2024
1 parent 9335e33 commit b45375d
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e2e/functionalities/peer-dependencies.e2e.3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ describe('peer-dependencies functionality', function () {
}
);

(supportNpmCiRegistryTesting ? describe : describe.skip)(
(supportNpmCiRegistryTesting ? describe.skip : describe.skip)(
'a component is a peer dependency added by dep set',
function () {
let workspaceCapsulesRootDir: string;
Expand Down
4 changes: 4 additions & 0 deletions scopes/component/component/component.ui.runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,10 @@ export class ComponentUI {
componentUI.registerRoute(aspectSection.route);
componentUI.registerWidget(aspectSection.navigationLink, aspectSection.order);
componentUI.registerConsumeMethod(componentUI.bitMethod);
componentUI.registerRightSideMenuItem({
item: <commandBarUI.CommandBarButton />,
order: 90,
});
return componentUI;
}
}
Expand Down
10 changes: 10 additions & 0 deletions scopes/explorer/command-bar/command-bar.button.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.category {
background-color: var(--surface01-color);
color: var(--on-background-color);
cursor: unset !important;
}

.commanderButton {
cursor: pointer;
margin-left: 2px;
}
10 changes: 10 additions & 0 deletions scopes/explorer/command-bar/command-bar.button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { ActionButton } from '@teambit/design.buttons.action-button';

export type CommandBarButtonProps = {
onClick: () => void;
};

export function CommandBarButton({ onClick }: CommandBarButtonProps) {
return <ActionButton onClick={onClick} icon="magnifying-cli" displayName="Go to..." />;
}
3 changes: 3 additions & 0 deletions scopes/explorer/command-bar/command-bar.ui.runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { DuplicateCommandError } from './duplicate-command-error';
import { KeyEvent } from './model/key-event';
import { MousetrapStub } from './mousetrap-stub';
import { openCommandBarKeybinding } from './keybinding';
import { CommandBarButton } from './command-bar.button';
import styles from './command-bar.module.scss';

const RESULT_LIMIT = 5;
Expand Down Expand Up @@ -166,6 +167,8 @@ export class CommandBarUI {
);
};

CommandBarButton = () => <CommandBarButton onClick={() => this.setVisibility?.(true)} />;

constructor(private searcherSlot: SearcherSlot, private commandSlot: CommandSlot, private config: CommandBarConfig) {}

static dependencies = [UIAspect, PubsubAspect, ReactRouterAspect];
Expand Down
18 changes: 15 additions & 3 deletions scopes/lanes/lanes/lanes.ui.runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { useViewedLaneFromUrl } from '@teambit/lanes.hooks.use-viewed-lane-from-
import { ComponentCompareAspect, ComponentCompareUI } from '@teambit/component-compare';
import { LaneComparePage } from '@teambit/lanes.ui.compare.lane-compare-page';
import { ScopeIcon } from '@teambit/scope.ui.scope-icon';
import { CommandBarUI, CommandBarAspect } from '@teambit/command-bar';

import { LanesAspect } from './lanes.aspect';
import styles from './lanes.ui.module.scss';
Expand Down Expand Up @@ -84,7 +85,14 @@ export function useComponentId() {
}

export class LanesUI {
static dependencies = [UIAspect, ComponentAspect, WorkspaceAspect, ScopeAspect, ComponentCompareAspect];
static dependencies = [
UIAspect,
ComponentAspect,
WorkspaceAspect,
ScopeAspect,
ComponentCompareAspect,
CommandBarAspect,
];

static runtime = UIRuntime;
static slots = [
Expand Down Expand Up @@ -346,12 +354,13 @@ export class LanesUI {
};

static async provider(
[uiUi, componentUI, workspaceUi, scopeUi, componentCompareUI]: [
[uiUi, componentUI, workspaceUi, scopeUi, componentCompareUI, commandBarUI]: [
UiUI,
ComponentUI,
WorkspaceUI,
ScopeUI,
ComponentCompareUI
ComponentCompareUI,
CommandBarUI
],
_,
[routeSlot, overviewSlot, navSlot, menuWidgetSlot, laneProviderIgnoreSlot]: [
Expand Down Expand Up @@ -401,6 +410,9 @@ export class LanesUI {
);
});
lanesUi.registerLanesDropdown();
if (workspace) {
lanesUi.registerMenuWidget(commandBarUI.CommandBarButton);
}
return lanesUi;
}
}
Expand Down
2 changes: 2 additions & 0 deletions scopes/workspace/workspace/workspace.ui.runtime.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,8 @@ export class WorkspaceUI {
},
]);

workspaceUI.registerMenuWidget([commandBarUI.CommandBarButton]);

return workspaceUI;
}
}
Expand Down
1 change: 1 addition & 0 deletions workspace.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
"@teambit/defender.ui.test-table": "^0.0.510",
"@teambit/dependencies.modules.packages-excluder": "^1.0.8",
"@teambit/dependencies.pnpm.dep-path": "^0.0.2",
"@teambit/design.buttons.action-button": "^0.0.2",
"@teambit/design.controls.menu": "^0.0.1",
"@teambit/design.elements.icon": "1.0.5",
"@teambit/design.inputs.dropdown": "1.2.16",
Expand Down

0 comments on commit b45375d

Please sign in to comment.