github.com/freiheit-com/kuberpult@v1.24.2-0.20240328135542-315d5630abe6/services/frontend-service/src/ui/Pages/CommitInfo/CommitInfoPage.tsx (about) 1 /*This file is part of kuberpult. 2 3 Kuberpult is free software: you can redistribute it and/or modify 4 it under the terms of the Expat(MIT) License as published by 5 the Free Software Foundation. 6 7 Kuberpult is distributed in the hope that it will be useful, 8 but WITHOUT ANY WARRANTY; without even the implied warranty of 9 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 MIT License for more details. 11 12 You should have received a copy of the MIT License 13 along with kuberpult. If not, see <https://directory.fsf.org/wiki/License:Expat>. 14 15 Copyright 2023 freiheit.com*/ 16 17 import { getCommitInfo, useCommitInfo, useGlobalLoadingState, CommitInfoState } from '../../utils/store'; 18 import { LoadingStateSpinner } from '../../utils/LoadingStateSpinner'; 19 import { TopAppBar } from '../../components/TopAppBar/TopAppBar'; 20 import { Spinner } from '../../components/Spinner/Spinner'; 21 import { useParams } from 'react-router-dom'; 22 import React from 'react'; 23 import { CommitInfo } from '../../components/CommitInfo/CommitInfo'; 24 25 export const CommitInfoPage: React.FC = () => { 26 const [everythingLoaded, loadingState] = useGlobalLoadingState(); 27 const { commit: commitHash } = useParams(); 28 29 React.useEffect(() => { 30 if (commitHash !== undefined) { 31 getCommitInfo(commitHash); 32 } 33 }, [commitHash]); 34 35 const commitInfo = useCommitInfo((res) => res); 36 37 if (!everythingLoaded) { 38 return <LoadingStateSpinner loadingState={loadingState} />; 39 } 40 41 if (commitHash === undefined) { 42 return ( 43 <div> 44 <TopAppBar showAppFilter={false} showTeamFilter={false} showWarningFilter={false} /> 45 <main className="main-content commit-page">commit ID not provided</main> 46 </div> 47 ); 48 } 49 switch (commitInfo.commitInfoReady) { 50 case CommitInfoState.LOADING: 51 return <Spinner message="Loading commit info" />; 52 case CommitInfoState.ERROR: 53 return ( 54 <div> 55 <TopAppBar showAppFilter={false} showTeamFilter={false} showWarningFilter={false} /> 56 <main className="main-content commit-page">Backend error</main> 57 </div> 58 ); 59 case CommitInfoState.NOTFOUND: 60 return ( 61 <div> 62 <TopAppBar showAppFilter={false} showTeamFilter={false} showWarningFilter={false} /> 63 <main className="main-content commit-page"> 64 The provided commit ID was not found in the manifest repository. This is because either the 65 commit "{commitHash}" is incorrect, is not tracked by Kuberpult yet, or it refers to an old 66 commit whose release has been cleaned up by now. 67 </main> 68 </div> 69 ); 70 case CommitInfoState.READY: 71 return <CommitInfo commitInfo={commitInfo.response} />; 72 } 73 };