Skip to content

Commit

Permalink
Use in Controller - update to external links
Browse files Browse the repository at this point in the history
  • Loading branch information
himdel committed Apr 14, 2024
1 parent 8cb2cc7 commit 3d7c993
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 21 deletions.
17 changes: 11 additions & 6 deletions src/containers/execution-environment-detail/base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
type AlertType,
DeleteExecutionEnvironmentModal,
ExecutionEnvironmentHeader,
ExternalLink,
LoadingPage,
Main,
RepositoryForm,
Expand All @@ -26,6 +27,7 @@ import {
RepoSigningUtils,
type RouteProps,
canSignEE,
controllerURL,
taskAlert,
waitForTask,
} from 'src/utilities';
Expand Down Expand Up @@ -122,12 +124,15 @@ export function withContainerRepo(WrappedComponent) {
),
<DropdownItem
key='use-in-controller'
onClick={() => {
// TODO image: this.state.repo.name,
}}
>
{t`Use in Controller`}
</DropdownItem>,
component={
<ExternalLink
href={controllerURL({ image: this.state.repo.name })}
variant='menu'
>
{t`Use in Controller`}
</ExternalLink>
}
/>,
hasPermission('container.delete_containerrepository') && (
<DropdownItem
key='delete'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
DeleteModal,
EmptyStateFilter,
EmptyStateNoData,
ExternalLink,
HubPagination,
LabelGroup,
ListItemActions,
Expand All @@ -37,6 +38,7 @@ import { AppContext, type IAppContextType } from 'src/loaders/app-context';
import { Paths, formatEEPath } from 'src/paths';
import {
ParamHelper,
controllerURL,
errorMessage,
filterIsSet,
getContainersURL,
Expand Down Expand Up @@ -379,14 +381,19 @@ class ExecutionEnvironmentDetailImages extends Component<
),
<DropdownItem
key='use-in-controller'
onClick={() => {
// TODO digest: image.digest,
// image: this.props.containerRepository.name,
// tag: image.tags[0],
}}
>
{t`Use in Controller`}
</DropdownItem>,
component={
<ExternalLink
href={controllerURL({
digest: image.digest,
image: this.props.containerRepository.name,
tag: image.tags[0],
})}
variant='menu'
>
{t`Use in Controller`}
</ExternalLink>
}
/>,
hasPermission('container.delete_containerrepository') && (
<DropdownItem
key='delete-image'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import { Paths, formatEEPath } from 'src/paths';
import {
ParamHelper,
type RouteProps,
controllerURL,
filterIsSet,
taskAlert,
withRouter,
Expand Down Expand Up @@ -366,12 +367,15 @@ class ExecutionEnvironmentList extends Component<RouteProps, IState> {
),
<DropdownItem
key='use-in-controller'
onClick={() => {
// TODO image: item.name,
}}
>
{t`Use in Controller`}
</DropdownItem>,
component={
<ExternalLink
href={controllerURL({ image: item.name })}
variant='menu'
>
{t`Use in Controller`}
</ExternalLink>
}
/>,
hasPermission('container.delete_containerrepository') && (
<DropdownItem
key='delete'
Expand Down
26 changes: 26 additions & 0 deletions src/utilities/get-repo-url.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,29 @@ export function getContainersURL({
digest && !tag ? `@${digest}` : ''
}`;
}

// returns controller UI URL for the EE add form, prefilling a chosen image from hub
export function controllerURL({
image,
tag,
digest,
}: {
image: string;
tag?: string;
digest?: string;
}) {
if (!digest && !tag) {
tag = 'latest';
}

const imageUrl = encodeURIComponent(
getContainersURL({
name: image,
tag,
digest,
}),
);

// TODO update to 2.5 link
return `${window.location.origin}/#/execution_environments/add?image=${imageUrl}`;
}
2 changes: 1 addition & 1 deletion src/utilities/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export { DeleteCollectionUtils } from './delete-collection';
export { downloadString } from './download-data';
export { errorMessage, handleHttpError } from './fail-alerts';
export { filterIsSet } from './filter-is-set';
export { getContainersURL, getRepoURL } from './get-repo-url';
export { controllerURL, getContainersURL, getRepoURL } from './get-repo-url';
export { getHumanSize } from './get_human_size';
export { hasPermission } from './has-permission';
export { lastSyncStatus, lastSynced } from './last-sync-task';
Expand Down

0 comments on commit 3d7c993

Please sign in to comment.