mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-04 00:20:07 +00:00
Session optimization (#3423)
This commit is contained in:
@@ -7,6 +7,7 @@ import { seafileAPI } from '../../utils/seafile-api';
|
|||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import SharedUploadInfo from '../../models/shared-upload-info';
|
import SharedUploadInfo from '../../models/shared-upload-info';
|
||||||
import toaster from '../toast';
|
import toaster from '../toast';
|
||||||
|
import SessionExpiredTip from '../session-expired-tip';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
itemPath: PropTypes.string.isRequired,
|
itemPath: PropTypes.string.isRequired,
|
||||||
@@ -38,6 +39,14 @@ class GenerateUploadLink extends React.Component {
|
|||||||
let sharedUploadInfo = new SharedUploadInfo(res.data[0]);
|
let sharedUploadInfo = new SharedUploadInfo(res.data[0]);
|
||||||
this.setState({sharedUploadInfo: sharedUploadInfo});
|
this.setState({sharedUploadInfo: sharedUploadInfo});
|
||||||
}
|
}
|
||||||
|
}).catch((err) => {
|
||||||
|
if (err.response.status === 403) {
|
||||||
|
toaster.danger(
|
||||||
|
<SessionExpiredTip />,
|
||||||
|
{id: 'session_expired', duration: 3600}
|
||||||
|
)
|
||||||
|
this.props.closeShareDialog();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +134,6 @@ class GenerateUploadLink extends React.Component {
|
|||||||
|
|
||||||
let passwordLengthTip = gettext('(at least {passwordLength} characters)');
|
let passwordLengthTip = gettext('(at least {passwordLength} characters)');
|
||||||
passwordLengthTip = passwordLengthTip.replace('{passwordLength}', shareLinkPasswordMinLength);
|
passwordLengthTip = passwordLengthTip.replace('{passwordLength}', shareLinkPasswordMinLength);
|
||||||
|
|
||||||
if (this.state.sharedUploadInfo) {
|
if (this.state.sharedUploadInfo) {
|
||||||
let sharedUploadInfo = this.state.sharedUploadInfo;
|
let sharedUploadInfo = this.state.sharedUploadInfo;
|
||||||
return (
|
return (
|
||||||
|
@@ -320,10 +320,10 @@ class ShareToUser extends React.Component {
|
|||||||
onChangeUserPermission={this.onChangeUserPermission}
|
onChangeUserPermission={this.onChangeUserPermission}
|
||||||
/>
|
/>
|
||||||
{ canInvitePeople &&
|
{ canInvitePeople &&
|
||||||
<a href={siteRoot + 'invitations/'} className="invite-link-in-popup">
|
<a href={siteRoot + 'invitations/'} className="invite-link-in-popup">
|
||||||
<i className="sf2-icon-invite invite-link-icon-in-popup"></i>
|
<i className="sf2-icon-invite invite-link-icon-in-popup"></i>
|
||||||
<span className="invite-link-icon-in-popup">{gettext('Invite People')}</span>
|
<span className="invite-link-icon-in-popup">{gettext('Invite People')}</span>
|
||||||
</a>
|
</a>
|
||||||
}
|
}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
12
frontend/src/components/session-expired-tip.js
Normal file
12
frontend/src/components/session-expired-tip.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { gettext, loginUrl } from '../utils/constants';
|
||||||
|
|
||||||
|
function SessionExpiredTip() {
|
||||||
|
return(
|
||||||
|
<span className="session-expired-tip">{gettext('You are log out.')}{' '}
|
||||||
|
<a className="action-link session-expired-link" href={`${loginUrl}?next=${encodeURIComponent(location.href)}`}>{gettext('Login again.')}</a>
|
||||||
|
</span>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SessionExpiredTip
|
@@ -18,6 +18,7 @@ import LibDecryptDialog from '../../components/dialog/lib-decrypt-dialog';
|
|||||||
import LibContentToolbar from './lib-content-toolbar';
|
import LibContentToolbar from './lib-content-toolbar';
|
||||||
import LibContentContainer from './lib-content-container';
|
import LibContentContainer from './lib-content-container';
|
||||||
import FileUploader from '../../components/file-uploader/file-uploader';
|
import FileUploader from '../../components/file-uploader/file-uploader';
|
||||||
|
import SessionExpiredTip from '../../components/session-expired-tip';
|
||||||
|
|
||||||
const propTypes = {
|
const propTypes = {
|
||||||
pathPrefix: PropTypes.array.isRequired,
|
pathPrefix: PropTypes.array.isRequired,
|
||||||
@@ -72,6 +73,7 @@ class LibContentView extends React.Component {
|
|||||||
isDirentDetailShow: false,
|
isDirentDetailShow: false,
|
||||||
updateDetail: false,
|
updateDetail: false,
|
||||||
itemsShowLength: 100,
|
itemsShowLength: 100,
|
||||||
|
isSessionExpired: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.oldonpopstate = window.onpopstate;
|
this.oldonpopstate = window.onpopstate;
|
||||||
@@ -340,13 +342,14 @@ class LibContentView extends React.Component {
|
|||||||
showDir = (path) => {
|
showDir = (path) => {
|
||||||
let repoID = this.props.repoID;
|
let repoID = this.props.repoID;
|
||||||
|
|
||||||
// update stste
|
if (!this.state.isSessionExpired) {
|
||||||
this.setState({
|
// update stste
|
||||||
isDirentListLoading: true,
|
this.setState({
|
||||||
path: path,
|
isDirentListLoading: true,
|
||||||
isViewFile: false,
|
isViewFile: false,
|
||||||
selectedDirentList: [],
|
selectedDirentList: [],
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// update data
|
// update data
|
||||||
this.loadDirentList(path);
|
this.loadDirentList(path);
|
||||||
@@ -411,7 +414,13 @@ class LibContentView extends React.Component {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}).catch(() => {
|
}).catch((err) => {
|
||||||
|
if (err.response.status === 403) {
|
||||||
|
toaster.danger(
|
||||||
|
<SessionExpiredTip />,
|
||||||
|
{id: 'session_expired', duration: 3600}
|
||||||
|
)
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
isFileLoading: false,
|
isFileLoading: false,
|
||||||
isFileLoadedErr: true,
|
isFileLoadedErr: true,
|
||||||
@@ -445,12 +454,22 @@ class LibContentView extends React.Component {
|
|||||||
direntList: Utils.sortDirents(direntList, this.state.sortBy, this.state.sortOrder),
|
direntList: Utils.sortDirents(direntList, this.state.sortBy, this.state.sortOrder),
|
||||||
dirID: res.data.dir_id,
|
dirID: res.data.dir_id,
|
||||||
readmeMarkdown: markdownItem,
|
readmeMarkdown: markdownItem,
|
||||||
|
path: path,
|
||||||
|
isSessionExpired: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!this.state.repoEncrypted && direntList.length) {
|
if (!this.state.repoEncrypted && direntList.length) {
|
||||||
this.getThumbnails(repoID, path, this.state.direntList);
|
this.getThumbnails(repoID, path, this.state.direntList);
|
||||||
}
|
}
|
||||||
}).catch(() => {
|
}).catch((err) => {
|
||||||
|
if (err.response.status === 403) {
|
||||||
|
toaster.danger(
|
||||||
|
<SessionExpiredTip />,
|
||||||
|
{id: 'session_expired', duration: 3600}
|
||||||
|
)
|
||||||
|
this.setState({isDirentListLoading: false})
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.setState({
|
this.setState({
|
||||||
isDirentListLoading: false,
|
isDirentListLoading: false,
|
||||||
pathExist: false,
|
pathExist: false,
|
||||||
|
@@ -1034,6 +1034,14 @@ a.table-sort-op:focus {
|
|||||||
color: red;
|
color: red;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.session-expired-tip {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
|
.session-expired-link {
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* file-tag */
|
/* file-tag */
|
||||||
.tag-list {
|
.tag-list {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
Reference in New Issue
Block a user