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 <fenn25.fn@gmail.com>
pull/43963/head
fenn-cs 9 months ago
parent 20953d0374
commit 0fd31cdb4c
  1. 11
      core/src/unified-search.ts
  2. 2
      webpack.modules.js

@ -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 // Register the add/register filter action API globally
window.OCA = window.OCA || {} window.OCA = window.OCA || {}
window.OCA.UnifiedSearch = { window.OCA.UnifiedSearch = {
registerFilterAction: ({ id, appId, label, callback, icon }) => { registerFilterAction: ({ id, appId, label, callback, icon }: UnifiedSearchAction) => {
const searchStore = useSearchStore() const searchStore = useSearchStore()
searchStore.registerExternalFilter({ id, appId, label, callback, icon }) searchStore.registerExternalFilter({ id, appId, label, callback, icon })
}, },

@ -37,7 +37,7 @@ module.exports = {
profile: path.join(__dirname, 'core/src', 'profile.ts'), profile: path.join(__dirname, 'core/src', 'profile.ts'),
recommendedapps: path.join(__dirname, 'core/src', 'recommendedapps.js'), recommendedapps: path.join(__dirname, 'core/src', 'recommendedapps.js'),
systemtags: path.resolve(__dirname, 'core/src', 'systemtags/merged-systemtags.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'), 'legacy-unified-search': path.join(__dirname, 'core/src', 'legacy-unified-search.js'),
'unsupported-browser': path.join(__dirname, 'core/src', 'unsupported-browser.js'), 'unsupported-browser': path.join(__dirname, 'core/src', 'unsupported-browser.js'),
'unsupported-browser-redirect': path.join(__dirname, 'core/src', 'unsupported-browser-redirect.js'), 'unsupported-browser-redirect': path.join(__dirname, 'core/src', 'unsupported-browser-redirect.js'),

Loading…
Cancel
Save