You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "alexandrusoare (via GitHub)" <gi...@apache.org> on 2024/10/28 12:55:36 UTC

[PR] refactor(Switch): Upgrade Switch to Ant Design 5 [superset]

alexandrusoare opened a new pull request, #30731:
URL: https://github.com/apache/superset/pull/30731

   Fixes #30728
   
   ### SUMMARY
   Upgrade Switch to Ant Design 5
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Before Unchecked:
   ![Before Unchecked](https://github.com/user-attachments/assets/9c25caa3-ed30-43f5-813c-38e155a0f592)
   
   After Unchecked:
   ![After Unchecked](https://github.com/user-attachments/assets/7796a3f3-fdc6-4bfe-94db-5c4a382a6dfc)
   
   Before Checked and Focused:
   ![Before Checked and Focused](https://github.com/user-attachments/assets/536afb65-4623-48eb-88bc-96c206b13e61)
   
   After Checked and Focused:
   ![After Checked and Focused](https://github.com/user-attachments/assets/7391fa15-daaa-4fc6-b8d7-94cc6bc9afd2)
   
   Before Checked and Unfocused: 
   ![Before Checked and Unfocused](https://github.com/user-attachments/assets/7eda06f4-2119-4b7a-a987-01a144c5ac63)
   
   After Checked and Unfocused:
   ![After Checked and Unfocused](https://github.com/user-attachments/assets/59a7e792-e1d8-497c-893a-a090ad8c90b3)
   
   Before Unchecked and Hover:
   ![Before Unchecked and Hover](https://github.com/user-attachments/assets/46b74127-d1b0-4299-8a4d-a0f7ef11bb48)
   
   After Unchecked and Hover:
   ![After Unchecked and Hover](https://github.com/user-attachments/assets/e540c466-62bb-4ed9-9bd7-c0d6fd5bc857)
   
   Before Checked and Hover:
   ![Before Checked and Hover](https://github.com/user-attachments/assets/616fb4dd-5d82-4faf-88c6-6b184a3fa72d)
   
   After Checked and Hover:
   ![After Checked and Hover](https://github.com/user-attachments/assets/d3bf87fa-c735-4ccf-9248-3e9d2e7c138e)
   
   ### TESTING INSTRUCTIONS
   Run the unit tests and do visual comparison between versions.
   
   ### ADDITIONAL INFORMATION
   <!--- Check any relevant boxes with "x" -->
   <!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
   - [ ] Has associated issue:
   - [ ] Required feature flags:
   - [ ] Changes UI
   - [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
     - [ ] Migration is atomic, supports rollback & is backwards-compatible
     - [ ] Confirm DB migration upgrade and downgrade tested
     - [ ] Runtime estimates and downtime expectations provided
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   


-- 
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: notifications-unsubscribe@superset.apache.org

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


Re: [PR] refactor(Switch): Upgrade Switch to Ant Design 5 [superset]

Posted by "mistercrunch (via GitHub)" <gi...@apache.org>.
mistercrunch commented on code in PR #30731:
URL: https://github.com/apache/superset/pull/30731#discussion_r1821256029


##########
superset-frontend/src/components/Switch/Switch.test.tsx:
##########
@@ -0,0 +1,41 @@
+/**
+ * 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 { render, screen } from 'spec/helpers/testing-library';
+import { Switch } from '.';
+
+const mockedProps = {
+  label: 'testLabel',
+  dataTest: 'dataTest',
+  checked: false,
+};
+
+test('should render', () => {

Review Comment:
   I think it's good to have even if just as a placeholder to enhance. It's a good assumption to know that `superset-frontend/src/components/*/*.tsx` has a matching `*.test.tsx`



-- 
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: notifications-unsubscribe@superset.apache.org

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


Re: [PR] refactor(Switch): Upgrade Switch to Ant Design 5 [superset]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30731:
URL: https://github.com/apache/superset/pull/30731#issuecomment-2441766015

   @geido Ephemeral environment spinning up at http://52.34.185.57:8080. Credentials are `admin`/`admin`. Please allow several minutes for bootstrapping and startup.


-- 
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: notifications-unsubscribe@superset.apache.org

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


Re: [PR] refactor(Switch): Upgrade Switch to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on code in PR #30731:
URL: https://github.com/apache/superset/pull/30731#discussion_r1819216506


##########
superset-frontend/src/components/Switch/Switch.test.tsx:
##########
@@ -0,0 +1,41 @@
+/**
+ * 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 { render, screen } from 'spec/helpers/testing-library';
+import { Switch } from '.';
+
+const mockedProps = {
+  label: 'testLabel',
+  dataTest: 'dataTest',
+  checked: false,
+};
+
+test('should render', () => {

Review Comment:
   I believe these components, in their most basic form, do not require these types of tests since Ant Design should already cover them. However, if we end up customizing them significantly, it would make sense to include these tests. For now, I think we can leave them here for reference.



##########
superset-frontend/src/components/Switch/Switch.stories.tsx:
##########
@@ -35,10 +35,13 @@ export const InteractiveSwitch = ({ checked, ...rest }: SwitchProps) => {
 };
 
 InteractiveSwitch.args = {
+  autoFocus: false,
   checked: false,
   disabled: false,
   loading: false,
   title: 'Switch',
+  className: 'test',

Review Comment:
   Do we need this as an interactive option? 



##########
superset-frontend/src/components/Switch/index.tsx:
##########
@@ -16,14 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { styled } from '@superset-ui/core';
-import BaseSwitch, { SwitchProps } from 'antd/lib/switch';
+import { SwitchProps } from 'antd-v5/lib/switch';
+import { Switch as AntdSwitch } from 'antd-v5';
 
-const StyledSwitch = styled(BaseSwitch)`
-  .ant-switch-checked {
-    background-color: ${({ theme }) => theme.colors.primary.base};

Review Comment:
   I don't see this in the theme config. Do we need to bring this over there?



-- 
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: notifications-unsubscribe@superset.apache.org

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


Re: [PR] refactor(Switch): Upgrade Switch to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido commented on PR #30731:
URL: https://github.com/apache/superset/pull/30731#issuecomment-2441741517

   /testenv up


-- 
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: notifications-unsubscribe@superset.apache.org

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


Re: [PR] refactor(Switch): Upgrade Switch to Ant Design 5 [superset]

Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #30731:
URL: https://github.com/apache/superset/pull/30731#issuecomment-2447996655

   Ephemeral environment shutdown and build artifacts deleted.


-- 
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: notifications-unsubscribe@superset.apache.org

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


Re: [PR] refactor(Switch): Upgrade Switch to Ant Design 5 [superset]

Posted by "geido (via GitHub)" <gi...@apache.org>.
geido merged PR #30731:
URL: https://github.com/apache/superset/pull/30731


-- 
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: notifications-unsubscribe@superset.apache.org

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


Re: [PR] refactor(Switch): Upgrade Switch to Ant Design 5 [superset]

Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare commented on code in PR #30731:
URL: https://github.com/apache/superset/pull/30731#discussion_r1819228063


##########
superset-frontend/src/components/Switch/index.tsx:
##########
@@ -16,14 +16,8 @@
  * specific language governing permissions and limitations
  * under the License.
  */
-import { styled } from '@superset-ui/core';
-import BaseSwitch, { SwitchProps } from 'antd/lib/switch';
+import { SwitchProps } from 'antd-v5/lib/switch';
+import { Switch as AntdSwitch } from 'antd-v5';
 
-const StyledSwitch = styled(BaseSwitch)`
-  .ant-switch-checked {
-    background-color: ${({ theme }) => theme.colors.primary.base};

Review Comment:
   This is covered by `colorPrimaryHover` in the theme config



-- 
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: notifications-unsubscribe@superset.apache.org

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