()
| 27 | } |
| 28 | |
| 29 | const ProjectSetting = () => { |
| 30 | const [ approvalSetting, saveApprovalSetting ] = useState<IApprovalSetting[]>([]); |
| 31 | const [ originSetting, saveOriginSetting ] = useState<IApprovalSetting[]>([]); |
| 32 | const [ isSame, saveIsSame ] = useState<boolean>(false); |
| 33 | const [ options, saveOptions ] = useState<IOption[]>([]); |
| 34 | const [ isLoading, saveIsLoading ] = useState<boolean>(true); |
| 35 | |
| 36 | const intl = useIntl(); |
| 37 | const { projectKey } = useParams<IParams>(); |
| 38 | const { userInfo } = HeaderContainer.useContainer(); |
| 39 | const { trigger, formState: { errors }, register, clearErrors } = useForm(); |
| 40 | const [ submitLoading, setSubmitLoading ] = useState<boolean>(false); |
| 41 | |
| 42 | const init = useCallback(async () => { |
| 43 | getProjectApprovalSettings<IApprovalSetting[]>(projectKey).then(res => { |
| 44 | saveIsLoading(false); |
| 45 | const { success, data } = res; |
| 46 | if (success && data) { |
| 47 | saveApprovalSetting(data); |
| 48 | saveOriginSetting(cloneDeep(data)); |
| 49 | } |
| 50 | }); |
| 51 | |
| 52 | const res = await getMemberList<IMemberList>({ |
| 53 | pageIndex: 0, |
| 54 | pageSize: 10, |
| 55 | }); |
| 56 | |
| 57 | const { success, data } = res; |
| 58 | if (success && data) { |
| 59 | const { content } = data; |
| 60 | const options = content.map((member: IMember) => { |
| 61 | return ({ |
| 62 | key: member.account, |
| 63 | value: member.account, |
| 64 | text: member.account, |
| 65 | }); |
| 66 | }); |
| 67 | saveOptions(options); |
| 68 | } |
| 69 | }, [projectKey]); |
| 70 | |
| 71 | useEffect(() => { |
| 72 | const isSame = isEqual(approvalSetting, originSetting); |
| 73 | saveIsSame(isSame); |
| 74 | }, [approvalSetting, originSetting]); |
| 75 | |
| 76 | useEffect(() => { |
| 77 | init(); |
| 78 | }, [init]); |
| 79 | |
| 80 | const renderLabel = useCallback((label: DropdownItemProps, setting: IApprovalSetting) => { |
| 81 | const cantRemove: boolean = setting.reviewers.length === 1 && setting.enable === true; |
| 82 | return ({ |
| 83 | content: label.text, |
| 84 | removeIcon: !cantRemove && <Icon type='close' customclass={styles['dropdown-remove-icon']} /> |
| 85 | }); |
| 86 | }, []); |
nothing calls this directly
no test coverage detected