Skip to content

Commit

Permalink
feat: link path directly to the path in repo (argoproj#10568) (argopr…
Browse files Browse the repository at this point in the history
…oj#10860)

* Wrap error objects to include context

Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

* Revert "Wrap error objects to include context"

This reverts commit d1789bd.

Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

* In Application Details, link the path field directly to the path in the repo

Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

* fix: duplicate source namespace validation (argoproj#10853)

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

* docs: fix examples for ArgoCD ApplicationSet Git Generator (argoproj#10857)

* Doc: ArgoCD ApplicationSet Git directory

Signed-off-by: toyamagu <toyamagu2021@gmail.com>

* Docs: use "my-project" rather than default project

Signed-off-by: toyamagu <toyamagu2021@gmail.com>

Signed-off-by: toyamagu <toyamagu2021@gmail.com>
Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

* Change 'branch' to 'src'

Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

* Fix CR

Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

* Fix CR

Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

* renaming

Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

* Add comment

Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>

Signed-off-by: Nir Shtein <89006520+nirsht@users.noreply.github.com>
Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Signed-off-by: toyamagu <toyamagu2021@gmail.com>
Co-authored-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
Co-authored-by: toyamagu <83329336+toyamagu-2021@users.noreply.github.com>
Signed-off-by: Nicholas Johnson <nbjohnson10@gmail.com>
  • Loading branch information
3 people authored and nbjohnson committed Oct 18, 2022
1 parent b61c721 commit 6b8986e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,11 @@ export const ApplicationSummary = (props: ApplicationSummaryProps) => {
},
{
title: 'PATH',
view: app.spec.source.path,
view: (
<Revision repoUrl={app.spec.source.repoURL} revision={app.spec.source.targetRevision || 'HEAD'} path={app.spec.source.path}>
{app.spec.source.path}
</Revision>
),
edit: (formApi: FormApi) => <FormField formApi={formApi} field='spec.source.path' component={Text} />
}
]),
Expand Down
8 changes: 6 additions & 2 deletions ui/src/app/shared/components/revision.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import * as React from 'react';
import {revisionUrl} from './urls';

export const Revision = ({repoUrl, revision, children}: {repoUrl: string; revision: string; children?: React.ReactNode}) => {
export const Revision = ({repoUrl, revision, path, children}: {repoUrl: string; revision: string; path?: string; children?: React.ReactNode}) => {
revision = revision || '';
const url = revisionUrl(repoUrl, revision);
const hasPath = path && path !== '.';
let url = revisionUrl(repoUrl, revision, hasPath);
if (hasPath) {
url += '/' + path;
}
const content = children || (isSHA(revision) ? revision.substr(0, 7) : revision);
return url !== null ? (
<a href={url} target='_blank' rel='noopener noreferrer'>
Expand Down
5 changes: 3 additions & 2 deletions ui/src/app/shared/components/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@ export function repoUrl(url: string): string {
}
}

export function revisionUrl(url: string, revision: string): string {
export function revisionUrl(url: string, revision: string, forPath: boolean): string {
const parsed = GitUrlParse(url);
let urlSubPath = isSHA(revision) ? 'commit' : 'tree';

if (url.indexOf('bitbucket') >= 0) {
urlSubPath = isSHA(revision) ? 'commits' : 'src';
// The reason for the condition of 'forPath' is that when we build nested path, we need to use 'src'
urlSubPath = isSHA(revision) && !forPath ? 'commits' : 'src';
}

if (!supportedSource(parsed)) {
Expand Down

0 comments on commit 6b8986e

Please sign in to comment.