Skip to content

Commit

Permalink
Shared feed import validation message: Format URLs using Markdown (#1897
Browse files Browse the repository at this point in the history
)

When trying to import media from a shared feed that already exist in the target workspace, return the existing item URLs in the error message as Markdown, so they can be better displayed on the frontend.

Reference: CV2-4631.
  • Loading branch information
caiosba committed May 23, 2024
1 parent dc560d6 commit 87e144a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/models/cluster.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def import_medias_to_team(team, claim_title, claim_context, parent_id = nil)
existing_items << existing_item
existing_item.nil?
end
raise ActiveRecord::RecordNotUnique.new(I18n.t(:shared_feed_imported_media_already_exist, urls: existing_items.map(&:full_url).uniq.compact_blank.join(', '))) if from_project_media.nil?
raise ActiveRecord::RecordNotUnique.new(I18n.t(:shared_feed_imported_media_already_exist, urls: existing_items.uniq.compact_blank.collect{ |pm| "•︎ [#{pm.title}](#{pm.full_url})" }.join("\n"))) if from_project_media.nil?
parent = nil
if parent_id.nil?
parent = self.import_media_to_team(team, from_project_media, claim_title, claim_context)
Expand Down
5 changes: 4 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,10 @@ en:
send_every_must_be_a_list_of_days_of_the_week: must be a list of days of the week.
send_on_must_be_in_the_future: can't be in the past.
cant_delete_default_folder: The default folder can't be deleted
shared_feed_imported_media_already_exist: "No media to import. All media items from this item already exist in your workspace: %{urls}"
shared_feed_imported_media_already_exist: |-
No media eligible to be imported into your workspace.
The media selected to import already exist in your workspace in the following items:
%{urls}
info:
messages:
sent_to_trash_by_rule: '"%{item_title}" has been sent to trash by an automation
Expand Down

0 comments on commit 87e144a

Please sign in to comment.