From fa8feff4cb5b78eb5694c0c99c9e0c0b53a12a90 Mon Sep 17 00:00:00 2001 From: Claire Date: Fri, 29 Apr 2022 00:24:44 +0200 Subject: [PATCH] Pre-fill domain block/allow domain from search filter (#18172) --- app/javascript/packs/admin.js | 19 +++++++++++++++++++ app/views/admin/instances/index.html.haml | 7 +++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/app/javascript/packs/admin.js b/app/javascript/packs/admin.js index 599015000..98f5d1e04 100644 --- a/app/javascript/packs/admin.js +++ b/app/javascript/packs/admin.js @@ -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'); 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 -- 2.47.3