From 0fd31cdb4c1fb26bf5cd7645d4a187237687049d Mon Sep 17 00:00:00 2001 From: fenn-cs Date: Sun, 3 Mar 2024 11:48:43 +0100 Subject: [PATCH] refactor: use TypeScript for unified-search boostrap file This would allow us to type guard what is sent to`registerFilterAction` for unified search, so that incompatibilties are caught quickly. Signed-off-by: fenn-cs --- core/src/{unified-search.js => unified-search.ts} | 11 ++++++++++- webpack.modules.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) rename core/src/{unified-search.js => unified-search.ts} (87%) diff --git a/core/src/unified-search.js b/core/src/unified-search.ts similarity index 87% rename from core/src/unified-search.js rename to core/src/unified-search.ts index 4be923085d3..24571f149a4 100644 --- a/core/src/unified-search.js +++ b/core/src/unified-search.ts @@ -49,10 +49,19 @@ Vue.mixin({ }, }) +// Define type structure for unified searc action +interface UnifiedSearchAction { + id: string; + appId: string; + label: string; + icon: string; + callback: () => void; +} + // Register the add/register filter action API globally window.OCA = window.OCA || {} window.OCA.UnifiedSearch = { - registerFilterAction: ({ id, appId, label, callback, icon }) => { + registerFilterAction: ({ id, appId, label, callback, icon }: UnifiedSearchAction) => { const searchStore = useSearchStore() searchStore.registerExternalFilter({ id, appId, label, callback, icon }) }, diff --git a/webpack.modules.js b/webpack.modules.js index c6662e7ee81..2ef663376c5 100644 --- a/webpack.modules.js +++ b/webpack.modules.js @@ -37,7 +37,7 @@ module.exports = { profile: path.join(__dirname, 'core/src', 'profile.ts'), recommendedapps: path.join(__dirname, 'core/src', 'recommendedapps.js'), systemtags: path.resolve(__dirname, 'core/src', 'systemtags/merged-systemtags.js'), - 'unified-search': path.join(__dirname, 'core/src', 'unified-search.js'), + 'unified-search': path.join(__dirname, 'core/src', 'unified-search.ts'), 'legacy-unified-search': path.join(__dirname, 'core/src', 'legacy-unified-search.js'), 'unsupported-browser': path.join(__dirname, 'core/src', 'unsupported-browser.js'), 'unsupported-browser-redirect': path.join(__dirname, 'core/src', 'unsupported-browser-redirect.js'),