Service import moved to container

This commit is contained in:
Diego Benetti 2019-04-12 16:01:31 -03:00
parent 6648b622be
commit aa5cdb64d1
2 changed files with 19 additions and 17 deletions

View File

@ -11,7 +11,6 @@ import DropdownList from '/imports/ui/components/dropdown/list/component';
import DropdownListItem from '/imports/ui/components/dropdown/list/item/component';
import LockViewersContainer from '/imports/ui/components/lock-viewers/container';
import BreakoutRoom from '/imports/ui/components/actions-bar/create-breakout-room/component';
import userListService from '/imports/ui/components/user-list/service';
import { styles } from './styles';
const propTypes = {
@ -94,21 +93,6 @@ const intlMessages = defineMessages({
});
class UserOptions extends PureComponent {
static onSaveUserNames() {
const link = document.createElement('a');
const mimeType = 'text/plain';
const userNamesObj = userListService.getUsers();
const userNameListString = Object.keys(userNamesObj)
.map(key => userNamesObj[key].name, []).join('\r\n');
link.setAttribute('download', `save-users-list-${Date.now()}.txt`);
link.setAttribute(
'href',
`data: ${mimeType} ;charset=utf-8,${userNameListString}`,
);
link.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }));
}
constructor(props) {
super(props);
@ -129,6 +113,22 @@ class UserOptions extends PureComponent {
this.onCreateBreakouts = this.onCreateBreakouts.bind(this);
this.onInvitationUsers = this.onInvitationUsers.bind(this);
this.renderMenuItems = this.renderMenuItems.bind(this);
this.onSaveUserNames = this.onSaveUserNames.bind(this);
}
onSaveUserNames() {
const link = document.createElement('a');
const mimeType = 'text/plain';
const { userListService } = this.props;
const userNamesObj = userListService.getUsers();
const userNameListString = Object.keys(userNamesObj)
.map(key => userNamesObj[key].name, []).join('\r\n');
link.setAttribute('download', `save-users-list-${Date.now()}.txt`);
link.setAttribute(
'href',
`data: ${mimeType} ;charset=utf-16,${encodeURIComponent(userNameListString)}`,
);
link.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }));
}
onActionsShow() {
@ -259,7 +259,7 @@ class UserOptions extends PureComponent {
icon="download"
label={intl.formatMessage(intlMessages.saveUserNames)}
key={this.saveUsersNameId}
onClick={UserOptions.onSaveUserNames}
onClick={this.onSaveUserNames}
/>
)
: null),

View File

@ -2,6 +2,7 @@ import { withTracker } from 'meteor/react-meteor-data';
import PropTypes from 'prop-types';
import Auth from '/imports/ui/services/auth';
import Service from '/imports/ui/components/actions-bar/service';
import userListService from '/imports/ui/components/user-list/service';
import UserOptions from './component';
const propTypes = {
@ -39,6 +40,7 @@ const UserOptionsContainer = withTracker((props) => {
getBreakouts: Service.getBreakouts,
sendInvitation: Service.sendInvitation,
getUsersNotAssigned: Service.getUsersNotAssigned,
userListService,
};
})(UserOptions);