From 00d0e55fe72ff314350b832f9ae94876cc0156f7 Mon Sep 17 00:00:00 2001 From: Arnob kumar saha Date: Wed, 8 Jan 2025 17:33:20 +0600 Subject: [PATCH] Add filter map in info Signed-off-by: Arnob kumar saha --- apis/meta/v1alpha1/openapi_generated.go | 15 ++++++++++++++ apis/meta/v1alpha1/resourcelayout_types.go | 1 + apis/meta/v1alpha1/zz_generated.deepcopy.go | 7 +++++++ ...meta.k8s.appscode.com_resourcelayouts.yaml | 20 +++++++++++++++++++ pkg/layouts/lib.go | 12 +++++++++++ 5 files changed, 55 insertions(+) diff --git a/apis/meta/v1alpha1/openapi_generated.go b/apis/meta/v1alpha1/openapi_generated.go index 6a78d1a34..eceec3ec3 100644 --- a/apis/meta/v1alpha1/openapi_generated.go +++ b/apis/meta/v1alpha1/openapi_generated.go @@ -20506,6 +20506,21 @@ func schema_resource_metadata_apis_meta_v1alpha1_PageBlockLayout(ref common.Refe }, }, }, + "filter": { + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: false, + Type: []string{"boolean"}, + Format: "", + }, + }, + }, + }, + }, }, Required: []string{"kind", "ref", "query"}, }, diff --git a/apis/meta/v1alpha1/resourcelayout_types.go b/apis/meta/v1alpha1/resourcelayout_types.go index de6b631a4..89f9ed1f1 100644 --- a/apis/meta/v1alpha1/resourcelayout_types.go +++ b/apis/meta/v1alpha1/resourcelayout_types.go @@ -84,6 +84,7 @@ type PageBlockLayout struct { View *PageBlockTableDefinition `json:"view,omitempty"` RequiredFeatureSets map[string]FeatureList `json:"requiredFeatureSets,omitempty"` + Filter map[string]bool `json:"filter,omitempty"` } type FeatureList []string diff --git a/apis/meta/v1alpha1/zz_generated.deepcopy.go b/apis/meta/v1alpha1/zz_generated.deepcopy.go index a42fa0d1f..3098e7ee0 100644 --- a/apis/meta/v1alpha1/zz_generated.deepcopy.go +++ b/apis/meta/v1alpha1/zz_generated.deepcopy.go @@ -911,6 +911,13 @@ func (in *PageBlockLayout) DeepCopyInto(out *PageBlockLayout) { (*out)[key] = outVal } } + if in.Filter != nil { + in, out := &in.Filter, &out.Filter + *out = make(map[string]bool, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } return } diff --git a/crds/meta.k8s.appscode.com_resourcelayouts.yaml b/crds/meta.k8s.appscode.com_resourcelayouts.yaml index 3f31fc4eb..54e8c5ec2 100644 --- a/crds/meta.k8s.appscode.com_resourcelayouts.yaml +++ b/crds/meta.k8s.appscode.com_resourcelayouts.yaml @@ -50,6 +50,10 @@ spec: type: string fieldPath: type: string + filter: + additionalProperties: + type: boolean + type: object icons: items: description: ImageSpec contains information about an image used @@ -300,6 +304,10 @@ spec: type: string fieldPath: type: string + filter: + additionalProperties: + type: boolean + type: object icons: items: description: ImageSpec contains information about @@ -571,6 +579,10 @@ spec: type: string fieldPath: type: string + filter: + additionalProperties: + type: boolean + type: object icons: items: description: ImageSpec contains information about @@ -815,6 +827,10 @@ spec: type: string fieldPath: type: string + filter: + additionalProperties: + type: boolean + type: object icons: items: description: ImageSpec contains information about @@ -1096,6 +1112,10 @@ spec: type: string fieldPath: type: string + filter: + additionalProperties: + type: boolean + type: object icons: items: description: ImageSpec contains information about an image used diff --git a/pkg/layouts/lib.go b/pkg/layouts/lib.go index ea5d8af4f..e9db2f577 100644 --- a/pkg/layouts/lib.go +++ b/pkg/layouts/lib.go @@ -314,6 +314,18 @@ func GetResourceLayout(kc client.Client, outline *rsapi.ResourceOutline) (*rsapi } section.Info = &tables[0] } + if page.Name == HomePage && sectionFilter.Info != nil { + if section.Info == nil { + section.Info = &rsapi.PageBlockLayout{} + } + section.Info.Filter = make(map[string]bool, len(sectionFilter.Info)-1) + for typ, show := range sectionFilter.Info { + if typ == "basic" { + continue + } + section.Info.Filter[typ] = show + } + } if sectionOutline.Insight != nil && sectionFilter.Insight { tables, err := FlattenPageBlockOutline(kc, src, *sectionOutline.Insight, rsapi.Field) if err != nil {