mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-20 10:58:33 +00:00
[share admin] upload links: added support for mobile; improvement (#4011)
* and improved 'share links'
This commit is contained in:
@@ -6,7 +6,7 @@ import { Button, Form, FormGroup, Label, Input, InputGroup, InputGroupAddon, Ale
|
||||
import { gettext, shareLinkPasswordMinLength, canSendShareLinkEmail } from '../../utils/constants';
|
||||
import { seafileAPI } from '../../utils/seafile-api';
|
||||
import { Utils } from '../../utils/utils';
|
||||
import SharedUploadInfo from '../../models/shared-upload-info';
|
||||
import UploadLink from '../../models/upload-link';
|
||||
import toaster from '../toast';
|
||||
import SendLink from '../send-link';
|
||||
import SessionExpiredTip from '../session-expired-tip';
|
||||
@@ -41,7 +41,7 @@ class GenerateUploadLink extends React.Component {
|
||||
let repoID = this.props.repoID;
|
||||
seafileAPI.getUploadLinks(repoID, path).then((res) => {
|
||||
if (res.data.length !== 0) {
|
||||
let sharedUploadInfo = new SharedUploadInfo(res.data[0]);
|
||||
let sharedUploadInfo = new UploadLink(res.data[0]);
|
||||
this.setState({sharedUploadInfo: sharedUploadInfo});
|
||||
}
|
||||
}).catch((err) => {
|
||||
@@ -98,7 +98,7 @@ class GenerateUploadLink extends React.Component {
|
||||
let isValid = this.validateParamsInput();
|
||||
if (isValid) {
|
||||
seafileAPI.createUploadLink(repoID, path, password, expireDays).then((res) => {
|
||||
let sharedUploadInfo = new SharedUploadInfo(res.data);
|
||||
let sharedUploadInfo = new UploadLink(res.data);
|
||||
this.setState({sharedUploadInfo: sharedUploadInfo});
|
||||
}).catch(error => {
|
||||
let errMessage = Utils.getErrorMsg(error);
|
||||
|
44
frontend/src/components/dialog/share-admin-link.js
Normal file
44
frontend/src/components/dialog/share-admin-link.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { Modal, ModalHeader, ModalBody, ModalFooter, Button } from 'reactstrap';
|
||||
import copy from '@seafile/seafile-editor/dist//utils/copy-to-clipboard';
|
||||
import { gettext } from '../../utils/constants';
|
||||
import toaster from '../../components/toast';
|
||||
|
||||
const propTypes = {
|
||||
link: PropTypes.string.isRequired,
|
||||
toggleDialog: PropTypes.func.isRequired
|
||||
};
|
||||
|
||||
class ShareAdminLink extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
copyToClipboard = () => {
|
||||
copy(this.props.link);
|
||||
this.props.toggleDialog();
|
||||
toaster.success(gettext('The link is copied to the clipboard.')), {duration: 2};
|
||||
}
|
||||
|
||||
render() {
|
||||
const { link, toggleDialog } = this.props;
|
||||
return (
|
||||
<Modal isOpen={true} toggle={toggleDialog}>
|
||||
<ModalHeader toggle={toggleDialog}>{gettext('Link')}</ModalHeader>
|
||||
<ModalBody>
|
||||
<a href={link}>{link}</a>
|
||||
</ModalBody>
|
||||
<ModalFooter>
|
||||
<Button color="primary" onClick={this.copyToClipboard}>{gettext('Copy')}</Button>
|
||||
<Button color="secondary" onClick={toggleDialog}>{gettext('Close')}</Button>
|
||||
</ModalFooter>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
ShareAdminLink.propTypes = propTypes;
|
||||
|
||||
export default ShareAdminLink;
|
Reference in New Issue
Block a user