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 2022/11/02 10:10:02 UTC

[GitHub] [superset] zhaoyongjie commented on a diff in pull request #22002: refactor: clean up codes

zhaoyongjie commented on code in PR #22002:
URL: https://github.com/apache/superset/pull/22002#discussion_r1011508618


##########
superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx:
##########
@@ -302,7 +295,7 @@ export default function DateFilterLabel(props: DateFilterControlProps) {
           disabled={!validTimeRange}
           key="apply"
           onClick={onSave}
-          {...getDateFilterControlTestId('apply-button')}
+          data-test={DATE_FILTER_TEST_KEY.applyButton}

Review Comment:
   Keep simple too.



##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/FilterBar.test.tsx:
##########
@@ -121,7 +117,7 @@ const changeFilterValue = async () => {
   userEvent.click(screen.getAllByText('No filter')[0]);
   userEvent.click(screen.getByDisplayValue('Last day'));
   expect(await screen.findByText(/2021-04-13/)).toBeInTheDocument();
-  userEvent.click(screen.getByTestId(getDateControlTestId('apply-button')));
+  userEvent.click(screen.getByTestId(DATE_FILTER_TEST_KEY.applyButton));

Review Comment:
   Keep simple logic for a simple use case.



##########
superset-frontend/src/addSlice/AddSliceContainer.tsx:
##########
@@ -19,10 +19,15 @@
 import React, { ReactNode } from 'react';
 import rison from 'rison';
 import querystring from 'query-string';
-import { styled, t, SupersetClient, JsonResponse } from '@superset-ui/core';
+import {
+  styled,
+  t,
+  SupersetClient,
+  JsonResponse,
+  isDefined,
+} from '@superset-ui/core';
 import { getUrlParam } from 'src/utils/urlUtils';
 import { URL_PARAMS } from 'src/constants';
-import { isNullish } from 'src/utils/common';

Review Comment:
   replace `isNullish` with `isDefined`



##########
superset-frontend/src/explore/components/controls/DateFilterControl/DateFilterLabel.tsx:
##########
@@ -174,11 +172,6 @@ export default function DateFilterLabel(props: DateFilterControlProps) {
           guessedFrame === 'No filter'
         ) {
           setActualTimeRange(value);
-          setTooltipTitle(
-            type === ('error' as Type)
-              ? t('Default value is required')
-              : actualRange || '',
-          );

Review Comment:
   Since the default value always gets from `Store` or `constants`, the value of the `DateFilterControl` will not be undefined.
   
   So the type in the `DateFilterControl` is useless.



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