1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
import { isNil, omitBy } from 'lodash';
import { objectToQuery } from '~/lib/utils/url_utility';
import { SEARCH_SCOPE } from './constants';
export const commandMapper = ({ name, items }) => {
// TODO: we filter out invite_members for now, because it is complicated to add the invite members modal here
// and is out of scope for the basic command palette items. If it proves to be useful, we can add it later.
return {
name,
items: items.filter(({ component }) => component !== 'invite_members'),
};
};
export const linksReducer = (acc, menuItem) => {
acc.push({
text: menuItem.title,
keywords: menuItem.title,
icon: menuItem.icon,
href: menuItem.link,
});
if (menuItem.items?.length) {
const items = menuItem.items.map(({ title, link }) => ({
keywords: title,
text: [menuItem.title, title].join(' > '),
href: link,
icon: menuItem.icon,
}));
/* eslint-disable-next-line no-param-reassign */
acc = [...acc, ...items];
}
return acc;
};
export const autocompleteQuery = ({ path, searchTerm, handle, projectId }) => {
const query = omitBy(
{
term: searchTerm,
project_id: projectId,
filter: 'search',
scope: SEARCH_SCOPE[handle],
},
isNil,
);
return `${path}?${objectToQuery(query)}`;
};
|