added api methods for settings, refactoring
This commit is contained in:
parent
95d5414718
commit
84d4446b23
@ -24,7 +24,7 @@ const App = ({ settings }) => {
|
||||
<Switch>
|
||||
<Redirect exact from="/" to={`${homepage}`} />
|
||||
<PrivateRoute exact path={[homepage, `${homepage}/filter`]} component={withStudioLayout(Home)} />
|
||||
<PrivateRoute exact path={`${homepage}/settings/:setting`} component={withStudioLayout(Settings)} />
|
||||
<PrivateRoute exact path={[`${homepage}/settings/:setting`, `${homepage}/settings/` ]} component={withStudioLayout(Settings)} />
|
||||
<PrivateRoute exact path={`${homepage}/doceditor`} component={DocEditor} />
|
||||
<PrivateRoute exact path={`${homepage}/:fileId/history`} component={withStudioLayout(VersionHistory)} />
|
||||
<PublicRoute exact path={["/login","/login/error=:error", "/login/confirmed-email=:confirmedEmail"]} component={Login} />
|
||||
|
@ -72,7 +72,7 @@ class PureTreeSettings extends React.Component {
|
||||
}
|
||||
|
||||
renderTreeNode = () => {
|
||||
const { t } = this.props;
|
||||
const { t, thirdParty } = this.props;
|
||||
return (
|
||||
<TreeNode
|
||||
id="settings"
|
||||
@ -95,14 +95,17 @@ class PureTreeSettings extends React.Component {
|
||||
isLeaf={true}
|
||||
title={t('treeSettingsAdminSettings')}
|
||||
/>
|
||||
<TreeNode
|
||||
selectable={true}
|
||||
className="settings-node"
|
||||
id='connected-clouds'
|
||||
key='thirdParty'
|
||||
isLeaf={true}
|
||||
title={t('treeSettingsConnectedCloud')}
|
||||
/>
|
||||
{thirdParty
|
||||
? <TreeNode
|
||||
selectable={true}
|
||||
className="settings-node"
|
||||
id='connected-clouds'
|
||||
key='thirdParty'
|
||||
isLeaf={true}
|
||||
title={t('treeSettingsConnectedCloud')}
|
||||
/>
|
||||
: null
|
||||
}
|
||||
</TreeNode>
|
||||
);
|
||||
}
|
||||
@ -145,11 +148,18 @@ const TreeSettings = props => {
|
||||
function mapStateToProps(state) {
|
||||
const {
|
||||
selectedTreeNode,
|
||||
expandedSetting
|
||||
settingsTree
|
||||
} = state.files;
|
||||
|
||||
const {
|
||||
expandedSetting,
|
||||
thirdParty
|
||||
} = settingsTree;
|
||||
|
||||
return {
|
||||
selectedTreeNode,
|
||||
expandedSetting
|
||||
expandedSetting,
|
||||
thirdParty
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -5,8 +5,9 @@ import {
|
||||
Heading,
|
||||
ToggleButton
|
||||
} from 'asc-web-components';
|
||||
import { history } from "asc-web-common";
|
||||
|
||||
import { setStoreOriginal } from '../../../../../store/files/actions';
|
||||
import { updateIfExist, storeOriginal, setThirdParty } from '../../../../../store/files/actions';
|
||||
|
||||
const StyledSettings = styled.div`
|
||||
display: grid;
|
||||
@ -27,7 +28,8 @@ class SectionBodyContent extends React.Component {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
originalCopy: false
|
||||
originalCopy: true,
|
||||
updateExist: true
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,11 +48,9 @@ class SectionBodyContent extends React.Component {
|
||||
document.title = 'ASC.Files';
|
||||
}
|
||||
|
||||
onChangeOriginalCopy = () => {
|
||||
const { originalCopy } = this.state;
|
||||
const { setStoreOriginal } = this.props;
|
||||
setStoreOriginal({ set: !originalCopy });
|
||||
this.setState({ originalCopy: !originalCopy });
|
||||
onChangeThirdParty = () => {
|
||||
const { thirdParty, setThirdParty } = this.props;
|
||||
setThirdParty(!thirdParty);
|
||||
}
|
||||
|
||||
renderAdminSettings = () => {
|
||||
@ -70,30 +70,45 @@ class SectionBodyContent extends React.Component {
|
||||
isChecked={intermediateVersion}
|
||||
/>
|
||||
<ToggleButton
|
||||
isDisabled={true}
|
||||
isDisabled={false}
|
||||
className="toggle-btn"
|
||||
label={t('thirdPartyBtn')}
|
||||
onChange={(e)=>console.log(e)}
|
||||
onChange={this.onChangeThirdParty}
|
||||
isChecked={thirdParty}
|
||||
/>
|
||||
</StyledSettings>
|
||||
)
|
||||
}
|
||||
|
||||
onChangeOriginalCopy = () => {
|
||||
const { originalCopy } = this.state;
|
||||
const { storeOriginal } = this.props;
|
||||
|
||||
storeOriginal( originalCopy );
|
||||
this.setState({ originalCopy: !originalCopy });
|
||||
}
|
||||
|
||||
onChangeUpdateIfExist = () => {
|
||||
const { updateExist } = this.state;
|
||||
const { updateIfExist } = this.props;
|
||||
|
||||
updateIfExist( !updateExist );
|
||||
this.setState({ updateExist: !updateExist });
|
||||
}
|
||||
|
||||
renderCommonSettings = () => {
|
||||
const {
|
||||
trash,
|
||||
recent,
|
||||
favorites,
|
||||
templates,
|
||||
updateOrCreate,
|
||||
keepIntermediate,
|
||||
setStoreOriginal,
|
||||
t
|
||||
} = this.props;
|
||||
|
||||
const {
|
||||
originalCopy
|
||||
originalCopy,
|
||||
updateExist
|
||||
} = this.state;
|
||||
|
||||
return (
|
||||
@ -135,11 +150,11 @@ class SectionBodyContent extends React.Component {
|
||||
/>
|
||||
<Heading className="heading" level={2} size="small">{t('storingFileVersion')}</Heading>
|
||||
<ToggleButton
|
||||
isDisabled={true}
|
||||
isDisabled={false}
|
||||
className="toggle-btn"
|
||||
label={t('updateOrCreate')}
|
||||
onChange={(e)=>console.log(e)}
|
||||
isChecked={updateOrCreate}
|
||||
onChange={this.onChangeUpdateIfExist}
|
||||
isChecked={updateExist}
|
||||
/>
|
||||
<ToggleButton
|
||||
isDisabled={true}
|
||||
@ -157,20 +172,27 @@ class SectionBodyContent extends React.Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { setting } = this.props;
|
||||
const { setting, thirdParty } = this.props;
|
||||
let content;
|
||||
|
||||
if(setting === 'admin')
|
||||
content = this.renderAdminSettings();
|
||||
if(setting === 'common')
|
||||
content = this.renderCommonSettings();
|
||||
if(setting === 'thirdParty')
|
||||
if(setting === 'thirdParty' && thirdParty )
|
||||
content = this.renderClouds();
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export default connect(null, {setStoreOriginal})(SectionBodyContent);
|
||||
function mapStateToProps(state) {
|
||||
const { settingsTree } = state.files;
|
||||
const { thirdParty } = settingsTree;
|
||||
|
||||
return {
|
||||
thirdParty
|
||||
}
|
||||
}
|
||||
|
||||
export default connect(mapStateToProps, { updateIfExist, storeOriginal, setThirdParty })(SectionBodyContent);
|
@ -27,7 +27,6 @@ class PureSettings extends React.Component {
|
||||
|
||||
this.state = {
|
||||
intermediateVersion: false,
|
||||
thirdParty: false,
|
||||
originalCopy: false,
|
||||
trash: false,
|
||||
recent: false,
|
||||
@ -42,7 +41,6 @@ class PureSettings extends React.Component {
|
||||
console.log('Settings render()');
|
||||
const {
|
||||
intermediateVersion,
|
||||
thirdParty,
|
||||
originalCopy,
|
||||
trash,
|
||||
recent,
|
||||
@ -89,7 +87,6 @@ class PureSettings extends React.Component {
|
||||
<PageLayout.SectionBody>
|
||||
<SectionBodyContent
|
||||
setting={setting}
|
||||
thirdParty={thirdParty}
|
||||
intermediateVersion={intermediateVersion}
|
||||
originalCopy={originalCopy}
|
||||
trash={trash}
|
||||
|
@ -42,6 +42,7 @@ export const SET_NEW_ROW_ITEMS = "SET_NEW_ROW_ITEMS";
|
||||
export const SET_SELECTED_NODE = "SET_SELECTED_NODE";
|
||||
export const SET_EXPAND_SETTINGS_TREE = "SET_EXPAND_SETTINGS_TREE";
|
||||
export const SET_IS_LOADING = "SET_IS_LOADING";
|
||||
export const SET_THIRD_PARTY = "SET_THIRD_PARTY";
|
||||
|
||||
export function setFile(file) {
|
||||
return {
|
||||
@ -211,6 +212,13 @@ export function setIsLoading(isLoading) {
|
||||
}
|
||||
}
|
||||
|
||||
export function setThirdParty(data) {
|
||||
return {
|
||||
type: SET_THIRD_PARTY,
|
||||
data
|
||||
}
|
||||
}
|
||||
|
||||
export function setFilterUrl(filter) {
|
||||
const defaultFilter = FilesFilter.getDefault();
|
||||
const params = [];
|
||||
@ -454,3 +462,15 @@ export function clearProgressData(dispatch) {
|
||||
});
|
||||
};
|
||||
}*/
|
||||
|
||||
export function updateIfExist(data) {
|
||||
return dispatch => {
|
||||
return files.updateIfExist(data);
|
||||
}
|
||||
}
|
||||
|
||||
export function storeOriginal(data) {
|
||||
return dispatch => {
|
||||
return files.storeOriginal(data);
|
||||
}
|
||||
}
|
@ -22,7 +22,8 @@ import {
|
||||
SET_NEW_ROW_ITEMS,
|
||||
SET_SELECTED_NODE,
|
||||
SET_EXPAND_SETTINGS_TREE,
|
||||
SET_IS_LOADING
|
||||
SET_IS_LOADING,
|
||||
SET_THIRD_PARTY
|
||||
} from "./actions";
|
||||
import { api } from "asc-web-common";
|
||||
import { isFileSelected, skipFile, getFilesBySelected } from "./selectors";
|
||||
@ -48,8 +49,12 @@ const initialState = {
|
||||
updateTreeNew: false,
|
||||
newRowItems: [],
|
||||
selectedTreeNode: [],
|
||||
expandedSetting: [],
|
||||
isLoading: false
|
||||
isLoading: false,
|
||||
settingsTree: {
|
||||
thirdParty: false,
|
||||
expandedSetting: []
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const filesReducer = (state = initialState, action) => {
|
||||
@ -157,12 +162,16 @@ const filesReducer = (state = initialState, action) => {
|
||||
}
|
||||
case SET_EXPAND_SETTINGS_TREE:
|
||||
return Object.assign({}, state, {
|
||||
expandedSetting: action.setting
|
||||
settingsTree: { ...state.settingsTree , expandedSetting: action.setting }
|
||||
})
|
||||
case SET_IS_LOADING:
|
||||
return Object.assign({}, state, {
|
||||
isLoading: action.isLoading
|
||||
})
|
||||
case SET_THIRD_PARTY:
|
||||
return Object.assign({}, state, {
|
||||
settingsTree: { ...state.settingsTree, thirdParty: action.data }
|
||||
})
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -380,3 +380,13 @@ export function lockFile(fileId, lockFile) {
|
||||
const data = { lockFile };
|
||||
return request({ method: "put", url: `/files/file/${fileId}/lock`, data });
|
||||
}
|
||||
|
||||
export function updateIfExist(val) {
|
||||
const data = { set: val };
|
||||
return request({ method: "put", url: "files/updateifexist", data });
|
||||
}
|
||||
|
||||
export function storeOriginal(val) {
|
||||
const data = { set: val };
|
||||
return request({ method: "put", url: "files/storeoriginal.json", data });
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user