2021-05-18 04:25:07 +08:00
|
|
|
import React, { useContext } from 'react';
|
2019-05-17 04:11:10 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2022-02-15 23:54:55 +08:00
|
|
|
import { withModalMounter } from '/imports/ui/components/common/modal/service';
|
2021-10-16 03:07:13 +08:00
|
|
|
import Service from '/imports/ui/components/captions/service';
|
2019-05-17 04:11:10 +08:00
|
|
|
import WriterMenu from './component';
|
2021-09-11 04:48:52 +08:00
|
|
|
import { layoutDispatch } from '../../layout/context';
|
2021-09-02 03:54:09 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import { UsersContext } from '/imports/ui/components/components-data/users-context/context';
|
|
|
|
|
|
|
|
const ROLE_MODERATOR = Meteor.settings.public.user.role_moderator;
|
2019-05-17 04:11:10 +08:00
|
|
|
|
2021-05-18 04:25:07 +08:00
|
|
|
const WriterMenuContainer = (props) => {
|
2021-09-11 04:48:52 +08:00
|
|
|
const layoutContextDispatch = layoutDispatch();
|
2021-09-10 21:16:44 +08:00
|
|
|
|
2021-09-02 03:54:09 +08:00
|
|
|
const usingUsersContext = useContext(UsersContext);
|
|
|
|
const { users } = usingUsersContext;
|
|
|
|
const currentUser = users[Auth.meetingID][Auth.userID];
|
|
|
|
const amIModerator = currentUser.role === ROLE_MODERATOR;
|
|
|
|
|
|
|
|
return amIModerator && <WriterMenu {...{ layoutContextDispatch, ...props }} />;
|
2021-05-18 04:25:07 +08:00
|
|
|
};
|
2019-05-17 04:11:10 +08:00
|
|
|
|
|
|
|
export default withModalMounter(withTracker(({ mountModal }) => ({
|
|
|
|
closeModal: () => mountModal(null),
|
2021-10-16 03:07:13 +08:00
|
|
|
availableLocales: Service.getAvailableLocales(),
|
2019-05-17 04:11:10 +08:00
|
|
|
}))(WriterMenuContainer));
|