Skip to content

Commit

Permalink
feat: add support for filter_content_type in schema definition
Browse files Browse the repository at this point in the history
  • Loading branch information
pvaneveld committed Jun 14, 2024
1 parent 4ee4fee commit c88ffad
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion docs/resources/component.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
3 changes: 3 additions & 0 deletions internal/component_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -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)

Check failure on line 163 in internal/component_model.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected utils in composite literal; possibly missing comma or }

Check failure on line 163 in internal/component_model.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected utils in composite literal; possibly missing comma or }

Check failure on line 163 in internal/component_model.go

View workflow job for this annotation

GitHub Actions / test

missing ',' in composite literal (typecheck)
FolderSlug: item.FolderSlug.ValueStringPointer(),
ForceLinkScope: item.ForceLinkScope.ValueBoolPointer(),

Check failure on line 165 in internal/component_model.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected :, expected := or = or comma

Check failure on line 165 in internal/component_model.go

View workflow job for this annotation

GitHub Actions / test

syntax error: unexpected :, expected := or = or comma
ImageCrop: item.ImageCrop.ValueBoolPointer(),
Expand Down Expand Up @@ -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),
Expand Down
5 changes: 5 additions & 0 deletions internal/component_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit c88ffad

Please sign in to comment.