Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ms2: fuzy search #160

Merged
merged 58 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
792d393
Fixed and Updated OpenApi and changed users endpoint
FelipeTrost Sep 29, 2023
cd30d33
Data hooks: added MutationOptions and changed keys
FelipeTrost Sep 29, 2023
63f5c61
Added Users page and Comming Soon page for roles
FelipeTrost Sep 29, 2023
ee745a0
Added useFuzySearch hook
FelipeTrost Sep 30, 2023
098ff11
Typo
FelipeTrost Sep 30, 2023
247cf3d
Merge branch 'main' into ms2/iam-interface
FelipeTrost Sep 30, 2023
1d71149
Merge branch 'main' into ms2/iam-interface
FelipeTrost Sep 30, 2023
9ed5851
Merge branch 'ms2/iam-interface' of github.com:PROCEED-Labs/proceed i…
FelipeTrost Sep 30, 2023
4e8c219
Removed submodule files
FelipeTrost Sep 30, 2023
1add266
Removed 204 response for roles
FelipeTrost Oct 6, 2023
911389f
Fix: cannot delete default roles
FelipeTrost Oct 6, 2023
e275685
Merge main into ms2/iam-interface
FelipeTrost Oct 6, 2023
47242a6
Moved toCaslResources to ms-v2
FelipeTrost Oct 9, 2023
fe81a29
Merged main into ms2/iam-interface
FelipeTrost Oct 10, 2023
b8b75ff
Removed debugger statement
FelipeTrost Oct 12, 2023
0c3b3a9
PUT /role now uses only fields that changed for auth
FelipeTrost Oct 12, 2023
e56aa78
Updated authorization rules
FelipeTrost Oct 12, 2023
9d3d303
Fixed API endpoints in OpenAPI description
FelipeTrost Oct 12, 2023
a169c8f
Refactor and implemented useInvalidateAsseta
FelipeTrost Oct 12, 2023
26c7ae2
Updated subject type to accept objects
FelipeTrost Oct 12, 2023
709cf6f
Moved AuthCallbackListener to be inside of AntDesign context
FelipeTrost Oct 12, 2023
1df00d5
Updated active segment logic
FelipeTrost Oct 12, 2023
8b3e0c4
Moved user list to a separate component
FelipeTrost Oct 12, 2023
7696a83
Implemented role pages
FelipeTrost Oct 12, 2023
d56a52c
Removed console.log
FelipeTrost Oct 16, 2023
d0e8c76
Fixed permission check in api
FelipeTrost Oct 16, 2023
7fd6759
Use custom Bar component
FelipeTrost Oct 16, 2023
e717b20
Updated POST: /roles endpoint in openapi
FelipeTrost Oct 16, 2023
4046c02
Default permissions value is now an empty object
FelipeTrost Oct 16, 2023
330c08f
Roles page header actions
FelipeTrost Oct 16, 2023
d9f1d68
Cleaned up imports
FelipeTrost Oct 16, 2023
d230f25
Changed texts and updated ui
FelipeTrost Oct 16, 2023
f64e6e6
Changed order of tabs
FelipeTrost Oct 16, 2023
bbc5c95
Changed roleGeneralData style
FelipeTrost Oct 16, 2023
06df5a0
merged 'main' into 'ms2/iam-interface'
FelipeTrost Oct 23, 2023
11efff0
toCaslResource creates a shallow copy
FelipeTrost Oct 23, 2023
2a183c7
Update openapi typescript types
FelipeTrost Oct 25, 2023
c61ac6d
Fix typo
FelipeTrost Oct 25, 2023
27b9720
use Bar + check if selected items can be deleted
FelipeTrost Oct 25, 2023
90700a3
Create role modal
FelipeTrost Oct 25, 2023
27bbfd7
Corrected confirmation popup text
FelipeTrost Oct 25, 2023
c9b378d
Rearange tabs in role page
FelipeTrost Oct 26, 2023
613c7ec
Merge 'origin/main' into ms2/iam-interface
FelipeTrost Oct 26, 2023
5db7d33
fixed openapi POST /role types
FelipeTrost Oct 26, 2023
5a99e57
Removed console log
FelipeTrost Oct 26, 2023
c233c7d
Fixed permission check
FelipeTrost Oct 26, 2023
43a8160
Disable button instead of hidding it
FelipeTrost Oct 26, 2023
d08a902
Moved skelleton to the inside of the container
FelipeTrost Nov 5, 2023
b17a3e1
Updated texts and form validation
FelipeTrost Nov 5, 2023
28a220a
Added Link component to sidebr items
FelipeTrost Nov 5, 2023
ce5d49a
searchQury defaults to empty string
FelipeTrost Nov 11, 2023
a2b48a0
Merge remote-tracking branch 'origin/main' into ms2/iam-interface
FelipeTrost Nov 17, 2023
2cb6bc2
Moved prettify into sepparate file
FelipeTrost Nov 17, 2023
98be9c4
search params hook
FelipeTrost Nov 17, 2023
71ba166
useFuzySearch: highlighting + searchParams state
FelipeTrost Nov 17, 2023
b8905a9
Implemented useFuzySearch in process list
FelipeTrost Nov 19, 2023
2aae5b4
Merged main into ms2/fuzy-search
FelipeTrost Nov 20, 2023
3429919
fuzySearch: include string w/ highlighted element
FelipeTrost Nov 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions src/management-system-v2/app/(dashboard)/iam/roles/role-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { FC, useState } from 'react';
import { DeleteOutlined } from '@ant-design/icons';
import { Tooltip, Space, Button, Result, Table, Popconfirm, App } from 'antd';
import { useGetAsset, useDeleteAsset, ApiData } from '@/lib/fetch-data';
import { useGetAsset, useDeleteAsset } from '@/lib/fetch-data';
import { CloseOutlined } from '@ant-design/icons';
import Content from '@/components/content';
import HeaderActions from './header-actions';
Expand All @@ -14,8 +14,6 @@ import Bar from '@/components/bar';
import { AuthCan } from '@/lib/clientAuthComponents';
import { useAbilityStore } from '@/lib/abilityStore';

type Role = ApiData<'/roles', 'get'>[number];

const RolesPage: FC = () => {
const { message: messageApi } = App.useApp();
const ability = useAbilityStore((store) => store.ability);
Expand All @@ -25,12 +23,17 @@ const RolesPage: FC = () => {
onError: () => messageApi.open({ type: 'error', content: 'Something went wrong' }),
});

const { setSearchQuery, filteredData: filteredRoles } = useFuzySearch(roles || [], ['name'], {
useSearchParams: false,
const { setSearchQuery, filteredData: filteredRoles } = useFuzySearch({
data: roles || [],
keys: ['name'],
highlightedKeys: ['name'],
transformData: (items) =>
items.map((item) => ({ ...item.item, name: item.item.name.highlighted })),
});
type FilteredRole = (typeof filteredRoles)[number];

const [selectedRowKeys, setSelectedRowKeys] = useState<string[]>([]);
const [selectedRow, setSelectedRows] = useState<Role[]>([]);
const [selectedRow, setSelectedRows] = useState<FilteredRole[]>([]);

const cannotDeleteSelected = selectedRow.some(
(role) => !ability.can('delete', toCaslResource('Role', role)),
Expand All @@ -47,20 +50,24 @@ const RolesPage: FC = () => {
title: 'Name',
dataIndex: 'name',
key: 'display',
render: (name: string, role: Role) => <Link href={`/iam/roles/${role.id}`}>{name}</Link>,
render: (name: string, role: FilteredRole) => (
<Link style={{ color: '#000' }} href={`/iam/roles/${role.id}`}>
{name}
</Link>
),
},
{
title: 'Members',
dataIndex: 'members',
render: (_: any, record: Role) => record.members.length,
render: (_: any, record: FilteredRole) => record.members.length,
key: 'username',
},
{
dataIndex: 'id',
key: 'tooltip',
title: '',
width: 100,
render: (id: string, role: Role) =>
render: (id: string, role: FilteredRole) =>
selectedRowKeys.length === 0 ? (
<AuthCan action="delete" resource={toCaslResource('Role', role)}>
<Tooltip placement="top" title={'Delete'}>
Expand Down Expand Up @@ -112,9 +119,9 @@ const RolesPage: FC = () => {
}}
/>

<Table
columns={columns}
<Table<FilteredRole>
dataSource={filteredRoles}
columns={columns}
rowSelection={{
selectedRowKeys,
onChange: (selectedRowKeys, selectedRows) => {
Expand Down
16 changes: 7 additions & 9 deletions src/management-system-v2/components/bpmn-viewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ const BPMNViewer =
typeof window !== 'undefined' ? import('bpmn-js/lib/Viewer').then((mod) => mod.default) : null;

type ViewerProps = {
selectedElement?: Process | undefined;
selectedElementId?: string;
rerenderTrigger?: any;
reduceLogo?: boolean;
};

const Viewer: FC<ViewerProps> = ({ selectedElement, rerenderTrigger, reduceLogo }) => {
const Viewer: FC<ViewerProps> = ({ selectedElementId, rerenderTrigger, reduceLogo }) => {
const [initialized, setInitialized] = useState(false);
const { data: bpmn, isSuccess } = useProcessBpmn(
selectedElement ? selectedElement.definitionId : '',
);
const { data: bpmn, isSuccess } = useProcessBpmn(selectedElementId ?? '');
const canvas = useRef<HTMLDivElement>(null);
const previewer = useRef<ViewerType | null>(null);

Expand All @@ -42,18 +40,18 @@ const Viewer: FC<ViewerProps> = ({ selectedElement, rerenderTrigger, reduceLogo
}, [bpmn]);

useEffect(() => {
if (initialized && bpmn && selectedElement) {
if (initialized && bpmn && selectedElementId) {
previewer.current!.importXML(bpmn).then(() => {
(previewer.current!.get('canvas') as any).zoom('fit-viewport', 'auto');
});
}
}, [initialized, bpmn, selectedElement]);
}, [initialized, bpmn, selectedElementId]);

useEffect(() => {
if (initialized && selectedElement) {
if (initialized && selectedElementId) {
(previewer.current!.get('canvas') as any)?.zoom('fit-viewport', 'auto');
}
}, [initialized, rerenderTrigger, selectedElement]);
}, [initialized, rerenderTrigger, selectedElementId]);

return (
<div
Expand Down
5 changes: 3 additions & 2 deletions src/management-system-v2/components/previewProcess.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import { useProcessBpmn } from '@/lib/process-queries';

import type ViewerType from 'bpmn-js/lib/Viewer';
import Viewer from './bpmn-viewer';
import { ProcessListProcess } from './processes';

type PropertiesPanelProperties = {
selectedElement?: ApiData<'/process', 'get'>[number];
selectedElement?: ProcessListProcess;
setOpen: (open: boolean) => void;
};

Expand Down Expand Up @@ -81,7 +82,7 @@ const Preview: React.FC<PropertiesPanelProperties> = ({ selectedElement, setOpen
}}
onMouseDown={handleMouseDown}
></div>
<Viewer selectedElement={selectedElement} rerenderTrigger={drawerHeight} />
<Viewer selectedElementId={selectedElement?.definitionId} rerenderTrigger={drawerHeight} />
</Drawer>
);

Expand Down
12 changes: 4 additions & 8 deletions src/management-system-v2/components/process-icon-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,16 @@ import React, { Dispatch, FC, Key, SetStateAction } from 'react';

import TabCard from './tabcard-model-metadata';

import { ApiData } from '@/lib/fetch-data';
import ScrollBar from './scrollbar';

type Processes = ApiData<'/process', 'get'>;
import { ProcessListProcess } from './processes';

type IconViewProps = {
data?: Processes;
data?: ProcessListProcess[];
selection: Key[];
setSelection: Dispatch<SetStateAction<Key[]>>;
search?: string;
};

const IconView: FC<IconViewProps> = ({ data, selection, setSelection, search }) => {
const IconView: FC<IconViewProps> = ({ data, selection, setSelection }) => {
return (
<>
<ScrollBar width="12px">
Expand All @@ -29,15 +26,14 @@ const IconView: FC<IconViewProps> = ({ data, selection, setSelection, search })
gridGap: '20px',
}}
>
{data?.map((item, i, arr) => (
{data?.map((item) => (
<TabCard
key={item.definitionId}
item={item}
completeList={data!}
selection={selection}
setSelection={setSelection}
tabcard={false}
search={search}
/>
))}
</div>
Expand Down
15 changes: 8 additions & 7 deletions src/management-system-v2/components/process-info-card.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
'use client';

import { generateDateString, getPreferences, addUserPreference } from '@/lib/utils';
import { generateDateString } from '@/lib/utils';
import { Card, Divider, Button } from 'antd';
import { DoubleRightOutlined, DoubleLeftOutlined } from '@ant-design/icons';
import React, { FC, Key, use, useCallback, useEffect, useState } from 'react';
import Viewer from './bpmn-viewer';
import classNames from 'classnames';
import { ApiData } from '@/lib/fetch-data';
import { useUserPreferences } from '@/lib/user-preferences';

type Processes = ApiData<'/process', 'get'>;
import { ProcessListProcess } from './processes';

type MetaDataType = {
data?: Processes;
data?: ProcessListProcess[];
selection: Key[];
triggerRerender?: () => void;
};
Expand Down Expand Up @@ -103,7 +102,7 @@ const MetaData: FC<MetaDataType> = ({ data, selection, triggerRerender }) => {
<DoubleRightOutlined />
</Button>
{selection.length
? data?.find((item) => item.definitionId === selection[0])?.definitionName
? data?.find((item) => item.definitionId === selection[0])?.definitionName.value
: 'How to PROCEED?'}
</>
}
Expand All @@ -119,7 +118,9 @@ const MetaData: FC<MetaDataType> = ({ data, selection, triggerRerender }) => {
<>
{showViewer && (
<Viewer
selectedElement={data?.find((item) => item.definitionId === selection[0])}
selectedElementId={
data?.find((item) => item.definitionId === selection[0])?.definitionId
}
reduceLogo={true}
/>
)}
Expand Down Expand Up @@ -155,7 +156,7 @@ const MetaData: FC<MetaDataType> = ({ data, selection, triggerRerender }) => {
<h5>
<b>Description</b>
</h5>
<p>{data?.find((item) => item.definitionId === selection[0])?.description}</p>
<p>{data?.find((item) => item.definitionId === selection[0])?.description.value}</p>

<Divider style={{ width: '140%', marginLeft: '-20%' }} />
<h3>Access Rights</h3>
Expand Down
Loading