@@ -30,6 +30,8 @@ export interface TransferListProps {
3030 assignedPage : ( ) => void ;
3131 originalLeftCount : number ;
3232 originalRightCount : number ;
33+ rightPermission : boolean ;
34+ leftPermission : boolean ;
3335}
3436
3537interface ListItemType {
@@ -58,6 +60,8 @@ function intersection<T>(a: T[], b: T[]): T[] {
5860 * @param {Element } props.emptyStateIconRight - Icon for empty state of list right.
5961 * @param {String } props.emtyStateMessageRight - Message for the empty state of the list right.
6062 * @param {String } props.transferComponentType - Type of the component transfer (There is two types: chip and other).
63+ * @param {Boolean } props.leftPermission - Permission to move data from left to right.
64+ * @param {Boolean } props.rightPermission - Permission to move data from right to left.
6165 */
6266
6367function TransferList ( {
@@ -73,6 +77,8 @@ function TransferList({
7377 emtyStateMessageRight,
7478 originalLeftCount,
7579 originalRightCount,
80+ leftPermission = true ,
81+ rightPermission = true ,
7682 transferComponentType = TRANSFER_COMPONET . OTHER
7783} : TransferListProps ) : JSX . Element {
7884 const [ checked , setChecked ] = React . useState < ListItemType [ ] > ( [ ] ) ;
@@ -280,7 +286,10 @@ function TransferList({
280286 variant = "outlined"
281287 size = "small"
282288 onClick = { handleAllRight }
283- disabled = { left . length === 0 }
289+ disabled = {
290+ ! rightPermission ||
291+ ( rightPermission && ( left ?. length === 0 || left . length < leftCount ) )
292+ }
284293 aria-label = "move all right"
285294 >
286295 < RightArrowIcon width = { 18 } height = { 18 } />
@@ -290,7 +299,7 @@ function TransferList({
290299 variant = "outlined"
291300 size = "small"
292301 onClick = { handleCheckedRight }
293- disabled = { leftChecked . length === 0 }
302+ disabled = { ! rightPermission || ( rightPermission && leftChecked . length === 0 ) }
294303 aria-label = "move selected right"
295304 >
296305 < RightArrowIcon width = { 18 } height = { 18 } />
@@ -299,7 +308,7 @@ function TransferList({
299308 variant = "outlined"
300309 size = "small"
301310 onClick = { handleCheckedLeft }
302- disabled = { rightChecked . length === 0 }
311+ disabled = { ! leftPermission || ( leftPermission && rightChecked . length === 0 ) }
303312 aria-label = "move selected left"
304313 >
305314 < LeftArrowIcon width = { 18 } height = { 18 } />
@@ -308,7 +317,10 @@ function TransferList({
308317 variant = "outlined"
309318 size = "small"
310319 onClick = { handleAllLeft }
311- disabled = { right . length === 0 }
320+ disabled = {
321+ ! leftPermission ||
322+ ( leftPermission && ( right ?. length === 0 || right . length < rightCount ) )
323+ }
312324 aria-label = "move all left"
313325 >
314326 < LeftArrowIcon width = { 18 } height = { 18 } />
0 commit comments