Revert "fix(gitops): clean trailing slash [EE-6346] (#10778)" (#10781)

This reverts commit e78519f492.
pull/10788/head
Ali 2023-12-07 16:33:00 +13:00 committed by GitHub
parent ee6c3f958f
commit 03a4f1227e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 18 deletions

View File

@ -9,13 +9,13 @@ import UpToDate from '@/assets/ico/icon_up-to-date.svg?c';
import { isoDateFromTimestamp } from '@/portainer/filters/filters'; import { isoDateFromTimestamp } from '@/portainer/filters/filters';
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service'; import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
import { getDashboardRoute } from '@/react/portainer/environments/utils'; import { getDashboardRoute } from '@/react/portainer/environments/utils';
import { cleanGitRepoUrl } from '@/react/portainer/gitops/utils';
import { Button } from '@@/buttons'; import { Button } from '@@/buttons';
import { Icon } from '@@/Icon'; import { Icon } from '@@/Icon';
import { Link } from '@@/Link'; import { Link } from '@@/Link';
import { DeploymentStatus, EdgeStackStatus, StatusType } from '../../types'; import { DeploymentStatus, EdgeStackStatus, StatusType } from '../../types';
import { removeTrailingGitExtension } from '../../utils';
import { EnvironmentActions } from './EnvironmentActions'; import { EnvironmentActions } from './EnvironmentActions';
import { ActionStatus } from './ActionStatus'; import { ActionStatus } from './ActionStatus';
@ -188,9 +188,9 @@ function TargetVersionCell({
{row.original.TargetCommitHash ? ( {row.original.TargetCommitHash ? (
<div> <div>
<a <a
href={`${cleanGitRepoUrl(row.original.GitConfigURL)}/commit/${ href={`${removeTrailingGitExtension(
row.original.TargetCommitHash row.original.GitConfigURL
}`} )}/commit/${row.original.TargetCommitHash}`}
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
> >
@ -239,9 +239,9 @@ function DeployedVersionCell({
<div> <div>
{statusIcon} {statusIcon}
<a <a
href={`${cleanGitRepoUrl(row.original.GitConfigURL)}/commit/${ href={`${removeTrailingGitExtension(
row.original.TargetCommitHash row.original.GitConfigURL
}`} )}/commit/${row.original.TargetCommitHash}`}
target="_blank" target="_blank"
rel="noreferrer" rel="noreferrer"
> >

View File

@ -3,12 +3,12 @@ import _ from 'lodash';
import { isoDateFromTimestamp } from '@/portainer/filters/filters'; import { isoDateFromTimestamp } from '@/portainer/filters/filters';
import { isBE } from '@/react/portainer/feature-flags/feature-flags.service'; import { isBE } from '@/react/portainer/feature-flags/feature-flags.service';
import { cleanGitRepoUrl } from '@/react/portainer/gitops/utils';
import { buildNameColumn } from '@@/datatables/NameCell'; import { buildNameColumn } from '@@/datatables/NameCell';
import { Link } from '@@/Link'; import { Link } from '@@/Link';
import { StatusType } from '../../types'; import { StatusType } from '../../types';
import { removeTrailingGitExtension } from '../../utils';
import { EdgeStackStatus } from './EdgeStacksStatus'; import { EdgeStackStatus } from './EdgeStacksStatus';
import { DecoratedEdgeStack } from './types'; import { DecoratedEdgeStack } from './types';
@ -152,9 +152,9 @@ export const columns = _.compact([
<div className="text-center"> <div className="text-center">
<a <a
target="_blank" target="_blank"
href={`${cleanGitRepoUrl(item.GitConfig.URL)}/commit/${ href={`${removeTrailingGitExtension(
item.GitConfig.ConfigHash item.GitConfig.URL
}`} )}/commit/${item.GitConfig.ConfigHash}`}
rel="noreferrer" rel="noreferrer"
> >
{item.GitConfig.ConfigHash.slice(0, 7)} {item.GitConfig.ConfigHash.slice(0, 7)}

View File

@ -19,3 +19,8 @@ export function getValidEditorTypes(
? _.intersection(...endpointTypes.map((type) => right[type])) ? _.intersection(...endpointTypes.map((type) => right[type]))
: [EditorType.Compose, EditorType.Kubernetes]; : [EditorType.Compose, EditorType.Kubernetes];
} }
export function removeTrailingGitExtension(url: string) {
// the url could have the .git extension. Remove it if it does.
return url.replace(/\.git$/, '');
}

View File

@ -32,10 +32,3 @@ 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.', '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
}