11require 'will_paginate/array'
22
33class Comfy ::Admin ::ApiNamespacesController < Comfy ::Admin ::Cms ::BaseController
4- before_action :set_api_namespace , only : %i[ show edit update destroy discard_failed_api_actions rerun_failed_api_actions export export_api_resources duplicate_with_associations duplicate_without_associations export_without_associations_as_json export_with_associations_as_json social_share_metadata api_action_workflow ]
4+ before_action :set_api_namespace , except : %i[ index new create import_as_json ]
55
66 before_action :ensure_authority_for_creating_api , only : %i[ new create import_as_json ]
77 before_action :ensure_authority_for_viewing_all_api , only : :index
@@ -12,6 +12,7 @@ class Comfy::Admin::ApiNamespacesController < Comfy::Admin::Cms::BaseController
1212 before_action :ensure_authority_for_allow_exports_in_api , only : %i[ export export_api_resources export_without_associations_as_json export_with_associations_as_json ]
1313 before_action :ensure_authority_for_allow_duplication_in_api , only : %i[ duplicate_with_associations duplicate_without_associations ]
1414 before_action :ensure_authority_for_allow_social_share_metadata_in_api , only : %i[ social_share_metadata ]
15+ before_action :ensure_authority_to_manage_analytics , only : :analytics_metadata
1516 before_action :ensure_authority_for_full_access_for_api_actions_only_in_api , only : %i[ api_action_workflow discard_failed_api_actions rerun_failed_api_actions ]
1617
1718 # GET /api_namespaces or /api_namespaces.json
@@ -219,6 +220,25 @@ def social_share_metadata
219220 end
220221 end
221222
223+
224+ def analytics_metadata
225+ respond_to do |format |
226+ if @api_namespace . update ( analytics_metadata_params )
227+ format . html do
228+ flash [ :notice ] = 'Analytics Metadata successfully updated.'
229+ redirect_to @api_namespace
230+ end
231+ format . json { render :show , status : :ok , location : @api_namespace }
232+ else
233+ format . html do
234+ flash [ :error ] = @api_namespace . errors . full_messages
235+ render :edit , status : :unprocessable_entity
236+ end
237+ format . json { render json : @api_namespace . errors , status : :unprocessable_entity }
238+ end
239+ end
240+ end
241+
222242 def api_action_workflow
223243 respond_to do |format |
224244 if @api_namespace . update ( api_action_workflow_params )
@@ -269,4 +289,8 @@ def api_action_workflow_params
269289 def api_namespace_social_share_metadata_params
270290 params . require ( :api_namespace ) . permit ( social_share_metadata : [ :title , :description , :image ] )
271291 end
292+
293+ def analytics_metadata_params
294+ params . require ( :api_namespace ) . permit ( analytics_metadata : [ :title , :author , :thumbnail ] )
295+ end
272296end
0 commit comments