michael-s-molina commented on code in PR #36644:
URL: https://github.com/apache/superset/pull/36644#discussion_r2662090306
##########
superset-frontend/src/SqlLab/components/SaveDatasetActionButton/index.tsx:
##########
@@ -19,27 +19,61 @@
import { t } from '@superset-ui/core';
import { useTheme } from '@apache-superset/core/ui';
import { Icons } from '@superset-ui/core/components/Icons';
+import { Menu } from '@superset-ui/core/components/Menu';
import { Button, DropdownButton } from '@superset-ui/core/components';
interface SaveDatasetActionButtonProps {
setShowSave: (arg0: boolean) => void;
- overlayMenu: JSX.Element | null;
+ onSaveAsExplore?: () => void;
+ compactMode?: boolean;
Review Comment:
`compactMode` comes from `SaveQuery` which always sets it to `true`. Should
we remove it?
##########
superset-frontend/src/SqlLab/components/ShareSqlLabQuery/index.tsx:
##########
@@ -29,11 +29,13 @@ import useLogAction from 'src/logger/useLogAction';
interface ShareSqlLabQueryProps {
queryEditorId: string;
addDangerToast: (msg: string) => void;
+ compactMode?: boolean;
Review Comment:
Same here. `compactMode` is always `true`.
##########
superset-frontend/src/components/ViewExtension/index.tsx:
##########
@@ -0,0 +1,34 @@
+/**
+ * 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 ExtensionsManager from 'src/extensions/ExtensionsManager';
+import { useExtensionsContext } from 'src/extensions/ExtensionsContext';
+
+export interface ViewExtensionProps {
+ viewId: string;
+}
+
+const ViewExtension = ({ viewId }: ViewExtensionProps) => {
Review Comment:
The name `ViewExtension` is a bit misleading as it receives a `viewId` but
returns a list of views.
##########
superset-frontend/src/components/DatabaseSelector/index.tsx:
##########
@@ -51,8 +52,21 @@ import type {
} from './types';
import { StyledFormLabel } from './styles';
-const DatabaseSelectorWrapper = styled.div`
- ${({ theme }) => `
+const DatabaseSelectorWrapper = styled.div<{ horizontal?: boolean }>`
+ ${({ theme, horizontal }) =>
+ horizontal
Review Comment:
I was not able to find any place in the code setting DatabaseSelector's
`horizontalMode`. Should we remove the property?
##########
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;
+}
Review Comment:
Unused currently.
```suggestion
```
##########
superset-frontend/src/SqlLab/components/AppLayout/index.tsx:
##########
@@ -126,11 +139,12 @@ const AppLayout: React.FC = ({ children }) => {
min={SQL_EDITOR_RIGHTBAR_WIDTH}
>
<ContentWrapper>
- {contributions.map(contribution => getView(contribution.id))}
+ <ViewExtension viewId={ViewContribution.RightSidebar} />
</ContentWrapper>
</Splitter.Panel>
)}
</Splitter>
+ {statusBarContributions.length > 0 && <StatusBar />}
Review Comment:
Inside `StatusBar` you're also checking the contributions registry. I wonder
if we should let `StatusBar` render the registry lookup and render as `null` if
needed instead of duplicating the logic here.
##########
superset-frontend/src/components/MenuExtension/index.tsx:
##########
@@ -0,0 +1,150 @@
+/**
+ * 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(
Review Comment:
Primary and secondary actions must be declared. You cannot infer them from
the commands as not all commands will be menu actions.
--
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]