diff --git a/app/services/smart_annotations/tag_to_html.rb b/app/services/smart_annotations/tag_to_html.rb index 83d14af2a..4cd1f255a 100644 --- a/app/services/smart_annotations/tag_to_html.rb +++ b/app/services/smart_annotations/tag_to_html.rb @@ -28,9 +28,11 @@ module SmartAnnotations if type == 'rep_item' repository_item(value[:name], user, team, type, object, preview_repository) else - next unless object && SmartAnnotations::PermissionEval.check(user, type, object) - - SmartAnnotations::HtmlPreview.html(nil, type, object) + if object && SmartAnnotations::PermissionEval.check(user, type, object) + SmartAnnotations::HtmlPreview.html(nil, type, object) + else + private_placeholder(object) + end end rescue ActiveRecord::RecordNotFound next @@ -40,7 +42,7 @@ module SmartAnnotations def repository_item(name, user, team, type, object, preview_repository) if object&.repository - return unless SmartAnnotations::PermissionEval.check(user, type, object) + return private_placeholder(object) unless SmartAnnotations::PermissionEval.check(user, type, object) return SmartAnnotations::HtmlPreview.html(nil, type, object, preview_repository) end @@ -62,5 +64,22 @@ module SmartAnnotations end klass.find_by(id: id) end + + def private_placeholder(object = nil) + label = case object + when Project + I18n.t('smart_annotations.private.project') + when Experiment + I18n.t('smart_annotations.private.experiment') + when MyModule + I18n.t('smart_annotations.private.my_module') + when RepositoryRow + I18n.t('smart_annotations.private.repository_row') + else + I18n.t('smart_annotations.private.object') + end + + "#{label}" + end end end diff --git a/app/services/smart_annotations/tag_to_text.rb b/app/services/smart_annotations/tag_to_text.rb index a1d2996bd..a02276047 100644 --- a/app/services/smart_annotations/tag_to_text.rb +++ b/app/services/smart_annotations/tag_to_text.rb @@ -29,9 +29,11 @@ module SmartAnnotations if type == 'rep_item' repository_item(value[:name], user, team, type, object, is_shared_object) else - next unless object && (is_shared_object || SmartAnnotations::PermissionEval.check(user, type, object)) - - SmartAnnotations::TextPreview.text(nil, type, object) + if object && (is_shared_object || SmartAnnotations::PermissionEval.check(user, type, object)) + SmartAnnotations::TextPreview.text(nil, type, object) + else + private_placeholder(object) + end end rescue ActiveRecord::RecordNotFound next @@ -56,7 +58,7 @@ module SmartAnnotations def repository_item(name, user, team, type, object, is_shared_object) if object - return unless is_shared_object || SmartAnnotations::PermissionEval.check(user, type, object) + return private_placeholder(object) unless is_shared_object || SmartAnnotations::PermissionEval.check(user, type, object) return SmartAnnotations::TextPreview.text(nil, type, object) end @@ -78,5 +80,20 @@ module SmartAnnotations end klass.find_by_id(id) end + + def private_placeholder(object = nil) + case object + when Project + I18n.t('smart_annotations.private.project') + when Experiment + I18n.t('smart_annotations.private.experiment') + when MyModule + I18n.t('smart_annotations.private.my_module') + when RepositoryRow + I18n.t('smart_annotations.private.repository_row') + else + I18n.t('smart_annotations.private.object') + end + end end end diff --git a/config/locales/en.yml b/config/locales/en.yml index e4e2b605e..266f9154f 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -428,6 +428,14 @@ en: activities: "Activity" archive: "Archived results" + smart_annotations: + private: + project: "#private project" + experiment: "#private experiment" + my_module: "#private task" + repository_row: "#private inventory item" + object: "#private object" + attachments: menu: office_file: "New Microsoft 365 file"