Skip to content

Commit

Permalink
Fix getRepoUrl so that it takes a parameter and returns the correct u…
Browse files Browse the repository at this point in the history
…rl. (ansible#3691)

* Fix getRepoUrl so that it takes a parameter and returns the correct url.
* Real equality.
* Fix trailing backslash.

No-Issue

Signed-off-by: James Tanner <tanner.jc@gmail.com>
  • Loading branch information
jctanner authored May 5, 2023
1 parent 0a303b3 commit 5d7c183
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/actions/ansible-repository-copy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const ansibleRepositoryCopyAction = Action({
`server_list = ${item.name}_repo`,
'',
`[galaxy_server.${item.name}_repo]`,
`url=${getRepoUrl()}`,
`url=${getRepoUrl(item.name)}`,
'token=<put your token here>',
].join('\n');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const CollectionDistributions = (props: RouteProps) => {
`server_list = ${distribution.base_path}`,
'',
`[galaxy_server.${distribution.base_path}]`,
`url=${getRepoUrl()}`,
`url=${getRepoUrl(distribution.base_path)}`,
'token=<put your token here>',
].join('\n');

Expand Down
2 changes: 1 addition & 1 deletion src/containers/namespace-detail/namespace-detail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ export class NamespaceDetail extends React.Component<RouteProps, IState> {
: null,
].filter(Boolean);

const repositoryUrl = getRepoUrl();
const repositoryUrl = getRepoUrl('published');

const noData =
itemCount === 0 &&
Expand Down
2 changes: 1 addition & 1 deletion src/containers/token/token-insights.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class TokenInsights extends React.Component<RouteProps, IState> {
download content from Automation Hub.
</Trans>
</p>
<ClipboardCopy isReadOnly>{getRepoUrl()}</ClipboardCopy>
<ClipboardCopy isReadOnly>{getRepoUrl('published')}</ClipboardCopy>
</section>
<section className='body pf-c-content'>
<h2>{t`SSO URL`}</h2>
Expand Down
7 changes: 5 additions & 2 deletions src/utilities/get-repo-url.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Returns the API path for a specific repository
export function getRepoUrl() {
export function getRepoUrl(reponame) {
// If the api is hosted on another URL, use API_HOST as the host part of the URL.
// Otherwise use the host that the UI is served from
const host = API_HOST ? API_HOST : window.location.origin;

return `${host}${API_BASE_PATH}`;
if (reponame === 'published') {
return `${host}${API_BASE_PATH}`;
}
return `${host}${API_BASE_PATH}content/${reponame}/`;
}

// returns the server name for (protocol-less) container urls
Expand Down

0 comments on commit 5d7c183

Please sign in to comment.