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

feat: added feature toggle #1013

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
6 changes: 3 additions & 3 deletions src/components/app/NavigationBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import {
ConsultingTypesContext,
SessionsDataContext,
SET_SESSIONS,
TenantContext,
LocaleContext
LocaleContext,
useTenant
} from '../../globalState';
import { initNavigationHandler } from './navigationHandler';
import { ReactComponent as LogoutIconOutline } from '../../resources/img/icons/logout_outline.svg';
Expand Down Expand Up @@ -62,7 +62,7 @@ export const NavigationBar = ({
group: unreadGroup,
teamsessions: unreadTeamSessions
} = useContext(RocketChatUnreadContext);
const { tenant } = useContext(TenantContext);
const tenant = useTenant();

const ref_menu = useRef<any>([]);
const ref_local = useRef<any>();
Expand Down
16 changes: 0 additions & 16 deletions src/components/app/TenantThemingLoader.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions src/components/app/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { ContextProvider } from '../../globalState/state';
import { WebsocketHandler } from './WebsocketHandler';
import ErrorBoundary from './ErrorBoundary';
import { LanguagesProvider } from '../../globalState/provider/LanguagesProvider';
import { TenantThemingLoader } from './TenantThemingLoader';
import {
AppConfigProvider,
InformalProvider,
Expand Down Expand Up @@ -137,7 +136,6 @@ const RouterWrapper = ({ extraRoutes }: RouterWrapperProps) => {
)}
<Route>
<ContextProvider>
<TenantThemingLoader />
{startWebsocket && (
<WebsocketHandler
disconnect={disconnectWebsocket}
Expand Down
6 changes: 3 additions & 3 deletions src/components/askerInfo/AskerInfoContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import {
AUTHORITIES,
hasUserAuthority,
SessionTypeContext,
TenantContext,
UserDataContext,
ActiveSessionContext
ActiveSessionContext,
useTenant
} from '../../globalState';
import { AskerInfoData } from './AskerInfoData';
import { AskerInfoAssign } from './AskerInfoAssign';
Expand All @@ -17,7 +17,7 @@ import { AskerInfoTools } from './AskerInfoTools';
import { Box } from '../box/Box';

export const AskerInfoContent = () => {
const { tenant } = useContext(TenantContext);
const tenant = useTenant();
const { activeSession } = useContext(ActiveSessionContext);
const { userData } = useContext(UserDataContext);

Expand Down
16 changes: 10 additions & 6 deletions src/components/error/Error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import { ReactComponent as Icon401 } from '../../resources/img/illustrations/una
import { ReactComponent as Icon404 } from '../../resources/img/illustrations/not-found.svg';
import { ReactComponent as Icon500 } from '../../resources/img/illustrations/internal-server-error.svg';
import { Button, BUTTON_TYPES } from '../button/Button';
import useTenantTheming from '../../utils/useTenantTheming';
import '../../resources/styles/styles';
import './error.styles';
import { useTranslation } from 'react-i18next';
import { LocaleSwitch } from '../localeSwitch/LocaleSwitch';
import { useAppConfig } from '../../hooks/useAppConfig';
import { LocaleProvider, AppConfigProvider } from '../../globalState';
import {
LocaleProvider,
AppConfigProvider,
TenantProvider
} from '../../globalState';
import { AppConfigInterface } from '../../globalState/interfaces';
import { useResponsive } from '../../hooks/useResponsive';

Expand All @@ -27,15 +30,16 @@ type ErrorProps = {

export const Error = ({ config }: ErrorProps) => (
<AppConfigProvider config={config}>
<LocaleProvider>
<ErrorContent />
</LocaleProvider>
<TenantProvider>
<LocaleProvider>
<ErrorContent />
</LocaleProvider>
</TenantProvider>
</AppConfigProvider>
);

export const ErrorContent = () => {
const { t: translate } = useTranslation();
useTenantTheming();
const settings = useAppConfig();
const statusCode = getStatusCode();
const { fromL } = useResponsive();
Expand Down
5 changes: 2 additions & 3 deletions src/components/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import * as React from 'react';
import { Headline } from '../headline/Headline';
import { Text } from '../text/Text';
import { useContext } from 'react';
import { TenantContext } from '../../globalState';
import { useTenant } from '../../globalState';
import './header.styles';
import { useTranslation } from 'react-i18next';
import { LocaleSwitch } from '../localeSwitch/LocaleSwitch';

export const Header = ({ showLocaleSwitch = false }) => {
const { t: translate } = useTranslation();
const { tenant } = useContext(TenantContext);
const tenant = useTenant();

return (
<header className="header">
Expand Down
3 changes: 1 addition & 2 deletions src/components/login/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {
AUTHORITIES,
hasUserAuthority,
RocketChatGlobalSettingsContext,
TenantContext,
UserDataContext,
LocaleContext,
useTenant
Expand Down Expand Up @@ -76,7 +75,7 @@ export const Login = () => {
const tenantData = useTenant();

const { locale, initLocale } = useContext(LocaleContext);
const { tenant } = useContext(TenantContext);
const tenant = useTenant();
const { getSetting } = useContext(RocketChatGlobalSettingsContext);
const { userData, reloadUserData } = useContext(UserDataContext);
const { Stage } = useContext(GlobalComponentContext);
Expand Down
6 changes: 3 additions & 3 deletions src/components/registration/RegistrationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { redirectToApp } from './autoLogin';
import {
NOTIFICATION_TYPE_ERROR,
NotificationsContext,
TenantContext,
useLocaleData
useLocaleData,
useTenant
} from '../../globalState';
import {
AgencyDataInterface,
Expand Down Expand Up @@ -88,7 +88,7 @@ export const RegistrationForm = () => {
string[]
>([]);

const { tenant } = useContext(TenantContext);
const tenant = useTenant();
const { featureToolsEnabled } = getTenantSettings();

// Logout from budibase
Expand Down
1 change: 1 addition & 0 deletions src/globalState/interfaces/TenantDataInterface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export interface TenantDataSettingsInterface {
activeLanguages: string[];
featureAppointmentsEnabled: boolean;
featureDemographicsEnabled: boolean;
featureCounsellingRelationsEnabled: boolean;
featureGroupChatV2Enabled: boolean;
featureStatisticsEnabled: boolean;
featureToolsEnabled: boolean;
Expand Down
5 changes: 1 addition & 4 deletions src/globalState/provider/LocaleProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import { InformalContext } from './InformalProvider';
import { useAppConfig } from '../../hooks/useAppConfig';
import { setValueInCookie } from '../../components/sessionCookie/accessSessionCookie';
import { useTenant } from './TenantProvider';
import useTenantTheming from '../../utils/useTenantTheming';
import { LocaleContext, TLocaleContext } from '../context/LocaleContext';

export const STORAGE_KEY_LOCALE = 'locale';

export function LocaleProvider(props) {
const settings = useAppConfig();
const isLoading = useTenantTheming();
const tenant = useTenant();
const [initialized, setInitialized] = useState(false);
const [initLocale, setInitLocale] = useState(null);
Expand All @@ -23,7 +21,7 @@ export function LocaleProvider(props) {
useEffect(() => {
// If using the tenant service we should load first the tenant because we need the
// active languages from the server to apply it on loading
if ((settings.useTenantService && isLoading) || initialized) {
if (initialized) {
return;
}

Expand Down Expand Up @@ -58,7 +56,6 @@ export function LocaleProvider(props) {
});
}, [
initialized,
isLoading,
settings.i18n,
settings.translation,
settings.useTenantService,
Expand Down
Loading
Loading