Skip to content

Commit

Permalink
CB-3733 removes closeOnMouseWheelClick prop
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeyteleshev committed Jul 26, 2024
1 parent 2565c6f commit 8112d75
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 64 deletions.
2 changes: 1 addition & 1 deletion webapp/packages/core-ui/src/SideBarPanel/SideBarPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const SideBarPanel = observer<SideBarPanelProps>(function SideBarPanel({
<SContext registry={sideBarPanelRegistry}>
<TabsState container={container} lazy>
<div className={s(style, { box: true })}>
<TabList className={s(style, { tabList: true })} closeOnMouseWheelClick underline />
<TabList className={s(style, { tabList: true })} underline />
<div className={s(style, { contentBox: true })}>
<TabPanelList />
</div>
Expand Down
2 changes: 1 addition & 1 deletion webapp/packages/core-ui/src/Tabs/Tab/Tab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const Tab = observer<TabProps>(function Tab(props) {
const canClose = getComputed(() => !!onClose || (tab.closable && tab.state.closable));

function onMouseUpHandler(event: React.MouseEvent<HTMLDivElement>) {
if (event.button === 1 && props.closeOnMouseWheelClick && canClose) {
if (event.button === 1 && canClose) {
tab.handleClose(event);
}
}
Expand Down
13 changes: 1 addition & 12 deletions webapp/packages/core-ui/src/Tabs/Tab/TabDefault.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ interface Props<T = Record<string, any>> {
component?: React.FC<TabProps & T>;
className?: string;
disabled?: boolean;
closeOnMouseWheelClick?: boolean;
onOpen?: (tab: ITabData<any>) => void;
onClose?: (tab: ITabData<any>) => void;
}
Expand All @@ -34,7 +33,6 @@ export function TabDefault<T = Record<string, any>>({
icon,
name,
component,
closeOnMouseWheelClick,
className,
disabled,
onOpen,
Expand All @@ -50,7 +48,6 @@ export function TabDefault<T = Record<string, any>>({
return (
<TabContext.Provider value={tabContext}>
<TabComponent
closeOnMouseWheelClick={closeOnMouseWheelClick}
tabId={tabId}
className={className}
{...(rest as unknown as T)}
Expand All @@ -64,15 +61,7 @@ export function TabDefault<T = Record<string, any>>({
}

return (
<Tab
closeOnMouseWheelClick={closeOnMouseWheelClick}
tabId={tabId}
className={className}
selected={selected}
disabled={disabled}
onOpen={onOpen}
onClose={onClose}
>
<Tab tabId={tabId} className={className} selected={selected} disabled={disabled} onOpen={onOpen} onClose={onClose}>
{icon && <TabIcon icon={icon} />}
{name && (
<TabTitle>
Expand Down
1 change: 0 additions & 1 deletion webapp/packages/core-ui/src/Tabs/Tab/TabProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export type TabProps = PropsWithChildren<{
selected?: boolean;
disabled?: boolean;
className?: string;
closeOnMouseWheelClick?: boolean;
onOpen?: (tab: ITabData<any>) => void;
onClose?: (tab: ITabData<any>) => void;
onClick?: (tabId: string) => void;
Expand Down
3 changes: 0 additions & 3 deletions webapp/packages/core-ui/src/Tabs/TabList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export interface TabListProps extends Omit<TabListOptions, keyof TabStateReturn>
rotated?: boolean;
underline?: boolean;
big?: boolean;
closeOnMouseWheelClick?: boolean;
className?: string;
}

Expand All @@ -38,7 +37,6 @@ export const TabList = observer<React.PropsWithChildren<TabListProps>>(function
rotated,
underline,
big,
closeOnMouseWheelClick,
childrenFirst,
...props
}) {
Expand Down Expand Up @@ -74,7 +72,6 @@ export const TabList = observer<React.PropsWithChildren<TabListProps>>(function
(tabInfo, key) => (
<TabDefault
key={key}
closeOnMouseWheelClick={closeOnMouseWheelClick}
tabId={key}
name={tabInfo.name}
icon={tabInfo.icon}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export const NavigationTabsBar = observer<Props>(function NavigationTabsBar({ cl
tabs={
<SContext registry={tabsRegistry}>
{navigation.tabIdList.map(tabId => (
<TabHandlerTab key={tabId} tabId={tabId} closeOnMouseWheelClick onSelect={handleSelect} onClose={handleClose} />
<TabHandlerTab key={tabId} tabId={tabId} onSelect={handleSelect} onClose={handleClose} />
))}
</SContext>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ import { useTabHandler } from './useTabHandler';

interface IProps {
tabId: string;
closeOnMouseWheelClick?: boolean;
onSelect: (tabId: string) => void;
onClose?: (tabId: string) => void;
}

export const TabHandlerTab = observer<IProps>(function TabHandlerTab({ tabId, onSelect, onClose, closeOnMouseWheelClick }) {
export const TabHandlerTab = observer<IProps>(function TabHandlerTab({ tabId, onSelect, onClose }) {
const tab = useTab(tabId);
const handler = useTabHandler(tab.handlerId);

const TabHandlerTab = handler.getTabComponent();

return <TabHandlerTab closeOnMouseWheelClick={closeOnMouseWheelClick} tab={tab} handler={handler} onSelect={onSelect} onClose={onClose} />;
return <TabHandlerTab tab={tab} handler={handler} onSelect={onSelect} onClose={onClose} />;
});
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import type { ITab } from './ITab';
export interface TabHandlerTabProps<T = any> {
tab: ITab<T>;
handler: TabHandler<T>;
closeOnMouseWheelClick?: boolean;
onSelect: (tabId: string) => void;
onClose?: (tabId: string) => void;
}
Expand Down
16 changes: 2 additions & 14 deletions webapp/packages/plugin-object-viewer/src/ObjectViewerTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@ import { useNode } from '@cloudbeaver/plugin-navigation-tree';

import type { IObjectViewerTabState } from './IObjectViewerTabState';

export const ObjectViewerTab: TabHandlerTabComponent<IObjectViewerTabState> = observer(function ObjectViewerTab({
tab,
onSelect,
onClose,
closeOnMouseWheelClick,
}) {
export const ObjectViewerTab: TabHandlerTabComponent<IObjectViewerTabState> = observer(function ObjectViewerTab({ tab, onSelect, onClose }) {
const viewContext = useContext(CaptureViewContext);
const tabMenuContext = useDataContext(viewContext);
const { node } = useNode(tab.handlerState.objectId);
Expand All @@ -30,14 +25,7 @@ export const ObjectViewerTab: TabHandlerTabComponent<IObjectViewerTabState> = ob
const title = node?.name || tab.handlerState.tabTitle;

return (
<Tab
closeOnMouseWheelClick={closeOnMouseWheelClick}
tabId={tab.id}
title={title}
menuContext={tabMenuContext}
onOpen={handleSelect}
onClose={handleClose}
>
<Tab tabId={tab.id} title={title} menuContext={tabMenuContext} onOpen={handleSelect} onClose={handleClose}>
<TabIcon icon={node?.icon || tab.handlerState.tabIcon} />
<TabTitle>{title}</TabTitle>
</Tab>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,7 @@ import {
import { DATA_CONTEXT_SQL_EDITOR_TAB } from './DATA_CONTEXT_SQL_EDITOR_TAB';
import sqlEditorTabStyles from './SqlEditorTab.module.css';

export const SqlEditorTab: TabHandlerTabComponent<ISqlEditorTabState> = observer(function SqlEditorTab({
tab,
onSelect,
onClose,
closeOnMouseWheelClick,
}) {
export const SqlEditorTab: TabHandlerTabComponent<ISqlEditorTabState> = observer(function SqlEditorTab({ tab, onSelect, onClose }) {
const viewContext = useContext(CaptureViewContext);
const tabMenuContext = useDataContext(viewContext);
const handlerState = tab.handlerState;
Expand Down Expand Up @@ -65,14 +60,7 @@ export const SqlEditorTab: TabHandlerTabComponent<ISqlEditorTabState> = observer
const handleClose = onClose ? ({ tabId }: ITabData<any>) => onClose(tabId) : undefined;

return (
<Tab
closeOnMouseWheelClick={closeOnMouseWheelClick}
tabId={tab.id}
title={name}
menuContext={tabMenuContext}
onOpen={handleSelect}
onClose={handleClose}
>
<Tab tabId={tab.id} title={name} menuContext={tabMenuContext} onOpen={handleSelect} onClose={handleClose}>
<TabIcon icon={icon} />
<TabTitle>{name}</TabTitle>
{isReadonly && isScript && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,10 @@ import { DATA_CONTEXT_SQL_EDITOR_RESULT_ID } from './DATA_CONTEXT_SQL_EDITOR_RES
interface Props {
result: ISqlEditorResultTab;
className?: string;
closeOnMouseWheelClick?: boolean;
onClose?: (tab: ITabData) => Promise<void>;
}

export const SqlResultTab = observer<Props>(function SqlResultTab({ result, className, onClose, closeOnMouseWheelClick }) {
export const SqlResultTab = observer<Props>(function SqlResultTab({ result, className, onClose }) {
const viewContext = useContext(CaptureViewContext);
const tabMenuContext = useDataContext(viewContext);

Expand All @@ -31,15 +30,7 @@ export const SqlResultTab = observer<Props>(function SqlResultTab({ result, clas
});

return (
<Tab
key={result.id}
closeOnMouseWheelClick={closeOnMouseWheelClick}
tabId={result.id}
title={result.name}
menuContext={tabMenuContext}
className={className}
onClose={onClose}
>
<Tab key={result.id} tabId={result.id} title={result.name} menuContext={tabMenuContext} className={className} onClose={onClose}>
<TabIcon icon={result.icon} />
<TabTitle>{result.name}</TabTitle>
</Tab>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const SqlResultTabs = observer<Props>(function SqlDataResult({ state, onT
<SContext registry={registry}>
<TabList className={s(style, { tabListNotExecutable: !executable })} aria-label="SQL Results">
{orderedTabs.map(result => (
<SqlResultTab key={result.id} result={result} closeOnMouseWheelClick />
<SqlResultTab key={result.id} result={result} />
))}
</TabList>
</SContext>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export const ToolsPanel = observer(function ToolsPanel() {
return (
<TabsState currentTabId={state.selectedTabId} container={toolsPanelService.tabsContainer} lazy onChange={handleTabChange}>
<div className={s(style, { box: true })}>
<TabList className={s(style, { tabList: true })} closeOnMouseWheelClick underline />
<TabList className={s(style, { tabList: true })} underline />
<div className={s(style, { contentBox: true })}>
<TabPanelList />
</div>
Expand Down

0 comments on commit 8112d75

Please sign in to comment.