Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

fix: front end CI tests and test runner #10897

Merged
merged 3 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/superset-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2
- name: Install dependencies
- name: npm install
working-directory: ./superset-frontend
run: |
npm install
Expand Down
34 changes: 22 additions & 12 deletions superset-frontend/src/dashboard/util/getComponentWidthFromDrop.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,39 +37,49 @@ export default function getComponentWidthFromDrop({
return component.meta.width;
}

const draggingWidth = getDetailedComponentWidth({
const {
width: draggingWidth,
minimumWidth: minDraggingWidth,
} = getDetailedComponentWidth({
component,
components,
});

const destinationWidth = getDetailedComponentWidth({
const {
width: destinationWidth,
occupiedWidth: draggingOccupiedWidth,
} = getDetailedComponentWidth({
id: destination.id,
components,
});

let destinationCapacity =
destinationWidth.width - destinationWidth.occupiedWidth;
let destinationCapacity = Number(destinationWidth - draggingOccupiedWidth);

if (Number.isNaN(destinationCapacity)) {
const grandparentWidth = getDetailedComponentWidth({
const {
width: grandparentWidth,
occupiedWidth: grandparentOccupiedWidth,
} = getDetailedComponentWidth({
id: findParentId({
childId: destination.id,
layout: components,
}),
components,
});

destinationCapacity =
grandparentWidth.width - grandparentWidth.occupiedWidth;
destinationCapacity = Number(grandparentWidth - grandparentOccupiedWidth);
}

if (Number.isNaN(destinationCapacity) || Number.isNaN(draggingWidth.width)) {
return draggingWidth.width;
if (
Number.isNaN(destinationCapacity) ||
Number.isNaN(Number(draggingWidth))
) {
return draggingWidth;
Copy link
Member Author

@eschutho eschutho Sep 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ktmud does this look more readable to you? It keeps the original return value here, to play it safe.
The value is coerced multiple times this way b/c it is defined multiple times depending on the condition.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good. I think the long-term solution would be to migrate this and all related files to TypeScript so we can be more confident in changes like this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, agree.

}
if (destinationCapacity >= draggingWidth.width) {
return draggingWidth.width;
if (destinationCapacity >= draggingWidth) {
return draggingWidth;
}
if (destinationCapacity >= draggingWidth.minimumWidth) {
if (destinationCapacity >= minDraggingWidth) {
return destinationCapacity;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ export default class BoundsControl extends React.Component {
onChange() {
const mm = this.state.minMax;
const errors = [];
if (mm[0] && Number.isNaN(mm[0])) {
if (mm[0] && Number.isNaN(Number(mm[0]))) {
errors.push(t('`Min` value should be numeric or empty'));
}
if (mm[1] && Number.isNaN(mm[1])) {
if (mm[1] && Number.isNaN(Number(mm[1]))) {
errors.push(t('`Max` value should be numeric or empty'));
}
if (errors.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ export default class FilterBoxItemControl extends React.Component {
if (type === 'BOOLEAN') {
typedValue = value === 'true';
} else if (INTEGRAL_TYPES.has(type)) {
typedValue = Number.isNaN(value) ? null : parseInt(value, 10);
typedValue = Number.isNaN(Number(value)) ? null : parseInt(value, 10);
} else if (DECIMAL_TYPES.has(type)) {
typedValue = Number.isNaN(value) ? null : parseFloat(value);
typedValue = Number.isNaN(Number(value)) ? null : parseFloat(value);
}
}
}
Expand Down