mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 07:08:55 +00:00
optimized-error-handle (#4366)
* optimized-error-handle * update css * optimized code
This commit is contained in:
12
frontend/src/components/permission-denied-tip.js
Normal file
12
frontend/src/components/permission-denied-tip.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { gettext, loginUrl } from '../utils/constants';
|
||||||
|
|
||||||
|
function PermissionDeniedTip() {
|
||||||
|
return(
|
||||||
|
<span className="error">{gettext('Permission denied. Please try')}{' '}
|
||||||
|
<a className="action-link p-0" href={`${loginUrl}?next=${encodeURIComponent(location.href)}`}>{gettext('login again.')}</a>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default PermissionDeniedTip;
|
@@ -3,8 +3,8 @@ import { gettext, loginUrl } from '../utils/constants';
|
|||||||
|
|
||||||
function SessionExpiredTip() {
|
function SessionExpiredTip() {
|
||||||
return(
|
return(
|
||||||
<span className="session-expired-tip">{gettext('You are logged out.')}{' '}
|
<span className="error">{gettext('You are logged out.')}{' '}
|
||||||
<a className="action-link session-expired-link" href={`${loginUrl}?next=${encodeURIComponent(location.href)}`}>{gettext('Login again.')}</a>
|
<a className="action-link p-0" href={`${loginUrl}?next=${encodeURIComponent(location.href)}`}>{gettext('Login again.')}</a>
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@@ -3,7 +3,7 @@ import { strChineseFirstPY } from './pinyin-by-unicode';
|
|||||||
import TextTranslation from './text-translation';
|
import TextTranslation from './text-translation';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import toaster from '../components/toast';
|
import toaster from '../components/toast';
|
||||||
import SessionExpiredTip from '../components/session-expired-tip';
|
import PermissionDeniedTip from '../components/permission-denied-tip';
|
||||||
|
|
||||||
export const Utils = {
|
export const Utils = {
|
||||||
|
|
||||||
@@ -972,15 +972,16 @@ export const Utils = {
|
|||||||
/*
|
/*
|
||||||
* only used in the 'catch' part of a seafileAPI request
|
* only used in the 'catch' part of a seafileAPI request
|
||||||
*/
|
*/
|
||||||
getErrorMsg: function(error, showLoginTipIf403) {
|
getErrorMsg: function(error, showPermissionDeniedTip) {
|
||||||
let errorMsg = '';
|
let errorMsg = '';
|
||||||
if (error.response) {
|
if (error.response) {
|
||||||
if (error.response.status == 403) {
|
if (error.response.status == 403) {
|
||||||
if (showLoginTipIf403) {
|
if (showPermissionDeniedTip) {
|
||||||
toaster.danger(
|
toaster.danger(
|
||||||
<SessionExpiredTip />,
|
<PermissionDeniedTip />,
|
||||||
{id: 'session_expired', duration: 3600}
|
{id: 'permission_denied', duration: 3600}
|
||||||
);
|
);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
errorMsg = gettext('Permission denied');
|
errorMsg = gettext('Permission denied');
|
||||||
} else if (error.response.data &&
|
} else if (error.response.data &&
|
||||||
|
@@ -1107,14 +1107,6 @@ 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