Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/apache/superset into fix/…
Browse files Browse the repository at this point in the history
…issue_16962_dup_d3category10
  • Loading branch information
geido committed Oct 8, 2021
2 parents 29559cb + 9e980b6 commit 1f824d3
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 26 deletions.
1 change: 1 addition & 0 deletions .github/workflows/superset-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
continue-on-error: true
run: ./scripts/ci_check_no_file_changes.sh frontend
- name: Setup Node.js
if: steps.check.outcome == 'failure'
uses: actions/setup-node@v2
with:
node-version: '16'
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/superset-python-misc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ jobs:
continue-on-error: true
run: ./scripts/ci_check_no_file_changes.sh python
- name: Setup Python
if: steps.check.outcome == 'failure'
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
Expand Down
13 changes: 9 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,18 +650,23 @@ pre-commit run --all-files
## Linting
Lint the project with:
### Python
We use [Pylint](https://pylint.org/) for linting which can be invoked via:
```bash
# for python
tox -e pylint
```
Alternatively, you can use pre-commit (mentioned above) for python linting
In terms of best practices please advoid blanket disablement of Pylint messages globally (via `.pylintrc`) or top-level within the file header, albeit there being a few exceptions. Disablement should occur inline as it prevents masking issues and provides context as to why said message is disabled.
The Python code is auto-formatted using [Black](https://github.com/python/black) which
Additionally the Python code is auto-formatted using [Black](https://github.com/python/black) which
is configured as a pre-commit hook. There are also numerous [editor integrations](https://black.readthedocs.io/en/stable/editor_integration.html)
# for frontend
### TypeScript
```bash
cd superset-frontend
npm ci
npm run lint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@ export default function DatabaseSelector({
return renderSelectRow(
<Select
ariaLabel={t('Select database or type database name')}
optionFilterProps={['database_name', 'value']}
data-test="select-database"
header={<FormLabel>{t('Database')}</FormLabel>}
lazyLoading={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ export default function BasicErrorAlert({

return (
<StyledContainer level={level} role="alert">
{level === 'error' ? (
<Icons.ErrorSolid iconColor={theme.colors[level].base} />
{!level || level === 'error' ? (
<Icons.ErrorSolid iconColor={theme.colors.error.base} />
) : (
<Icons.WarningSolid iconColor={theme.colors[level].base} />
)}
Expand Down
8 changes: 4 additions & 4 deletions superset-frontend/src/components/ErrorMessage/ErrorAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ export default function ErrorAlert({
<ErrorAlertDiv level={level} role="alert">
<div className="top-row">
<LeftSideContent>
{level === 'error' ? (
{!level || level === 'error' ? (
<Icons.ErrorSolid
className="icon"
iconColor={theme.colors[level].base}
iconColor={theme.colors.error.base}
/>
) : (
<Icons.WarningSolid
Expand Down Expand Up @@ -171,10 +171,10 @@ export default function ErrorAlert({
onHide={() => setIsModalOpen(false)}
title={
<div className="header">
{level === 'error' ? (
{!level || level === 'error' ? (
<Icons.ErrorSolid
className="icon"
iconColor={theme.colors[level].base}
iconColor={theme.colors.error.base}
/>
) : (
<Icons.WarningSolid
Expand Down
24 changes: 14 additions & 10 deletions superset-frontend/src/components/Select/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const Select = ({
mode = 'single',
name,
notFoundContent,
onError,
onChange,
onClear,
optionFilterProps = ['label', 'value'],
Expand Down Expand Up @@ -328,15 +329,18 @@ const Select = ({
setSearchedValue('');
};

const onError = (response: Response) =>
getClientErrorObject(response).then(e => {
const { error } = e;
setError(error);
const internalOnError = useCallback(
(response: Response) =>
getClientErrorObject(response).then(e => {
const { error } = e;
setError(error);

if (props.onError) {
props.onError(error);
}
});
if (onError) {
onError(error);
}
}),
[onError],
);

const handleData = (data: OptionsType) => {
let mergedData: OptionsType = [];
Expand Down Expand Up @@ -391,13 +395,13 @@ const Select = ({
setAllValuesLoaded(true);
}
})
.catch(onError)
.catch(internalOnError)
.finally(() => {
setIsLoading(false);
setIsTyping(false);
});
},
[allValuesLoaded, fetchOnlyOnSearch, options],
[allValuesLoaded, fetchOnlyOnSearch, internalOnError, options],
);

const handleOnSearch = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ const FilterControls: FC<FilterControlsProps> = ({
dataMask: dataMaskSelected[filter.id],
}));
return buildCascadeFiltersTree(filtersWithValue);
}, [filterValues, dataMaskSelected]);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [JSON.stringify(filterValues), dataMaskSelected]);
const cascadeFilterIds = new Set(cascadeFilters.map(item => item.id));

const [filtersInScope, filtersOutOfScope] = useSelectFiltersInScope(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
getChartMetadataRegistry,
} from '@superset-ui/core';
import { useDispatch, useSelector } from 'react-redux';
import { areObjectsEqual } from 'src/reduxUtils';
import { isEqual, isEqualWith } from 'lodash';
import { getChartDataRequest } from 'src/chart/chartAction';
import Loading from 'src/components/Loading';
import BasicErrorAlert from 'src/components/ErrorMessage/BasicErrorAlert';
Expand Down Expand Up @@ -105,10 +105,17 @@ const FilterValue: React.FC<FilterProps> = ({
time_range,
});
const filterOwnState = filter.dataMask?.ownState || {};
// TODO: We should try to improve our useEffect hooks to depend more on
// granular information instead of big objects that require deep comparison.
const customizer = (
objValue: Partial<QueryFormData>,
othValue: Partial<QueryFormData>,
key: string,
) => (key === 'url_params' ? true : undefined);
if (
!isRefreshing &&
(!areObjectsEqual(formData, newFormData) ||
!areObjectsEqual(ownState, filterOwnState) ||
(!isEqualWith(formData, newFormData, customizer) ||
!isEqual(ownState, filterOwnState) ||
isDashboardRefreshing)
) {
setFormData(newFormData);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ type DBReducerActionType =
database_name?: string;
engine?: string;
configuration_method: CONFIGURATION_METHOD;
paramProperties?: Record<string, any>;
};
}
| {
Expand Down Expand Up @@ -651,7 +650,6 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
configuration_method: isDynamic
? CONFIGURATION_METHOD.DYNAMIC_FORM
: CONFIGURATION_METHOD.SQLALCHEMY_URI,
paramProperties: parameters?.properties,
},
});
}
Expand Down

0 comments on commit 1f824d3

Please sign in to comment.