Merge branch 'master' of github.com:ONLYOFFICE/AppServer

This commit is contained in:
Ilya Oleshko 2019-11-07 12:12:17 +03:00
commit 2b18e75606
9 changed files with 69 additions and 92 deletions

View File

@ -116,13 +116,9 @@ namespace ASC.Api.Settings
var settings = new SettingsWrapper var settings = new SettingsWrapper
{ {
Culture = Tenant.GetCulture().ToString(), Culture = Tenant.GetCulture().ToString(),
GreetingSettings = Tenant.Name
}; };
if (!SecurityContext.IsAuthenticated)
{
settings.GreetingSettings = Tenant.Name;
}
if (SecurityContext.IsAuthenticated) if (SecurityContext.IsAuthenticated)
{ {
settings.TrustedDomains = Tenant.TrustedDomains; settings.TrustedDomains = Tenant.TrustedDomains;
@ -178,11 +174,11 @@ namespace ASC.Api.Settings
return listOfTimezones; return listOfTimezones;
} }
[Read("greetingsettings")] /* [Read("greetingsettings")]
public string GetGreetingSettings() public string GetGreetingSettings()
{ {
return Tenant.Name; return Tenant.Name;
} }*/
[Create("greetingsettings")] [Create("greetingsettings")]
public object SaveGreetingSettings(GreetingSettingsModel model) public object SaveGreetingSettings(GreetingSettingsModel model)

View File

@ -18,7 +18,6 @@ import {
getConfirmationInfo, getConfirmationInfo,
logout logout
} from "../../../../../src/store/auth/actions"; } from "../../../../../src/store/auth/actions";
import { getGreetingTitle } from '../../../../store/settings/actions';
const BodyStyle = styled(Container)` const BodyStyle = styled(Container)`
margin-top: 70px; margin-top: 70px;
@ -108,13 +107,12 @@ class Form extends React.PureComponent {
}; };
componentDidMount() { componentDidMount() {
const { getConfirmationInfo, history, getGreetingTitle } = this.props; const { getConfirmationInfo, history } = this.props;
getConfirmationInfo(this.state.key) getConfirmationInfo(this.state.key)
.catch(error => { .catch(error => {
toastr.error(this.props.t(`${error}`)); toastr.error(this.props.t(`${error}`));
history.push("/"); history.push("/");
}); });
getGreetingTitle();
window.addEventListener("keydown", this.onKeyPress); window.addEventListener("keydown", this.onKeyPress);
window.addEventListener("keyup", this.onKeyPress); window.addEventListener("keyup", this.onKeyPress);
@ -219,11 +217,11 @@ function mapStateToProps(state) {
isConfirmLoaded: state.auth.isConfirmLoaded, isConfirmLoaded: state.auth.isConfirmLoaded,
settings: state.auth.settings.passwordSettings, settings: state.auth.settings.passwordSettings,
isAuthenticated: state.auth.isAuthenticated, isAuthenticated: state.auth.isAuthenticated,
greetingTitle: state.settings.greetingSettings, greetingTitle: state.auth.settings.greetingSettings,
}; };
} }
export default connect( export default connect(
mapStateToProps, mapStateToProps,
{ changePassword, getConfirmationInfo, logout, getGreetingTitle } { changePassword, getConfirmationInfo, logout }
)(withRouter(withTranslation()(ChangePasswordForm))); )(withRouter(withTranslation()(ChangePasswordForm)));

View File

@ -7,7 +7,6 @@ import PropTypes from 'prop-types';
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
import { deleteSelf } from './../../../../store/services/api'; import { deleteSelf } from './../../../../store/services/api';
import { logout } from '../../../../store/auth/actions'; import { logout } from '../../../../store/auth/actions';
import { getGreetingTitle } from '../../../../store/settings/actions';
const ProfileRemoveContainer = styled.div` const ProfileRemoveContainer = styled.div`
display: flex; display: flex;
@ -30,25 +29,14 @@ const ProfileRemoveContainer = styled.div`
class ProfileRemove extends React.PureComponent { class ProfileRemove extends React.PureComponent {
constructor(props) { constructor() {
super(props); super();
const { greetingTitle } = props;
this.state = { this.state = {
isProfileDeleted: false, isProfileDeleted: false,
greetingTitle
}; };
} }
componentDidMount() {
const { greetingTitle } = this.state;
const { getGreetingTitle } = this.props;
if (!greetingTitle) {
getGreetingTitle()
.then(() => this.setState({ greetingTitle: this.props.greetingTitleSettings }));
}
}
onDeleteProfile = () => { onDeleteProfile = () => {
this.setState({ isLoading: true }, function () { this.setState({ isLoading: true }, function () {
const { linkData, logout } = this.props; const { linkData, logout } = this.props;
@ -72,8 +60,8 @@ class ProfileRemove extends React.PureComponent {
render() { render() {
console.log('profileRemove render'); console.log('profileRemove render');
const { t } = this.props; const { t, greetingTitle } = this.props;
const { isProfileDeleted, greetingTitle } = this.state; const { isProfileDeleted } = this.state;
return ( return (
<ProfileRemoveContainer> <ProfileRemoveContainer>
<div className='start-basis'> <div className='start-basis'>
@ -120,9 +108,8 @@ const ProfileRemoveForm = (props) => (<PageLayout sectionBodyContent={<ProfileRe
function mapStateToProps(state) { function mapStateToProps(state) {
return { return {
greetingTitle: state.auth.settings.greetingSettings, greetingTitle: state.auth.settings.greetingSettings
greetingTitleSettings: state.settings.greetingSettings
}; };
} }
export default connect(mapStateToProps, { logout, getGreetingTitle })(withRouter(withTranslation()(ProfileRemoveForm))); export default connect(mapStateToProps, { logout })(withRouter(withTranslation()(ProfileRemoveForm)));

View File

@ -2,8 +2,7 @@ import React from "react";
import { connect } from "react-redux"; import { connect } from "react-redux";
import { withTranslation } from 'react-i18next'; import { withTranslation } from 'react-i18next';
import { FieldContainer, Text, ComboBox, Loader, Button, toastr, Link, TextInput } from "asc-web-components"; import { FieldContainer, Text, ComboBox, Loader, Button, toastr, Link, TextInput } from "asc-web-components";
import { getCultures, setLanguageAndTime, getPortalTimezones } from '../../../../../store/auth/actions'; import { getCultures, setLanguageAndTime, getPortalTimezones, setGreetingTitle, restoreGreetingTitle } from '../../../../../store/auth/actions';
import { getGreetingTitle, setGreetingTitle, restoreGreetingTitle } from '../../../../../store/settings/actions';
import styled from 'styled-components'; import styled from 'styled-components';
import { Trans } from 'react-i18next'; import { Trans } from 'react-i18next';
@ -72,13 +71,8 @@ class Customization extends React.Component {
componentDidMount() { componentDidMount() {
const { getCultures, portalLanguage, portalTimeZoneId, t, getPortalTimezones, getGreetingTitle } = this.props; const { getCultures, portalLanguage, portalTimeZoneId, t, getPortalTimezones } = this.props;
const { timezones, languages, greetingTitle } = this.state; const { timezones, languages } = this.state;
if (!greetingTitle) {
getGreetingTitle()
.then(() => this.setState({ greetingTitle: this.props.greetingSettings }));
}
if (!timezones.length && !languages.length) { if (!timezones.length && !languages.length) {
let languages; let languages;
@ -98,8 +92,8 @@ class Customization extends React.Component {
} }
componentDidUpdate(prevProps, prevState) { componentDidUpdate(prevProps, prevState) {
const { timezones, languages, greetingTitle } = this.state; const { timezones, languages } = this.state;
if (greetingTitle !== null && timezones.length && languages.length && !prevState.isLoadedData) { if (timezones.length && languages.length && !prevState.isLoadedData) {
this.setState({ isLoadedData: true }); this.setState({ isLoadedData: true });
} }
} }
@ -280,11 +274,11 @@ function mapStateToProps(state) {
language: state.auth.user.cultureName || state.auth.settings.culture, language: state.auth.user.cultureName || state.auth.settings.culture,
rawTimezones: state.auth.settings.timezones, rawTimezones: state.auth.settings.timezones,
rawCultures: state.auth.settings.cultures, rawCultures: state.auth.settings.cultures,
greetingSettings: state.settings.greetingSettings, greetingSettings: state.auth.settings.greetingSettings,
}; };
} }
export default connect(mapStateToProps, { export default connect(mapStateToProps, {
getCultures, setLanguageAndTime, getPortalTimezones, getCultures, setLanguageAndTime, getPortalTimezones,
getGreetingTitle, setGreetingTitle, restoreGreetingTitle setGreetingTitle, restoreGreetingTitle
})(withTranslation()(Customization)); })(withTranslation()(Customization));

View File

@ -14,6 +14,7 @@ export const GET_PORTAL_CULTURES = 'GET_PORTAL_CULTURES';
export const SET_PORTAL_LANGUAGE_AND_TIME = 'SET_PORTAL_LANGUAGE_AND_TIME'; export const SET_PORTAL_LANGUAGE_AND_TIME = 'SET_PORTAL_LANGUAGE_AND_TIME';
export const GET_TIMEZONES = 'GET_TIMEZONES'; export const GET_TIMEZONES = 'GET_TIMEZONES';
export const SET_CURRENT_PRODUCT_ID = 'SET_CURRENT_PRODUCT_ID'; export const SET_CURRENT_PRODUCT_ID = 'SET_CURRENT_PRODUCT_ID';
export const SET_GREETING_SETTINGS = "SET_GREETING_SETTINGS";
export function setCurrentUser(user) { export function setCurrentUser(user) {
return { return {
@ -98,6 +99,13 @@ export function setCurrentProductId(currentProductId) {
}; };
}; };
export function setGreetingSettings(title) {
return {
type: SET_GREETING_SETTINGS,
title
};
};
export function getUser(dispatch) { export function getUser(dispatch) {
return api.getUser() return api.getUser()
.then(user => dispatch(setCurrentUser(user))); .then(user => dispatch(setCurrentUser(user)));
@ -219,8 +227,35 @@ export function setLanguageAndTime(lng, timeZoneID) {
export function getPortalTimezones() { export function getPortalTimezones() {
return dispatch => { return dispatch => {
return api.getPortalTimezones() return api.getPortalTimezones()
.then((timezones) => { .then((timezones) => {
dispatch(getTimezones(timezones)) dispatch(getTimezones(timezones))
}); });
}; };
}; };
/* export function getGreetingTitle() {
return dispatch => {
return api.getGreetingSettings()
.then(greetingTitle => dispatch(setGreetingSettings(greetingTitle)));
};
} */
export function setGreetingTitle(greetingTitle) {
return dispatch => {
return api.setGreetingSettings(greetingTitle)
.then((res) => {
dispatch(setGreetingSettings(greetingTitle))
});
};
}
export function restoreGreetingTitle() {
return dispatch => {
return api.restoreGreetingSettings()
.then((res) => {
dispatch(setGreetingSettings(res.companyName))
});
};
}

View File

@ -1,6 +1,6 @@
import { import {
SET_CURRENT_USER, SET_MODULES, SET_SETTINGS, SET_IS_LOADED, LOGOUT, SET_PASSWORD_SETTINGS, SET_IS_CONFIRM_LOADED, SET_NEW_EMAIL, SET_CURRENT_USER, SET_MODULES, SET_SETTINGS, SET_IS_LOADED, LOGOUT, SET_PASSWORD_SETTINGS, SET_IS_CONFIRM_LOADED, SET_NEW_EMAIL,
GET_PORTAL_CULTURES, SET_PORTAL_LANGUAGE_AND_TIME, GET_TIMEZONES, SET_CURRENT_PRODUCT_ID GET_PORTAL_CULTURES, SET_PORTAL_LANGUAGE_AND_TIME, GET_TIMEZONES, SET_CURRENT_PRODUCT_ID, SET_GREETING_SETTINGS
} from './actions'; } from './actions';
import isEmpty from 'lodash/isEmpty'; import isEmpty from 'lodash/isEmpty';
import config from "../../../package.json"; import config from "../../../package.json";
@ -31,9 +31,7 @@ const initialState = {
dateTimePattern: "DD, mm dd, yy h:mm:ss tt", dateTimePattern: "DD, mm dd, yy h:mm:ss tt",
timePattern: "h:mm tt" timePattern: "h:mm tt"
}, },
settingsTree: { greetingSettings: 'Web Office Applications'
selectedKey: ['0-0']
}
}/*, }/*,
password: null*/ password: null*/
} }
@ -85,8 +83,14 @@ const authReducer = (state = initialState, action) => {
return Object.assign({}, state, { return Object.assign({}, state, {
settings: { ...state.settings, currentProductId: action.currentProductId } settings: { ...state.settings, currentProductId: action.currentProductId }
}); });
case SET_GREETING_SETTINGS:
return Object.assign({}, state, {
settings: { ...state.settings, greetingSettings: action.title }
});
case LOGOUT: case LOGOUT:
return initialState; return Object.assign({}, initialState, {
settings: { greetingSettings: state.settings.greetingSettings, culture: state.settings.culture }
});
default: default:
return state; return state;
} }

View File

@ -182,12 +182,12 @@ export function getUserById(userId) {
}); });
} }
export function getGreetingSettings() { /* export function getGreetingSettings() {
return request({ return request({
method: "get", method: "get",
url: `/settings/greetingsettings.json`, url: `/settings/greetingsettings.json`,
}); });
} } */
export function setGreetingSettings(title) { export function setGreetingSettings(title) {
return request({ return request({

View File

@ -10,7 +10,6 @@ import {
export const SET_USERS = "SET_USERS"; export const SET_USERS = "SET_USERS";
export const SET_ADMINS = "SET_ADMINS"; export const SET_ADMINS = "SET_ADMINS";
export const SET_OWNER = "SET_OWNER"; export const SET_OWNER = "SET_OWNER";
export const SET_GREETING_SETTINGS = "SET_GREETING_SETTINGS";
export function setUsers(options) { export function setUsers(options) {
return { return {
@ -34,12 +33,6 @@ export function setOwner(owner) {
}; };
} }
export function setGreetingSettings(title) {
return {
type: SET_GREETING_SETTINGS,
title
};
}
export function getListUsers() { export function getListUsers() {
return (dispatch, getState) => { return (dispatch, getState) => {
@ -109,28 +102,3 @@ export function getUserById(userId) {
return api.getUserById(userId).then(owner => dispatch(setOwner(owner))); return api.getUserById(userId).then(owner => dispatch(setOwner(owner)));
}; };
} }
export function getGreetingTitle() {
return dispatch => {
return api.getGreetingSettings()
.then(greetingTitle => dispatch(setGreetingSettings(greetingTitle)));
};
}
export function setGreetingTitle(greetingTitle) {
return dispatch => {
return api.setGreetingSettings(greetingTitle)
.then((res) => {
dispatch(setGreetingSettings(greetingTitle))
});
};
}
export function restoreGreetingTitle() {
return dispatch => {
return api.restoreGreetingSettings()
.then((res) => {
dispatch(setGreetingSettings(res.companyName))
});
};
}

View File

@ -1,4 +1,4 @@
import { SET_USERS, SET_ADMINS, SET_OWNER, SET_GREETING_SETTINGS } from "./actions"; import { SET_USERS, SET_ADMINS, SET_OWNER } from "./actions";
const initialState = { const initialState = {
@ -7,7 +7,6 @@ const initialState = {
admins: [], admins: [],
owner: {} owner: {}
}, },
greetingSettings: null
}; };
const peopleReducer = (state = initialState, action) => { const peopleReducer = (state = initialState, action) => {
@ -30,10 +29,6 @@ const peopleReducer = (state = initialState, action) => {
owner: action.owner owner: action.owner
}) })
}); });
case SET_GREETING_SETTINGS:
return Object.assign({}, state, {
greetingSettings: action.title
});
default: default:
return state; return state;
} }