Skip to content

Commit

Permalink
Prevent reassignment of bot run before it is completed
Browse files Browse the repository at this point in the history
  • Loading branch information
stalgiag committed Dec 20, 2024
1 parent 3bf1fa8 commit ad53d16
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
15 changes: 15 additions & 0 deletions client/components/ManageBotRunDialog/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import RetryCanceledCollectionsButton from './RetryCanceledCollectionsButton';
import StopRunningCollectionButton from './StopRunningCollectionButton';
import ViewLogsButton from './ViewLogsButton';
import { TestPlanRunPropType, UserPropType } from '../common/proptypes';
import { COLLECTION_JOB_STATUS } from '../../utils/collectionJobStatus';

const ManageBotRunDialog = ({
testPlanReportId,
Expand Down Expand Up @@ -68,6 +69,19 @@ const ManageBotRunDialog = ({
[testers, testPlanReportAssignedTestersQuery]
);

const isBotRunFinished = useMemo(() => {
const status = collectionJobQuery?.collectionJobByTestPlanRunId?.status;
if (!status) return false;
switch (status) {
case COLLECTION_JOB_STATUS.COMPLETED:
case COLLECTION_JOB_STATUS.ERROR:
case COLLECTION_JOB_STATUS.CANCELLED:
return true;
default:
return false;
}
}, [collectionJobQuery]);

const actions = useMemo(() => {
return [
{
Expand All @@ -77,6 +91,7 @@ const ManageBotRunDialog = ({
testPlanRun: testPlanRun,
possibleTesters: possibleReassignees,
label: 'Assign To ...',
disabled: !isBotRunFinished,
onChange
}
},
Expand Down
5 changes: 4 additions & 1 deletion client/components/common/AssignTesterDropdown/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const AssignTesterDropdown = ({
possibleTesters,
onChange,
label,
disabled = false,
dropdownAssignTesterButtonRef,
setAlertMessage = () => {}
}) => {
Expand Down Expand Up @@ -139,6 +140,7 @@ const AssignTesterDropdown = ({
aria-label="Assign testers"
className="assign-tester"
variant="secondary"
disabled={disabled}
>
{renderLabel()}
</Dropdown.Toggle>
Expand Down Expand Up @@ -216,7 +218,8 @@ AssignTesterDropdown.propTypes = {
label: PropTypes.string,
draftTestPlanRuns: PropTypes.arrayOf(TestPlanRunPropType),
setAlertMessage: PropTypes.func,
dropdownAssignTesterButtonRef: PropTypes.object
dropdownAssignTesterButtonRef: PropTypes.object,
disabled: PropTypes.bool
};

export default AssignTesterDropdown;

0 comments on commit ad53d16

Please sign in to comment.