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

feat(UI): allow applications to declare default view preferences (#12019) #12080

Merged
merged 2 commits into from
Jan 23, 2023
Merged
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 @@ -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