2022-02-23 01:41:16 +08:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import { defineMessages, injectIntl } from 'react-intl';
|
2023-11-28 19:14:22 +08:00
|
|
|
import { LAYOUT_TYPE, CAMERADOCK_POSITION, HIDDEN_LAYOUTS } from '/imports/ui/components/layout/enums';
|
2022-02-23 01:41:16 +08:00
|
|
|
import SettingsService from '/imports/ui/components/settings/service';
|
2022-03-15 22:54:33 +08:00
|
|
|
import deviceInfo from '/imports/utils/deviceInfo';
|
2022-03-10 05:28:12 +08:00
|
|
|
import Button from '/imports/ui/components/common/button/component';
|
2024-09-09 19:48:07 +08:00
|
|
|
import Toggle from '/imports/ui/components/common/switch/component';
|
2022-03-15 22:54:33 +08:00
|
|
|
import Styled from './styles';
|
2022-02-23 01:41:16 +08:00
|
|
|
|
2024-06-11 21:05:08 +08:00
|
|
|
const LayoutModalComponent = ({
|
|
|
|
intl,
|
|
|
|
setIsOpen,
|
|
|
|
isModerator = false,
|
|
|
|
isPresenter,
|
|
|
|
application,
|
|
|
|
updateSettings,
|
|
|
|
onRequestClose,
|
|
|
|
isOpen,
|
|
|
|
setLocalSettings,
|
|
|
|
}) => {
|
2022-02-23 01:41:16 +08:00
|
|
|
const [selectedLayout, setSelectedLayout] = useState(application.selectedLayout);
|
2024-09-09 19:48:07 +08:00
|
|
|
const [keepPushingLayout, setKeepPushingLayout] = useState(application.pushLayout);
|
2022-02-23 01:41:16 +08:00
|
|
|
|
2024-03-18 21:36:08 +08:00
|
|
|
const BASE_NAME = window.meetingClientSettings.public.app.cdn + window.meetingClientSettings.public.app.basename;
|
2022-03-15 22:54:33 +08:00
|
|
|
|
2023-03-31 04:00:41 +08:00
|
|
|
const LAYOUTS_PATH = `${BASE_NAME}/resources/images/layouts/`;
|
2022-02-23 01:41:16 +08:00
|
|
|
const isKeepPushingLayoutEnabled = SettingsService.isKeepPushingLayoutEnabled();
|
|
|
|
|
|
|
|
const intlMessages = defineMessages({
|
|
|
|
title: {
|
|
|
|
id: 'app.layout.modal.title',
|
|
|
|
description: 'Modal title',
|
|
|
|
},
|
2023-07-07 20:53:58 +08:00
|
|
|
update: {
|
|
|
|
id: 'app.layout.modal.update',
|
2022-02-23 01:41:16 +08:00
|
|
|
description: 'Modal confirm button',
|
|
|
|
},
|
2023-07-07 20:53:58 +08:00
|
|
|
updateAll: {
|
|
|
|
id: 'app.layout.modal.updateAll',
|
|
|
|
description: 'Modal updateAll button',
|
2022-02-23 01:41:16 +08:00
|
|
|
},
|
|
|
|
layoutLabel: {
|
|
|
|
id: 'app.layout.modal.layoutLabel',
|
|
|
|
description: 'Layout label',
|
|
|
|
},
|
2024-03-19 02:33:37 +08:00
|
|
|
layoutToastLabelAuto: {
|
|
|
|
id: 'app.layout.modal.layoutToastLabelAuto',
|
|
|
|
description: 'Layout toast label',
|
|
|
|
},
|
|
|
|
layoutToastLabelAutoOff: {
|
|
|
|
id: 'app.layout.modal.layoutToastLabelAutoOff',
|
|
|
|
description: 'Layout toast label',
|
|
|
|
},
|
2022-02-23 01:41:16 +08:00
|
|
|
layoutToastLabel: {
|
|
|
|
id: 'app.layout.modal.layoutToastLabel',
|
|
|
|
description: 'Layout toast label',
|
|
|
|
},
|
|
|
|
customLayout: {
|
|
|
|
id: 'app.layout.style.custom',
|
|
|
|
description: 'label for custom layout style',
|
|
|
|
},
|
|
|
|
smartLayout: {
|
|
|
|
id: 'app.layout.style.smart',
|
|
|
|
description: 'label for smart layout style',
|
|
|
|
},
|
|
|
|
presentationFocusLayout: {
|
|
|
|
id: 'app.layout.style.presentationFocus',
|
|
|
|
description: 'label for presentationFocus layout style',
|
|
|
|
},
|
|
|
|
videoFocusLayout: {
|
|
|
|
id: 'app.layout.style.videoFocus',
|
|
|
|
description: 'label for videoFocus layout style',
|
|
|
|
},
|
2022-09-29 21:20:38 +08:00
|
|
|
layoutSingular: {
|
|
|
|
id: 'app.layout.modal.layoutSingular',
|
|
|
|
description: 'label for singular layout',
|
|
|
|
},
|
2022-09-29 22:46:49 +08:00
|
|
|
layoutBtnDesc: {
|
|
|
|
id: 'app.layout.modal.layoutBtnDesc',
|
|
|
|
description: 'label for singular layout',
|
|
|
|
},
|
2024-09-09 19:48:07 +08:00
|
|
|
on: {
|
|
|
|
id: 'app.switch.onLabel',
|
|
|
|
description: 'label for toggle switch on state',
|
|
|
|
},
|
|
|
|
off: {
|
|
|
|
id: 'app.switch.offLabel',
|
|
|
|
description: 'label for toggle switch off state',
|
|
|
|
},
|
2022-02-23 01:41:16 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
const handleSwitchLayout = (e) => {
|
|
|
|
setSelectedLayout(e);
|
|
|
|
};
|
|
|
|
|
2024-09-09 19:48:07 +08:00
|
|
|
const handleUpdateLayout = () => {
|
2022-02-23 01:41:16 +08:00
|
|
|
const obj = {
|
|
|
|
application:
|
2024-09-09 19:48:07 +08:00
|
|
|
{ ...application, selectedLayout, pushLayout: keepPushingLayout },
|
2022-02-23 01:41:16 +08:00
|
|
|
};
|
2024-09-09 19:48:07 +08:00
|
|
|
if ((isModerator || isPresenter) && keepPushingLayout) {
|
2024-03-19 02:33:37 +08:00
|
|
|
updateSettings(obj, intlMessages.layoutToastLabelAuto);
|
2024-09-09 19:48:07 +08:00
|
|
|
} else if ((isModerator || isPresenter) && !keepPushingLayout) {
|
2024-03-19 02:33:37 +08:00
|
|
|
updateSettings(obj, intlMessages.layoutToastLabelAutoOff);
|
|
|
|
} else {
|
|
|
|
updateSettings(obj, intlMessages.layoutToastLabel);
|
|
|
|
}
|
2024-01-30 21:03:11 +08:00
|
|
|
updateSettings(obj, intlMessages.layoutToastLabel, setLocalSettings);
|
2023-03-22 01:55:43 +08:00
|
|
|
setIsOpen(false);
|
2022-02-23 01:41:16 +08:00
|
|
|
};
|
|
|
|
|
2024-09-09 19:48:07 +08:00
|
|
|
const toggleKeepPushingLayout = () => {
|
|
|
|
setKeepPushingLayout((current) => !current);
|
|
|
|
};
|
|
|
|
|
|
|
|
const displayToggleStatus = (toggleValue) => (
|
|
|
|
<Styled.ToggleLabel>
|
|
|
|
{toggleValue ? intl.formatMessage(intlMessages.on)
|
|
|
|
: intl.formatMessage(intlMessages.off)}
|
|
|
|
</Styled.ToggleLabel>
|
|
|
|
);
|
|
|
|
|
|
|
|
const renderToggle = () => (
|
|
|
|
<Styled.ToggleStatusWrapper>
|
|
|
|
{displayToggleStatus(keepPushingLayout)}
|
|
|
|
<Toggle
|
|
|
|
id="TogglePush"
|
|
|
|
icons={false}
|
|
|
|
defaultChecked={keepPushingLayout}
|
|
|
|
onChange={toggleKeepPushingLayout}
|
|
|
|
ariaLabel="push"
|
|
|
|
data-test="updateEveryoneLayoutToggle"
|
|
|
|
showToggleLabel={false}
|
|
|
|
/>
|
|
|
|
</Styled.ToggleStatusWrapper>
|
|
|
|
);
|
|
|
|
|
2022-02-23 01:41:16 +08:00
|
|
|
const renderPushLayoutsOptions = () => {
|
2023-03-04 05:59:47 +08:00
|
|
|
if (!isModerator && !isPresenter) {
|
2022-02-23 01:41:16 +08:00
|
|
|
return null;
|
|
|
|
}
|
2022-04-26 03:57:11 +08:00
|
|
|
|
2022-05-28 05:11:42 +08:00
|
|
|
if (isKeepPushingLayoutEnabled) {
|
2022-02-23 01:41:16 +08:00
|
|
|
return (
|
2024-09-09 19:48:07 +08:00
|
|
|
<Styled.PushContainer>
|
|
|
|
<Styled.LabelPushLayout>
|
|
|
|
{intl.formatMessage(intlMessages.updateAll)}
|
|
|
|
</Styled.LabelPushLayout>
|
|
|
|
{renderToggle()}
|
|
|
|
</Styled.PushContainer>
|
2022-02-23 01:41:16 +08:00
|
|
|
);
|
|
|
|
}
|
2022-03-09 00:48:48 +08:00
|
|
|
return null;
|
2022-02-23 01:41:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
const renderLayoutButtons = () => (
|
2022-03-15 22:54:33 +08:00
|
|
|
<Styled.ButtonsContainer>
|
|
|
|
{Object.values(LAYOUT_TYPE)
|
2023-11-28 19:14:22 +08:00
|
|
|
.filter((layout) => !HIDDEN_LAYOUTS.includes(layout))
|
2022-02-23 01:41:16 +08:00
|
|
|
.map((layout) => (
|
2022-03-15 22:54:33 +08:00
|
|
|
<Styled.ButtonLayoutContainer key={layout}>
|
|
|
|
<Styled.LayoutBtn
|
2024-10-03 21:23:21 +08:00
|
|
|
layout={layout}
|
2022-02-23 01:41:16 +08:00
|
|
|
label=""
|
2022-09-29 22:46:49 +08:00
|
|
|
customIcon={(
|
|
|
|
<Styled.IconSvg
|
|
|
|
src={`${LAYOUTS_PATH}${layout}.svg`}
|
|
|
|
alt={`${layout} ${intl.formatMessage(intlMessages.layoutSingular)}`}
|
|
|
|
/>
|
2023-11-24 15:07:41 +08:00
|
|
|
)}
|
2023-06-27 23:47:59 +08:00
|
|
|
onClick={() => {
|
|
|
|
handleSwitchLayout(layout);
|
|
|
|
if (layout === LAYOUT_TYPE.CUSTOM_LAYOUT && application.selectedLayout !== layout) {
|
|
|
|
document.getElementById('layout')?.setAttribute('data-cam-position', CAMERADOCK_POSITION.CONTENT_TOP);
|
|
|
|
}
|
|
|
|
}}
|
2022-03-15 22:54:33 +08:00
|
|
|
active={(layout === selectedLayout).toString()}
|
2022-09-29 22:46:49 +08:00
|
|
|
aria-describedby="layout-btn-desc"
|
2023-01-24 01:31:01 +08:00
|
|
|
data-test={`${layout}Layout`}
|
2022-02-23 01:41:16 +08:00
|
|
|
/>
|
2024-10-03 21:23:21 +08:00
|
|
|
<Styled.LabelLayoutNames
|
|
|
|
layout={layout}
|
|
|
|
aria-hidden>{intl.formatMessage(intlMessages[`${layout}Layout`])}
|
|
|
|
</Styled.LabelLayoutNames>
|
2022-03-15 22:54:33 +08:00
|
|
|
</Styled.ButtonLayoutContainer>
|
2022-02-23 01:41:16 +08:00
|
|
|
))}
|
2022-03-15 22:54:33 +08:00
|
|
|
</Styled.ButtonsContainer>
|
2022-02-23 01:41:16 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
return (
|
2022-03-15 22:54:33 +08:00
|
|
|
<Styled.LayoutModal
|
|
|
|
contentLabel={intl.formatMessage(intlMessages.title)}
|
|
|
|
shouldShowCloseButton
|
|
|
|
shouldCloseOnOverlayClick
|
|
|
|
isPhone={deviceInfo.isPhone}
|
|
|
|
data-test="layoutChangeModal"
|
2023-03-22 01:55:43 +08:00
|
|
|
onRequestClose={() => setIsOpen(false)}
|
2022-11-11 02:09:21 +08:00
|
|
|
title={intl.formatMessage(intlMessages.title)}
|
2023-04-12 23:51:23 +08:00
|
|
|
{...{
|
|
|
|
isOpen,
|
|
|
|
onRequestClose,
|
|
|
|
}}
|
2022-02-23 01:41:16 +08:00
|
|
|
>
|
2022-03-15 22:54:33 +08:00
|
|
|
<Styled.Content>
|
|
|
|
<Styled.BodyContainer>
|
2022-02-23 01:41:16 +08:00
|
|
|
{renderLayoutButtons()}
|
2022-03-15 22:54:33 +08:00
|
|
|
</Styled.BodyContainer>
|
|
|
|
</Styled.Content>
|
|
|
|
<Styled.ButtonBottomContainer>
|
2023-07-07 20:53:58 +08:00
|
|
|
{renderPushLayoutsOptions()}
|
2022-03-15 22:54:33 +08:00
|
|
|
<Button
|
|
|
|
color="primary"
|
2023-07-07 20:53:58 +08:00
|
|
|
label={intl.formatMessage(intlMessages.update)}
|
2024-09-09 19:48:07 +08:00
|
|
|
onClick={() => handleUpdateLayout()}
|
2023-07-11 03:28:00 +08:00
|
|
|
data-test="updateLayoutBtn"
|
2022-03-15 22:54:33 +08:00
|
|
|
/>
|
|
|
|
</Styled.ButtonBottomContainer>
|
2022-09-29 22:46:49 +08:00
|
|
|
<div style={{ display: 'none' }} id="layout-btn-desc">{intl.formatMessage(intlMessages.layoutBtnDesc)}</div>
|
2022-03-15 22:54:33 +08:00
|
|
|
</Styled.LayoutModal>
|
2022-02-23 01:41:16 +08:00
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
intl: PropTypes.shape({
|
|
|
|
formatMessage: PropTypes.func.isRequired,
|
|
|
|
}).isRequired,
|
2024-02-17 04:32:14 +08:00
|
|
|
isModerator: PropTypes.bool,
|
2022-02-23 01:41:16 +08:00
|
|
|
isPresenter: PropTypes.bool.isRequired,
|
|
|
|
application: PropTypes.shape({
|
|
|
|
selectedLayout: PropTypes.string.isRequired,
|
|
|
|
}).isRequired,
|
|
|
|
updateSettings: PropTypes.func.isRequired,
|
2024-01-30 21:03:11 +08:00
|
|
|
setLocalSettings: PropTypes.func.isRequired,
|
2022-02-23 01:41:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
LayoutModalComponent.propTypes = propTypes;
|
|
|
|
|
2023-03-22 01:55:43 +08:00
|
|
|
export default injectIntl(LayoutModalComponent);
|