diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/environments/environemnts-page.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/environments/environemnts-page.tsx deleted file mode 100644 index 56814b86a..000000000 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/environments/environemnts-page.tsx +++ /dev/null @@ -1,158 +0,0 @@ -'use client'; - -import Bar from '@/components/bar'; -import { OrganizationEnvironment } from '@/lib/data/environment-schema'; -import { App, Button, Space, Typography } from 'antd'; -import { FC, useState } from 'react'; -import useFuzySearch, { ReplaceKeysWithHighlighted } from '@/lib/useFuzySearch'; -import EnvironmentSidePanel from './environments-side-panel'; -import ConfirmationButton from '@/components/confirmation-button'; -import { useSession } from 'next-auth/react'; -import { deleteOrganizationEnvironments } from '@/lib/data/environments'; -import { useRouter } from 'next/navigation'; -import { AiOutlineClose, AiOutlineDelete } from 'react-icons/ai'; -import SelectionActions from '@/components/selection-actions'; -import ElementList from '@/components/item-list-view'; -import styles from '@/components/item-list-view.module.scss'; -import { wrapServerCall } from '@/lib/wrap-server-call'; - -const highlightedKeys = ['name', 'description'] as const; -export type FilteredEnvironment = ReplaceKeysWithHighlighted< - OrganizationEnvironment, - (typeof highlightedKeys)[number] ->; - -const EnvironmentsPage: FC<{ organizationEnvironments: OrganizationEnvironment[] }> = ({ - organizationEnvironments, -}) => { - const app = App.useApp(); - const router = useRouter(); - - const { searchQuery, filteredData, setSearchQuery } = useFuzySearch({ - data: organizationEnvironments, - keys: ['name', 'description'], - highlightedKeys, - transformData: (results) => results.map((result) => result.item), - }); - - const [selectedRows, setSelectedRows] = useState([]); - const selectedRowKeys = selectedRows.map((row) => row.id); - const selectedRow = selectedRows.at(-1); - - const session = useSession(); - const userId = session.data?.user?.id || ''; - - async function deleteEnvironments(environmentIds: string[]) { - await wrapServerCall({ - fn: () => deleteOrganizationEnvironments(environmentIds), - onSuccess: () => { - setSelectedRows([]); - router.refresh(); - app.message.success(`Environment${environmentIds.length > 1 ? 's' : ''} deleted`); - }, - app, - }); - } - - return ( -
-
- - - -
- - -
- ); -}; -export default EnvironmentsPage; diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/environments/environments-side-panel.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/environments/environments-side-panel.tsx deleted file mode 100644 index 37198ecfd..000000000 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/environments/environments-side-panel.tsx +++ /dev/null @@ -1,82 +0,0 @@ -'use client'; - -import { FC, useRef } from 'react'; -import { Alert, Typography } from 'antd'; -import CollapsibleCard from '@/components/collapsible-card'; -import { useUserPreferences } from '@/lib/user-preferences'; -import ResizableElement, { ResizableElementRefType } from '@/components/ResizableElement'; -import { FilteredEnvironment } from './environemnts-page'; - -const EnvironmentSidePanel: FC<{ environment: FilteredEnvironment | undefined }> = ({ - environment, -}) => { - const setUserPreferences = useUserPreferences.use.addPreferences(); - const sidePanelOpen = useUserPreferences( - (store) => store.preferences['environments-page-side-panel'].open, - ); - const hydrated = useUserPreferences.use._hydrated(); - - const resizableElementRef = useRef(null); - - if (!hydrated) return null; - return ( - - setUserPreferences({ - 'environments-page-side-panel': { - open: sidePanelOpen, - width: width, - }, - }) - } - ref={resizableElementRef} - > - { - const resizeCard = resizableElementRef.current; - const sidepanelWidth = - useUserPreferences.getState().preferences['environments-page-side-panel'].width; - - if (resizeCard) { - if (sidePanelOpen) resizeCard(30); - else resizeCard(sidepanelWidth); - } - setUserPreferences({ - 'environments-page-side-panel': { - open: !sidePanelOpen, - width: sidepanelWidth, - }, - }); - }} - > - {environment ? ( - <> - Description - {environment.description.value} - - Members - TODO - - Created On - TODO - - ) : ( - Select an environment. - )} - - - ); -}; - -export default EnvironmentSidePanel; diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/layout-client.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/layout-client.tsx index bdbb94038..6ec7f01cf 100644 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/layout-client.tsx +++ b/src/management-system-v2/app/(dashboard)/[environmentId]/layout-client.tsx @@ -96,9 +96,9 @@ const Layout: FC< icon: , }, { - key: 'environments', + key: 'spaces', title: 'My Spaces', - label: My Spaces, + label: My Spaces, icon: , }, ], @@ -187,7 +187,6 @@ const Layout: FC< priority /> - {loggedIn ? menu : null} )} diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/spaces/environments-page.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/spaces/environments-page.tsx new file mode 100644 index 000000000..5d1f1963a --- /dev/null +++ b/src/management-system-v2/app/(dashboard)/[environmentId]/spaces/environments-page.tsx @@ -0,0 +1,68 @@ +'use client'; + +import Bar from '@/components/bar'; +import { OrganizationEnvironment } from '@/lib/data/environment-schema'; +import { Button } from 'antd'; +import { FC } from 'react'; +import useFuzySearch, { ReplaceKeysWithHighlighted } from '@/lib/useFuzySearch'; +import ElementList from '@/components/item-list-view'; +import Link from 'next/link'; + +const highlightedKeys = ['name', 'description'] as const; +export type FilteredEnvironment = ReplaceKeysWithHighlighted< + OrganizationEnvironment, + (typeof highlightedKeys)[number] +>; + +const EnvironmentsPage: FC<{ organizationEnvironments: OrganizationEnvironment[] }> = ({ + organizationEnvironments, +}) => { + const { searchQuery, filteredData, setSearchQuery } = useFuzySearch({ + data: organizationEnvironments, + keys: ['name', 'description'], + highlightedKeys, + transformData: (results) => results.map((result) => result.item), + }); + + return ( + <> + + + + } + searchProps={{ + value: searchQuery, + onChange: (e) => setSearchQuery(e.target.value), + placeholder: 'Search Environments', + }} + /> + + columns={[ + { title: 'Name', render: (_, environment) => environment.name.highlighted }, + { + title: 'Description', + render: (_, environment) => environment.description.highlighted, + }, + { + dataIndex: 'id', + key: 'tooltip', + title: '', + width: 100, + render: (id: string) => ( + + + + ), + }, + ]} + data={filteredData} + tableProps={{ + rowKey: 'id', + }} + /> + + ); +}; +export default EnvironmentsPage; diff --git a/src/management-system-v2/app/(dashboard)/[environmentId]/environments/page.tsx b/src/management-system-v2/app/(dashboard)/[environmentId]/spaces/page.tsx similarity index 91% rename from src/management-system-v2/app/(dashboard)/[environmentId]/environments/page.tsx rename to src/management-system-v2/app/(dashboard)/[environmentId]/spaces/page.tsx index 1642eae2a..f55912d0e 100644 --- a/src/management-system-v2/app/(dashboard)/[environmentId]/environments/page.tsx +++ b/src/management-system-v2/app/(dashboard)/[environmentId]/spaces/page.tsx @@ -3,7 +3,7 @@ import Content from '@/components/content'; import { getEnvironmentById } from '@/lib/data/DTOs'; import { getUserOrganizationEnvironments } from '@/lib/data/DTOs'; import { OrganizationEnvironment } from '@/lib/data/environment-schema'; -import EnvironmentsPage from './environemnts-page'; +import EnvironmentsPage from './environments-page'; import { getUserById } from '@/lib/data/DTOs'; import UnauthorizedFallback from '@/components/unauthorized-fallback'; @@ -19,7 +19,7 @@ const Page = async () => { )) as OrganizationEnvironment[]; return ( - + ); diff --git a/src/management-system-v2/components/header-actions.tsx b/src/management-system-v2/components/header-actions.tsx index 147da1761..ba915432e 100644 --- a/src/management-system-v2/components/header-actions.tsx +++ b/src/management-system-v2/components/header-actions.tsx @@ -126,9 +126,9 @@ const HeaderActions: FC = () => { avatarDropdownItems.push( { - key: 'environments', + key: 'spaces', title: 'My Spaces', - label: My Spaces, + label: My Spaces, icon: , }, { diff --git a/src/management-system-v2/lib/user-preferences.ts b/src/management-system-v2/lib/user-preferences.ts index a44c17178..bc463ed4b 100644 --- a/src/management-system-v2/lib/user-preferences.ts +++ b/src/management-system-v2/lib/user-preferences.ts @@ -41,7 +41,6 @@ const defaultPreferences = { 'role-page-side-panel': { open: false, width: 300 }, 'user-page-side-panel': { open: false, width: 300 }, 'process-meta-data': { open: false, width: 300 }, - 'environments-page-side-panel': { open: false, width: 300 }, 'tech-data-open-tree-items': [] as { id: string; open: string[] }[], 'tech-data-editor': { siderOpen: true, siderWidth: 300 }, }; /* as const */ /* Does not work for strings */ diff --git a/src/management-system-v2/next.config.js b/src/management-system-v2/next.config.js index 2e7f9ce33..d893b3325 100644 --- a/src/management-system-v2/next.config.js +++ b/src/management-system-v2/next.config.js @@ -48,7 +48,7 @@ const nextConfig = { rewrites: async () => { return [ 'processes', - 'environments', + 'spaces', 'executions', 'engines', 'tasklist',