-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: page runtime detail info (#644)
* runtime detail api * fix runtime detail page path * feat: fetch runtime detail * init page runtime * init to runtime detail item * runtime, add detail item * fill list data
- Loading branch information
Showing
6 changed files
with
98 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,59 @@ | ||
import { useEffect } from "react"; | ||
import { useDispatch, useSelector } from "react-redux"; | ||
import { useParams } from "react-router-dom"; | ||
import BreadCrumb from "../components/breadCrumb"; | ||
import DetailLayout from "../components/layout/detailLayout"; | ||
import List from "../components/list"; | ||
import { Panel } from "../components/styled/panel"; | ||
import { | ||
clearRuntimeDetail, | ||
runtimeDetailSelector, | ||
runtimeFetchDetail, | ||
} from "../store/reducers/runtimeSlice"; | ||
import { | ||
clearHttpError, | ||
handleApiError, | ||
} from "../utils/viewFuncs/errorHandles"; | ||
import { toRuntimeDetailItem } from "../utils/viewFuncs/toDetailItem"; | ||
|
||
export default function Runtime() { | ||
return <div>page runtime</div>; | ||
const { runtimeSlug } = useParams(); | ||
const [version, startHeight] = runtimeSlug.split("_"); | ||
|
||
const dispatch = useDispatch(); | ||
const runtime = useSelector(runtimeDetailSelector); | ||
|
||
const listData = runtime ? toRuntimeDetailItem(runtime) : {}; | ||
|
||
useEffect(() => { | ||
if (version && startHeight) { | ||
clearHttpError(dispatch); | ||
dispatch(runtimeFetchDetail(version, startHeight)).catch((e) => | ||
handleApiError(e, dispatch), | ||
); | ||
} | ||
|
||
return () => { | ||
dispatch(clearRuntimeDetail()); | ||
}; | ||
}, [version, dispatch, startHeight]); | ||
|
||
const breadCrumb = ( | ||
<BreadCrumb | ||
data={[ | ||
{ name: "Runtimes", path: "/runtimes" }, | ||
{ | ||
name: version, | ||
}, | ||
]} | ||
/> | ||
); | ||
|
||
return ( | ||
<DetailLayout breadCrumb={breadCrumb}> | ||
<Panel> | ||
<List data={listData} /> | ||
</Panel> | ||
</DetailLayout> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters