[IMPROVEMENT] Move toggle and inquiry to Enterprise
This commit is contained in:
parent
7f7bab8e03
commit
6c11015a63
|
@ -0,0 +1,43 @@
|
|||
The Rocket.Chat Enterprise Edition (EE) license (the "EE License")
|
||||
Copyright (c) 2015-2020 Rocket.Chat Technologies Corp.
|
||||
|
||||
With regard to the Rocket.Chat Software:
|
||||
|
||||
This software and associated documentation files (the "Software") may only be
|
||||
used in production, if you (and any entity that you represent) have agreed to,
|
||||
and are in compliance with, the Rocket.Chat Subscription Terms of Service,
|
||||
available at https://rocket.chat/terms (the "EE Terms"), or other agreement
|
||||
governing the use of the Software, as agreed by you and Rocket.Chat, and otherwise
|
||||
have a valid Rocket.Chat Enterprise Edition subscription for the correct number
|
||||
of user seats. Subject to the foregoing sentence, you are free to modify this
|
||||
Software and publish patches to the Software. You agree that Rocket.Chat and/or
|
||||
its licensors (as applicable) retain all right, title and interest in and to all
|
||||
such modifications and/or patches, and all such modifications and/or patches may
|
||||
only be used, copied, modified, displayed, distributed, or otherwise exploited
|
||||
with a valid Rocket.Chat Enterprise Edition subscription for the correct number
|
||||
of user seats. Notwithstanding the foregoing, you may copy and modify the Software
|
||||
for development and testing purposes, without requiring a Subscription. You agree
|
||||
that Rocket.Chat and/or its licensors (as applicable) retain all right, title and
|
||||
interest in and to all such modifications. You are not granted any other rights
|
||||
beyond what is expressly stated herein. Subject to the foregoing, it is forbidden
|
||||
to copy, merge, publish, distribute, sublicense, and/or sell the Software.
|
||||
|
||||
This EE License applies only to the part of this Software that is not distributed
|
||||
as part of Rocket.Chat Community Edition (CE). Any part of this Software distributed
|
||||
as part of Rocket.Chat CE or is served client-side as an image, font, cascading
|
||||
stylesheet (CSS), file which produces or is compiled, arranged, augmented, or combined
|
||||
into client-side JavaScript, in whole or in part, is copyrighted under the MIT Expat
|
||||
license. The full text of this EE License shall be included in all copies or substantial
|
||||
portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
For all third-party components incorporated into the Rocket.Chat Software,
|
||||
those components are licensed under the original license provided by the owner
|
||||
of the applicable component.
|
|
@ -1,4 +1,4 @@
|
|||
import * as types from './actionsTypes';
|
||||
import * as types from '../../../actions/actionsTypes';
|
||||
|
||||
export function inquirySetEnabled(enabled) {
|
||||
return {
|
|
@ -7,11 +7,12 @@ import PropTypes from 'prop-types';
|
|||
import Touch from '../../../utils/touch';
|
||||
import { CustomIcon } from '../../../lib/Icons';
|
||||
import I18n from '../../../i18n';
|
||||
import styles from '../styles';
|
||||
import styles from '../../../views/RoomsListView/styles';
|
||||
import { themes, SWITCH_TRACK_COLOR } from '../../../constants/colors';
|
||||
import { withTheme } from '../../../theme';
|
||||
import UnreadBadge from '../../../presentation/UnreadBadge';
|
||||
import RocketChat from '../../../lib/rocketchat';
|
||||
import { isOmnichannelStatusAvailable, changeLivechatStatus } from '../lib';
|
||||
|
||||
const OmnichannelStatus = memo(({
|
||||
searching, goQueue, theme, queueSize, inquiryEnabled, user
|
||||
|
@ -19,16 +20,16 @@ const OmnichannelStatus = memo(({
|
|||
if (searching > 0 || !(RocketChat.isOmnichannelModuleAvailable() && user?.roles?.includes('livechat-agent'))) {
|
||||
return null;
|
||||
}
|
||||
const [status, setStatus] = useState(user?.statusLivechat === 'available');
|
||||
const [status, setStatus] = useState(isOmnichannelStatusAvailable(user));
|
||||
|
||||
useEffect(() => {
|
||||
setStatus(user.statusLivechat === 'available');
|
||||
setStatus(isOmnichannelStatusAvailable(user));
|
||||
}, [user.statusLivechat]);
|
||||
|
||||
const toggleLivechat = async() => {
|
||||
try {
|
||||
setStatus(v => !v);
|
||||
await RocketChat.changeLivechatStatus();
|
||||
await changeLivechatStatus();
|
||||
} catch {
|
||||
setStatus(v => !v);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
import RocketChat from '../../../lib/rocketchat';
|
||||
|
||||
export const isOmnichannelStatusAvailable = user => user?.statusLivechat === 'available';
|
||||
|
||||
// RC 0.26.0
|
||||
export const changeLivechatStatus = () => RocketChat.methodCallWrapper('livechat:changeLivechatStatus');
|
||||
|
||||
// RC 2.4.0
|
||||
export const getInquiriesQueued = () => RocketChat.sdk.get('livechat/inquiries.queued');
|
||||
|
||||
// this inquiry is added to the db by the subscriptions stream
|
||||
// and will be removed by the queue stream
|
||||
// RC 2.4.0
|
||||
export const takeInquiry = inquiryId => RocketChat.methodCallWrapper('livechat:takeInquiry', inquiryId);
|
|
@ -1,4 +1,4 @@
|
|||
import { INQUIRY } from '../actions/actionsTypes';
|
||||
import { INQUIRY } from '../../../actions/actionsTypes';
|
||||
|
||||
const initialState = {
|
||||
enabled: false,
|
|
@ -1,19 +1,20 @@
|
|||
import { put, takeLatest, select } from 'redux-saga/effects';
|
||||
|
||||
import * as types from '../actions/actionsTypes';
|
||||
import RocketChat from '../lib/rocketchat';
|
||||
import * as types from '../../../actions/actionsTypes';
|
||||
import RocketChat from '../../../lib/rocketchat';
|
||||
import { inquirySuccess, inquiryFailure, inquirySetEnabled } from '../actions/inquiry';
|
||||
import { isOmnichannelStatusAvailable, getInquiriesQueued } from '../lib';
|
||||
|
||||
const handleRequest = function* handleRequest() {
|
||||
try {
|
||||
const routingConfig = yield RocketChat.getRoutingConfig();
|
||||
const statusLivechat = yield select(state => state.login.user.statusLivechat);
|
||||
const user = yield select(state => state.login.user);
|
||||
// if routingConfig showQueue is enabled and omnichannel is enabled
|
||||
const showQueue = routingConfig.showQueue && statusLivechat === 'available';
|
||||
const showQueue = routingConfig.showQueue && isOmnichannelStatusAvailable(user);
|
||||
|
||||
if (showQueue) {
|
||||
// get all the current chats on the queue
|
||||
const result = yield RocketChat.getInquiriesQueued();
|
||||
const result = yield getInquiriesQueued();
|
||||
if (result.success) {
|
||||
const { inquiries } = result;
|
||||
|
|
@ -4,20 +4,20 @@ import { FlatList } from 'react-native';
|
|||
import { connect } from 'react-redux';
|
||||
import isEqual from 'react-fast-compare';
|
||||
|
||||
import I18n from '../i18n';
|
||||
import RoomItem, { ROW_HEIGHT } from '../presentation/RoomItem';
|
||||
import { MAX_SIDEBAR_WIDTH } from '../constants/tablet';
|
||||
import { isTablet, isIOS } from '../utils/deviceInfo';
|
||||
import { getUserSelector } from '../selectors/login';
|
||||
import { withTheme } from '../theme';
|
||||
import { withDimensions } from '../dimensions';
|
||||
import SafeAreaView from '../containers/SafeAreaView';
|
||||
import { themes } from '../constants/colors';
|
||||
import StatusBar from '../containers/StatusBar';
|
||||
import { goRoom } from '../utils/goRoom';
|
||||
import { CloseModalButton } from '../containers/HeaderButton';
|
||||
import RocketChat from '../lib/rocketchat';
|
||||
import { logEvent, events } from '../utils/log';
|
||||
import I18n from '../../../i18n';
|
||||
import RoomItem, { ROW_HEIGHT } from '../../../presentation/RoomItem';
|
||||
import { MAX_SIDEBAR_WIDTH } from '../../../constants/tablet';
|
||||
import { isTablet, isIOS } from '../../../utils/deviceInfo';
|
||||
import { getUserSelector } from '../../../selectors/login';
|
||||
import { withTheme } from '../../../theme';
|
||||
import { withDimensions } from '../../../dimensions';
|
||||
import SafeAreaView from '../../../containers/SafeAreaView';
|
||||
import { themes } from '../../../constants/colors';
|
||||
import StatusBar from '../../../containers/StatusBar';
|
||||
import { goRoom } from '../../../utils/goRoom';
|
||||
import { CloseModalButton } from '../../../containers/HeaderButton';
|
||||
import RocketChat from '../../../lib/rocketchat';
|
||||
import { logEvent, events } from '../../../utils/log';
|
||||
import { getInquiryQueueSelector } from '../selectors/inquiry';
|
||||
|
||||
const INITIAL_NUM_TO_RENDER = isTablet ? 20 : 12;
|
|
@ -6,7 +6,7 @@ import {
|
|||
inquiryQueueAdd,
|
||||
inquiryQueueUpdate,
|
||||
inquiryQueueRemove
|
||||
} from '../../../actions/inquiry';
|
||||
} from '../../../ee/omnichannel/actions/inquiry';
|
||||
|
||||
const removeListener = listener => listener.stop();
|
||||
|
||||
|
|
|
@ -853,20 +853,6 @@ const RocketChat = {
|
|||
// RC 2.2.0
|
||||
return this.sdk.get('livechat/custom-fields');
|
||||
},
|
||||
changeLivechatStatus() {
|
||||
// RC 0.26.0
|
||||
return this.methodCallWrapper('livechat:changeLivechatStatus');
|
||||
},
|
||||
getInquiriesQueued() {
|
||||
// RC 2.4.0
|
||||
return this.sdk.get('livechat/inquiries.queued');
|
||||
},
|
||||
takeInquiry(inquiryId) {
|
||||
// this inquiry is added to the db by the subscriptions stream
|
||||
// and will be removed by the queue stream
|
||||
// RC 2.4.0
|
||||
return this.methodCallWrapper('livechat:takeInquiry', inquiryId);
|
||||
},
|
||||
|
||||
getUidDirectMessage(room) {
|
||||
const { id: userId } = reduxStore.getState().login.user;
|
||||
|
|
|
@ -16,7 +16,7 @@ import activeUsers from './activeUsers';
|
|||
import usersTyping from './usersTyping';
|
||||
import inviteLinks from './inviteLinks';
|
||||
import createDiscussion from './createDiscussion';
|
||||
import inquiry from './inquiry';
|
||||
import inquiry from '../ee/omnichannel/reducers/inquiry';
|
||||
import enterpriseModules from './enterpriseModules';
|
||||
|
||||
export default combineReducers({
|
||||
|
|
|
@ -10,7 +10,7 @@ import state from './state';
|
|||
import deepLinking from './deepLinking';
|
||||
import inviteLinks from './inviteLinks';
|
||||
import createDiscussion from './createDiscussion';
|
||||
import inquiry from './inquiry';
|
||||
import inquiry from '../ee/omnichannel/sagas/inquiry';
|
||||
|
||||
const root = function* root() {
|
||||
yield all([
|
||||
|
|
|
@ -14,7 +14,7 @@ import {
|
|||
loginFailure, loginSuccess, setUser, logout
|
||||
} from '../actions/login';
|
||||
import { roomsRequest } from '../actions/rooms';
|
||||
import { inquiryRequest, inquiryReset } from '../actions/inquiry';
|
||||
import { inquiryRequest, inquiryReset } from '../ee/omnichannel/actions/inquiry';
|
||||
import { toMomentLocale } from '../utils/moment';
|
||||
import RocketChat from '../lib/rocketchat';
|
||||
import log, { logEvent, events } from '../utils/log';
|
||||
|
@ -26,6 +26,7 @@ import { showErrorAlert } from '../utils/info';
|
|||
import { localAuthenticate } from '../utils/localAuthentication';
|
||||
import { setActiveUsers } from '../actions/activeUsers';
|
||||
import UserPreferences from '../lib/userPreferences';
|
||||
import { isOmnichannelStatusAvailable } from '../ee/omnichannel/lib';
|
||||
|
||||
const getServer = state => state.server.server;
|
||||
const loginWithPasswordCall = args => RocketChat.loginWithPassword(args);
|
||||
|
@ -88,7 +89,7 @@ const fetchUsersPresence = function* fetchUserPresence() {
|
|||
const fetchEnterpriseModules = function* fetchEnterpriseModules({ user }) {
|
||||
yield RocketChat.getEnterpriseModules();
|
||||
|
||||
if (user && user.statusLivechat === 'available' && RocketChat.isOmnichannelModuleAvailable()) {
|
||||
if (isOmnichannelStatusAvailable(user) && RocketChat.isOmnichannelModuleAvailable()) {
|
||||
yield put(inquiryRequest());
|
||||
}
|
||||
};
|
||||
|
@ -219,7 +220,7 @@ const handleSetUser = function* handleSetUser({ user }) {
|
|||
}
|
||||
|
||||
if (user?.statusLivechat && RocketChat.isOmnichannelModuleAvailable()) {
|
||||
if (user.statusLivechat === 'available') {
|
||||
if (isOmnichannelStatusAvailable(user)) {
|
||||
yield put(inquiryRequest());
|
||||
} else {
|
||||
yield put(inquiryReset());
|
||||
|
|
|
@ -18,7 +18,7 @@ import I18n from '../i18n';
|
|||
import { BASIC_AUTH_KEY, setBasicAuth } from '../utils/fetch';
|
||||
import { appStart, ROOT_INSIDE, ROOT_OUTSIDE } from '../actions/app';
|
||||
import UserPreferences from '../lib/userPreferences';
|
||||
import { inquiryReset } from '../actions/inquiry';
|
||||
import { inquiryReset } from '../ee/omnichannel/actions/inquiry';
|
||||
|
||||
const getServerInfo = function* getServerInfo({ server, raiseError = true }) {
|
||||
try {
|
||||
|
|
|
@ -30,7 +30,7 @@ import PickerView from '../views/PickerView';
|
|||
import ThreadMessagesView from '../views/ThreadMessagesView';
|
||||
import MarkdownTableView from '../views/MarkdownTableView';
|
||||
import ReadReceiptsView from '../views/ReadReceiptView';
|
||||
import QueueListView from '../views/QueueListView';
|
||||
import QueueListView from '../ee/omnichannel/views/QueueListView';
|
||||
|
||||
// Profile Stack
|
||||
import ProfileView from '../views/ProfileView';
|
||||
|
|
|
@ -41,7 +41,7 @@ import ScreenLockConfigView from '../../views/ScreenLockConfigView';
|
|||
import AdminPanelView from '../../views/AdminPanelView';
|
||||
import NewMessageView from '../../views/NewMessageView';
|
||||
import CreateChannelView from '../../views/CreateChannelView';
|
||||
import QueueListView from '../../views/QueueListView';
|
||||
import QueueListView from '../../ee/omnichannel/views/QueueListView';
|
||||
import UserPreferencesView from '../../views/UserPreferencesView';
|
||||
import UserNotificationPrefView from '../../views/UserNotificationPreferencesView';
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ import Navigation from '../../lib/Navigation';
|
|||
import SafeAreaView from '../../containers/SafeAreaView';
|
||||
import { withDimensions } from '../../dimensions';
|
||||
import { getHeaderTitlePosition } from '../../containers/Header';
|
||||
import { takeInquiry } from '../../ee/omnichannel/lib';
|
||||
|
||||
const stateAttrsUpdate = [
|
||||
'joined',
|
||||
|
@ -689,7 +690,7 @@ class RoomView extends React.Component {
|
|||
const { room } = this.state;
|
||||
|
||||
if (this.isOmnichannel) {
|
||||
await RocketChat.takeInquiry(room._id);
|
||||
await takeInquiry(room._id);
|
||||
} else {
|
||||
await RocketChat.joinRoom(this.rid, this.t);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
|||
import PropTypes from 'prop-types';
|
||||
|
||||
import Sort from './Sort';
|
||||
import OmnichannelStatus from './OmnichannelStatus';
|
||||
import OmnichannelStatus from '../../../ee/omnichannel/containers/OmnichannelStatus';
|
||||
|
||||
const ListHeader = React.memo(({
|
||||
searching,
|
||||
|
|
|
@ -63,7 +63,8 @@ import SafeAreaView from '../../containers/SafeAreaView';
|
|||
import Header, { getHeaderTitlePosition } from '../../containers/Header';
|
||||
import { withDimensions } from '../../dimensions';
|
||||
import { showErrorAlert, showConfirmationAlert } from '../../utils/info';
|
||||
import { getInquiryQueueSelector } from '../../selectors/inquiry';
|
||||
import { getInquiryQueueSelector } from '../../ee/omnichannel/selectors/inquiry';
|
||||
import { changeLivechatStatus, isOmnichannelStatusAvailable } from '../../ee/omnichannel/lib';
|
||||
|
||||
const INITIAL_NUM_TO_RENDER = isTablet ? 20 : 12;
|
||||
const CHATS_HEADER = 'Chats';
|
||||
|
@ -690,13 +691,13 @@ class RoomsListView extends React.Component {
|
|||
} = this.props;
|
||||
|
||||
// if not-available, prompt to change to available
|
||||
if (user?.statusLivechat !== 'available') {
|
||||
if (!isOmnichannelStatusAvailable(user)) {
|
||||
showConfirmationAlert({
|
||||
message: I18n.t('Omnichannel_enable_alert'),
|
||||
callToAction: I18n.t('Yes'),
|
||||
onPress: async() => {
|
||||
try {
|
||||
await RocketChat.changeLivechatStatus();
|
||||
await changeLivechatStatus();
|
||||
} catch {
|
||||
// Do nothing
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue