mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-19 18:29:23 +00:00
support set permission for share link (#6332)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import React from 'react';
|
||||
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 { Utils } from '../../utils/utils';
|
||||
import ShareLink from '../../models/share-link';
|
||||
@@ -55,34 +55,32 @@ class ShareLinkPanel extends React.Component {
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
|
||||
if (isPro) {
|
||||
const { itemType, userPerm } = this.props;
|
||||
if (itemType == 'library') {
|
||||
let permissionOptions = Utils.getShareLinkPermissionList(itemType, userPerm, path);
|
||||
const { itemType, userPerm } = this.props;
|
||||
if (itemType == 'library') {
|
||||
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({
|
||||
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({
|
||||
permissionOptions: permissionOptions,
|
||||
currentPermission: permissionOptions[0],
|
||||
});
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
toaster.danger(errMessage);
|
||||
});
|
||||
}
|
||||
}).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 moment from 'moment';
|
||||
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 { Utils } from '../../utils/utils';
|
||||
import ShareLink from '../../models/share-link';
|
||||
@@ -101,11 +101,11 @@ class LinkCreation extends React.Component {
|
||||
this.setState({errorInfo: ''});
|
||||
let { type, itemPath, repoID } = this.props;
|
||||
let { linkAmount, isShowPasswordInput, password, isExpireChecked, expType, expireDays, expDate } = this.state;
|
||||
|
||||
const permissionDetails = Utils.getShareLinkPermissionObject(this.state.currentPermission).permissionDetails;
|
||||
let permissions;
|
||||
if (isPro) {
|
||||
const permissionDetails = Utils.getShareLinkPermissionObject(this.state.currentPermission).permissionDetails;
|
||||
permissions = JSON.stringify(permissionDetails);
|
||||
}
|
||||
permissions = JSON.stringify(permissionDetails);
|
||||
|
||||
let expirationTime = '';
|
||||
if (isExpireChecked) {
|
||||
if (expType == 'by-days') {
|
||||
@@ -327,7 +327,7 @@ class LinkCreation extends React.Component {
|
||||
</div>
|
||||
}
|
||||
</FormGroup>
|
||||
{(isPro && !isCustomPermission) && (
|
||||
{!isCustomPermission && (
|
||||
<FormGroup check>
|
||||
<Label check>
|
||||
<span>{gettext('Set permission')}</span>
|
||||
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
||||
import moment from 'moment';
|
||||
import copy from 'copy-to-clipboard';
|
||||
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 CommonOperationConfirmationDialog from '../../components/dialog/common-operation-confirmation-dialog';
|
||||
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>
|
||||
<dd style={{width:'250px'}} onMouseEnter={this.handleMouseOver} onMouseLeave={this.handleMouseOut}>
|
||||
|
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
|
||||
import moment from 'moment';
|
||||
import copy from 'copy-to-clipboard';
|
||||
import toaster from '../toast';
|
||||
import { isPro, gettext } from '../../utils/constants';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import CommonOperationConfirmationDialog from '../../components/dialog/common-operation-confirmation-dialog';
|
||||
|
||||
@@ -103,7 +103,7 @@ class LinkItem extends React.Component {
|
||||
{this.cutLink(link)}
|
||||
</td>
|
||||
<td>
|
||||
{(isPro && permissions) && Utils.getShareLinkPermissionObject(currentPermission).text}
|
||||
{permissions && Utils.getShareLinkPermissionObject(currentPermission).text}
|
||||
</td>
|
||||
<td>
|
||||
{expire_date ? moment(expire_date).format('YYYY-MM-DD HH:mm') : '--'}
|
||||
|
Reference in New Issue
Block a user