Skip to content

Commit

Permalink
more fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveDarsa committed Jan 15, 2025
1 parent b792529 commit fb0694d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/components/newEnvironment/NewEnvironment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const NewEnvironment: FC<Props> = ({ projectName, renderType = 'card', re
<Input placeholder="Enter a branch name" />
</FormItem>
</StepWrapper>
<Tip content="Add the branch you wish to build this environment from. This branch must already exist in your git repository. Please note, that only lowercase alpha characters and “-” are available for group names." />
<Tip content="Add the branch you wish to build this environment from. This branch must already exist in your git repository." />
</>
);

Expand Down
41 changes: 38 additions & 3 deletions src/components/pages/environment/EnvironmentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,17 @@ import deleteEnvironment from '@/lib/mutation/deleteEnvironment';
import switchActiveStandby from '@/lib/mutation/switchActiveStandby';
import { QueryRef, useMutation, useQueryRefHandlers, useReadQuery } from '@apollo/client';
import { DetailedStats, Head3, Head4, Text } from '@uselagoon/ui-library';
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import gitUrlParse from 'git-url-parse';

import ActiveStandbyConfirm from '../../activestandbyconfirm/ActiveStandbyConfirm';
import DeleteConfirm from '../../deleteConfirm/DeleteConfirm';
import { StyledGitLink } from '../projectDetails/styles';
import LimitedRoutes from './_components/LimitedRoutes';
import { EnvironmentActions, RoutesSection, RoutesWrapper } from './styles';
import { EnvironmentActions, RoutesSection } from './styles';

dayjs.extend(utc);

// active/standby routes
export const createLinks = (routes: string | null) =>
Expand Down Expand Up @@ -45,6 +51,22 @@ export default function EnvironmentPage({
return <EnvironmentNotFound openshiftProjectName={environmentSlug} />;
}

let gitUrlParsed;

try {
gitUrlParsed = gitUrlParse(environment.project.gitUrl);
} catch {
gitUrlParsed = null;
}

const gitBranchLink = gitUrlParsed
? `${gitUrlParsed.resource}/${gitUrlParsed.full_name}/${
environment.deployType === 'branch'
? `tree/${environment.name}`
: `pull/${environment.name.replace(/pr-/i, '')}`
}`
: '';

const environmentDetailItems = [
{
children: environment.environmentType,
Expand All @@ -57,15 +79,28 @@ export default function EnvironmentPage({
label: 'Deployment Type',
},
{
children: environment.created,
children: dayjs.utc(environment.created).local().format('YYYY-MM-DD HH:mm:ss Z'),
key: 'created',
label: 'Created',
},
{
children: environment.updated,
children: dayjs.utc(environment.updated).local().format('YYYY-MM-DD HH:mm:ss Z'),
key: 'updated',
label: 'Updated',
},
...(gitBranchLink
? [
{
children: (
<StyledGitLink className="hover-state" data-cy="source" target="_blank" href={`https://${gitBranchLink}`}>
{gitBranchLink}
</StyledGitLink>
),
key: 'source',
label: 'Source',
},
]
: []),
];

const routes = createLinks(environment.routes);
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3413,7 +3413,7 @@

"@uselagoon/ui-library@github:uselagoon/ui-library":
version "1.1.2"
resolved "https://codeload.github.com/uselagoon/ui-library/tar.gz/3863033db65385fddde41340289eb3745f1fe0d8"
resolved "https://codeload.github.com/uselagoon/ui-library/tar.gz/72583bb218482840428e9b17d23690c0b8861e8a"
dependencies:
dayjs "^1.11.13"
react-highlight-words "^0.20.0"
Expand Down

0 comments on commit fb0694d

Please sign in to comment.