Skip to content

Commit

Permalink
Merge pull request layer5io#896 from amitamrutiya/support-views
Browse files Browse the repository at this point in the history
Add support for views in transferList
  • Loading branch information
amitamrutiya authored Jan 23, 2025
2 parents 93cf965 + a64543e commit a54c20d
Show file tree
Hide file tree
Showing 8 changed files with 540 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/custom/TransferModal/TransferList/TransferList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function getFallbackImageBasedOnKind(kind: string | undefined): JSX.Eleme
}

export interface TransferListProps {
name: string;
name?: string;
assignableData: ListItemType[];
assignedData: (data: ListItemType[]) => void;
originalAssignedData: ListItemType[];
Expand Down
57 changes: 56 additions & 1 deletion src/custom/Workspaces/AssignmentModal.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import { Divider } from '../../base';
import { Modal, ModalBody, ModalButtonPrimary, ModalButtonSecondary, ModalFooter } from '../Modal';
import { TransferList } from '../TransferModal/TransferList';
import { ModalActionDiv } from './styles';
Expand All @@ -22,6 +23,21 @@ interface AssignmentModalProps {
isAssignAllowed: boolean;
isRemoveAllowed: boolean;
helpText: string;
showViews?: boolean;
nameViews?: string;
assignableViewsData?: any[];
handleAssignedViewsData?: (data: any) => void;
originalAssignedViewsData?: any[];

emptyStateViewsIcon?: JSX.Element;
handleAssignableViewsPage?: () => void;
handleAssignedViewsPage?: () => void;
originalLeftViewsCount?: number;
originalRightViewsCount?: number;
onAssignViews?: () => void;
disableTransferViews?: boolean;
isAssignAllowedViews?: boolean;
isRemoveAllowedViews?: boolean;
}

const AssignmentModal: React.FC<AssignmentModalProps> = ({
Expand All @@ -42,7 +58,19 @@ const AssignmentModal: React.FC<AssignmentModalProps> = ({
disableTransfer,
isAssignAllowed,
isRemoveAllowed,
helpText
helpText,
showViews,
nameViews,
assignableViewsData,
handleAssignedViewsData,
originalAssignedViewsData,
emptyStateViewsIcon,
handleAssignableViewsPage,
handleAssignedViewsPage,
originalLeftViewsCount,
originalRightViewsCount,
isAssignAllowedViews = false,
isRemoveAllowedViews = false
}) => {
return (
<Modal
Expand Down Expand Up @@ -71,6 +99,33 @@ const AssignmentModal: React.FC<AssignmentModalProps> = ({
rightPermission={isRemoveAllowed}
transferComponentType={''}
/>
<Divider
style={{
margin: 'auto',
width: '80%',
marginTop: '22px',
marginBottom: '22px'
}}
/>
{showViews && (
<TransferList
name={nameViews}
assignableData={assignableViewsData || []}
assignedData={handleAssignedViewsData || (() => {})}
originalAssignedData={originalAssignedViewsData || []}
emptyStateIconLeft={emptyStateViewsIcon || <></>}
emtyStateMessageLeft={`No views available`}
emptyStateIconRight={emptyStateViewsIcon || <></>}
emtyStateMessageRight={`No views assigned`}
assignablePage={handleAssignableViewsPage || (() => {})}
assignedPage={handleAssignedViewsPage || (() => {})}
originalLeftCount={originalLeftViewsCount ?? 0}
originalRightCount={originalRightViewsCount ?? 0}
leftPermission={isAssignAllowedViews}
rightPermission={isRemoveAllowedViews}
transferComponentType={''}
/>
)}
</ModalBody>
<ModalFooter variant="filled" helpText={helpText}>
<ModalActionDiv>
Expand Down
1 change: 1 addition & 0 deletions src/custom/Workspaces/DesignTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ const DesignTable: React.FC<DesignTableProps> = ({
helpText={`Assign Designs to ${workspaceName}`}
isAssignAllowed={isAssignAllowed}
isRemoveAllowed={isRemoveAllowed}
showViews={false}
/>
<GenericRJSFModal
open={publishModal.open}
Expand Down
Loading

0 comments on commit a54c20d

Please sign in to comment.