Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adding namespace to badges url with "Applications in any namespace" (#15655) #15771

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}`
}
Comment on lines +23 to +25
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this check is not necessary; you can pass the namespace parameter regardless of whether apps-in-any-namespace is enabled. However, passing a namespace other than the installation namespace to an Argo CD that does not have apps-in-any-namespace enabled, will result in an error.

entityURL = `${root}applications/${app}`;
alt = 'App Status';
} else if (project) {
Expand Down
Loading