Skip to content

Commit

Permalink
Chore: Service cap (#28022)
Browse files Browse the repository at this point in the history
  • Loading branch information
juliajforesti authored Feb 14, 2023
1 parent 7c064aa commit 3081c36
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 42 deletions.
36 changes: 24 additions & 12 deletions apps/meteor/client/sidebar/header/UserDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {
} from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import type { TranslationKey } from '@rocket.chat/ui-contexts';
import { useLayout, useRoute, useLogout, useSetting, useTranslation, useSetModal } from '@rocket.chat/ui-contexts';
import { useLayout, useRole, useRoute, useLogout, useSetting, useTranslation, useSetModal } from '@rocket.chat/ui-contexts';
import { useThemeMode } from '@rocket.chat/ui-theming/src/hooks/useThemeMode';
import type { ReactElement } from 'react';
import React from 'react';
Expand Down Expand Up @@ -58,6 +58,7 @@ const UserDropdown = ({ user, onClose }: UserDropdownProps): ReactElement => {
const logout = useLogout();
const { isMobile } = useLayout();
const presenceDisabled = useSetting<boolean>('Presence_broadcast_disabled');
const isAdmin = useRole('admin');

const setModal = useSetModal();
const closeModal = useMutableCallback(() => setModal());
Expand Down Expand Up @@ -130,17 +131,28 @@ const UserDropdown = ({ user, onClose }: UserDropdownProps): ReactElement => {
color='status-font-on-info'
onClick={() =>
setModal(
<GenericModal
title={t('User_status_disabled_learn_more')}
cancelText={t('Close')}
confirmText={t('Go_to_workspace_settings')}
children={t('User_status_disabled_learn_more_description')}
onConfirm={handleGoToSettings}
onClose={closeModal}
onCancel={closeModal}
icon={null}
variant='warning'
/>,
isAdmin ? (
<GenericModal
title={t('User_status_disabled_learn_more')}
cancelText={t('Close')}
confirmText={t('Go_to_workspace_settings')}
children={t('User_status_disabled_learn_more_description')}
onConfirm={handleGoToSettings}
onClose={closeModal}
onCancel={closeModal}
icon={null}
variant='warning'
/>
) : (
<GenericModal
title={t('User_status_disabled_learn_more')}
confirmText={t('Close')}
children={t('User_status_disabled_learn_more_description')}
onConfirm={closeModal}
onClose={closeModal}
icon={null}
/>
),
)
}
>
Expand Down
36 changes: 24 additions & 12 deletions apps/meteor/client/sidebar/sections/StatusDisabledSection.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { SidebarBanner } from '@rocket.chat/fuselage';
import { useMutableCallback } from '@rocket.chat/fuselage-hooks';
import { useRoute, useSetModal, useTranslation } from '@rocket.chat/ui-contexts';
import { useRole, useRoute, useSetModal, useTranslation } from '@rocket.chat/ui-contexts';
import React from 'react';

import GenericModal from '../../components/GenericModal';
Expand All @@ -14,6 +14,7 @@ const StatusDisabledSection = ({ onDismiss }: { onDismiss: () => void }) => {
userStatusRoute.push({});
closeModal();
});
const isAdmin = useRole('admin');

return (
<SidebarBanner
Expand All @@ -22,17 +23,28 @@ const StatusDisabledSection = ({ onDismiss }: { onDismiss: () => void }) => {
onClose={onDismiss}
onClick={() =>
setModal(
<GenericModal
title={t('User_status_disabled_learn_more')}
cancelText={t('Close')}
confirmText={t('Go_to_workspace_settings')}
children={t('User_status_disabled_learn_more_description')}
onConfirm={handleGoToSettings}
onClose={closeModal}
onCancel={closeModal}
icon={null}
variant='warning'
/>,
isAdmin ? (
<GenericModal
title={t('User_status_disabled_learn_more')}
cancelText={t('Close')}
confirmText={t('Go_to_workspace_settings')}
children={t('User_status_disabled_learn_more_description')}
onConfirm={handleGoToSettings}
onClose={closeModal}
onCancel={closeModal}
icon={null}
variant='warning'
/>
) : (
<GenericModal
title={t('User_status_disabled_learn_more')}
confirmText={t('Close')}
children={t('User_status_disabled_learn_more_description')}
onConfirm={closeModal}
onClose={closeModal}
icon={null}
/>
),
)
}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { useMutation } from '@tanstack/react-query';
import React from 'react';

import VerticalBar from '../../../components/VerticalBar';
import { useIsEnterprise } from '../../../hooks/useIsEnterprise';
import { useActiveConnections } from './hooks/useActiveConnections';

const CustomUserStatusService = () => {
Expand All @@ -25,6 +26,7 @@ const CustomUserStatusService = () => {
const presenceDisabled = useSetting<boolean>('Presence_broadcast_disabled');
const togglePresenceServiceEndpoint = useEndpoint('POST', '/v1/presence.enableBroadcast');
const disablePresenceService = useMutation(() => togglePresenceServiceEndpoint());
const isEnterprise = useIsEnterprise();

if (result.isLoading || disablePresenceService.isLoading) {
return <Skeleton />;
Expand Down Expand Up @@ -61,11 +63,9 @@ const CustomUserStatusService = () => {
</Box>
<Box display='flex' fontScale='c1' justifyContent='space-between' mb='x16'>
<Box>{t('Active_connections')}</Box>
<Box>
{current}/{max}
</Box>
<Box>{isEnterprise ? current : `${current}/${max}`}</Box>
</Box>
<ProgressBar percentage={percentage} variant='success' />
{!isEnterprise && <ProgressBar percentage={percentage} variant={percentage > 80 ? 'danger' : 'success'} />}
{presenceDisabled && (
<Margins block='x16'>
<Callout type='danger' title={t('Service_disabled')}>
Expand All @@ -75,21 +75,39 @@ const CustomUserStatusService = () => {
)}
</div>
<Box display='flex' flexDirection='column' mb='x16'>
<Box fontScale='p2' mb='x8'>
{t('Community_cap_description')}
</Box>
<Box fontScale='p2' mb='x8'>
{t('Enterprise_cap_description')}
</Box>
{isEnterprise ? (
<>
<Box fontScale='p2' mb='x8'>
{t('Enterprise_cap_description')}
</Box>
<Box fontScale='p2' mb='x8'>
{t('Larger_amounts_of_active_connections')}{' '}
<Box is='a' href='https://go.rocket.chat/i/presence-cap-learn-more' target='_blank' color='status-font-on-info'>
{t('multiple_instance_solutions')}
</Box>
</Box>
</>
) : (
<>
<Box fontScale='p2' mb='x8'>
{t('Community_cap_description')}
</Box>
<Box fontScale='p2' mb='x8'>
{t('Enterprise_cap_description')}
</Box>
</>
)}
</Box>
</VerticalBar.Content>
<VerticalBar.Footer borderBlockStartWidth='default' borderBlockColor='extra-light'>
<ButtonGroup stretch vertical>
<Button primary width='100%'>
{t('More_about_Enterprise_Edition')}
</Button>
</ButtonGroup>
</VerticalBar.Footer>
{!isEnterprise && (
<VerticalBar.Footer borderBlockStartWidth='default' borderBlockColor='extra-light'>
<ButtonGroup stretch vertical>
<Button primary width='100%' is='a' href='https://go.rocket.chat/i/presence-cap-learn-more' target='_blank'>
{t('More_about_Enterprise_Edition')}
</Button>
</ButtonGroup>
</VerticalBar.Footer>
)}
</>
);
};
Expand Down
4 changes: 3 additions & 1 deletion apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -5565,5 +5565,7 @@
"RegisterWorkspace_Syncing_Complete": "Sync Complete",
"RegisterWorkspace_Connection_Error": "An error occured connecting",
"cloud.RegisterWorkspace_Token_Step_One": "1. Go to: <1>cloud.rocket.chat > Workspaces</1> and click <3>'Register self-managed'</3>.",
"cloud.RegisterWorkspace_Setup_Terms_Privacy": "I agree with <1>Terms and Conditions</1> and <3>Privacy Policy</3>"
"cloud.RegisterWorkspace_Setup_Terms_Privacy": "I agree with <1>Terms and Conditions</1> and <3>Privacy Policy</3>",
"Larger_amounts_of_active_connections": "For larger amounts of active connections you can consider our",
"multiple_instance_solutions": "multiple instance solutions"
}

0 comments on commit 3081c36

Please sign in to comment.