-
Notifications
You must be signed in to change notification settings - Fork 17.9k
fix(charts): Table chart shows an error on row limit #37218
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
3dc4594
1c5418e
d7f86a7
a419754
84c1224
c95eec0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
| */ | ||
|
|
||
| /** | ||
| * Wraps a validator function to prepend a label to its error message. | ||
| * | ||
| * @param validator - The validator function to wrap | ||
| * @param label - The label to prepend to error messages | ||
| * @returns A new validator function that includes the label in error messages | ||
| * | ||
| * @example | ||
| * validators: [ | ||
| * withLabel(validateInteger, t('Row limit')), | ||
| * ] | ||
| * // Returns: "Row limit is expected to be an integer" | ||
| */ | ||
| export default function withLabel( | ||
| validator: (v: unknown, state?: any) => string | false, | ||
| label: string, | ||
| ) { | ||
| return (v: unknown, state?: any) => { | ||
| const error = validator(v, state); | ||
| return error ? `${label} ${error}` : false; | ||
| }; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -52,6 +52,7 @@ import { | |
| SMART_DATE_ID, | ||
| validateMaxValue, | ||
| validateServerPagination, | ||
| withLabel, | ||
| } from '@superset-ui/core'; | ||
| import { GenericDataType } from '@apache-superset/core/api/core'; | ||
| import { isEmpty, last } from 'lodash'; | ||
|
|
@@ -407,7 +408,7 @@ const config: ControlPanelConfig = { | |
| description: t('Rows per page, 0 means no pagination'), | ||
| visibility: ({ controls }: ControlPanelsContainerProps) => | ||
| Boolean(controls?.server_pagination?.value), | ||
| validators: [validateInteger], | ||
| validators: [withLabel(validateInteger, t('Server Page Length'))], | ||
| }, | ||
| }, | ||
| ], | ||
|
|
@@ -419,14 +420,15 @@ const config: ControlPanelConfig = { | |
| freeForm: true, | ||
| label: t('Row limit'), | ||
| clearable: false, | ||
| mapStateToProps: state => ({ | ||
| mapStateToProps: (state, controlState) => ({ | ||
| value: controlState?.value ?? 10000, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Config has a default field you can use. Wouldn't that be enough?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default value is 10000, but the issue persists even after changing it.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Then do you think the issue might be in the control or the component?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let me revise the control again.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found this issue here with undefined & null. Also, there was another |
||
| maxValue: state?.common?.conf?.TABLE_VIZ_MAX_ROW_SERVER, | ||
| server_pagination: state?.form_data?.server_pagination, | ||
| maxValueWithoutServerPagination: | ||
| state?.common?.conf?.SQL_MAX_ROW, | ||
| }), | ||
| validators: [ | ||
| validateInteger, | ||
| withLabel(validateInteger, t('Row limit')), | ||
| (v, state) => | ||
| validateMaxValue( | ||
| v, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Types are a bit shallow. Can we improve?