@@ -8,11 +8,17 @@ import deleteEnvironment from '@/lib/mutation/deleteEnvironment';
88import switchActiveStandby from '@/lib/mutation/switchActiveStandby' ;
99import { QueryRef , useMutation , useQueryRefHandlers , useReadQuery } from '@apollo/client' ;
1010import { DetailedStats , Head3 , Head4 , Text } from '@uselagoon/ui-library' ;
11+ import dayjs from 'dayjs' ;
12+ import utc from 'dayjs/plugin/utc' ;
13+ import gitUrlParse from 'git-url-parse' ;
1114
1215import ActiveStandbyConfirm from '../../activestandbyconfirm/ActiveStandbyConfirm' ;
1316import DeleteConfirm from '../../deleteConfirm/DeleteConfirm' ;
17+ import { StyledGitLink } from '../projectDetails/styles' ;
1418import LimitedRoutes from './_components/LimitedRoutes' ;
15- import { EnvironmentActions , RoutesSection , RoutesWrapper } from './styles' ;
19+ import { EnvironmentActions , RoutesSection } from './styles' ;
20+
21+ dayjs . extend ( utc ) ;
1622
1723// active/standby routes
1824export const createLinks = ( routes : string | null ) =>
@@ -45,6 +51,22 @@ export default function EnvironmentPage({
4551 return < EnvironmentNotFound openshiftProjectName = { environmentSlug } /> ;
4652 }
4753
54+ let gitUrlParsed ;
55+
56+ try {
57+ gitUrlParsed = gitUrlParse ( environment . project . gitUrl ) ;
58+ } catch {
59+ gitUrlParsed = null ;
60+ }
61+
62+ const gitBranchLink = gitUrlParsed
63+ ? `${ gitUrlParsed . resource } /${ gitUrlParsed . full_name } /${
64+ environment . deployType === 'branch'
65+ ? `tree/${ environment . name } `
66+ : `pull/${ environment . name . replace ( / p r - / i, '' ) } `
67+ } `
68+ : '' ;
69+
4870 const environmentDetailItems = [
4971 {
5072 children : environment . environmentType ,
@@ -57,15 +79,28 @@ export default function EnvironmentPage({
5779 label : 'Deployment Type' ,
5880 } ,
5981 {
60- children : environment . created ,
82+ children : dayjs . utc ( environment . created ) . local ( ) . format ( 'YYYY-MM-DD HH:mm:ss Z' ) ,
6183 key : 'created' ,
6284 label : 'Created' ,
6385 } ,
6486 {
65- children : environment . updated ,
87+ children : dayjs . utc ( environment . updated ) . local ( ) . format ( 'YYYY-MM-DD HH:mm:ss Z' ) ,
6688 key : 'updated' ,
6789 label : 'Updated' ,
6890 } ,
91+ ...( gitBranchLink
92+ ? [
93+ {
94+ children : (
95+ < StyledGitLink className = "hover-state" data-cy = "source" target = "_blank" href = { `https://${ gitBranchLink } ` } >
96+ { gitBranchLink }
97+ </ StyledGitLink >
98+ ) ,
99+ key : 'source' ,
100+ label : 'Source' ,
101+ } ,
102+ ]
103+ : [ ] ) ,
69104 ] ;
70105
71106 const routes = createLinks ( environment . routes ) ;
0 commit comments