Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Community Edition Watermark #25844

Merged
merged 17 commits into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion apps/meteor/client/contexts/CallContext.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IVoipRoom } from '@rocket.chat/core-typings';
import type { CallStates, IVoipRoom } from '@rocket.chat/core-typings';
import { ICallerInfo, VoIpCallerInfo } from '@rocket.chat/core-typings';
import { createContext, useContext, useMemo } from 'react';
import { useSyncExternalStore } from 'use-sync-external-store/shim';
Expand Down Expand Up @@ -83,6 +83,16 @@ export const useCallActions = (): CallActionsType => {
return context.actions;
};

export const useCallerStatus = (): CallStates => {
const context = useContext(CallContext);

if (isCallContextReady(context)) {
return context.voipClient.callState;
}

return 'INITIAL';
};

export const useCallerInfo = (): VoIpCallerInfo => {
const context = useContext(CallContext);

Expand Down
32 changes: 29 additions & 3 deletions apps/meteor/client/sidebar/footer/SidebarFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import { CallStates } from '@rocket.chat/core-typings';
import { css } from '@rocket.chat/css-in-js';
import { Box, SidebarFooter as Footer } from '@rocket.chat/fuselage';
import { Box, Divider, SidebarFooter as Footer } from '@rocket.chat/fuselage';
import colors from '@rocket.chat/fuselage-tokens/colors.json';
import { useEndpoint, useTranslation } from '@rocket.chat/ui-contexts';
import React, { ReactElement } from 'react';
import { useQuery } from 'react-query';

import { settings } from '../../../app/settings/client';
import { useIsCallEnabled, useIsCallReady } from '../../contexts/CallContext';
import { useCallerStatus, useIsCallEnabled, useIsCallReady } from '../../contexts/CallContext';
import { VoipFooter } from './voip';

const SidebarFooter = (): ReactElement => {
Expand All @@ -20,15 +23,26 @@ const SidebarFooter = (): ReactElement => {
}
`;

const getLicenses = useEndpoint('GET', '/v1/licenses.get');
const { data, isSuccess } = useQuery(['licences'], () => getLicenses());

const t = useTranslation();

const isCallEnabled = useIsCallEnabled();
const ready = useIsCallReady();
const callerStatus = useCallerStatus();

if (isCallEnabled && ready) {
const activeCallStatus: CallStates[] = ['OFFER_RECEIVED', 'IN_CALL', 'ON_HOLD', 'ANSWER_SENT'];

if (activeCallStatus.includes(callerStatus) && isCallEnabled && ready) {
return <VoipFooter />;
}

const isCommunityEdition = isSuccess ? data?.licenses?.length === 0 : false;

return (
<Footer>
<Divider mbs={-2} mbe={0} borderColor={`${colors.n900}40`} />
<Box
is='footer'
pb='x12'
Expand All @@ -38,6 +52,18 @@ const SidebarFooter = (): ReactElement => {
className={sidebarFooterStyle}
dangerouslySetInnerHTML={{ __html: String(settings.get('Layout_Sidenav_Footer')).trim() }}
/>
{isCommunityEdition && (
<Box pi='x16' pbe='x8'>
<Box fontSize='x10' fontWeight={700} color={colors.n600} pbe='x4'>
<a href='https://rocket.chat/' target='_blank' rel='noopener noreferrer' style={{ textDecoration: 'none', color: 'inherit' }}>
{t('Powered_by_RocketChat')}
</a>
</Box>
<Box fontSize='x10' fontWeight={700} color={colors.n100} pbe='x4'>
{t('Free_Edition')}
</Box>
</Box>
)}
</Footer>
);
};
Expand Down
4 changes: 0 additions & 4 deletions apps/meteor/ee/server/api/licenses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ API.v1.addRoute(
{ authRequired: true },
{
get() {
if (!hasPermission(this.userId, 'view-privileged-setting')) {
return API.v1.unauthorized();
}

const licenses = getLicenses()
.filter(({ valid }) => valid)
.map(({ license }) => licenseTransform(license));
Expand Down
2 changes: 2 additions & 0 deletions apps/meteor/packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -986,6 +986,7 @@
"Comment": "Comment",
"Common_Access": "Common Access",
"Community": "Community",
"Free_Edition": "Free edition",
"Compact": "Compact",
"Composer_not_available_phone_calls": "Messages are not available on phone calls",
"Condensed": "Condensed",
Expand Down Expand Up @@ -3954,6 +3955,7 @@
"seconds": "seconds",
"Secret_token": "Secret Token",
"Security": "Security",
"Powered_by_RocketChat": "Powered by Rocket.Chat",
"See_full_profile": "See full profile",
"Select_a_department": "Select a department",
"Select_a_room": "Select a room",
Expand Down