Skip to content

Commit

Permalink
Add option to hide pages, sections and actions (#352)
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <tamal@appscode.com>
  • Loading branch information
tamalsaha authored Dec 25, 2024
1 parent d34f47b commit facabee
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 15 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ require (
kmodules.xyz/go-containerregistry v0.0.12
kmodules.xyz/monitoring-agent-api v0.30.4
kmodules.xyz/offshoot-api v0.30.1
kmodules.xyz/resource-metadata v0.24.0
kmodules.xyz/resource-metadata v0.24.1-0.20241225081542-68efe80753bd
kmodules.xyz/resource-metrics v0.30.5
kmodules.xyz/resource-metrics/utils v0.30.4
kmodules.xyz/sets v0.29.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,8 @@ kmodules.xyz/monitoring-agent-api v0.30.4 h1:6CTKxYJKpWDsDYb0WRBHGFoW3xQof05d+W8
kmodules.xyz/monitoring-agent-api v0.30.4/go.mod h1:ZuTQ5uGi6H80QLsOTuuC7m58dfXDGUv0YB+s059gnr4=
kmodules.xyz/offshoot-api v0.30.1 h1:TrulAYO+oBsXe9sZZGTmNWIuI8qD2izMpgcTSPvgAmI=
kmodules.xyz/offshoot-api v0.30.1/go.mod h1:T3mpjR6fui0QzOcmQvIuANytW48fe9ytmy/1cgx6D4g=
kmodules.xyz/resource-metadata v0.24.0 h1:kdj7Sx67V0LIePE4BsgtAoKFsClg/L0xtiEeEqT+zx8=
kmodules.xyz/resource-metadata v0.24.0/go.mod h1:PEwsZsPeCN0a77xfZzIr+QLL4SbeOIPZ9kqBaQllZTk=
kmodules.xyz/resource-metadata v0.24.1-0.20241225081542-68efe80753bd h1:w2C5p2MzHFzFcTiJRH4p2AvLkAOwkA18ES+1SrazJoI=
kmodules.xyz/resource-metadata v0.24.1-0.20241225081542-68efe80753bd/go.mod h1:PEwsZsPeCN0a77xfZzIr+QLL4SbeOIPZ9kqBaQllZTk=
kmodules.xyz/resource-metrics v0.30.5 h1:ZhpGeR9DCz1HTrKUg/mWhr95wlFzCPRdgVAqwaggy1o=
kmodules.xyz/resource-metrics v0.30.5/go.mod h1:w9+rz7/s/kGP1GWzYSuRdCn+l7EwpesmESSEHkLBnIQ=
kmodules.xyz/resource-metrics/utils v0.30.4 h1:bJS/x0Qr7N1FFdxugFbzZ/Es6HVs4ptsFlhkmgj3jac=
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ func (a ResourceOutlineFilterSpec) GetPage(name string) ResourcePageOutlineFilte
}
return ResourcePageOutlineFilter{
Name: name,
Show: false,
Sections: nil,
}
}
Expand All @@ -36,6 +37,7 @@ func (a ResourceOutlineFilterSpec) GetAction(name string) ActionTemplateGroupFil
}
return ActionTemplateGroupFilter{
Name: name,
Show: false,
Items: nil,
}
}
Expand All @@ -48,6 +50,7 @@ func (a ResourcePageOutlineFilter) GetSection(name string) SectionOutlineFilter
}
return SectionOutlineFilter{
Name: name,
Show: false,
Blocks: nil,
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,18 @@ type ResourceOutlineFilterSpec struct {
type ResourcePageOutlineFilter struct {
Name string `json:"name"`
Sections []SectionOutlineFilter `json:"sections,omitempty"`
Show bool `json:"show"`
}

type ActionTemplateGroupFilter struct {
Name string `json:"name,omitempty"`
Items map[string]bool `json:"items"`
Name string `json:"name"`
Items map[string]bool `json:"items,omitempty"`
Show bool `json:"show"`
}

type SectionOutlineFilter struct {
Name string `json:"name,omitempty"`
Show bool `json:"show"`
Info bool `json:"info"`
Insight bool `json:"insight"`
Blocks map[string]bool `json:"blocks,omitempty"`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ spec:
type: object
name:
type: string
show:
type: boolean
required:
- items
- name
- show
type: object
type: array
header:
Expand All @@ -65,13 +68,19 @@ spec:
type: boolean
name:
type: string
show:
type: boolean
required:
- info
- insight
- show
type: object
type: array
show:
type: boolean
required:
- name
- show
type: object
type: array
resource:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ spec:
type: object
name:
type: string
show:
type: boolean
required:
- items
- name
- show
type: object
type: array
header:
Expand All @@ -65,13 +68,19 @@ spec:
type: boolean
name:
type: string
show:
type: boolean
required:
- info
- insight
- show
type: object
type: array
show:
type: boolean
required:
- name
- show
type: object
type: array
resource:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ spec:
type: object
name:
type: string
show:
type: boolean
required:
- items
- name
- show
type: object
type: array
header:
Expand All @@ -88,13 +91,19 @@ spec:
type: boolean
name:
type: string
show:
type: boolean
required:
- info
- insight
- show
type: object
type: array
show:
type: boolean
required:
- name
- show
type: object
type: array
resource:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,11 @@ spec:
type: object
name:
type: string
show:
type: boolean
required:
- items
- name
- show
type: object
type: array
header:
Expand All @@ -88,13 +91,19 @@ spec:
type: boolean
name:
type: string
show:
type: boolean
required:
- info
- insight
- show
type: object
type: array
show:
type: boolean
required:
- name
- show
type: object
type: array
resource:
Expand Down
3 changes: 3 additions & 0 deletions vendor/kmodules.xyz/resource-metadata/pkg/layouts/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func GetDefaultResourceOutlineFilter(kc client.Client, outline *rsapi.ResourceOu
for _, ag := range ed.Spec.UI.Actions {
ag2 := uiapi.ActionTemplateGroupFilter{
Name: ag.Name,
Show: true,
Items: make(map[string]bool, len(ag.Items)),
}
for _, a := range ag.Items {
Expand Down Expand Up @@ -95,12 +96,14 @@ func GetDefaultResourceOutlineFilter(kc client.Client, outline *rsapi.ResourceOu
for _, pageOutline := range pages {
page := uiapi.ResourcePageOutlineFilter{
Name: pageOutline.Name,
Show: true,
Sections: make([]uiapi.SectionOutlineFilter, 0, len(pageOutline.Sections)),
}
for _, sectionOutline := range pageOutline.Sections {

section := uiapi.SectionOutlineFilter{
Name: sectionOutline.Name,
Show: true,
Info: sectionOutline.Info != nil,
Insight: sectionOutline.Insight != nil,
}
Expand Down
9 changes: 9 additions & 0 deletions vendor/kmodules.xyz/resource-metadata/pkg/layouts/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ func GetResourceLayout(kc client.Client, outline *rsapi.ResourceOutline) (*rsapi
result.Spec.UI.Actions = make([]*shared.ActionTemplateGroup, 0, len(ed.Spec.UI.Actions))
for _, ag := range ed.Spec.UI.Actions {
agFilter := filter.Spec.GetAction(ag.Name)
if !agFilter.Show {
continue
}
ag2 := shared.ActionTemplateGroup{
ActionInfo: ag.ActionInfo,
Items: make([]shared.ActionTemplate, 0, len(ag.Items)),
Expand Down Expand Up @@ -280,13 +283,19 @@ func GetResourceLayout(kc client.Client, outline *rsapi.ResourceOutline) (*rsapi

for _, pageOutline := range pages {
pageFilter := filter.Spec.GetPage(pageOutline.Name)
if !pageFilter.Show {
continue
}
page := rsapi.ResourcePageLayout{
Name: pageOutline.Name,
RequiredFeatureSets: pageOutline.RequiredFeatureSets,
Sections: make([]rsapi.SectionLayout, 0, len(pageOutline.Sections)),
}
for _, sectionOutline := range pageOutline.Sections {
sectionFilter := pageFilter.GetSection(sectionOutline.Name)
if !sectionFilter.Show {
continue
}

section := rsapi.SectionLayout{
Name: sectionOutline.Name,
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,7 @@ kmodules.xyz/monitoring-agent-api/client
kmodules.xyz/offshoot-api/api/v1
kmodules.xyz/offshoot-api/api/v2
kmodules.xyz/offshoot-api/util
# kmodules.xyz/resource-metadata v0.24.0
# kmodules.xyz/resource-metadata v0.24.1-0.20241225081542-68efe80753bd
## explicit; go 1.22.1
kmodules.xyz/resource-metadata/apis/core/install
kmodules.xyz/resource-metadata/apis/core/v1alpha1
Expand Down

0 comments on commit facabee

Please sign in to comment.