From 279c26ff8f455034321fcc3d91e6692709ac282b Mon Sep 17 00:00:00 2001 From: Md Kaif Ansari Date: Mon, 9 Dec 2024 12:17:01 +0000 Subject: [PATCH 1/3] feat: incorrect download of design from client Signed-off-by: Md Kaif Ansari --- src/custom/CatalogDetail/ActionButton.tsx | 8 ++++---- src/custom/CatalogDetail/helper.ts | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/custom/CatalogDetail/ActionButton.tsx b/src/custom/CatalogDetail/ActionButton.tsx index 76d14edd..cbbb2a3a 100644 --- a/src/custom/CatalogDetail/ActionButton.tsx +++ b/src/custom/CatalogDetail/ActionButton.tsx @@ -4,7 +4,7 @@ import { CopyIcon, EditIcon, KanvasIcon, PublishIcon } from '../../icons'; import Download from '../../icons/Download/Download'; import { charcoal, useTheme } from '../../theme'; import { Pattern } from '../CustomCatalog/CustomCard'; -import { downloadFilter, downloadYaml } from './helper'; +import { downloadPattern, downloadYaml } from './helper'; import { ActionButton, StyledActionWrapper, UnpublishAction } from './style'; import { RESOURCE_TYPES } from './types'; @@ -79,9 +79,9 @@ const ActionButtons: React.FC = ({ color: theme.palette.text.default }} onClick={() => - cleanedType === RESOURCE_TYPES.FILTERS - ? downloadFilter(details.id, details.name) - : downloadYaml(details.pattern_file, details.name) + cleanedType === RESOURCE_TYPES.VIEWS + ? downloadYaml(details.pattern_file, details.name) + : downloadPattern(details.id, details.name, cleanedType) } > diff --git a/src/custom/CatalogDetail/helper.ts b/src/custom/CatalogDetail/helper.ts index 2d6601f7..153d7a70 100644 --- a/src/custom/CatalogDetail/helper.ts +++ b/src/custom/CatalogDetail/helper.ts @@ -34,8 +34,9 @@ export function slugify(str: string): string { return str; } -export const downloadFilter = (id: string, name: string): void => { - const dataUri = `${process.env.API_ENDPOINT_PREFIX}/api/content/filters/download/${id}`; +export const downloadPattern = (id: string, name: string, type: string): void => { + const pattern = type == 'design' ? 'patterns' : 'filters'; + const dataUri = `${process.env.API_ENDPOINT_PREFIX}/api/content/${pattern}/download/${id}`; // Add the .wasm extension to the filename const fileNameWithExtension = name + '.wasm'; From 9301dd89a4395228e3d124db5705f3459a392418 Mon Sep 17 00:00:00 2001 From: Md Kaif Ansari Date: Mon, 9 Dec 2024 12:22:49 +0000 Subject: [PATCH 2/3] chore: fix build error Signed-off-by: Md Kaif Ansari --- src/custom/CatalogDetail/helper.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/custom/CatalogDetail/helper.ts b/src/custom/CatalogDetail/helper.ts index 153d7a70..48075ee2 100644 --- a/src/custom/CatalogDetail/helper.ts +++ b/src/custom/CatalogDetail/helper.ts @@ -34,6 +34,19 @@ export function slugify(str: string): string { return str; } +export const downloadFilter = (id: string, name: string): void => { + const dataUri = `${process.env.API_ENDPOINT_PREFIX}/api/content/filters/download/${id}`; + + // Add the .wasm extension to the filename + const fileNameWithExtension = name + '.wasm'; + + const linkElement = document.createElement('a'); + linkElement.setAttribute('href', dataUri); + linkElement.setAttribute('download', fileNameWithExtension); + linkElement.click(); + linkElement.remove(); +}; + export const downloadPattern = (id: string, name: string, type: string): void => { const pattern = type == 'design' ? 'patterns' : 'filters'; const dataUri = `${process.env.API_ENDPOINT_PREFIX}/api/content/${pattern}/download/${id}`; From a7749754e1fe89547e1a5cfc420c74fdb11e7029 Mon Sep 17 00:00:00 2001 From: Md Kaif Ansari Date: Wed, 11 Dec 2024 14:25:25 +0000 Subject: [PATCH 3/3] fix: ResponsiveDataTable bug Signed-off-by: Md Kaif Ansari --- src/custom/ResponsiveDataTable.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/custom/ResponsiveDataTable.tsx b/src/custom/ResponsiveDataTable.tsx index 489abb38..8c39b03d 100644 --- a/src/custom/ResponsiveDataTable.tsx +++ b/src/custom/ResponsiveDataTable.tsx @@ -409,7 +409,7 @@ const ResponsiveDataTable = ({ return (