Fix 'Open application' link when using basehref (#2729)

This commit is contained in:
Christine Banek 2019-12-03 11:26:37 -07:00 committed by Alex Collins
parent 3258f2deee
commit 0715d05733
3 changed files with 11 additions and 5 deletions

View file

@ -156,7 +156,7 @@ export class App extends React.Component<{}, {popupProps: PopupProps; error: Err
<link rel='icon' type='image/png' href={`${base}assets/favicon/favicon-16x16.png`} sizes='16x16' />
</Helmet>
<PageContext.Provider value={{title: 'Argo CD'}}>
<Provider value={{history, popup: this.popupManager, notifications: this.notificationsManager, navigation: this.navigationManager}}>
<Provider value={{history, popup: this.popupManager, notifications: this.notificationsManager, navigation: this.navigationManager, baseHref: base}}>
{this.state.popupProps && <Popup {...this.state.popupProps} />}
<Router history={history}>
<Switch>

View file

@ -6,6 +6,7 @@ import * as React from 'react';
import * as models from '../../../shared/models';
import {EmptyState} from '../../../shared/components';
import {Consumer} from '../../../shared/context';
import {ApplicationURLs} from '../application-urls';
import {ResourceIcon} from '../resource-icon';
import {ComparisonStatusIcon, getAppOverridesCount, HealthStatusIcon, isAppNode, NodeId, nodeKey} from '../utils';
@ -214,9 +215,13 @@ function renderResourceNode(props: ApplicationResourceTreeProps, id: string, nod
{healthState != null && <HealthStatusIcon state={healthState} />}
{comparisonStatus != null && <ComparisonStatusIcon status={comparisonStatus} resource={!rootNode && node} />}
{appNode && !rootNode && (
<a href={'/applications/' + node.name} title='Open application'>
<i className='fa fa-external-link-alt' />
</a>
<Consumer>
{ctx => (
<a href={ctx.baseHref + 'applications/' + node.name} title='Open application'>
<i className='fa fa-external-link-alt' />
</a>
)}
</Consumer>
)}
<ApplicationURLs urls={rootNode ? props.app.status.summary.externalURLs : node.networkingInfo && node.networkingInfo.externalURLs} />
</div>

View file

@ -2,12 +2,13 @@ import {AppContext as ArgoAppContext, NavigationApi, NotificationsApi, PopupApi}
import {History} from 'history';
import * as React from 'react';
export type AppContext = ArgoAppContext & {apis: {popup: PopupApi; notifications: NotificationsApi; navigation: NavigationApi}};
export type AppContext = ArgoAppContext & {apis: {popup: PopupApi; notifications: NotificationsApi; navigation: NavigationApi; baseHref: string}};
export interface ContextApis {
popup: PopupApi;
notifications: NotificationsApi;
navigation: NavigationApi;
baseHref: string;
}
export const {Provider, Consumer} = React.createContext<ContextApis & {history: History}>(null);