mirror of
https://github.com/haiwen/seahub.git
synced 2025-09-14 06:11:16 +00:00
Optimize internal link dialog cod (#5466)
* optimize code * optimize code
This commit is contained in:
6
frontend/src/components/operations/index.js
Normal file
6
frontend/src/components/operations/index.js
Normal file
@@ -0,0 +1,6 @@
|
||||
import InternalLinkOperation from './internal-link-operation';
|
||||
import './style.css';
|
||||
|
||||
export {
|
||||
InternalLinkOperation,
|
||||
};
|
@@ -0,0 +1,48 @@
|
||||
import React, { Fragment } from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import { gettext } from '../../../utils/constants';
|
||||
import InternalLinkDialog from '../../dialog/internal-link-dialog';
|
||||
|
||||
const propTypes = {
|
||||
repoID: PropTypes.string.isRequired,
|
||||
path: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
class InternalLinkOperation extends React.Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
isShowInternalLinkDialog: false
|
||||
};
|
||||
}
|
||||
|
||||
onInternalLinkDialogToggle = () => {
|
||||
this.setState({isShowInternalLinkDialog: !this.state.isShowInternalLinkDialog});
|
||||
}
|
||||
|
||||
render() {
|
||||
const { repoID, path } = this.props;
|
||||
const { isShowInternalLinkDialog } = this.state;
|
||||
const title = gettext('Internal Link');
|
||||
return (
|
||||
<Fragment>
|
||||
<span className='dialog-operation'>
|
||||
<i className="file-internal-link fa fa-link" title={title} aria-label={title} onClick={this.onInternalLinkDialogToggle}/>
|
||||
</span>
|
||||
{isShowInternalLinkDialog && (
|
||||
<InternalLinkDialog
|
||||
repoID={repoID}
|
||||
path={path}
|
||||
onInternalLinkDialogToggle={this.onInternalLinkDialogToggle}
|
||||
/>
|
||||
)}
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
InternalLinkOperation.propTypes = propTypes;
|
||||
|
||||
export default InternalLinkOperation;
|
17
frontend/src/components/operations/style.css
Normal file
17
frontend/src/components/operations/style.css
Normal file
@@ -0,0 +1,17 @@
|
||||
.dialog-operation {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.dialog-operation .file-internal-link {
|
||||
font-size: 12px;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
margin-left: 0.5rem;
|
||||
color: #999;
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
.dialog-operation .file-internal-link:hover {
|
||||
color: #333;
|
||||
}
|
Reference in New Issue
Block a user