You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2020/06/19 06:23:25 UTC

[GitHub] [incubator-superset] ktmud commented on a change in pull request #10104: style: dataset modal view

ktmud commented on a change in pull request #10104:
URL: https://github.com/apache/incubator-superset/pull/10104#discussion_r442646425



##########
File path: superset-frontend/src/views/datasetList/Button.tsx
##########
@@ -0,0 +1,64 @@
+/**
+ * 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 React from 'react';
+import styled from '@superset-ui/style';
+import BaseButton from 'src/components/Button';
+
+type Button = 'default' | 'primary' | 'secondary';
+
+interface Props {

Review comment:
       nit: name this `ButtonProps`.
   
   Related: https://github.com/apache-superset/superset-ui/pull/586

##########
File path: superset-frontend/src/views/datasetList/DatasetModal.tsx
##########
@@ -0,0 +1,318 @@
+/**
+ * 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 React from 'react';
+import styled from '@superset-ui/style';
+import { SupersetClient } from '@superset-ui/connection';
+import { t } from '@superset-ui/translation';
+import Icon from 'src/components/Icon';
+import Select from 'src/components/Select';
+import Modal from './Modal';
+
+import withToasts from '../../messageToasts/enhancers/withToasts';
+
+type option = {
+  label: string;
+  value: string;
+};
+
+interface Props {
+  addDangerToast: (msg: string) => void;
+  addSuccessToast: (msg: string) => void;
+  onChange: any;
+  onDatasourceSave: any;
+  onHide: any;
+  show: boolean;
+}
+
+interface State {

Review comment:
       `DatasetModalProps` and `DatasetModalState`

##########
File path: superset-frontend/src/views/datasetList/DatasetModal.tsx
##########
@@ -0,0 +1,318 @@
+/**
+ * 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 React from 'react';
+import styled from '@superset-ui/style';
+import { SupersetClient } from '@superset-ui/connection';
+import { t } from '@superset-ui/translation';
+import Icon from 'src/components/Icon';
+import Select from 'src/components/Select';
+import Modal from './Modal';
+
+import withToasts from '../../messageToasts/enhancers/withToasts';
+
+type option = {
+  label: string;
+  value: string;
+};
+
+interface Props {
+  addDangerToast: (msg: string) => void;
+  addSuccessToast: (msg: string) => void;
+  onChange: any;
+  onDatasourceSave: any;
+  onHide: any;

Review comment:
       ++ to what @etr2460 said. TypeScript will actually start complaining about explicit anys at some point. They already emit warnings in `superset-ui`.

##########
File path: superset-frontend/src/views/datasetList/Button.tsx
##########
@@ -0,0 +1,64 @@
+/**
+ * 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 React from 'react';
+import styled from '@superset-ui/style';
+import BaseButton from 'src/components/Button';
+
+type Button = 'default' | 'primary' | 'secondary';
+
+interface Props {
+  bsStyle: Button;
+  disabled?: boolean;
+  onClick: (...args: any[]) => any;
+  title: string | React.ReactNode;
+}
+
+const StyledButton = styled(BaseButton)`
+  border: none;
+  border-radius: ${({ theme }) => theme.borderRadius}px;
+  padding: 8px;
+  text-transform: uppercase;
+  width: 160px;
+  &.btn[disabled],
+  &.btn[disabled]:hover {
+    background-color: ${({ theme }) => theme.colors.grayscale.light2};
+    color: ${({ theme }) => theme.colors.grayscale.light1};
+  }
+  &.btn-primary,
+  &.btn-primary:hover {
+    background-color: ${({ theme }) => theme.colors.primary.base};
+  }
+  &.btn-secondary {
+    background-color: ${({ theme }) => theme.colors.primary.light4};
+    color: ${({ theme }) => theme.colors.primary.base};
+  }
+`;

Review comment:
       Maybe move this whole file to something like `src/components/SIP-34/Button.tsx` so we can slowly build a shared library of all SIP-34 related UI components.
   
   @rusackas @mistercrunch  thoughts?

##########
File path: superset-frontend/src/views/datasetList/Modal.tsx
##########
@@ -0,0 +1,102 @@
+/**
+ * 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 React from 'react';
+import styled from '@superset-ui/style';
+import { Modal as BaseModal } from 'react-bootstrap';
+import { t } from '@superset-ui/translation';
+import Button from './Button';
+
+type Callback = (...args: any[]) => void;

Review comment:
       I'd say maybe make each callback more explicit instead... For example, here it could be 
   
   ```ts
   interface ModalProps {
     ...
     onHide: BaseModal['onHide'] | Button['onClick'];
     onSave: Button['onClick'];
     ...
   }
   ```
   
   or if we don't actually want to pass any arguments to the callback, name it
   
   ```ts
   type EmptyCallback = () => void;
   ```
   
   and update component accordingly
   
   ```ts
   export default function Modal({
     children,
     disableSave,
     onHide,
     onSave,
     show,
     title,
   }: Props) {
     const onHideHandler = useCallback(() => if (onHide) onHide(), [onHide]);
     const onSaveHandler = useCallback(() => if (onSave) onSave(), [onSave]);
     return (
       <StyledModal show={show} onHide={onHideHandler} bsSize="lg">
         <StyledModalHeader closeButton>
           <BaseModal.Title>
             <Title>{title}</Title>
           </BaseModal.Title>
         </StyledModalHeader>
         <StyledModalBody>{children}</StyledModalBody>
         <StyledModalFooter>
           <span className="float-right">
             <Button title={t('Cancel')} bsStyle="secondary" onClick={onHideHandler} />
             <Button
               bsStyle="primary"
               disabled={disableSave}
               onClick={onSaveHandler}
               title={t('Add')}
             />
           </span>
         </StyledModalFooter>
       </StyledModal>
     );
   }
   ```
   




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org