Skip to content

Commit 44299fb

Browse files
authored
Merge branch 'master' into fix/faheemonhub/aspectRatio
2 parents 0bfdaf9 + 74bc041 commit 44299fb

File tree

17 files changed

+711
-408
lines changed

17 files changed

+711
-408
lines changed

package-lock.json

Lines changed: 14 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"commitlint": "commitlint --edit",
1919
"coverage": "jest --coverage",
2020
"dev": "NODE_ENV=development tsup",
21+
"dev:watch": "NODE_ENV=development tsup",
2122
"format:check": "prettier --check \"**/*.{ts,tsx,md}\" --config ./.prettierrc",
2223
"format:write": "prettier --write \"**/*.{ts,tsx,md}\" --config ./.prettierrc",
2324
"lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
@@ -109,6 +110,7 @@
109110
"mui-datatables": "*",
110111
"re-resizable": "^6.10.3",
111112
"react-draggable": "^4.4.6",
112-
"react-share": "^5.1.0"
113+
"react-share": "^5.1.0",
114+
"use-debounce": "^10.0.4"
113115
}
114116
}

site/package-lock.json

Lines changed: 45 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
"postcss": "^8.4.31",
2222
"react": "^18.2.0",
2323
"react-dom": "^18.2.0",
24-
"react-router-dom": "^6.17.0",
24+
"react-router-dom": "^7.5.2",
2525
"tailwindcss": "^3.3.5"
2626
},
2727
"overrides": {

src/constants/constants.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,24 @@ export const CARIBBEAN_GREEN_FILL = '#00D3A9';
77
export const DEFAULT_STROKE = '#000';
88
export const DEFAULT_STROKE_WIDTH = '2';
99
export const CLOUD_URL = 'https://cloud.layer5.io';
10-
export const PLAYGROUND_MODES = {
10+
11+
export const KANVAS_MODE = {
1112
DESIGNER: 'design',
1213
OPERATOR: 'operator'
1314
} as const;
15+
16+
export const PLAYGROUND_MODES = KANVAS_MODE;
17+
18+
export const VISIBILITY = {
19+
PUBLIC: 'public',
20+
PRIVATE: 'private'
21+
};
22+
23+
export const RESOURCE_TYPE = {
24+
FILTER: 'filter',
25+
DESIGN: 'design',
26+
CATALOG: 'catalog',
27+
VIEW: 'view'
28+
} as const;
29+
30+
export type ResourceType = (typeof RESOURCE_TYPE)[keyof typeof RESOURCE_TYPE];

src/custom/CatalogDesignTable/CatalogDesignTable.tsx

Lines changed: 5 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import _ from 'lodash';
33
import { MUIDataTableColumn } from 'mui-datatables';
4-
import { useCallback, useMemo, useRef } from 'react';
4+
import { useCallback, useMemo, useRef, useState } from 'react';
55
import { PublishIcon } from '../../icons';
66
import { CHARCOAL } from '../../theme';
7-
import { FormattedTime } from '../../utils';
87
import { Pattern } from '../CustomCatalog/CustomCard';
98
import { ErrorBoundary } from '../ErrorBoundary';
109
import { ColView } from '../Helpers/ResponsiveColumns/responsive-coulmns.tsx/responsive-column';
@@ -56,37 +55,7 @@ export const CatalogDesignsTable: React.FC<CatalogDesignsTableProps> = ({
5655
handleBulkpatternsDataUnpublishModal
5756
}) => {
5857
const modalRef = useRef<PromptRef>(null);
59-
60-
const processedColumns: MUIDataTableColumn[] = useMemo(() => {
61-
return columns.map((col) => {
62-
const newCol = { ...col };
63-
if (!newCol.options) newCol.options = {};
64-
newCol.options.display = columnVisibility[col.name];
65-
if (
66-
[
67-
'updated_at',
68-
'created_at',
69-
'deleted_at',
70-
'last_login_time',
71-
'joined_at',
72-
'last_run',
73-
'next_run'
74-
].includes(col.name)
75-
) {
76-
newCol.options.customBodyRender = (value: any) => {
77-
if (!value || value === 'NA') return <>NA</>;
78-
if (typeof value === 'object' && 'Valid' in value) {
79-
if (value.Valid && value.Time) {
80-
return <FormattedTime date={value.Time} />;
81-
}
82-
return <>NA</>;
83-
}
84-
return <FormattedTime date={value.Time} />;
85-
};
86-
}
87-
return newCol;
88-
});
89-
}, [columns, columnVisibility]);
58+
const [tableCols, updateCols] = useState(columns);
9059

9160
const handleTableChange = useCallback(
9261
(action: string, tableState: any) => {
@@ -176,22 +145,19 @@ export const CatalogDesignsTable: React.FC<CatalogDesignsTableProps> = ({
176145
]
177146
);
178147

179-
if (!processedColumns.length) {
180-
return null;
181-
}
182-
183148
return (
184149
<ErrorBoundary>
185150
<PromptComponent ref={modalRef} />
186151
<ResponsiveDataTable
187-
columns={processedColumns}
152+
columns={columns}
188153
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
189154
//@ts-ignore
190155
data={patterns || []}
191156
rowsPerPageOptions={rowsPerPageOptions}
192157
options={options}
193158
colViews={colViews}
194-
tableCols={processedColumns}
159+
tableCols={tableCols}
160+
updateCols={updateCols}
195161
columnVisibility={columnVisibility}
196162
/>
197163
</ErrorBoundary>

src/custom/CatalogDesignTable/DesignTableColumnConfig.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ interface ColumnConfigProps {
4545
showPlaygroundActions: boolean;
4646
handleVisibilityChange?: (id: string, visibility: VIEW_VISIBILITY) => void;
4747
currentUserId?: string;
48+
refetchWorkspaceDesigns: () => void;
4849
}
4950

5051
export const colViews: ColView[] = [
5152
['id', 'na'],
5253
['name', 'xs'],
53-
['first_name', 'xs'],
54+
['user', 'xs'],
5455
['created_at', 'na'],
5556
['updated_at', 'l'],
5657
['visibility', 'l'],
@@ -78,7 +79,8 @@ export const createDesignsColumnsConfig = ({
7879
showPlaygroundActions = true,
7980
isFromWorkspaceTable = false,
8081
currentUserId,
81-
handleVisibilityChange
82+
handleVisibilityChange,
83+
refetchWorkspaceDesigns
8284
}: ColumnConfigProps): MUIDataTableColumn[] => {
8385
return [
8486
{
@@ -105,7 +107,7 @@ export const createDesignsColumnsConfig = ({
105107
}
106108
},
107109
{
108-
name: 'first_name',
110+
name: 'user',
109111
label: 'Author',
110112
options: {
111113
filter: false,
@@ -169,9 +171,12 @@ export const createDesignsColumnsConfig = ({
169171
return (
170172
<VisibilityChipMenu
171173
value={value as VIEW_VISIBILITY}
172-
onChange={(value) =>
173-
handleVisibilityChange && handleVisibilityChange(designId, value as VIEW_VISIBILITY)
174-
}
174+
onChange={(value) => {
175+
if (handleVisibilityChange) {
176+
handleVisibilityChange(designId, value as VIEW_VISIBILITY);
177+
refetchWorkspaceDesigns();
178+
}
179+
}}
175180
enabled={isEnabled}
176181
options={[
177182
[VIEW_VISIBILITY.PUBLIC, Public],
@@ -262,7 +267,7 @@ export const createDesignsColumnsConfig = ({
262267
},
263268

264269
{
265-
title: isFromWorkspaceTable ? 'Remove Design' : 'Delete',
270+
title: isFromWorkspaceTable ? 'Move Design' : 'Delete',
266271
disabled: isFromWorkspaceTable ? !isRemoveAllowed : !isDeleteAllowed,
267272
onClick: () => handleDeleteModal(rowData)(),
268273
icon: isFromWorkspaceTable ? (

0 commit comments

Comments
 (0)