]> cat aescling's git repositories - mastodon.git/commitdiff
Pre-fill domain block/allow domain from search filter (#18172)
authorClaire <claire.github-309c@sitedethib.com>
Thu, 28 Apr 2022 22:24:44 +0000 (00:24 +0200)
committersingle-right-quote <11325618-aescling@users.noreply.gitlab.com>
Thu, 5 May 2022 17:49:12 +0000 (13:49 -0400)
app/javascript/packs/admin.js
app/views/admin/instances/index.html.haml

index 59901500011dc142049907b9c0af23045e387d15..98f5d1e04287bf4b6fa272a8f8b2248d683e27af 100644 (file)
@@ -2,6 +2,25 @@ import './public-path';
 import ready from '../mastodon/ready';
 
 ready(() => {
+  const domainBlockSeverityInput = document.getElementById('domain_block_severity');
+  if (domainBlockSeverityInput) onDomainBlockSeverityChange(domainBlockSeverityInput);
+
+  const enableBootstrapTimelineAccounts = document.getElementById('form_admin_settings_enable_bootstrap_timeline_accounts');
+  if (enableBootstrapTimelineAccounts) onEnableBootstrapTimelineAccountsChange(enableBootstrapTimelineAccounts);
+
+  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');
 
index f8273718d4e2d0ab439d08bc293a246d1da8a6d4..cc50203986546cc059df2d3e62f0069ff1ef2ec9 100644 (file)
@@ -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