Skip to content

Commit

Permalink
adding namespace to badges url
Browse files Browse the repository at this point in the history
  • Loading branch information
Nandini Singh committed Oct 2, 2023
1 parent a1c9d6b commit 8ca6995
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
RevisionHelpIcon
} from '../../../shared/components';
import {BadgePanel, Spinner} from '../../../shared/components';
import {Consumer, ContextApis} from '../../../shared/context';
import {AuthSettingsCtx, Consumer, ContextApis} from '../../../shared/context';
import * as models from '../../../shared/models';
import {services} from '../../../shared/services';

Expand Down Expand Up @@ -49,6 +49,7 @@ export const ApplicationSummary = (props: ApplicationSummaryProps) => {
const initialState = app.spec.destination.server === undefined ? 'NAME' : 'URL';
const [destFormat, setDestFormat] = React.useState(initialState);
const [changeSync, setChangeSync] = React.useState(false);
const useAuthSettingsCtx = React.useContext(AuthSettingsCtx);

const notificationSubscriptions = useEditNotificationSubscriptions(app.metadata.annotations || {});
const updateApp = notificationSubscriptions.withNotificationSubscriptions(props.updateApp);
Expand Down Expand Up @@ -590,6 +591,8 @@ export const ApplicationSummary = (props: ApplicationSummaryProps) => {
)}
</Consumer>
<BadgePanel app={props.app.metadata.name} />
<BadgePanel appNamespace={props.app.metadata.namespace} />
<BadgePanel nsEnabled={useAuthSettingsCtx?.appsInAnyNamespaceEnabled} />
<EditablePanel
save={updateApp}
values={app}
Expand Down
5 changes: 4 additions & 1 deletion ui/src/app/shared/components/badge-panel/badge-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Context} from '../../context';

require('./badge-panel.scss');

export const BadgePanel = ({app, project}: {app?: string; project?: string}) => {
export const BadgePanel = ({app, project, appNamespace, nsEnabled}: {app?: string; project?: string, appNamespace?: string; nsEnabled?: boolean}) => {
const [badgeType, setBadgeType] = React.useState('URL');
const context = React.useContext(Context);
if (!app && !project) {
Expand All @@ -20,6 +20,9 @@ export const BadgePanel = ({app, project}: {app?: string; project?: string}) =>
let alt = '';
if (app) {
badgeURL = `${root}api/badge?name=${app}&revision=true`;
if (nsEnabled) {
badgeURL += `&namespace=${appNamespace}`
}
entityURL = `${root}applications/${app}`;
alt = 'App Status';
} else if (project) {
Expand Down

0 comments on commit 8ca6995

Please sign in to comment.