Skip to content

Commit

Permalink
Badge for apps in any namespace
Browse files Browse the repository at this point in the history
Signed-off-by: sshenoy6 <[email protected]>
  • Loading branch information
sshenoy6 committed Jan 3, 2024
1 parent 0e67ed8 commit d829aa4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 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 @@ -47,6 +47,7 @@ export const ApplicationSummary = (props: ApplicationSummaryProps) => {
const source = getAppDefaultSource(app);
const isHelm = source.hasOwnProperty('chart');
const initialState = app.spec.destination.server === undefined ? 'NAME' : 'URL';
const useAuthSettingsCtx = React.useContext(AuthSettingsCtx);
const [destFormat, setDestFormat] = React.useState(initialState);
const [changeSync, setChangeSync] = React.useState(false);

Expand Down Expand Up @@ -589,7 +590,7 @@ export const ApplicationSummary = (props: ApplicationSummaryProps) => {
</div>
)}
</Consumer>
<BadgePanel app={props.app.metadata.name} />
<BadgePanel app={props.app.metadata.name} appNamespace={props.app.metadata.namespace} 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 d829aa4

Please sign in to comment.