forked from RocketChat/Rocket.Chat
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AppsModelList.tsx
67 lines (62 loc) · 1.77 KB
/
AppsModelList.tsx
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import { OptionTitle } from '@rocket.chat/fuselage';
import { useTranslation, useRoute } from '@rocket.chat/ui-contexts';
import type { ReactElement } from 'react';
import React from 'react';
import { triggerActionButtonAction } from '../../../app/ui-message/client/ActionManager';
import type { IAppAccountBoxItem } from '../../../app/ui-utils/client/lib/AccountBox';
import ListItem from '../Sidebar/ListItem';
type AppsModelListProps = {
appBoxItems: IAppAccountBoxItem[];
appsManagementAllowed: boolean;
onDismiss: () => void;
};
const AppsModelList = ({ appBoxItems, appsManagementAllowed, onDismiss }: AppsModelListProps): ReactElement => {
const t = useTranslation();
const marketplaceRoute = useRoute('admin-marketplace');
const page = 'list';
return (
<>
<OptionTitle>{t('Apps')}</OptionTitle>
<ul>
{appsManagementAllowed && (
<>
<ListItem
icon='store'
text={t('Marketplace')}
action={(): void => {
marketplaceRoute.push({ context: 'all', page });
onDismiss();
}}
/>
<ListItem
icon='cube'
text={t('Installed')}
action={(): void => {
marketplaceRoute.push({ context: 'installed', page });
onDismiss();
}}
/>
</>
)}
{appBoxItems.length > 0 && (
<>
{appBoxItems.map((item, key) => {
const action = (): void => {
triggerActionButtonAction({
rid: '',
mid: '',
actionId: item.actionId,
appId: item.appId,
payload: { context: item.context },
});
onDismiss();
};
return <ListItem text={(t.has(item.name) && t(item.name)) || item.name} action={action} key={item.actionId + key} />;
})}
</>
)}
</ul>
</>
);
};
export default AppsModelList;