Skip to content

Commit

Permalink
feat(UI): allow applications to declare default view preferences (arg…
Browse files Browse the repository at this point in the history
…oproj#12019) (argoproj#12080)

Signed-off-by: Alex Eftimie <alex.eftimie@getyourguide.com>
Co-authored-by: Remington Breeze <remington@breeze.software>
Signed-off-by: emirot <emirot.nolan@gmail.com>
  • Loading branch information
2 people authored and emirot committed Jan 27, 2023
1 parent c02204b commit 9afb524
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {AppDetailsPreferences, AppsDetailsViewKey, AppsDetailsViewType, services
import {ApplicationConditions} from '../application-conditions/application-conditions';
import {ApplicationDeploymentHistory} from '../application-deployment-history/application-deployment-history';
import {ApplicationOperationState} from '../application-operation-state/application-operation-state';
import {PodView} from '../application-pod-view/pod-view';
import {PodGroupType, PodView} from '../application-pod-view/pod-view';
import {ApplicationResourceTree, ResourceTreeNode} from '../application-resource-tree/application-resource-tree';
import {ApplicationStatusPanel} from '../application-status-panel/application-status-panel';
import {ApplicationSyncPanel} from '../application-sync-panel/application-sync-panel';
Expand Down Expand Up @@ -169,6 +169,7 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{app
load={name =>
combineLatest([this.loadAppInfo(name, this.appNamespace), services.viewPreferences.getPreferences(), q]).pipe(
map(items => {
const application = items[0].application;
const pref = items[1].appDetails;
const params = items[2];
if (params.get('resource') != null) {
Expand All @@ -179,10 +180,27 @@ export class ApplicationDetails extends React.Component<RouteComponentProps<{app
}
if (params.get('view') != null) {
pref.view = params.get('view') as AppsDetailsViewType;
} else {
const appDefaultView = (application.metadata &&
application.metadata.annotations &&
application.metadata.annotations[appModels.AnnotationDefaultView]) as AppsDetailsViewType;
if (appDefaultView != null) {
pref.view = appDefaultView;
}
}
if (params.get('orphaned') != null) {
pref.orphanedResources = params.get('orphaned') === 'true';
}
if (params.get('podSortMode') != null) {
pref.podView.sortMode = params.get('podSortMode') as PodGroupType;
} else {
const appDefaultPodSort = (application.metadata &&
application.metadata.annotations &&
application.metadata.annotations[appModels.AnnotationDefaultPodSort]) as PodGroupType;
if (appDefaultPodSort != null) {
pref.podView.sortMode = appDefaultPodSort;
}
}
return {...items[0], pref};
})
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export class PodView extends React.Component<PodViewProps> {
</React.Fragment>
),
action: () => {
this.appContext.apis.navigation.goto('.', {podSortMode: mode});
services.viewPreferences.updatePreferences({appDetails: {...prefs.appDetails, podView: {...podPrefs, sortMode: mode}}});
}
}));
Expand Down
2 changes: 2 additions & 0 deletions ui/src/app/shared/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ export interface ResourceResult {
export const AnnotationRefreshKey = 'argocd.argoproj.io/refresh';
export const AnnotationHookKey = 'argocd.argoproj.io/hook';
export const AnnotationSyncWaveKey = 'argocd.argoproj.io/sync-wave';
export const AnnotationDefaultView = 'pref.argocd.argoproj.io/default-view';
export const AnnotationDefaultPodSort = 'pref.argocd.argoproj.io/default-pod-sort';

export interface Application {
apiVersion?: string;
Expand Down

0 comments on commit 9afb524

Please sign in to comment.