Skip to content

Commit

Permalink
Set default availability mode to ALL
Browse files Browse the repository at this point in the history
Rather than letting the default mode be UNSPECIFIED, this sets the
default mode to "ALL".
Note: this does not mean that a user can see all by default. It only
reflects the "Availability filter" selection. If a cluster has
showResources set to "accessible_only", the filter will reflect that
value instead
  • Loading branch information
avatus committed May 30, 2024
1 parent 79d2a27 commit 5a4fccd
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 15 deletions.
7 changes: 4 additions & 3 deletions lib/auth/userpreferences/userpreferencesv1/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,10 @@ func TestService_GetUserPreferences(t *testing.T) {
},
Theme: userpreferencesv1.Theme_THEME_UNSPECIFIED,
UnifiedResourcePreferences: &userpreferencesv1.UnifiedResourcePreferences{
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_ALL,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_CARD,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_ALL,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_CARD,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
AvailableResourceMode: userpreferencesv1.AvailableResourceMode_AVAILABLE_RESOURCE_MODE_ALL,
},
Onboard: &userpreferencesv1.OnboardUserPreferences{
PreferredResources: []userpreferencesv1.Resource{},
Expand Down
7 changes: 4 additions & 3 deletions lib/services/local/userpreferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ func DefaultUserPreferences() *userpreferencesv1.UserPreferences {
},
Theme: userpreferencesv1.Theme_THEME_UNSPECIFIED,
UnifiedResourcePreferences: &userpreferencesv1.UnifiedResourcePreferences{
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_ALL,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_CARD,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_ALL,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_CARD,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
AvailableResourceMode: userpreferencesv1.AvailableResourceMode_AVAILABLE_RESOURCE_MODE_ALL,
},
Onboard: &userpreferencesv1.OnboardUserPreferences{
PreferredResources: []userpreferencesv1.Resource{},
Expand Down
43 changes: 34 additions & 9 deletions lib/services/local/userpreferences_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,28 @@ func TestUserPreferencesCRUD(t *testing.T) {
ClusterPreferences: defaultPref.ClusterPreferences,
},
},
{
name: "update the availability view only",
req: &userpreferencesv1.UpsertUserPreferencesRequest{
Preferences: &userpreferencesv1.UserPreferences{
UnifiedResourcePreferences: &userpreferencesv1.UnifiedResourcePreferences{
AvailableResourceMode: userpreferencesv1.AvailableResourceMode_AVAILABLE_RESOURCE_MODE_ACCESSIBLE,
},
},
},
expected: &userpreferencesv1.UserPreferences{
Assist: defaultPref.Assist,
Onboard: defaultPref.Onboard,
Theme: defaultPref.Theme,
UnifiedResourcePreferences: &userpreferencesv1.UnifiedResourcePreferences{
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_ALL,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_CARD,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
AvailableResourceMode: userpreferencesv1.AvailableResourceMode_AVAILABLE_RESOURCE_MODE_ACCESSIBLE,
},
ClusterPreferences: defaultPref.ClusterPreferences,
},
},
{
name: "update the unified tab preference only",
req: &userpreferencesv1.UpsertUserPreferencesRequest{
Expand All @@ -122,9 +144,10 @@ func TestUserPreferencesCRUD(t *testing.T) {
Onboard: defaultPref.Onboard,
Theme: defaultPref.Theme,
UnifiedResourcePreferences: &userpreferencesv1.UnifiedResourcePreferences{
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_PINNED,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_CARD,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_PINNED,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_CARD,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
AvailableResourceMode: userpreferencesv1.AvailableResourceMode_AVAILABLE_RESOURCE_MODE_ALL,
},
ClusterPreferences: defaultPref.ClusterPreferences,
},
Expand Down Expand Up @@ -233,9 +256,10 @@ func TestUserPreferencesCRUD(t *testing.T) {
Preferences: &userpreferencesv1.UserPreferences{
Theme: userpreferencesv1.Theme_THEME_LIGHT,
UnifiedResourcePreferences: &userpreferencesv1.UnifiedResourcePreferences{
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_PINNED,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_LIST,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_PINNED,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_LIST,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
AvailableResourceMode: userpreferencesv1.AvailableResourceMode_AVAILABLE_RESOURCE_MODE_ALL,
},
Assist: &userpreferencesv1.AssistUserPreferences{
PreferredLogins: []string{"baz"},
Expand All @@ -260,9 +284,10 @@ func TestUserPreferencesCRUD(t *testing.T) {
expected: &userpreferencesv1.UserPreferences{
Theme: userpreferencesv1.Theme_THEME_LIGHT,
UnifiedResourcePreferences: &userpreferencesv1.UnifiedResourcePreferences{
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_PINNED,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_LIST,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
DefaultTab: userpreferencesv1.DefaultTab_DEFAULT_TAB_PINNED,
ViewMode: userpreferencesv1.ViewMode_VIEW_MODE_LIST,
LabelsViewMode: userpreferencesv1.LabelsViewMode_LABELS_VIEW_MODE_COLLAPSED,
AvailableResourceMode: userpreferencesv1.AvailableResourceMode_AVAILABLE_RESOURCE_MODE_ALL,
},
Assist: &userpreferencesv1.AssistUserPreferences{
PreferredLogins: []string{"baz"},
Expand Down

0 comments on commit 5a4fccd

Please sign in to comment.