Skip to content

Commit

Permalink
Merge pull request #864 from US-Trustee-Program/CAMS-418-assignment-b…
Browse files Browse the repository at this point in the history
…utton-updates

CAMS-418 assignment button updates
  • Loading branch information
fmaddenflx authored Aug 28, 2024
2 parents a8c9c7c + 3547f2e commit 5d1cf9d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
12 changes: 10 additions & 2 deletions user-interface/src/staff-assignment/modal/AssignAttorneyModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@ import { CaseBasics } from '@common/cams/cases';
import { AttorneyUser, CamsUserReference } from '@common/cams/users';
import { getCamsUserReference } from '@common/cams/session';
import { deepEqual } from '@/lib/utils/objectEquality';
import { ModalRefType, SubmitCancelButtonGroupRef } from '@/lib/components/uswds/modal/modal-refs';
import {
ModalRefType,
OpenModalButtonRef,
SubmitCancelButtonGroupRef,
} from '@/lib/components/uswds/modal/modal-refs';
import Api from '@/lib/models/api';
import Modal from '@/lib/components/uswds/modal/Modal';
import Checkbox from '@/lib/components/uswds/Checkbox';
Expand All @@ -29,6 +33,7 @@ type CallbackFunction = (props: CallbackProps) => void;
export interface ModalOpenProps {
bCase: CaseBasics;
callback: CallbackFunction;
openModalButtonRef?: React.Ref<OpenModalButtonRef>;
}

export interface AssignAttorneyModalRef {
Expand Down Expand Up @@ -99,7 +104,10 @@ function _AssignAttorneyModal(
}
}
if (modalRef.current?.show) {
modalRef.current?.show({});
const showOptions = {
openModalButtonRef: showProps?.openModalButtonRef ?? undefined,
};
modalRef.current?.show(showOptions);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ describe('StaffAssignmentRow tests', () => {
const button = cols?.[4].querySelector('button');
expect(button).not.toHaveClass(UswdsButtonStyle.Outline);
expect(button).toHaveTextContent('Assign');
expect(button).toHaveAttribute('title', 'add assignments');
expect(button).toHaveAttribute('title', 'Add Staff Assignments');
expect(button).toHaveAttribute('data-testid', 'open-modal-button-0');
});
});
Expand All @@ -120,7 +120,7 @@ describe('StaffAssignmentRow tests', () => {
const button = cols?.[4].querySelector('button');
expect(button).toHaveClass(UswdsButtonStyle.Outline);
expect(button).toHaveTextContent('Edit');
expect(button).toHaveAttribute('title', 'edit assignments');
expect(button).toHaveAttribute('title', 'Edit Staff Assignments');
expect(button).toHaveAttribute('data-testid', 'open-modal-button-0');
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from 'react';
import { useEffect, useRef } from 'react';
import { TableRow, TableRowData } from '@/lib/components/uswds/Table';
import { OpenModalButton } from '@/lib/components/uswds/modal/OpenModalButton';
import { CaseNumber } from '@/lib/components/CaseNumber';
Expand All @@ -10,6 +10,7 @@ import { SearchResultsRowProps } from '@/search-results/SearchResults';
import { AssignAttorneyModalRef, CallbackProps } from '../modal/AssignAttorneyModal';
import { AttorneyUser } from '@common/cams/users';
import Internal from './StaffAssignmentRow.internal';
import { OpenModalButtonRef } from '../../lib/components/uswds/modal/modal-refs';

export type StaffAssignmentRowOptions = {
modalId: string;
Expand All @@ -31,6 +32,7 @@ export function StaffAssignmentRow(props: StaffAssignmentRowProps) {
modalRef,
};

const openAssignmentsModalButtonRef = useRef<OpenModalButtonRef>(null);
const { state, actions } = Internal.useStateActions(initialState);

useEffect(() => {
Expand All @@ -53,21 +55,22 @@ export function StaffAssignmentRow(props: StaffAssignmentRowProps) {
},
modalId,
modalRef,
ref: openAssignmentsModalButtonRef,
};

if (assignments.length > 0) {
return (
<OpenModalButton
{...commonModalButtonProps}
uswdsStyle={UswdsButtonStyle.Outline}
title="edit assignments"
title="Edit Staff Assignments"
>
Edit
</OpenModalButton>
);
} else {
return (
<OpenModalButton {...commonModalButtonProps} title="add assignments">
<OpenModalButton {...commonModalButtonProps} title="Add Staff Assignments">
Assign
</OpenModalButton>
);
Expand Down

0 comments on commit 5d1cf9d

Please sign in to comment.