Merge branch 'feature/mobile-apps-on-reactjs' into feature/mobile-apps-on-reactjs-searchbar

This commit is contained in:
SergeyEzhin 2021-04-05 13:38:11 +03:00
commit 1cc8510e12
7 changed files with 192 additions and 19 deletions

View file

@ -119,5 +119,7 @@ const PageAbout = props => {
};
const About = inject("storeAppOptions")(observer(PageAbout));
About.appVersion = () => (__PRODUCT_VERSION__);
export default About;

View file

@ -26,7 +26,25 @@
"List Paragraph": "List Paragraph",
"footnote text": "Footnote Text"
},
"leavePageText": "You have unsaved changes in this document. Click 'Stay on this Page' to await the autosave of the document. Click 'Leave this Page' to discard all the unsaved changes."
"leavePageText": "You have unsaved changes in this document. Click 'Stay on this Page' to await the autosave of the document. Click 'Leave this Page' to discard all the unsaved changes.",
"titleLicenseExp": "License expired",
"warnLicenseExp": "Your license has expired. Please update your license and refresh the page.",
"errorServerVersion": "The editor version has been updated. The page will be reloaded to apply the changes.",
"titleServerVersion": "Editor updated",
"notcriticalErrorTitle": "Warning",
"errorOpensource": "Using the free Community version you can open documents for viewing only. To access mobile web editors, a commercial license is required.",
"warnLicenseLimitedNoAccess": "License expired. You have no access to document editing functionality. Please contact your administrator.",
"warnLicenseLimitedRenewed": "License needs to be renewed. You have a limited access to document editing functionality.<br>Please contact your administrator to get full access",
"warnLicenseExceeded": "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only. Contact your administrator to learn more.",
"warnLicenseUsersExceeded": "You've reached the user limit for %1 editors. Contact your administrator to learn more.",
"warnNoLicense": "You've reached the limit for simultaneous connections to %1 editors. This document will be opened for viewing only. Contact %1 sales team for personal upgrade terms.",
"warnNoLicenseUsers": "You've reached the user limit for %1 editors. Contact %1 sales team for personal upgrade terms.",
"textBuyNow": "Visit website",
"textContactUs": "Contact sales",
"textNoLicenseTitle": "License limit reached",
"textPaidFeature": "Paid feature",
"textCustomLoader": "Please note that according to the terms of the license you are not entitled to change the loader. Please contact our Sales Department to get a quote.",
"textClose": "Close"
},
"Toolbar": {
"dlgLeaveTitleText": "You leave the application",

View file

@ -13,8 +13,8 @@ import {
EditCommentController,
ViewCommentsController
} from "../../../../common/mobile/lib/controller/collaboration/Comments";
import patch from '../lib/patch'
import About from '../../../../common/mobile/lib/view/About';
import EditorUIController from '../lib/patch';
@inject(
"storeAppOptions",
@ -30,6 +30,13 @@ class MainController extends Component {
constructor(props) {
super(props);
window.editorType = 'de';
this._state = {
licenseType: false
};
const { t } = this.props;
this._t = t('Main', {returnObjects:true});
}
initSdk() {
@ -59,7 +66,7 @@ class MainController extends Component {
};
const loadConfig = data => {
patch.isSupportEditFeature();
EditorUIController.isSupportEditFeature();
console.log('load config');
this.editorConfig = Object.assign({}, this.editorConfig, data.config);
@ -112,7 +119,7 @@ class MainController extends Component {
this.api.asc_registerCallback('asc_onGetEditorPermissions', onEditorPermissions);
this.api.asc_registerCallback('asc_onDocumentContentReady', onDocumentContentReady);
// this.api.asc_registerCallback('asc_onLicenseChanged', _.bind(this.onLicenseChanged, this));
this.api.asc_registerCallback('asc_onLicenseChanged', this.onLicenseChanged.bind(this));
// this.api.asc_registerCallback('asc_onRunAutostartMacroses', _.bind(this.onRunAutostartMacroses, this));
this.api.asc_setDocInfo(docInfo);
this.api.asc_getEditorPermissions(this.editorConfig.licenseUrl, this.editorConfig.customerId);
@ -138,6 +145,20 @@ class MainController extends Component {
const licType = params.asc_getLicenseType();
// check licType
if (Asc.c_oLicenseResult.Expired === licType ||
Asc.c_oLicenseResult.Error === licType ||
Asc.c_oLicenseResult.ExpiredTrial === licType) {
f7.dialog.create({
title : this._t.titleLicenseExp,
text : this._t.warnLicenseExp
}).open();
return;
}
if (Asc.c_oLicenseResult.ExpiredLimited === licType) {
this._state.licenseType = licType;
}
if ( this.onServerVersion(params.asc_getBuildVersion()) ) return;
this.appOptions.canLicense = (licType === Asc.c_oLicenseResult.Success || licType === Asc.c_oLicenseResult.SuccessLimit);
@ -158,6 +179,8 @@ class MainController extends Component {
f7.emit('resize');
Common.Notifications.trigger('document:ready');
this._isDocReady = true;
};
const _process_array = (array, fn) => {
@ -241,9 +264,7 @@ class MainController extends Component {
this.api.asc_continueSaving();
}, 500);
const { t } = this.props;
const _t = t('Main', {returnObjects:true})
return _t.leavePageText;
return this._t.leavePageText;
}
}
@ -252,8 +273,118 @@ class MainController extends Component {
clearTimeout(this.continueSavingTimer);
}
applyLicense () {
onLicenseChanged (params) {
const appOptions = this.props.storeAppOptions;
const licType = params.asc_getLicenseType();
if (licType !== undefined && appOptions.canEdit && appOptions.config.mode !== 'view' &&
(licType === Asc.c_oLicenseResult.Connections || licType === Asc.c_oLicenseResult.UsersCount || licType === Asc.c_oLicenseResult.ConnectionsOS || licType === Asc.c_oLicenseResult.UsersCountOS
|| licType === Asc.c_oLicenseResult.SuccessLimit && (appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0))
this._state.licenseType = licType;
if (this._isDocReady && this._state.licenseType)
this.applyLicense();
}
applyLicense () {
const _t = this._t;
const appOptions = this.props.storeAppOptions;
if (appOptions.config.mode !== 'view' && !EditorUIController.isSupportEditFeature()) {
let value = LocalStorage.getItem("de-opensource-warning");
value = (value !== null) ? parseInt(value) : 0;
const now = (new Date).getTime();
if (now - value > 86400000) {
LocalStorage.setItem("de-opensource-warning", now);
f7.dialog.create({
title: _t.notcriticalErrorTitle,
text : _t.errorOpensource,
buttons: [{text: 'OK'}]
}).open();
}
Common.Notifications.trigger('toolbar:activatecontrols');
return;
}
if (this._state.licenseType) {
let license = this._state.licenseType;
let buttons = [{text: 'OK'}];
if ((appOptions.trialMode & Asc.c_oLicenseMode.Limited) !== 0 &&
(license === Asc.c_oLicenseResult.SuccessLimit ||
license === Asc.c_oLicenseResult.ExpiredLimited ||
appOptions.permissionsLicense === Asc.c_oLicenseResult.SuccessLimit)
) {
license = (license === Asc.c_oLicenseResult.ExpiredLimited) ? _t.warnLicenseLimitedNoAccess : _t.warnLicenseLimitedRenewed;
} else if (license === Asc.c_oLicenseResult.Connections || license === Asc.c_oLicenseResult.UsersCount) {
license = (license===Asc.c_oLicenseResult.Connections) ? _t.warnLicenseExceeded : _t.warnLicenseUsersExceeded;
} else {
license = (license === Asc.c_oLicenseResult.ConnectionsOS) ? _t.warnNoLicense : _t.warnNoLicenseUsers;
buttons = [{
text: _t.textBuyNow,
bold: true,
onClick: function() {
window.open(`${__PUBLISHER_URL__}`, "_blank");
}
},
{
text: _t.textContactUs,
onClick: function() {
window.open(`mailto:${__SALES_EMAIL__}`, "_blank");
}
}];
}
if (this._state.licenseType === Asc.c_oLicenseResult.SuccessLimit) {
Common.Notifications.trigger('toolbar:activatecontrols');
} else {
Common.Notifications.trigger('toolbar:activatecontrols');
Common.Notifications.trigger('toolbar:deactivateeditcontrols');
Common.Notifications.trigger('api:disconnect');
}
let value = LocalStorage.getItem("de-license-warning");
value = (value !== null) ? parseInt(value) : 0;
const now = (new Date).getTime();
if (now - value > 86400000) {
LocalStorage.setItem("de-license-warning", now);
f7.dialog.create({
title: _t.textNoLicenseTitle,
text : license,
buttons: buttons
}).open();
}
} else {
if (!appOptions.isDesktopApp && !appOptions.canBrandingExt &&
appOptions.config && appOptions.config.customization && (appOptions.config.customization.loaderName || appOptions.config.customization.loaderLogo)) {
f7.dialog.create({
title: _t.textPaidFeature,
text : _t.textCustomLoader,
buttons: [{
text: _t.textContactUs,
bold: true,
onClick: () => {
window.open(`mailto:${__SALES_EMAIL__}`, "_blank");
}
},
{ text: _t.textClose }]
}).open();
}
Common.Notifications.trigger('toolbar:activatecontrols');
}
}
onServerVersion (buildVersion) {
if (this.changeServerVersion) return true;
const _t = this._t;
if (About.appVersion() !== buildVersion && !window.compareVersions) {
this.changeServerVersion = true;
f7.dialog.alert(
_t.errorServerVersion,
_t.titleServerVersion,
() => {
setTimeout(() => {Common.Gateway.updateVersion()}, 0);
});
return true;
}
return false;
}
bindEvents() {

View file

@ -22,6 +22,8 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop
api.asc_registerCallback('asc_onFocusObject', onApiFocusObject);
api.asc_registerCallback('asc_onCoAuthoringDisconnect', onCoAuthoringDisconnect);
Common.Notifications.on('api:disconnect', onCoAuthoringDisconnect);
Common.Notifications.on('toolbar:activatecontrols', activateControls);
Common.Notifications.on('toolbar:deactivateeditcontrols', deactivateEditControls);
};
if ( !Common.EditorApi ) {
Common.Notifications.on('document:ready', onDocumentReady);
@ -35,6 +37,8 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop
Common.Notifications.off('document:ready', onDocumentReady);
Common.Notifications.off('setdoctitle', setDocTitle);
Common.Notifications.off('api:disconnect', onCoAuthoringDisconnect);
Common.Notifications.off('toolbar:activatecontrols', activateControls);
Common.Notifications.off('toolbar:deactivateeditcontrols', deactivateEditControls);
const api = Common.EditorApi.get();
api.asc_unregisterCallback('asc_onCanUndo', onApiCanUndo);
@ -163,6 +167,11 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop
f7.popup.close();
};
const [disabledControls, setDisabledControls] = useState(true);
const activateControls = () => {
setDisabledControls(false);
};
return (
<ToolbarView openOptions={props.openOptions}
docTitle={docTitle}
@ -174,6 +183,7 @@ const ToolbarController = inject('storeAppOptions', 'users', 'storeReview')(prop
onRedo={onRedo}
isObjectLocked={isObjectLocked}
stateDisplayMode={stateDisplayMode}
disabledControls={disabledControls}
disabledEditControls={disabledEditControls}
disabledSettings={disabledSettings}
displayCollaboration={displayCollaboration}

View file

@ -1,10 +1,14 @@
const patch = () => {
const EditorUIController = () => {
return null
};
patch.isSupportEditFeature = () => {
EditorUIController.isSupportEditFeature = () => {
return false
};
export default patch;
EditorUIController.getToolbarOptions = () => {
return null
};
export default EditorUIController;

View file

@ -1,23 +1,29 @@
import React, {Fragment} from 'react';
import {NavLeft, NavRight, NavTitle, Link, Icon} from 'framework7-react';
import { Device } from '../../../../common/mobile/utils/device';
import EditorUIController from '../lib/patch'
const ToolbarView = props => {
const disableEditBtn = props.isObjectLocked || props.stateDisplayMode || props.disabledEditControls;
return (
<Fragment>
<NavLeft>
{props.isShowBack && <Link className='btn-doc-back' icon='icon-back' onClick={props.onBack}></Link>}
{props.isShowBack && <Link className={`btn-doc-back${props.disabledControls && ' disabled'}`} icon='icon-back' onClick={props.onBack}></Link>}
<Link icon='icon-undo' className={!props.isCanUndo && 'disabled'} onClick={props.onUndo}></Link>
<Link icon='icon-redo' className={!props.isCanRedo && 'disabled'} onClick={props.onRedo}></Link>
</NavLeft>
{!Device.phone && <NavTitle>{props.docTitle}</NavTitle>}
<NavRight>
<Link className={disableEditBtn && 'disabled'} id='btn-edit' icon='icon-edit-settings' href={false} onClick={e => props.openOptions('edit')}></Link>
<Link className={disableEditBtn && 'disabled'} id='btn-add' icon='icon-plus' href={false} onClick={e => props.openOptions('add')}></Link>
{ Device.phone ? null : <Link icon='icon-search' searchbarEnable='.searchbar' href={false}></Link> }
{props.displayCollaboration && <Link id='btn-coauth' href={false} icon='icon-collaboration' onClick={e => props.openOptions('coauth')}></Link>}
<Link className={props.disabledSettings && 'disabled'} id='btn-settings' icon='icon-settings' href={false} onClick={e => props.openOptions('settings')}></Link>
{
EditorUIController.getToolbarOptions({
disabled: disableEditBtn || props.disabledControls,
onEditClick: e => props.openOptions('edit'),
onAddClick: e => props.openOptions('add'),
})
}
{ Device.phone ? null : <Link className={props.disabledControls && 'disabled'} icon='icon-search' searchbarEnable='.searchbar' href={false}></Link> }
{props.displayCollaboration && <Link className={props.disabledControls && 'disabled'} id='btn-coauth' href={false} icon='icon-collaboration' onClick={e => props.openOptions('coauth')}></Link>}
<Link className={(props.disabledSettings || props.disabledControls) && 'disabled'} id='btn-settings' icon='icon-settings' href={false} onClick={e => props.openOptions('settings')}></Link>
</NavRight>
</Fragment>
)

View file

@ -77,6 +77,8 @@ module.exports = {
resolvePath('node_modules/template7'),
resolvePath('node_modules/dom7'),
resolvePath('node_modules/ssr-window'),
resolvePath('../../../web-apps-mobile/word'),
],
},
@ -156,7 +158,7 @@ module.exports = {
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(env),
'process.env.TARGET': JSON.stringify(target),
__PRODUCT_VERSION__: JSON.stringify(process.env.PRODUCT_VERSION ? process.env.PRODUCT_VERSION : '0.0.1'),
__PRODUCT_VERSION__: JSON.stringify(process.env.PRODUCT_VERSION ? process.env.PRODUCT_VERSION : '6.2.0'),
__PUBLISHER_ADDRESS__: JSON.stringify('20A-12 Ernesta Birznieka-Upisha street, Riga, Latvia, EU, LV-1050'),
__SUPPORT_EMAIL__: JSON.stringify('support@onlyoffice.com'),
__PUBLISHER_PHONE__: JSON.stringify('+371 633-99867'),