Web: Files: VersionHistory: added action fetchFileVersions
This commit is contained in:
parent
e6938def26
commit
274b147a3c
@ -27,6 +27,8 @@ import {
|
|||||||
getTreeFolders,
|
getTreeFolders,
|
||||||
getSettingsTree,
|
getSettingsTree,
|
||||||
getPrivacyFolder,
|
getPrivacyFolder,
|
||||||
|
getVerHistoryFileId,
|
||||||
|
getFileVersions,
|
||||||
} from "./selectors";
|
} from "./selectors";
|
||||||
|
|
||||||
import sumBy from "lodash/sumBy";
|
import sumBy from "lodash/sumBy";
|
||||||
@ -69,8 +71,9 @@ export const SET_FILES_SETTING = "SET_FILES_SETTING";
|
|||||||
export const SET_IS_ERROR_SETTINGS = "SET_IS_ERROR_SETTINGS";
|
export const SET_IS_ERROR_SETTINGS = "SET_IS_ERROR_SETTINGS";
|
||||||
export const SET_FIRST_LOAD = "SET_FIRST_LOAD";
|
export const SET_FIRST_LOAD = "SET_FIRST_LOAD";
|
||||||
export const SET_UPLOAD_DATA = "SET_UPLOAD_DATA";
|
export const SET_UPLOAD_DATA = "SET_UPLOAD_DATA";
|
||||||
export const SET_IS_VERSION_HISTORY_PANEL = "SET_IS_VERSION_HISTORY_PANEL";
|
export const SET_IS_VER_HISTORY_PANEL = "SET_IS_VER_HISTORY_PANEL";
|
||||||
export const SET_VERSION_HISTORY_FILE_ID = "SET_VERSION_HISTORY_FILE_ID";
|
export const SET_VER_HISTORY_FILE_ID = "SET_VER_HISTORY_FILE_ID";
|
||||||
|
export const SET_FILE_VERSIONS = "SET_FILE_VERSIONS";
|
||||||
|
|
||||||
export function setFile(file) {
|
export function setFile(file) {
|
||||||
return {
|
return {
|
||||||
@ -290,20 +293,27 @@ export function setUploadData(uploadData) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setIsVersionHistoryPanel(isVisible) {
|
export function setIsVerHistoryPanel(isVisible) {
|
||||||
return {
|
return {
|
||||||
type: SET_IS_VERSION_HISTORY_PANEL,
|
type: SET_IS_VER_HISTORY_PANEL,
|
||||||
isVisible,
|
isVisible,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export function setVersionHistoryFileId(fileId) {
|
export function setVerHistoryFileId(fileId) {
|
||||||
return {
|
return {
|
||||||
type: SET_VERSION_HISTORY_FILE_ID,
|
type: SET_VER_HISTORY_FILE_ID,
|
||||||
fileId,
|
fileId,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function setFileVersions(versions) {
|
||||||
|
return {
|
||||||
|
type: SET_FILE_VERSIONS,
|
||||||
|
versions,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
export function setFilterUrl(filter) {
|
export function setFilterUrl(filter) {
|
||||||
const defaultFilter = FilesFilter.getDefault();
|
const defaultFilter = FilesFilter.getDefault();
|
||||||
const params = [];
|
const params = [];
|
||||||
@ -1569,3 +1579,18 @@ export function itemOperationToFolder(
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function fetchFileVersions(fileId) {
|
||||||
|
return (dispatch, getState) => {
|
||||||
|
const state = getState();
|
||||||
|
const currentId = getVerHistoryFileId(state);
|
||||||
|
if (currentId !== fileId) {
|
||||||
|
return api.files
|
||||||
|
.getFileVersionInfo(fileId)
|
||||||
|
.then((versions) => dispatch(setFileVersions(versions)));
|
||||||
|
} else {
|
||||||
|
const currentVersions = getFileVersions(state);
|
||||||
|
return Promise.resolve(currentVersions);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -31,8 +31,9 @@ import {
|
|||||||
SET_IS_ERROR_SETTINGS,
|
SET_IS_ERROR_SETTINGS,
|
||||||
SET_FIRST_LOAD,
|
SET_FIRST_LOAD,
|
||||||
SET_UPLOAD_DATA,
|
SET_UPLOAD_DATA,
|
||||||
SET_IS_VERSION_HISTORY_PANEL,
|
SET_IS_VER_HISTORY_PANEL,
|
||||||
SET_VERSION_HISTORY_FILE_ID,
|
SET_VER_HISTORY_FILE_ID,
|
||||||
|
SET_FILE_VERSIONS,
|
||||||
} from "./actions";
|
} from "./actions";
|
||||||
import { api } from "asc-web-common";
|
import { api } from "asc-web-common";
|
||||||
import { isFileSelected, skipFile, getFilesBySelected } from "./selectors";
|
import { isFileSelected, skipFile, getFilesBySelected } from "./selectors";
|
||||||
@ -389,7 +390,7 @@ const initialState = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
privacyInstructions: "https://www.onlyoffice.com/private-rooms.aspx",
|
privacyInstructions: "https://www.onlyoffice.com/private-rooms.aspx",
|
||||||
versionHistory: { isVisible: false, fileId: null },
|
versionHistory: { isVisible: false, fileId: null, versions: null },
|
||||||
};
|
};
|
||||||
|
|
||||||
const filesReducer = (state = initialState, action) => {
|
const filesReducer = (state = initialState, action) => {
|
||||||
@ -569,14 +570,14 @@ const filesReducer = (state = initialState, action) => {
|
|||||||
uploadData: action.uploadData,
|
uploadData: action.uploadData,
|
||||||
});
|
});
|
||||||
|
|
||||||
case SET_IS_VERSION_HISTORY_PANEL:
|
case SET_IS_VER_HISTORY_PANEL:
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
versionHistory: {
|
versionHistory: {
|
||||||
...state.versionHistory,
|
...state.versionHistory,
|
||||||
isVisible: action.isVisible,
|
isVisible: action.isVisible,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
case SET_VERSION_HISTORY_FILE_ID: {
|
case SET_VER_HISTORY_FILE_ID: {
|
||||||
return Object.assign({}, state, {
|
return Object.assign({}, state, {
|
||||||
versionHistory: {
|
versionHistory: {
|
||||||
...state.versionHistory,
|
...state.versionHistory,
|
||||||
@ -584,6 +585,15 @@ const filesReducer = (state = initialState, action) => {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case SET_FILE_VERSIONS: {
|
||||||
|
return Object.assign({}, state, {
|
||||||
|
versionHistory: {
|
||||||
|
...state.versionHistory,
|
||||||
|
versions: action.versions,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -1053,14 +1053,18 @@ export const getPrivacyInstructionsLink = (state) => {
|
|||||||
return state.files.privacyInstructions;
|
return state.files.privacyInstructions;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getIsVersionHistoryPanel = (state) => {
|
export const getIsVerHistoryPanel = (state) => {
|
||||||
return state.files.versionHistory.isVisible;
|
return state.files.versionHistory.isVisible;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getVersionHistoryFileId = (state) => {
|
export const getVerHistoryFileId = (state) => {
|
||||||
return state.files.versionHistory.fileId;
|
return state.files.versionHistory.fileId;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const getFileVersions = (state) => {
|
||||||
|
return state.files.versionHistory.versions;
|
||||||
|
};
|
||||||
|
|
||||||
export const getHeaderVisible = createSelector(
|
export const getHeaderVisible = createSelector(
|
||||||
getSelectionLength,
|
getSelectionLength,
|
||||||
getSelected,
|
getSelected,
|
||||||
|
Loading…
Reference in New Issue
Block a user