You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2023/12/08 02:47:14 UTC
(superset) 02/03: Down to 81
This is an automated email from the ASF dual-hosted git repository.
rusackas pushed a commit to branch shut-up-eslint
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 104b43f983289a3b82e818b6f3728c533fd56e61
Author: Evan Rusackas <ev...@rusackas.com>
AuthorDate: Thu Dec 7 17:01:30 2023 -0700
Down to 81
---
.../src/operators/sortOperator.ts | 60 +++++++++++-----------
.../superset-ui-core/src/api/types/core.ts | 31 -----------
.../ShareSqlLabQuery/ShareSqlLabQuery.test.tsx | 4 +-
.../src/explore/exploreUtils/exploreUtils.test.jsx | 6 +++
.../src/features/allEntities/AllEntitiesTable.tsx | 2 -
.../src/features/profile/RecentActivity.tsx | 7 +--
.../src/features/tags/BulkTagModal.tsx | 2 +-
superset-frontend/src/pages/AllEntities/index.tsx | 6 +--
superset-frontend/src/utils/downloadAsImage.ts | 1 +
.../src/utils/getClientErrorObject.ts | 46 ++++++++---------
superset-frontend/src/utils/testUtils.ts | 1 -
11 files changed, 66 insertions(+), 100 deletions(-)
diff --git a/superset-frontend/packages/superset-ui-chart-controls/src/operators/sortOperator.ts b/superset-frontend/packages/superset-ui-chart-controls/src/operators/sortOperator.ts
index 4d7b5deaf4..412fa0ca9e 100644
--- a/superset-frontend/packages/superset-ui-chart-controls/src/operators/sortOperator.ts
+++ b/superset-frontend/packages/superset-ui-chart-controls/src/operators/sortOperator.ts
@@ -28,42 +28,40 @@ import {
import { PostProcessingFactory } from './types';
import { extractExtraMetrics } from './utils';
-export const sortOperator: PostProcessingFactory<PostProcessingSort> = (
- formData,
- queryObject,
-) => {
- // the sortOperator only used in the barchart v2
- const sortableLabels = [
- getXAxisLabel(formData),
- ...ensureIsArray(formData.metrics).map(getMetricLabel),
- ...extractExtraMetrics(formData).map(getMetricLabel),
- ].filter(Boolean);
+export const sortOperator: PostProcessingFactory<PostProcessingSort> =
+ formData => {
+ // the sortOperator only used in the barchart v2
+ const sortableLabels = [
+ getXAxisLabel(formData),
+ ...ensureIsArray(formData.metrics).map(getMetricLabel),
+ ...extractExtraMetrics(formData).map(getMetricLabel),
+ ].filter(Boolean);
+
+ if (
+ hasGenericChartAxes &&
+ isDefined(formData?.x_axis_sort) &&
+ isDefined(formData?.x_axis_sort_asc) &&
+ sortableLabels.includes(formData.x_axis_sort) &&
+ // the sort operator doesn't support sort-by multiple series.
+ isEmpty(formData.groupby)
+ ) {
+ if (formData.x_axis_sort === getXAxisLabel(formData)) {
+ return {
+ operation: 'sort',
+ options: {
+ is_sort_index: true,
+ ascending: formData.x_axis_sort_asc,
+ },
+ };
+ }
- if (
- hasGenericChartAxes &&
- isDefined(formData?.x_axis_sort) &&
- isDefined(formData?.x_axis_sort_asc) &&
- sortableLabels.includes(formData.x_axis_sort) &&
- // the sort operator doesn't support sort-by multiple series.
- isEmpty(formData.groupby)
- ) {
- if (formData.x_axis_sort === getXAxisLabel(formData)) {
return {
operation: 'sort',
options: {
- is_sort_index: true,
+ by: formData.x_axis_sort,
ascending: formData.x_axis_sort_asc,
},
};
}
-
- return {
- operation: 'sort',
- options: {
- by: formData.x_axis_sort,
- ascending: formData.x_axis_sort_asc,
- },
- };
- }
- return undefined;
-};
+ return undefined;
+ };
diff --git a/superset-frontend/packages/superset-ui-core/src/api/types/core.ts b/superset-frontend/packages/superset-ui-core/src/api/types/core.ts
deleted file mode 100644
index 9aeba85acc..0000000000
--- a/superset-frontend/packages/superset-ui-core/src/api/types/core.ts
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * 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.
- */
-
-// /superset/sqllab_viz
-interface SqlLabPostRequest {
- data: {
- schema: string;
- sql: string;
- dbId: number;
- templateParams?: string | undefined;
- datasourceName: string;
- metrics?: string[];
- columns?: string[];
- };
-}
diff --git a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/ShareSqlLabQuery.test.tsx b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/ShareSqlLabQuery.test.tsx
index 877edb76c8..06497a1cef 100644
--- a/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/ShareSqlLabQuery.test.tsx
+++ b/superset-frontend/src/SqlLab/components/ShareSqlLabQuery/ShareSqlLabQuery.test.tsx
@@ -123,7 +123,7 @@ describe('ShareSqlLabQuery', () => {
});
});
const button = screen.getByRole('button');
- const { id, remoteId, ...expected } = mockQueryEditor;
+ const expected = (({ id, remoteId, ...rest }) => rest)(mockQueryEditor);
const storeQuerySpy = jest.spyOn(utils, 'storeQuery');
userEvent.click(button);
expect(storeQuerySpy.mock.calls).toHaveLength(1);
@@ -138,7 +138,7 @@ describe('ShareSqlLabQuery', () => {
});
});
const button = screen.getByRole('button');
- const { id, ...expected } = unsavedQueryEditor;
+ const expected = (({ id, ...rest }) => rest)(mockQueryEditor);
const storeQuerySpy = jest.spyOn(utils, 'storeQuery');
userEvent.click(button);
expect(storeQuerySpy.mock.calls).toHaveLength(1);
diff --git a/superset-frontend/src/explore/exploreUtils/exploreUtils.test.jsx b/superset-frontend/src/explore/exploreUtils/exploreUtils.test.jsx
index 3105f30868..5e1b0f4bf1 100644
--- a/superset-frontend/src/explore/exploreUtils/exploreUtils.test.jsx
+++ b/superset-frontend/src/explore/exploreUtils/exploreUtils.test.jsx
@@ -53,6 +53,7 @@ describe('exploreUtils', () => {
});
compareURI(URI(url), URI('/explore/'));
});
+ // eslint-disable-next-line jest/expect-expect
it('generates proper json url', () => {
const url = getExploreUrl({
formData,
@@ -62,6 +63,7 @@ describe('exploreUtils', () => {
});
compareURI(URI(url), URI('/superset/explore_json/'));
});
+ // eslint-disable-next-line jest/expect-expect
it('generates proper json forced url', () => {
const url = getExploreUrl({
formData,
@@ -74,6 +76,7 @@ describe('exploreUtils', () => {
URI('/superset/explore_json/').search({ force: 'true' }),
);
});
+ // eslint-disable-next-line jest/expect-expect
it('generates proper csv URL', () => {
const url = getExploreUrl({
formData,
@@ -86,6 +89,7 @@ describe('exploreUtils', () => {
URI('/superset/explore_json/').search({ csv: 'true' }),
);
});
+ // eslint-disable-next-line jest/expect-expect
it('generates proper standalone URL', () => {
const url = getExploreUrl({
formData,
@@ -100,6 +104,7 @@ describe('exploreUtils', () => {
}),
);
});
+ // eslint-disable-next-line jest/expect-expect
it('preserves main URLs params', () => {
const url = getExploreUrl({
formData,
@@ -112,6 +117,7 @@ describe('exploreUtils', () => {
URI('/superset/explore_json/').search({ foo: 'bar' }),
);
});
+ // eslint-disable-next-line jest/expect-expect
it('generate proper save slice url', () => {
const url = getExploreUrl({
formData,
diff --git a/superset-frontend/src/features/allEntities/AllEntitiesTable.tsx b/superset-frontend/src/features/allEntities/AllEntitiesTable.tsx
index 50fdd5a51b..e3c75c27b7 100644
--- a/superset-frontend/src/features/allEntities/AllEntitiesTable.tsx
+++ b/superset-frontend/src/features/allEntities/AllEntitiesTable.tsx
@@ -68,13 +68,11 @@ export interface TaggedObjects {
}
interface AllEntitiesTableProps {
- search?: string;
setShowTagModal: (show: boolean) => void;
objects: TaggedObjects;
}
export default function AllEntitiesTable({
- search = '',
setShowTagModal,
objects,
}: AllEntitiesTableProps) {
diff --git a/superset-frontend/src/features/profile/RecentActivity.tsx b/superset-frontend/src/features/profile/RecentActivity.tsx
index d550d2a953..5a57f5c988 100644
--- a/superset-frontend/src/features/profile/RecentActivity.tsx
+++ b/superset-frontend/src/features/profile/RecentActivity.tsx
@@ -21,14 +21,9 @@ import moment from 'moment';
import { t } from '@superset-ui/core';
import rison from 'rison';
import TableLoader from 'src/components/TableLoader';
-import { BootstrapUser } from 'src/types/bootstrapTypes';
import { ActivityResult } from './types';
-interface RecentActivityProps {
- user: BootstrapUser;
-}
-
-export default function RecentActivity({ user }: RecentActivityProps) {
+export default function RecentActivity() {
const rowLimit = 50;
const mutator = function (data: ActivityResult) {
return data.result
diff --git a/superset-frontend/src/features/tags/BulkTagModal.tsx b/superset-frontend/src/features/tags/BulkTagModal.tsx
index 643dcdb432..6f8e38d00f 100644
--- a/superset-frontend/src/features/tags/BulkTagModal.tsx
+++ b/superset-frontend/src/features/tags/BulkTagModal.tsx
@@ -80,7 +80,7 @@ const BulkTagModal: React.FC<BulkTagModalProps> = ({
}
addSuccessToast(t('Tagged %s %ss', tagged.length, resourceName));
})
- .catch(err => {
+ .catch(() => {
addDangerToast(t('Failed to tag items'));
});
diff --git a/superset-frontend/src/pages/AllEntities/index.tsx b/superset-frontend/src/pages/AllEntities/index.tsx
index b94cab846d..ed6fd5f681 100644
--- a/superset-frontend/src/pages/AllEntities/index.tsx
+++ b/superset-frontend/src/pages/AllEntities/index.tsx
@@ -117,7 +117,7 @@ function AllEntities() {
const editableTitleProps = {
title: tag?.name || '',
placeholder: 'testing',
- onSave: (newDatasetName: string) => {},
+ onSave: () => {},
canEdit: false,
label: t('dataset name'),
};
@@ -162,7 +162,7 @@ function AllEntities() {
setObjects(objects);
setLoading(false);
},
- (error: Response) => {
+ () => {
addDangerToast('Error Fetching Tagged Objects');
setLoading(false);
},
@@ -176,7 +176,7 @@ function AllEntities() {
setTag(tag);
setLoading(false);
},
- (error: Response) => {
+ () => {
addDangerToast(t('Error Fetching Tagged Objects'));
setLoading(false);
},
diff --git a/superset-frontend/src/utils/downloadAsImage.ts b/superset-frontend/src/utils/downloadAsImage.ts
index 79373cc76a..54172ee32e 100644
--- a/superset-frontend/src/utils/downloadAsImage.ts
+++ b/superset-frontend/src/utils/downloadAsImage.ts
@@ -81,6 +81,7 @@ export default function downloadAsImage(
link.click();
})
.catch(e => {
+ // eslint-disable-next-line no-console
console.error('Creating image failed', e);
});
};
diff --git a/superset-frontend/src/utils/getClientErrorObject.ts b/superset-frontend/src/utils/getClientErrorObject.ts
index a5f2871872..7c806e4d52 100644
--- a/superset-frontend/src/utils/getClientErrorObject.ts
+++ b/superset-frontend/src/utils/getClientErrorObject.ts
@@ -86,29 +86,6 @@ export function parseErrorJson(responseObject: JsonObject): ClientErrorObject {
return { ...error, error: error.error }; // explicit ClientErrorObject
}
-/*
- * Utility to get standardized error text for generic update failures
- */
-export async function getErrorText(
- errorObject: ErrorType,
- source: ErrorTextSource,
-) {
- const { error, message } = await getClientErrorObject(errorObject);
- let errorText = t('Sorry, an unknown error occurred.');
-
- if (error) {
- errorText = t(
- 'Sorry, there was an error saving this %s: %s',
- source,
- error,
- );
- }
- if (typeof message === 'string' && message === 'Forbidden') {
- errorText = t('You do not have permission to edit this %s', source);
- }
- return errorText;
-}
-
export function getClientErrorObject(
response:
| SupersetClientResponse
@@ -203,6 +180,29 @@ export function getClientErrorObject(
});
}
+/*
+ * Utility to get standardized error text for generic update failures
+ */
+export async function getErrorText(
+ errorObject: ErrorType,
+ source: ErrorTextSource,
+) {
+ const { error, message } = await getClientErrorObject(errorObject);
+ let errorText = t('Sorry, an unknown error occurred.');
+
+ if (error) {
+ errorText = t(
+ 'Sorry, there was an error saving this %s: %s',
+ source,
+ error,
+ );
+ }
+ if (typeof message === 'string' && message === 'Forbidden') {
+ errorText = t('You do not have permission to edit this %s', source);
+ }
+ return errorText;
+}
+
export function getClientErrorMessage(
message: string,
clientError?: ClientErrorObject,
diff --git a/superset-frontend/src/utils/testUtils.ts b/superset-frontend/src/utils/testUtils.ts
index c62ce741a2..6faebb595b 100644
--- a/superset-frontend/src/utils/testUtils.ts
+++ b/superset-frontend/src/utils/testUtils.ts
@@ -37,7 +37,6 @@ export const testWithId =
return (resultIdOnly ? id : { 'data-test': id }) as TestWithIdType<T>;
}
if (!id && !prefix) {
- console.warn('testWithId function has missed "prefix" and "id" params');
return (resultIdOnly ? '' : { 'data-test': '' }) as TestWithIdType<T>;
}
const newId = `${prefix}__${id}`;