diff --git a/src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx b/src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx
index 2d6725de..17c26b20 100644
--- a/src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx
+++ b/src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx
@@ -4,7 +4,7 @@ import { ChainIcon, CopyIcon, KanvasIcon, PublishIcon } from '../../icons';
import Download from '../../icons/Download/Download';
import { CHARCOAL } from '../../theme';
import { downloadPattern, slugify } from '../CatalogDetail/helper';
-import { PATTERNS, RESOURCE_TYPES } from '../CatalogDetail/types';
+import { RESOURCE_TYPES } from '../CatalogDetail/types';
import { Pattern } from '../CustomCatalog/CustomCard';
import { ConditionalTooltip } from '../Helpers/CondtionalTooltip';
import { ColView } from '../Helpers/ResponsiveColumns/responsive-coulmns.tsx';
@@ -25,7 +25,7 @@ interface ColumnConfigProps {
handleCopyUrl: (type: string, name: string, id: string) => void;
handleClone: (name: string, id: string) => void;
handleShowDetails: (designId: string, designName: string) => void;
- getDownloadUrl: (sorceType: string, id: string) => string;
+ getDownloadUrl: (id: string) => string;
isDownloadAllowed: boolean;
isCopyLinkAllowed: boolean;
isDeleteAllowed: boolean;
@@ -169,7 +169,7 @@ export const createDesignsColumnsConfig = ({
const actionsList = [
{
title: 'Download',
- onClick: () => downloadPattern(rowData.id, rowData.name, PATTERNS, getDownloadUrl),
+ onClick: () => downloadPattern(rowData.id, rowData.name, getDownloadUrl),
disabled: !isDownloadAllowed,
icon:
},
@@ -177,7 +177,7 @@ export const createDesignsColumnsConfig = ({
title: 'Copy Link',
disabled: rowData.visibility === 'private' || !isCopyLinkAllowed,
onClick: () => {
- handleCopyUrl(RESOURCE_TYPES.DESIGNS, rowData?.name, rowData?.id);
+ handleCopyUrl(RESOURCE_TYPES.DESIGN, rowData?.name, rowData?.id);
},
icon:
},
@@ -187,9 +187,7 @@ export const createDesignsColumnsConfig = ({
window.open(
`https://playground.meshery.io/extension/meshmap?mode=${
PLAYGROUND_MODES.DESIGNER
- }&type=${RESOURCE_TYPES.DESIGNS}&id=${rowData?.id}&name=${slugify(
- rowData?.name
- )}`,
+ }&type=${RESOURCE_TYPES.DESIGN}&id=${rowData?.id}&name=${slugify(rowData?.name)}`,
'_blank'
);
},
diff --git a/src/custom/CatalogDesignTable/columnConfig.tsx b/src/custom/CatalogDesignTable/columnConfig.tsx
index 3d7d016e..06cca4e0 100644
--- a/src/custom/CatalogDesignTable/columnConfig.tsx
+++ b/src/custom/CatalogDesignTable/columnConfig.tsx
@@ -14,7 +14,6 @@ import {
TwitterIcon
} from '../../icons';
import { downloadPattern } from '../CatalogDetail/helper';
-import { PATTERNS } from '../CatalogDetail/types';
import { Pattern } from '../CustomCatalog/CustomCard';
import { ConditionalTooltip } from '../Helpers/CondtionalTooltip';
import { ColView } from '../Helpers/ResponsiveColumns/responsive-coulmns.tsx/responsive-column';
@@ -54,7 +53,7 @@ interface ColumnConfigProps {
currentUserId?: string;
isCloneDisabled?: boolean;
isUnpublishDisabled?: boolean;
- getDownloadUrl: (sorceType: string, id: string) => string;
+ getDownloadUrl: (id: string) => string;
}
interface ActionItem {
@@ -259,7 +258,7 @@ export const createDesignColumns = ({
},
{
title: 'Download',
- onClick: () => downloadPattern(rowData.id, rowData.name, PATTERNS, getDownloadUrl),
+ onClick: () => downloadPattern(rowData.id, rowData.name, getDownloadUrl),
icon:
},
{
diff --git a/src/custom/CatalogDetail/ActionButton.tsx b/src/custom/CatalogDetail/ActionButton.tsx
index aa5fe223..bf601a09 100644
--- a/src/custom/CatalogDetail/ActionButton.tsx
+++ b/src/custom/CatalogDetail/ActionButton.tsx
@@ -4,16 +4,16 @@ import { CopyIcon, DeleteIcon, EditIcon, KanvasIcon, PublishIcon } from '../../i
import Download from '../../icons/Download/Download';
import { charcoal, useTheme } from '../../theme';
import { Pattern } from '../CustomCatalog/CustomCard';
-import { downloadPattern, downloadYaml, getValidSorceType } from './helper';
+import { downloadPattern, downloadYaml } from './helper';
import { ActionButton, StyledActionWrapper, UnpublishAction } from './style';
-import { RESOURCE_TYPES } from './types';
+import { FILTERS, VIEWS } from './types';
interface ActionButtonsProps {
actionItems: boolean;
details: Pattern;
type: string;
isCloneLoading: boolean;
- getDownloadUrl: (sorceType: string, id: string) => string;
+ getDownloadUrl: (id: string) => string;
handleClone: (name: string, id: string) => void;
handleUnpublish: () => void;
isCloneDisabled: boolean;
@@ -44,7 +44,6 @@ const ActionButtons: React.FC = ({
handleDelete
}) => {
const cleanedType = type.replace('my-', '').replace(/s$/, '');
- const sorceType = getValidSorceType(type);
const theme = useTheme();
return (
@@ -86,16 +85,16 @@ const ActionButtons: React.FC = ({
color: theme.palette.text.default
}}
onClick={() =>
- cleanedType === RESOURCE_TYPES.VIEWS
+ cleanedType === VIEWS
? downloadYaml(details.pattern_file, details.name)
- : downloadPattern(details.id, details.name, sorceType, getDownloadUrl)
+ : downloadPattern(details.id, details.name, getDownloadUrl)
}
>
Download
- {cleanedType !== RESOURCE_TYPES.FILTERS && (
+ {cleanedType !== FILTERS && (
void;
showDeleteAction?: boolean;
handleDelete: () => void;
- getDownloadUrl: (sorceType: string, id: string) => string;
+ getDownloadUrl: (id: string) => string;
}
const LeftPanel: React.FC = ({
diff --git a/src/custom/CatalogDetail/helper.ts b/src/custom/CatalogDetail/helper.ts
index e3a43455..b43477bf 100644
--- a/src/custom/CatalogDetail/helper.ts
+++ b/src/custom/CatalogDetail/helper.ts
@@ -37,10 +37,9 @@ export function slugify(str: string): string {
export const downloadPattern = (
id: string,
name: string,
- sorceType: string,
- getDownloadUrl: (sorceType: string, id: string) => string
+ getDownloadUrl: (id: string) => string
): void => {
- const downloadUrl = getDownloadUrl(sorceType, id);
+ const downloadUrl = getDownloadUrl(id);
const fileNameWithExtension = `${name}.yaml`;
const linkElement = document.createElement('a');
@@ -62,16 +61,3 @@ export const formatDate = (date: Date) => {
const formattedDate = new Date(date).toLocaleDateString('en-US', options);
return formattedDate;
};
-
-export const getValidSorceType = (type: string): string => {
- if (type === 'my-designs' || type === 'catalog') {
- return 'patterns';
- }
- if (type === 'my-filters') {
- return 'filters';
- }
- if (type === 'my-views') {
- return 'views';
- }
- return '';
-};
diff --git a/src/custom/CatalogDetail/types.ts b/src/custom/CatalogDetail/types.ts
index 165c6845..2255a6f5 100644
--- a/src/custom/CatalogDetail/types.ts
+++ b/src/custom/CatalogDetail/types.ts
@@ -32,12 +32,14 @@ export interface Theme {
}
export const RESOURCE_TYPES = {
- DESIGNS: 'design',
- FILTERS: 'filter',
- VIEWS: 'view'
+ DESIGN: 'design',
+ FILTER: 'filter',
+ VIEW: 'view'
};
export const PATTERNS = 'patterns';
+export const FILTERS = 'filters';
+export const VIEWS = 'views';
export type ContentClassType = {
community: {
diff --git a/src/custom/Workspaces/DesignTable.tsx b/src/custom/Workspaces/DesignTable.tsx
index 3fe4278e..e099cc57 100644
--- a/src/custom/Workspaces/DesignTable.tsx
+++ b/src/custom/Workspaces/DesignTable.tsx
@@ -39,7 +39,7 @@ export interface DesignTableProps {
workspaceName: string,
workspaceId: string
) => void;
- getDownloadUrl: (sorceType: string, id: string) => string;
+ getDownloadUrl: (id: string) => string;
handlePublish: (publishModal: PublishModalState, data: any) => void;
publishModalHandler: any;
handleUnpublishModal: (design: Pattern, modalRef: React.RefObject) => void;