2023-05-12 11:24:34 +08:00
|
|
|
import React, { Fragment } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2024-09-23 16:21:08 +08:00
|
|
|
import { gettext } from '../../utils/constants';
|
|
|
|
import InternalLinkDialog from '../dialog/internal-link-dialog';
|
|
|
|
import './internal-link-operation.css';
|
2023-05-12 11:24:34 +08:00
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
repoID: PropTypes.string.isRequired,
|
|
|
|
path: PropTypes.string.isRequired,
|
|
|
|
};
|
|
|
|
|
|
|
|
class InternalLinkOperation extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
isShowInternalLinkDialog: false
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
onInternalLinkDialogToggle = () => {
|
2024-07-18 11:58:42 +08:00
|
|
|
this.setState({ isShowInternalLinkDialog: !this.state.isShowInternalLinkDialog });
|
2023-09-13 08:40:50 +08:00
|
|
|
};
|
2023-05-12 11:24:34 +08:00
|
|
|
|
|
|
|
render() {
|
|
|
|
const { repoID, path } = this.props;
|
|
|
|
const { isShowInternalLinkDialog } = this.state;
|
|
|
|
const title = gettext('Internal Link');
|
|
|
|
return (
|
|
|
|
<Fragment>
|
|
|
|
<span className='dialog-operation'>
|
2024-06-28 08:39:44 +08:00
|
|
|
<i className="file-internal-link sf3-font sf3-font-link" title={title} aria-label={title} onClick={this.onInternalLinkDialogToggle}/>
|
2023-05-12 11:24:34 +08:00
|
|
|
</span>
|
|
|
|
{isShowInternalLinkDialog && (
|
|
|
|
<InternalLinkDialog
|
|
|
|
repoID={repoID}
|
|
|
|
path={path}
|
|
|
|
onInternalLinkDialogToggle={this.onInternalLinkDialogToggle}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
</Fragment>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
InternalLinkOperation.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default InternalLinkOperation;
|