bito-code-review[bot] commented on code in PR #36644: URL: https://github.com/apache/superset/pull/36644#discussion_r2655902736
########## superset-frontend/src/components/MenuExtension/index.tsx: ########## @@ -0,0 +1,147 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { useMemo } from 'react'; +import { css, useTheme } from '@apache-superset/core/ui'; +import { Button, Dropdown } from '@superset-ui/core/components'; +import { Menu, MenuItemType } from '@superset-ui/core/components/Menu'; +import { Icons } from '@superset-ui/core/components/Icons'; +import { commands } from 'src/core'; +import ExtensionsManager from 'src/extensions/ExtensionsManager'; + +export type MenuExtensionProps = { + viewId: string; +} & ( + | { + primary: boolean; + secondary?: never; + children?: React.ReactNode; + defaultItems?: never; + compactMode?: boolean; + } + | { + primary?: never; + secondary: boolean; + children?: never; + defaultItems?: MenuItemType[]; + compactMode?: never; + } +); + +const MenuExtension = ({ + viewId, + primary, + secondary, + defaultItems, + children, + compactMode, +}: MenuExtensionProps) => { + const theme = useTheme(); + const iconColor = theme.colorPrimary; + const contributions = + ExtensionsManager.getInstance().getMenuContributions(viewId); + + const actions = primary ? contributions?.primary : contributions?.secondary; + const primaryActions = useMemo( + () => + primary + ? (actions || []).map(contribution => { + const command = + ExtensionsManager.getInstance().getCommandContribution( + contribution.command, + )!; Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Undefined Command Access</b></div> <div id="fix"> If getCommandContribution returns undefined, accessing command.icon will throw at runtime; add a guard or filter. </div> </div> <small><i>Code Review Run #bb862d</i></small> </div> --- Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>) - [ ] Yes, avoid them ########## superset-frontend/src/SqlLab/components/TabbedSqlEditors/index.tsx: ########## @@ -41,6 +41,40 @@ const StyledEditableTabs = styled(EditableTabs)` height: 100%; display: flex; flex-direction: column; + & .ant-tabs-nav::before { + border-color: ${({ theme }) => theme.colorBorder} !important; + } + & .ant-tabs-nav-add { + border-color: ${({ theme }) => theme.colorBorder} !important; + height: 34px; + } + & .ant-tabs-nav-list { + align-items: end; + padding-top: 1px; + column-gap: ${({ theme }) => theme.sizeUnit}px; + } + & .ant-tabs-tab-active { + border-left-color: ${({ theme }) => theme.colorPrimaryActive} !important; + border-top-color: ${({ theme }) => theme.colorPrimaryActive} !important; + border-right-color: ${({ theme }) => theme.colorPrimaryActive} !important; + box-shadow: 0 0 2px ${({ theme }) => theme.colorPrimaryActive} !important; + border-top: 2px; Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Invisible border due to missing style</b></div> <div id="fix"> The CSS shorthand 'border-top: 2px;' sets the width but defaults the style to 'none', preventing any visible border from rendering. Since 'border-top-color' is already set to the theme's primary active color, adding 'solid' to the shorthand will make the intended 2px top border appear for active tabs. </div> </div> <small><i>Code Review Run #bb862d</i></small> </div> --- Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>) - [ ] Yes, avoid them ########## superset-frontend/src/components/MenuExtension/index.tsx: ########## @@ -0,0 +1,147 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { useMemo } from 'react'; +import { css, useTheme } from '@apache-superset/core/ui'; +import { Button, Dropdown } from '@superset-ui/core/components'; +import { Menu, MenuItemType } from '@superset-ui/core/components/Menu'; +import { Icons } from '@superset-ui/core/components/Icons'; +import { commands } from 'src/core'; +import ExtensionsManager from 'src/extensions/ExtensionsManager'; + +export type MenuExtensionProps = { + viewId: string; +} & ( + | { + primary: boolean; + secondary?: never; + children?: React.ReactNode; + defaultItems?: never; + compactMode?: boolean; + } + | { + primary?: never; + secondary: boolean; + children?: never; + defaultItems?: MenuItemType[]; + compactMode?: never; + } +); + +const MenuExtension = ({ + viewId, + primary, + secondary, + defaultItems, + children, + compactMode, +}: MenuExtensionProps) => { + const theme = useTheme(); + const iconColor = theme.colorPrimary; + const contributions = + ExtensionsManager.getInstance().getMenuContributions(viewId); + + const actions = primary ? contributions?.primary : contributions?.secondary; + const primaryActions = useMemo( + () => + primary + ? (actions || []).map(contribution => { + const command = + ExtensionsManager.getInstance().getCommandContribution( + contribution.command, + )!; + // @ts-ignore + const Icon = Icons[command?.icon as IconNameType]; + + return ( + <Button + key={contribution.view} + onClick={() => commands.executeCommand(command.command)} + tooltip={command?.description} + icon={<Icon iconSize="m" iconColor={iconColor} />} + buttonSize="small" + > + {!compactMode ? command?.title : undefined} + </Button> + ); + }) + : [], + [actions, primary, iconColor, compactMode], + ); + const secondaryActions = useMemo( + () => + secondary + ? (actions || []) + .map(contribution => { + const command = + ExtensionsManager.getInstance().getCommandContribution( + contribution.command, + )!; Review Comment: <div> <div id="suggestion"> <div id="issue"><b>Undefined Command Access</b></div> <div id="fix"> If getCommandContribution returns undefined, accessing command.title will throw at runtime; add a guard or filter. </div> </div> <small><i>Code Review Run #bb862d</i></small> </div> --- Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>) - [ ] Yes, avoid them ########## superset-frontend/src/SqlLab/components/StatusBar/index.tsx: ########## @@ -0,0 +1,49 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { styled } from '@apache-superset/core'; +import { Flex } from '@superset-ui/core/components'; +import ViewExtension from 'src/components/ViewExtension'; +import { SQL_EDITOR_STATUSBAR_HEIGHT } from 'src/SqlLab/constants'; +import { ViewContribution } from 'src/SqlLab/contributions'; + +const Container = styled(Flex)` + flex-direction: row-reverse; + height: ${SQL_EDITOR_STATUSBAR_HEIGHT}px; + background-color: ${({ theme }) => theme.colorPrimary}; + color: ${({ theme }) => theme.colorWhite}; + padding: 0 ${({ theme }) => theme.sizeUnit * 4}px; + + & .ant-tag { + color: ${({ theme }) => theme.colorWhite}; + background-color: transparent; + border: 0; + } +`; + +export interface StatusBarProps { + queryEditorId: string; +} + +const StatusBar = () => ( + <Container align="center" justify="space-bewteen"> Review Comment: <div> <div id="suggestion"> <div id="issue"><b>CSS Property Typo</b></div> <div id="fix"> The justify prop has a typo: "space-bewteen" should be "space-between" to apply correct CSS flexbox justification and ensure proper horizontal spacing of status bar items. </div> </div> <small><i>Code Review Run #bb862d</i></small> </div> --- Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>) - [ ] Yes, avoid them -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
