discourse/app/assets/javascripts/admin/addon/templates/components
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
..
report-filters DEV: select-kit third major update with focus on accessibility (#13303) 2021-08-23 10:44:19 +02:00
site-settings FEATURE: Change all core to use uppy-image-uploader (#14428) 2021-10-19 13:25:42 +10:00
ace-editor.hbs
admin-backups-logs.hbs
admin-editable-field.hbs
admin-form-row.hbs
admin-nav.hbs
admin-penalty-history.hbs FEATURE: Penalty history improvements (#13359) 2021-07-12 11:36:56 -07:00
admin-report-chart.hbs
admin-report-counters.hbs
admin-report-counts.hbs
admin-report-inline-table.hbs
admin-report-per-day-counts.hbs
admin-report-stacked-chart.hbs
admin-report-storage-stats.hbs
admin-report-table-cell.hbs
admin-report-table-header.hbs DEV: allows reports to display an html title (#12687) 2021-04-22 13:38:10 +02:00
admin-report-table-row.hbs
admin-report-table.hbs
admin-report-trust-level-counts.hbs
admin-report.hbs FIX: correctly implements average for reports (#13447) 2021-06-21 10:35:11 +02:00
admin-theme-editor.hbs DEV: Show warning in admin UI for core SCSS color vars (#12984) 2021-05-11 09:01:06 -04:00
admin-user-field-item.hbs FEATURE: the ability to search users by custom fields (#12762) 2021-04-27 15:52:45 +10:00
admin-watched-word.hbs FIX: only delete the word/phrase when the 'x' icon is clicked (#13547) 2021-06-28 15:14:18 +05:30
admin-web-hook-event-chooser.hbs
admin-web-hook-event.hbs
admin-web-hook-status.hbs
dashboard-new-feature-item.hbs FEATURE: Add new features section in admin dashboard (#11731) 2021-01-22 10:09:02 -05:00
dashboard-new-features.hbs DEV: Buttons were missing btn-default classes (#12991) 2021-05-08 11:45:18 -04:00
dashboard-problems.hbs FIX: Tone down admin dashboard critical problem messaging (#15442) 2022-01-04 13:00:58 +10:00
email-styles-editor.hbs UX: Allow saving with cmd+s/ctrl+s with Ace editor (#12674) 2021-05-04 12:56:10 +01:00
embeddable-host.hbs FIX: Display embeddable host's post to category. (#14517) 2021-10-05 13:59:27 -03:00
embedding-setting.hbs
emoji-value-list.hbs DEV: Rename emoji icon (#13499) 2021-06-23 11:12:48 -04:00
flag-user-lists.hbs
flag-user.hbs
highlighted-code.hbs
inline-edit-checkbox.hbs FIX: Checkbox value should not leak between themes (#11327) 2020-11-24 12:10:28 +02:00
install-theme-item.hbs
penalty-post-action.hbs
permalink-form.hbs DEV: jquery removal/listeners/cleanup of permalink form (#14944) 2021-11-16 10:25:54 +01:00
resumable-upload.hbs
screened-ip-address-form.hbs UX: Normalize sizing for inputs, buttons, dropdowns (#14226) 2021-09-09 11:01:56 -04:00
secret-value-list.hbs
setting-validation-message.hbs
silence-details.hbs
simple-list.hbs
site-customization-change-details.hbs
site-customization-change-field.hbs
site-setting.hbs FIX: force refresh staff action logs when transitioning from site settings (#12096) 2021-02-17 00:18:39 +05:30
site-text-summary.hbs
staff-actions.hbs DEV: drops jquery/simplify code/removes leaked event (#14947) 2021-11-16 10:26:39 +01:00
suspension-details.hbs UX: add stock suspension reasons to suspend dialog. (#10990) 2020-11-11 01:01:28 +05:30
tags-uploader.hbs DEV: Buttons were missing btn-default classes (#12991) 2021-05-08 11:45:18 -04:00
themes-list-item.hbs DEV: Update default tagName and connectorTagName for plugin outlets (#13685) 2022-01-06 20:38:17 +00:00
themes-list.hbs FEATURE: Add filter box to the themes/components list (#13767) 2021-07-19 09:33:58 +08:00
value-list.hbs DEV: select-kit third major update with focus on accessibility (#13303) 2021-08-23 10:44:19 +02:00
version-checks.hbs
watched-word-form.hbs FIX: Allow every tag for watched words (#14684) 2021-10-25 10:53:42 +03:00
watched-word-uploader.hbs FEATURE: Import and export watched word (#12444) 2021-03-22 22:32:18 +02:00