From d6e599dab3ba539261f25c940e0bbaf6bd7b6fc8 Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Thu, 11 Apr 2024 15:01:39 +0100 Subject: [PATCH] Generalised Admin search for use in editor (#20011) ref https://linear.app/tryghost/issue/MOM-1 - renamed `searchable` to `groupName` so it better matches usage and avoids leaking internal naming to external clients - added `url` to the fetched data for each data type as the editor will want to use front-end URLs in content - added acceptance tests to help avoid regressions as we further generalise/optimise the search behaviour --- .../admin/app/components/gh-nav-menu/main.hbs | 2 +- ghost/admin/app/components/gh-search-input.js | 8 +- ghost/admin/app/components/modals/search.hbs | 2 +- ghost/admin/app/services/search.js | 13 +- ghost/admin/mirage/config/pages.js | 34 +--- ghost/admin/tests/acceptance/search-test.js | 145 ++++++++++++++++++ 6 files changed, 159 insertions(+), 45 deletions(-) create mode 100644 ghost/admin/tests/acceptance/search-test.js diff --git a/ghost/admin/app/components/gh-nav-menu/main.hbs b/ghost/admin/app/components/gh-nav-menu/main.hbs index 0e1e22c0bc..36acc26874 100644 --- a/ghost/admin/app/components/gh-nav-menu/main.hbs +++ b/ghost/admin/app/components/gh-nav-menu/main.hbs @@ -7,7 +7,7 @@
{{this.config.blogTitle}}
{{/unless}} diff --git a/ghost/admin/app/components/gh-search-input.js b/ghost/admin/app/components/gh-search-input.js index 63466a8359..de268ed062 100644 --- a/ghost/admin/app/components/gh-search-input.js +++ b/ghost/admin/app/components/gh-search-input.js @@ -15,22 +15,22 @@ export default class GhSearchInputComponent extends Component { this.args.onSelected?.(selected); - if (selected.searchable === 'Posts') { + if (selected.groupName === 'Posts') { let id = selected.id.replace('post.', ''); this.router.transitionTo('lexical-editor.edit', 'post', id); } - if (selected.searchable === 'Pages') { + if (selected.groupName === 'Pages') { let id = selected.id.replace('page.', ''); this.router.transitionTo('lexical-editor.edit', 'page', id); } - if (selected.searchable === 'Users') { + if (selected.groupName === 'Users') { let id = selected.id.replace('user.', ''); this.router.transitionTo('settings-x.settings-x', `staff/${id}`); } - if (selected.searchable === 'Tags') { + if (selected.groupName === 'Tags') { let id = selected.id.replace('tag.', ''); this.router.transitionTo('tag', id); } diff --git a/ghost/admin/app/components/modals/search.hbs b/ghost/admin/app/components/modals/search.hbs index 9b2a32ece8..f10c91864f 100644 --- a/ghost/admin/app/components/modals/search.hbs +++ b/ghost/admin/app/components/modals/search.hbs @@ -1,4 +1,4 @@ -