about summary refs log tree commit diff
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-04-29 00:24:44 +0200
committerGitHub <noreply@github.com>2022-04-29 00:24:44 +0200
commite7f0c9f7dad3ae7deceaf289d3cefd41b768efc8 (patch)
tree660a57825cda75c453a7200b9047b71fda4f465c
parentbe0bc9acbffe2d6126f382b946be0469d756048c (diff)
Pre-fill domain block/allow domain from search filter (#18172)
-rw-r--r--app/javascript/packs/admin.js10
-rw-r--r--app/views/admin/instances/index.html.haml7
2 files changed, 15 insertions, 2 deletions
diff --git a/app/javascript/packs/admin.js b/app/javascript/packs/admin.js
index f32679619..a3ed1ffed 100644
--- a/app/javascript/packs/admin.js
+++ b/app/javascript/packs/admin.js
@@ -100,6 +100,16 @@ ready(() => {
   const registrationMode = document.getElementById('form_admin_settings_registrations_mode');
   if (registrationMode) onChangeRegistrationMode(registrationMode);
 
+  document.querySelector('a#add-instance-button')?.addEventListener('click', (e) => {
+    const domain = document.getElementById('by_domain')?.value;
+
+    if (domain) {
+      const url = new URL(event.target.href);
+      url.searchParams.set('_domain', domain);
+      e.target.href = url;
+    }
+  });
+
   const React    = require('react');
   const ReactDOM = require('react-dom');
 
diff --git a/app/views/admin/instances/index.html.haml b/app/views/admin/instances/index.html.haml
index f8273718d..cc5020398 100644
--- a/app/views/admin/instances/index.html.haml
+++ b/app/views/admin/instances/index.html.haml
@@ -1,11 +1,14 @@
 - content_for :page_title do
   = t('admin.instances.title')
 
+- content_for :header_tags do
+  = javascript_pack_tag 'admin', async: true, crossorigin: 'anonymous'
+
 - content_for :heading_actions do
   - if whitelist_mode?
-    = link_to t('admin.domain_allows.add_new'), new_admin_domain_allow_path, class: 'button'
+    = link_to t('admin.domain_allows.add_new'), new_admin_domain_allow_path, class: 'button', id: 'add-instance-button'
   - else
-    = link_to t('admin.domain_blocks.add_new'), new_admin_domain_block_path, class: 'button'
+    = link_to t('admin.domain_blocks.add_new'), new_admin_domain_block_path, class: 'button', id: 'add-instance-button'
 
 .filters
   .filter-subset