You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by mi...@apache.org on 2024/02/13 16:02:17 UTC
(superset) 04/16: fix(tags): Improve support for tags with colons (#26965)
This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch 3.1
in repository https://gitbox.apache.org/repos/asf/superset.git
commit 4df40bedc28c162eb62504a17cb8386a1c873c50
Author: Vitor Avila <96...@users.noreply.github.com>
AuthorDate: Wed Feb 7 13:20:28 2024 -0300
fix(tags): Improve support for tags with colons (#26965)
(cherry picked from commit e437356013adc8beb2eca39a31beca6ba56f4c23)
---
superset-frontend/src/components/Tags/utils.tsx | 9 +++++----
superset-frontend/src/features/tags/tags.ts | 16 +++++++---------
2 files changed, 12 insertions(+), 13 deletions(-)
diff --git a/superset-frontend/src/components/Tags/utils.tsx b/superset-frontend/src/components/Tags/utils.tsx
index 2dd38e6236..ec08a3b126 100644
--- a/superset-frontend/src/components/Tags/utils.tsx
+++ b/superset-frontend/src/components/Tags/utils.tsx
@@ -56,7 +56,10 @@ export const loadTags = async (
) => {
const searchColumn = 'name';
const query = rison.encode({
- filters: [{ col: searchColumn, opr: 'ct', value: search }],
+ filters: [
+ { col: searchColumn, opr: 'ct', value: search },
+ { col: 'type', opr: 'custom_tag', value: true },
+ ],
page,
page_size: pageSize,
order_column: searchColumn,
@@ -78,9 +81,7 @@ export const loadTags = async (
const data: {
label: string;
value: string | number;
- }[] = response.json.result
- .filter((item: Tag & { table_name: string }) => item.type === 1)
- .map(tagToSelectOption);
+ }[] = response.json.result.map(tagToSelectOption);
return {
data,
totalCount: response.json.count,
diff --git a/superset-frontend/src/features/tags/tags.ts b/superset-frontend/src/features/tags/tags.ts
index db172681cb..c1f5c38151 100644
--- a/superset-frontend/src/features/tags/tags.ts
+++ b/superset-frontend/src/features/tags/tags.ts
@@ -47,10 +47,15 @@ const map_object_type_to_id = (objectType: string) => {
};
export function fetchAllTags(
+ // fetch all tags (excluding system tags)
callback: (json: JsonObject) => void,
error: (response: Response) => void,
) {
- SupersetClient.get({ endpoint: `/api/v1/tag` })
+ SupersetClient.get({
+ endpoint: `/api/v1/tag/?q=${rison.encode({
+ filters: [{ col: 'type', opr: 'custom_tag', value: true }],
+ })}`,
+ })
.then(({ json }) => callback(json))
.catch(response => error(response));
}
@@ -89,11 +94,7 @@ export function fetchTags(
endpoint: `/api/v1/${objectType}/${objectId}`,
})
.then(({ json }) =>
- callback(
- json.result.tags.filter(
- (tag: Tag) => tag.name.indexOf(':') === -1 || includeTypes,
- ),
- ),
+ callback(json.result.tags.filter((tag: Tag) => tag.type === 1)),
)
.catch(response => error(response));
}
@@ -163,9 +164,6 @@ export function addTag(
if (objectType === undefined || objectId === undefined) {
throw new Error('Need to specify objectType and objectId');
}
- if (tag.indexOf(':') !== -1 && !includeTypes) {
- return;
- }
const objectTypeId = map_object_type_to_id(objectType);
SupersetClient.post({
endpoint: `/api/v1/tag/${objectTypeId}/${objectId}/`,