Skip to content
This repository has been archived by the owner on Aug 18, 2024. It is now read-only.

Using og_audience field with media entity: Field does not show the groups user is member in #638

Open
geek-andi opened this issue Apr 15, 2020 · 0 comments
Labels

Comments

@geek-andi
Copy link

geek-andi commented Apr 15, 2020

We're using latest #571 branch. I assume that we can simply add the needed config to media entities to make og work with it (see code below). If done so, the add/edit/delete media permissions show up correctly in /admin/config/group/permissions/node/groupname.

However a group member is not able to select a group he/she is member of. A group administrator however can select from the groups he/she is member of.

Steps to reproduce:

  1. Add og_audience to media entity (see code below)
  2. Create group member without checking the administrator checkbox undre roles
  3. Give member permission to add/edti/delete media
  4. Login as group member and create a media item, see that og_audience field is empty

og_audience field added to media entity as diff:

diff --git a/config-sync/core.entity_form_display.media.media_image.default.yml b/config-sync/core.entity_form_display.media.media_image.default.yml
index 910abeb..84b8af6 100644
--- a/config-sync/core.entity_form_display.media.media_image.default.yml
+++ b/config-sync/core.entity_form_display.media.media_image.default.yml
@@ -4,6 +4,7 @@ status: true
 dependencies:
   config:
     - field.field.media.media_image.field_media_image
+    - field.field.media.media_image.og_audience
     - image.style.medium
     - media.type.media_image
   module:
@@ -39,6 +40,12 @@ content:
       size: 60
       placeholder: ''
     third_party_settings: {  }
+  og_audience:
+    type: options_select
+    weight: 0
+    region: content
+    settings: {  }
+    third_party_settings: {  }
   revision_log_message:
     type: hide_revision_field_log_widget
     weight: 4
diff --git a/config-sync/core.entity_form_display.media.media_image.media_library.yml b/config-sync/core.entity_form_display.media.media_image.media_library.yml
index a38f963..370a6be 100644
--- a/config-sync/core.entity_form_display.media.media_image.media_library.yml
+++ b/config-sync/core.entity_form_display.media.media_image.media_library.yml
@@ -5,6 +5,7 @@ dependencies:
   config:
     - core.entity_form_mode.media.media_library
     - field.field.media.media_image.field_media_image
+    - field.field.media.media_image.og_audience
     - image.style.medium
     - media.type.media_image
   module:
@@ -24,6 +25,12 @@ content:
       preview_image_style: medium
       progress_indicator: throbber
     third_party_settings: {  }
+  og_audience:
+    type: options_select
+    weight: -1
+    region: content
+    settings: {  }
+    third_party_settings: {  }
   status:
     type: boolean_checkbox
     weight: 1
diff --git a/config-sync/core.entity_view_display.media.media_image.h4c_preview.yml b/config-sync/core.entity_view_display.media.media_image.h4c_preview.yml
index 8bee15f..9b27c10 100644
--- a/config-sync/core.entity_view_display.media.media_image.h4c_preview.yml
+++ b/config-sync/core.entity_view_display.media.media_image.h4c_preview.yml
@@ -5,6 +5,7 @@ dependencies:
   config:
     - core.entity_view_mode.media.h4c_preview
     - field.field.media.media_image.field_media_image
+    - field.field.media.media_image.og_audience
     - media.type.media_image
     - responsive_image.styles.narrow
   module:
@@ -28,6 +29,14 @@ content:
         handler: ''
     type: responsive_image
     region: content
+  og_audience:
+    type: entity_reference_label
+    weight: 0
+    region: content
+    label: above
+    settings:
+      link: true
+    third_party_settings: {  }
 hidden:
   created: true
   langcode: true
diff --git a/config-sync/field.field.media.media_image.og_audience.yml b/config-sync/field.field.media.media_image.og_audience.yml
new file mode 100644
index 0000000..f33240d
--- /dev/null
+++ b/config-sync/field.field.media.media_image.og_audience.yml
@@ -0,0 +1,30 @@
+uuid: c885bd87-8f5e-484e-be42-633ad387911e
+langcode: en
+status: true
+dependencies:
+  config:
+    - field.storage.media.og_audience
+    - media.type.media_image
+    - node.type.organisation
+  module:
+    - og
+id: media.media_image.og_audience
+field_name: og_audience
+entity_type: media
+bundle: media_image
+label: 'Groups audience'
+description: 'The group this media belongs to <strong>cannot</strong> be changed after saving.'
+required: true
+translatable: true
+default_value: {  }
+default_value_callback: ''
+settings:
+  handler: 'og:default'
+  handler_settings:
+    target_bundles:
+      organisation: organisation
+    sort:
+      field: _none
+    auto_create: false
+    auto_create_bundle: ''
+field_type: og_standard_reference
diff --git a/config-sync/field.storage.media.og_audience.yml b/config-sync/field.storage.media.og_audience.yml
new file mode 100644
index 0000000..294e04b
--- /dev/null
+++ b/config-sync/field.storage.media.og_audience.yml
@@ -0,0 +1,25 @@
+uuid: 2ae13d3d-41c8-41b1-a143-8fc11095de9f
+langcode: en
+status: true
+dependencies:
+  module:
+    - field_permissions
+    - media
+    - node
+    - og
+third_party_settings:
+  field_permissions:
+    permission_type: public
+id: media.og_audience
+field_name: og_audience
+entity_type: media
+type: og_standard_reference
+settings:
+  target_type: node
+module: og
+locked: false
+cardinality: 1
+translatable: true
+indexes: {  }
+persist_with_no_fields: false
+custom_storage: false

Edit: Also the permissions seem to be set correctly, at least judging from the config export:

 group_type: node
 group_bundle: organisation
 group_id: null
-permissions: {  }
+permissions:
+  - 'create media_image media'
+  - 'delete any media_image media'
+  - 'delete own media_image media'
+  - 'update any media_image media'
+  - 'update own media_image media'
 role_type: required
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants