mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-16 15:19:06 +00:00
support set permission for share link (#6332)
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { isPro, gettext, shareLinkExpireDaysMin, shareLinkExpireDaysMax, shareLinkExpireDaysDefault } from '../../utils/constants';
|
import { gettext, shareLinkExpireDaysMin, shareLinkExpireDaysMax, shareLinkExpireDaysDefault } from '../../utils/constants';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import ShareLink from '../../models/share-link';
|
import ShareLink from '../../models/share-link';
|
||||||
@@ -55,34 +55,32 @@ class ShareLinkPanel extends React.Component {
|
|||||||
toaster.danger(errMessage);
|
toaster.danger(errMessage);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (isPro) {
|
const { itemType, userPerm } = this.props;
|
||||||
const { itemType, userPerm } = this.props;
|
if (itemType == 'library') {
|
||||||
if (itemType == 'library') {
|
let permissionOptions = Utils.getShareLinkPermissionList(itemType, userPerm, path);
|
||||||
let permissionOptions = Utils.getShareLinkPermissionList(itemType, userPerm, path);
|
this.setState({
|
||||||
|
permissionOptions: permissionOptions,
|
||||||
|
currentPermission: permissionOptions[0],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
let getDirentInfoAPI;
|
||||||
|
if (this.props.itemType === 'file') {
|
||||||
|
getDirentInfoAPI = seafileAPI.getFileInfo(repoID, path);
|
||||||
|
} else if (this.props.itemType === 'dir') {
|
||||||
|
getDirentInfoAPI = seafileAPI.getDirInfo(repoID, path);
|
||||||
|
}
|
||||||
|
getDirentInfoAPI.then((res) => {
|
||||||
|
let canEdit = res.data.can_edit;
|
||||||
|
let permission = res.data.permission;
|
||||||
|
let permissionOptions = Utils.getShareLinkPermissionList(this.props.itemType, permission, path, canEdit);
|
||||||
this.setState({
|
this.setState({
|
||||||
permissionOptions: permissionOptions,
|
permissionOptions: permissionOptions,
|
||||||
currentPermission: permissionOptions[0],
|
currentPermission: permissionOptions[0],
|
||||||
});
|
});
|
||||||
} else {
|
}).catch(error => {
|
||||||
let getDirentInfoAPI;
|
let errMessage = Utils.getErrorMsg(error);
|
||||||
if (this.props.itemType === 'file') {
|
toaster.danger(errMessage);
|
||||||
getDirentInfoAPI = seafileAPI.getFileInfo(repoID, path);
|
});
|
||||||
} else if (this.props.itemType === 'dir') {
|
|
||||||
getDirentInfoAPI = seafileAPI.getDirInfo(repoID, path);
|
|
||||||
}
|
|
||||||
getDirentInfoAPI.then((res) => {
|
|
||||||
let canEdit = res.data.can_edit;
|
|
||||||
let permission = res.data.permission;
|
|
||||||
let permissionOptions = Utils.getShareLinkPermissionList(this.props.itemType, permission, path, canEdit);
|
|
||||||
this.setState({
|
|
||||||
permissionOptions: permissionOptions,
|
|
||||||
currentPermission: permissionOptions[0],
|
|
||||||
});
|
|
||||||
}).catch(error => {
|
|
||||||
let errMessage = Utils.getErrorMsg(error);
|
|
||||||
toaster.danger(errMessage);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,7 +2,7 @@ import React, { Fragment } from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import { Button, Form, FormGroup, Label, Input, InputGroup, InputGroupAddon, Alert } from 'reactstrap';
|
import { Button, Form, FormGroup, Label, Input, InputGroup, InputGroupAddon, Alert } from 'reactstrap';
|
||||||
import { isPro, gettext, shareLinkExpireDaysMin, shareLinkExpireDaysMax, shareLinkExpireDaysDefault, shareLinkForceUsePassword, shareLinkPasswordMinLength, shareLinkPasswordStrengthLevel } from '../../utils/constants';
|
import { gettext, shareLinkExpireDaysMin, shareLinkExpireDaysMax, shareLinkExpireDaysDefault, shareLinkForceUsePassword, shareLinkPasswordMinLength, shareLinkPasswordStrengthLevel } from '../../utils/constants';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import ShareLink from '../../models/share-link';
|
import ShareLink from '../../models/share-link';
|
||||||
@@ -101,11 +101,11 @@ class LinkCreation extends React.Component {
|
|||||||
this.setState({errorInfo: ''});
|
this.setState({errorInfo: ''});
|
||||||
let { type, itemPath, repoID } = this.props;
|
let { type, itemPath, repoID } = this.props;
|
||||||
let { linkAmount, isShowPasswordInput, password, isExpireChecked, expType, expireDays, expDate } = this.state;
|
let { linkAmount, isShowPasswordInput, password, isExpireChecked, expType, expireDays, expDate } = this.state;
|
||||||
|
|
||||||
|
const permissionDetails = Utils.getShareLinkPermissionObject(this.state.currentPermission).permissionDetails;
|
||||||
let permissions;
|
let permissions;
|
||||||
if (isPro) {
|
permissions = JSON.stringify(permissionDetails);
|
||||||
const permissionDetails = Utils.getShareLinkPermissionObject(this.state.currentPermission).permissionDetails;
|
|
||||||
permissions = JSON.stringify(permissionDetails);
|
|
||||||
}
|
|
||||||
let expirationTime = '';
|
let expirationTime = '';
|
||||||
if (isExpireChecked) {
|
if (isExpireChecked) {
|
||||||
if (expType == 'by-days') {
|
if (expType == 'by-days') {
|
||||||
@@ -327,7 +327,7 @@ class LinkCreation extends React.Component {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
{(isPro && !isCustomPermission) && (
|
{!isCustomPermission && (
|
||||||
<FormGroup check>
|
<FormGroup check>
|
||||||
<Label check>
|
<Label check>
|
||||||
<span>{gettext('Set permission')}</span>
|
<span>{gettext('Set permission')}</span>
|
||||||
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import copy from 'copy-to-clipboard';
|
import copy from 'copy-to-clipboard';
|
||||||
import { Button } from 'reactstrap';
|
import { Button } from 'reactstrap';
|
||||||
import { isPro, gettext, shareLinkExpireDaysMin, shareLinkExpireDaysMax, shareLinkExpireDaysDefault, canSendShareLinkEmail } from '../../utils/constants';
|
import { gettext, shareLinkExpireDaysMin, shareLinkExpireDaysMax, shareLinkExpireDaysDefault, canSendShareLinkEmail } from '../../utils/constants';
|
||||||
import Selector from '../../components/single-selector';
|
import Selector from '../../components/single-selector';
|
||||||
import CommonOperationConfirmationDialog from '../../components/dialog/common-operation-confirmation-dialog';
|
import CommonOperationConfirmationDialog from '../../components/dialog/common-operation-confirmation-dialog';
|
||||||
import { seafileAPI } from '../../utils/seafile-api';
|
import { seafileAPI } from '../../utils/seafile-api';
|
||||||
@@ -234,7 +234,7 @@ class LinkDetails extends React.Component {
|
|||||||
}
|
}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{(isPro && sharedLinkInfo.permissions) && (
|
{sharedLinkInfo.permissions && (
|
||||||
<>
|
<>
|
||||||
<dt className="text-secondary font-weight-normal">{gettext('Permission:')}</dt>
|
<dt className="text-secondary font-weight-normal">{gettext('Permission:')}</dt>
|
||||||
<dd style={{width:'250px'}} onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}>
|
<dd style={{width:'250px'}} onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}>
|
||||||
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
|||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import copy from 'copy-to-clipboard';
|
import copy from 'copy-to-clipboard';
|
||||||
import toaster from '../toast';
|
import toaster from '../toast';
|
||||||
import { isPro, gettext } from '../../utils/constants';
|
import { gettext } from '../../utils/constants';
|
||||||
import { Utils } from '../../utils/utils';
|
import { Utils } from '../../utils/utils';
|
||||||
import CommonOperationConfirmationDialog from '../../components/dialog/common-operation-confirmation-dialog';
|
import CommonOperationConfirmationDialog from '../../components/dialog/common-operation-confirmation-dialog';
|
||||||
|
|
||||||
@@ -103,7 +103,7 @@ class LinkItem extends React.Component {
|
|||||||
{this.cutLink(link)}
|
{this.cutLink(link)}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{(isPro && permissions) && Utils.getShareLinkPermissionObject(currentPermission).text}
|
{permissions && Utils.getShareLinkPermissionObject(currentPermission).text}
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
{expire_date ? moment(expire_date).format('YYYY-MM-DD HH:mm') : '--'}
|
{expire_date ? moment(expire_date).format('YYYY-MM-DD HH:mm') : '--'}
|
||||||
|
Reference in New Issue
Block a user