mirror of https://github.com/portainer/portainer
fix(gitops): correct commit hash link [EE-6346] (#10800)
parent
9978b88ed4
commit
0e59cf76ec
|
@ -9,6 +9,7 @@ import UpToDate from '@/assets/ico/icon_up-to-date.svg?c';
|
|||
import { isoDateFromTimestamp } from '@/portainer/filters/filters';
|
||||
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
|
||||
import { getDashboardRoute } from '@/react/portainer/environments/utils';
|
||||
import { cleanGitRepoUrl } from '@/react/portainer/gitops/utils';
|
||||
|
||||
import { Button } from '@@/buttons';
|
||||
import { Icon } from '@@/Icon';
|
||||
|
@ -187,7 +188,9 @@ function TargetVersionCell({
|
|||
{row.original.TargetCommitHash ? (
|
||||
<div>
|
||||
<a
|
||||
href={`${row.original.GitConfigURL}/commit/${row.original.TargetCommitHash}`}
|
||||
href={`${cleanGitRepoUrl(row.original.GitConfigURL)}/commit/${
|
||||
row.original.TargetCommitHash
|
||||
}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
@ -236,7 +239,9 @@ function DeployedVersionCell({
|
|||
<div>
|
||||
{statusIcon}
|
||||
<a
|
||||
href={`${row.original.GitConfigURL}/commit/${row.original.TargetCommitHash}`}
|
||||
href={`${cleanGitRepoUrl(row.original.GitConfigURL)}/commit/${
|
||||
row.original.TargetCommitHash
|
||||
}`}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
>
|
||||
|
|
|
@ -3,6 +3,7 @@ import _ from 'lodash';
|
|||
|
||||
import { isoDateFromTimestamp } from '@/portainer/filters/filters';
|
||||
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
|
||||
import { cleanGitRepoUrl } from '@/react/portainer/gitops/utils';
|
||||
|
||||
import { buildNameColumn } from '@@/datatables/NameCell';
|
||||
import { Link } from '@@/Link';
|
||||
|
@ -151,7 +152,9 @@ export const columns = _.compact([
|
|||
<div className="text-center">
|
||||
<a
|
||||
target="_blank"
|
||||
href={`${item.GitConfig.URL}/commit/${item.GitConfig.ConfigHash}`}
|
||||
href={`${cleanGitRepoUrl(item.GitConfig.URL)}/commit/${
|
||||
item.GitConfig.ConfigHash
|
||||
}`}
|
||||
rel="noreferrer"
|
||||
>
|
||||
{item.GitConfig.ConfigHash.slice(0, 7)}
|
||||
|
|
|
@ -32,3 +32,10 @@ export function confirmEnableTLSVerify() {
|
|||
'Enabling the verification of TLS certificates without ensuring the correct configuration of your Certificate Authority (CA) for self-signed certificates can result in deployment failures.',
|
||||
});
|
||||
}
|
||||
|
||||
export function cleanGitRepoUrl(url: string) {
|
||||
return url
|
||||
.trim() // remove leading and trailing whitespace
|
||||
.replace(/\/$/, '') // if there's a trailing slash, remove it
|
||||
.replace(/\.git$/, ''); // if there's a trailing .git extension, remove it
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue