(props: IProps)
| 95 | ]; |
| 96 | |
| 97 | const ProjectLayout = (props: IProps) => { |
| 98 | const { projectKey, environmentKey, toggleKey, segmentKey } = useParams<IRouterParams>(); |
| 99 | const [ projectInfo, setProjectInfo ] = useState<IProject>({ |
| 100 | name: '', |
| 101 | key: '', |
| 102 | description: '', |
| 103 | environments: [{ |
| 104 | name: '', |
| 105 | key: '', |
| 106 | clientSdkKey: '', |
| 107 | serverSdkKey: '' |
| 108 | }] |
| 109 | }); |
| 110 | const [ envIndex, setEnvIndex ] = useState<number>(0); |
| 111 | const [ toggleName, saveToggleName ] = useState<string>(''); |
| 112 | const [ segmentName, setSegmentName ] = useState<string>(''); |
| 113 | const [ tipVisible, saveTipVisible ] = useState<boolean>(false); |
| 114 | const [ isLoading, saveIsLoading ] = useState<boolean>(false); |
| 115 | const [ run, saveRun ] = useState<boolean>(false); |
| 116 | const [ stepIndex, saveStepIndex ] = useState<number>(0); |
| 117 | const history = useHistory(); |
| 118 | const match = useRouteMatch(); |
| 119 | const intl = useIntl(); |
| 120 | |
| 121 | useEffect(() => { |
| 122 | getProjectInfo<IProject>(projectKey).then(res => { |
| 123 | saveIsLoading(false); |
| 124 | if (res.success) { |
| 125 | const { data } = res; |
| 126 | if (data) { |
| 127 | setProjectInfo(data); |
| 128 | } |
| 129 | } else { |
| 130 | message.error(res.message || 'Get project information error!'); |
| 131 | } |
| 132 | }); |
| 133 | }, [projectKey]); |
| 134 | |
| 135 | useEffect(() => { |
| 136 | if(segmentKey) { |
| 137 | getSegmentDetail<ISegmentInfo>(projectKey, segmentKey).then(res => { |
| 138 | saveIsLoading(false); |
| 139 | if (res.success) { |
| 140 | const { data } = res; |
| 141 | if (data) { |
| 142 | setSegmentName(data.name); |
| 143 | } |
| 144 | } else { |
| 145 | message.error(res.message || 'Error getting segment'); |
| 146 | } |
| 147 | }); |
| 148 | } |
| 149 | }, [projectKey, segmentKey]); |
| 150 | |
| 151 | useEffect(() => { |
| 152 | if (!toggleKey) return; |
| 153 | |
| 154 | getToggleInfo<IToggleInfo>(projectKey, environmentKey, toggleKey).then(res => { |
nothing calls this directly
no test coverage detected