This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/admin/addon/templates
David Taylor c1f74cd92a
DEV: Update default tagName and connectorTagName for plugin outlets (#13685)
This commit should be a no-op for all existing core outlets. Outlets which are introduced by themes/plugins may see a change in behavior, and should follow the steps below if they want to maintain their previous behavior.

`tagName="" connectorTagName=""` is almost always the correct choice for plugin outlets. 40eba8cd introduced a `noTags=true` shortcut which achieved this, and left a comment saying it should be the future default. This commit does exactly that. To avoid any breaking changes for plugins, all existing plugin outlets have been reviewed and adjusted by following this logic:

1) If `noTags=true`, remove the `noTags` parameter, and do not complete any further steps
2) If `tagName` is not specified, set `tagName="span"` (the previous default)
3) If `connectorTagName` is not specified, set `selectorTagName="div"` (the previous default)
4) If `tagName=""`, remove it
5) If `connectorTagName=""`, remove it

The updates were accomplished with the help of a ruby script:

```ruby
def removeAttr(tag, attribute)
  tag = tag.sub /\s#{attribute}="?\w*"? /, " "
  tag = tag.sub /\s#{attribute}="?\w*"?}}/, "}}"
  tag = tag.sub /^\s*#{attribute}="?\w*"?\n/, ""
  tag
end

files = Dir.glob("app/assets/javascripts/**/*.hbs")

puts "Checking #{files.count} files..."
files.each do |f|
  content = File.read(f)

  count = 0
  edits = 0
  content.gsub!(/{{\s*plugin-outlet.*?}}/m) do |match|
    count += 1

    result = match

    noTags = result.include?("noTags=true")
    tagName = result[/tagName="(\w*)"/, 1]
    connectorTagName = result[/connectorTagName="(\w*)"/, 1]

    if noTags
      result = removeAttr(result, "noTags")
    else
      if connectorTagName == ""
        result = removeAttr(result, "connectorTagName")
      elsif connectorTagName.nil?
        result = result.sub(/name="[\w-]+"/) { |m| "#{m} connectorTagName=\"div\"" }
      end

      if tagName == ""
        result = removeAttr(result, "tagName")
      elsif tagName.nil?
        result = result.sub(/name="[\w-]+"/) { |m| "#{m} tagName=\"span\"" }
      end
    end

    edits += 1 if match != result

    result
  end

  puts "#{count} outlets, #{edits} edited -> #{f}"

  File.write(f, content)
end
```
2022-01-06 20:38:17 +00:00
..
components DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
logs UX: Extend user hyperlink in staff action logs (#15293) 2021-12-14 17:14:18 +02:00
modal FEATURE: allow admin to delete all posts by a user irrespectively (#14128) 2021-08-25 10:14:22 +05:30
admin.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
api-keys-index.hbs FEATURE: Add pagination to API keys page (#14777) 2021-11-09 12:18:23 +02:00
api-keys-new.hbs FEATURE: Add read-only scope to API keys (#14856) 2021-11-10 17:48:00 +02:00
api-keys-show.hbs FEATURE: Add read-only scope to API keys (#14856) 2021-11-10 17:48:00 +02:00
api.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
backups-index.hbs DEV: Promote uppy backup uploader to primary uploader (#15363) 2021-12-20 13:39:35 +10:00
backups-logs.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
backups.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
badges-award.hbs DEV: Clean up some styles (#14374) 2021-09-20 09:52:03 -04:00
badges-index.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
badges-show.hbs FEATURE: Change all core to use uppy-image-uploader (#14428) 2021-10-19 13:25:42 +10:00
badges.hbs DEV: Buttons were missing btn-default classes (#12991) 2021-05-08 11:45:18 -04:00
customize-colors-index.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
customize-colors-show.hbs UX: Fix mobile styling for admin color schemes (#14314) 2021-09-13 13:43:57 -04:00
customize-colors.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
customize-email-style-edit.hbs UX: Allow saving with cmd+s/ctrl+s with Ace editor (#12674) 2021-05-04 12:56:10 +01:00
customize-email-style.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
customize-email-templates-edit.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
customize-email-templates.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
customize-robots-txt.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
customize-themes-edit.hbs UX: Allow saving with cmd+s/ctrl+s with Ace editor (#12674) 2021-05-04 12:56:10 +01:00
customize-themes-index.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
customize-themes-show.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
customize-themes.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
customize.hbs FIX: allow moderators to access /admin/customize/watched_words (#12816) 2021-04-23 18:51:45 +05:30
dashboard_general.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
dashboard_moderation.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
dashboard_reports.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
dashboard_security.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
dashboard.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
email-advanced-test.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
email-bounced.hbs UX: handle large email addresses on email skipped and bounced tabs (#11259) 2020-11-17 18:01:40 +05:30
email-index.hbs UX: Normalize sizing for inputs, buttons, dropdowns (#14226) 2021-09-09 11:01:56 -04:00
email-preview-digest.hbs UX: Normalize sizing for inputs, buttons, dropdowns (#14226) 2021-09-09 11:01:56 -04:00
email-received.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
email-rejected.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
email-sent.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
email-skipped.hbs UX: handle large email addresses on email skipped and bounced tabs (#11259) 2020-11-17 18:01:40 +05:30
email.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
embedding.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
emojis.hbs DEV: Add missing IDs to uppy upload components (#14880) 2021-11-11 15:38:39 +10:00
logs.hbs UX: move logs/watched_words to customize/watched_words in admin section (#12571) 2021-04-01 11:44:17 +05:30
permalinks.hbs UX: Layout fixes for admin permalinks page (#14819) 2021-11-04 14:15:55 -04:00
plugins-index.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
plugins.hbs DEV: refactors admin-plugins/admin-site-settings (#15244) 2021-12-09 13:47:56 +01:00
reports-show.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
search-logs-index.hbs REVERT: revert change from action + mut to mut (#10844) 2020-10-06 23:50:05 +02:00
search-logs-term.hbs REVERT: revert change from action + mut to mut (#10844) 2020-10-06 23:50:05 +02:00
site-settings-category.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
site-settings.hbs UX: Fix alignment for admin controls on mobile (#14312) 2021-09-13 13:43:43 -04:00
site-text-edit.hbs UX: Text customization for different languages. (#11729) 2021-01-18 14:53:45 -03:00
site-text-index.hbs FIX: do not show default locale option on site text customization (#14083) 2021-08-19 05:54:21 +05:30
site-text.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
user-badges.hbs DEV: Clean up some styles (#14374) 2021-09-20 09:52:03 -04:00
user-fields.hbs enable eol-last for eslint and ember-template-lint (#12678) 2021-04-12 17:22:00 -07:00
user-index.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
user-tl3-requirements.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
user.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
users-list-show.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
users-list.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
watched-words-action.hbs DEV: Add missing IDs to uppy upload components (#14880) 2021-11-11 15:38:39 +10:00
watched-words.hbs UX: Fix alignment for admin controls on mobile (#14312) 2021-09-13 13:43:43 -04:00
web-hooks-show-events.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00
web-hooks-show.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
web-hooks.hbs REFACTOR: Support bundling our admin section as an ember addon 2020-09-22 15:14:29 -04:00