Skip to content

Commit

Permalink
Regression: Re-add view logs button (#25876)
Browse files Browse the repository at this point in the history
  • Loading branch information
rique223 authored Jun 21, 2022
1 parent 8e7135b commit d1c59c3
Showing 1 changed file with 30 additions and 2 deletions.
32 changes: 30 additions & 2 deletions apps/meteor/client/views/admin/apps/AppMenu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Icon, Menu } from '@rocket.chat/fuselage';
import { useSetModal, useMethod, useEndpoint, useTranslation } from '@rocket.chat/ui-contexts';
import { useSetModal, useMethod, useEndpoint, useTranslation, useRoute, useRouteParameter } from '@rocket.chat/ui-contexts';
import React, { useMemo, useCallback } from 'react';

import CloudLoginModal from './CloudLoginModal';
Expand All @@ -11,6 +11,8 @@ function AppMenu({ app, ...props }) {
const t = useTranslation();
const setModal = useSetModal();
const checkUserLoggedIn = useMethod('cloud:checkUserLoggedIn');
const appsRoute = useRoute('admin-apps');
const context = useRouteParameter('context');

const setAppStatus = useEndpoint('POST', `/apps/${app.id}/status`);
const buildExternalUrl = useEndpoint('GET', '/apps');
Expand Down Expand Up @@ -64,6 +66,10 @@ function AppMenu({ app, ...props }) {
setModal(<IframeModal url={data.url} confirm={confirm} cancel={closeModal} />);
}, [checkUserLoggedIn, setModal, closeModal, buildExternalUrl, app.id, app.purchaseType, syncApp]);

const handleViewLogs = useCallback(() => {
appsRoute.push({ context: 'details', id: app.id, version: app.version, tab: 'logs' });
}, [app.id, app.version, appsRoute]);

const handleDisable = useCallback(() => {
const confirm = async () => {
closeModal();
Expand Down Expand Up @@ -124,6 +130,17 @@ function AppMenu({ app, ...props }) {
action: handleSubscription,
},
}),
...(context !== 'details' && {
viewLogs: {
label: (
<Box>
<Icon name='list-alt' size='x16' marginInlineEnd='x4' />
{t('View_Logs')}
</Box>
),
action: handleViewLogs,
},
}),
...(app.installed &&
isAppEnabled && {
disable: {
Expand Down Expand Up @@ -160,7 +177,18 @@ function AppMenu({ app, ...props }) {
},
}),
}),
[canAppBeSubscribed, t, handleSubscription, app.installed, isAppEnabled, handleDisable, handleEnable, handleUninstall],
[
canAppBeSubscribed,
t,
handleSubscription,
context,
handleViewLogs,
app.installed,
isAppEnabled,
handleDisable,
handleEnable,
handleUninstall,
],
);

return <Menu options={menuOptions} placement='bottom-start' {...props} />;
Expand Down

0 comments on commit d1c59c3

Please sign in to comment.