From c88ffad41458911644a47c1e86bea2c059e02cac Mon Sep 17 00:00:00 2001 From: Paul Vaneveld Date: Fri, 14 Jun 2024 11:39:57 +0200 Subject: [PATCH] feat: add support for `filter_content_type` in schema definition --- docs/resources/component.md | 3 ++- internal/component_model.go | 3 +++ internal/component_resource.go | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/docs/resources/component.md b/docs/resources/component.md index e47527a..a822bb0 100644 --- a/docs/resources/component.md +++ b/docs/resources/component.md @@ -143,7 +143,7 @@ Optional: - `allow_target_blank` (Boolean) Allows to open links in a new tab for Richtext; Default: false - `asset_folder_id` (Number) Default asset folder numeric id to store uploaded image of that field - `can_sync` (Boolean) Advanced usage to sync with field in preview; Default: false -- `component_whitelist` (List of String) Array of component/content type names: ["post","page","product"] +- `component_whitelist` An array of component/content type names: ["post", "page", "product"]. Only for type: bloks, multilink, and richtext (for nestable bloks inside that) - `customize_toolbar` (Boolean) Allow to customize the Markdown or Richtext toolbar; Default: false - `datasource_slug` (String) Define selectable datasources string; Effects editor only if source=internal - `default_value` (String) Default value for the field; Can be an escaped JSON object @@ -153,6 +153,7 @@ Optional: - `external_datasource` (String) Define external datasource JSON Url; Effects editor only if source=external - `field_type` (String) Name of the custom field type plugin - `filetypes` (List of String) Array of file type names: ["images", "videos", "audios", "texts"] +- `filter_content_type` An array of content types that can be selected in a option or options field where source is internal_stories - `folder_slug` (String) Filter on selectable stories path; Effects editor only if source=internal_stories; In case you have a multi-language folder structure you can add the '{0}' placeholder and the path will be adapted dynamically. Examples: "{0}/categories/", {0}/{1}/categories/ - `force_link_scope` (Boolean) Force link scope to be internal_stories; Default: false - `image_crop` (Boolean) Activate force crop for images: (true/false) diff --git a/internal/component_model.go b/internal/component_model.go index 2972a2f..9824fce 100644 --- a/internal/component_model.go +++ b/internal/component_model.go @@ -46,6 +46,7 @@ type fieldModel struct { ExternalDatasource types.String `tfsdk:"external_datasource"` FieldType types.String `tfsdk:"field_type"` Filetypes []types.String `tfsdk:"filetypes"` + FilterContentType []types.String `tfsdk:"filter_content_type"` FolderSlug types.String `tfsdk:"folder_slug"` ForceLinkScope types.Bool `tfsdk:"force_link_scope"` ImageCrop types.Bool `tfsdk:"image_crop"` @@ -159,6 +160,7 @@ func toFieldInput(item fieldModel) sbmgmt.FieldInput { ExternalDatasource: item.ExternalDatasource.ValueStringPointer(), FieldType: item.FieldType.ValueStringPointer(), Filetypes: utils.ConvertToPointerStringSlice(item.Filetypes), + FilterContentType utils.ConvertToPointerStringSlice(item.FilterContentType) FolderSlug: item.FolderSlug.ValueStringPointer(), ForceLinkScope: item.ForceLinkScope.ValueBoolPointer(), ImageCrop: item.ImageCrop.ValueBoolPointer(), @@ -237,6 +239,7 @@ func toFieldModel(field sbmgmt.FieldInput) fieldModel { ExternalDatasource: types.StringPointerValue(field.ExternalDatasource), FieldType: types.StringPointerValue(field.FieldType), Filetypes: utils.ConvertToStringSlice(field.Filetypes), + FilterContentType: utils.ConvertToStringSlice(field.FilterContentType), FolderSlug: types.StringPointerValue(field.FolderSlug), ForceLinkScope: types.BoolPointerValue(field.ForceLinkScope), ImageCrop: types.BoolPointerValue(field.ImageCrop), diff --git a/internal/component_resource.go b/internal/component_resource.go index b451ea0..95ab65c 100644 --- a/internal/component_resource.go +++ b/internal/component_resource.go @@ -201,6 +201,11 @@ func (r *componentResource) Schema(_ context.Context, _ resource.SchemaRequest, Optional: true, ElementType: types.StringType, }, + "filter_content_type": schema.ListAttribute{ + Description: "An array of content types that can be selected in a option or options field where source is internal_stories: [\"post\", \"faq_item\"]", + Optional: true, + ElementType: types.StringType, + }, "force_link_scope": schema.BoolAttribute{ Description: "Force link scope to be internal_stories; Default: false", Optional: true,