2019-01-09 04:10:33 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import ModalPortal from './modal-portal';
|
|
|
|
import ListTaggedFilesDialog from './dialog/list-taggedfiles-dialog';
|
|
|
|
|
|
|
|
import '../css/repo-info-bar.css';
|
|
|
|
|
|
|
|
const propTypes = {
|
|
|
|
repoID: PropTypes.string.isRequired,
|
|
|
|
usedRepoTags: PropTypes.array.isRequired,
|
2022-03-14 08:48:57 +00:00
|
|
|
updateUsedRepoTags: PropTypes.func,
|
|
|
|
onFileTagChanged: PropTypes.func,
|
|
|
|
className: PropTypes.string,
|
2022-03-15 02:53:16 +00:00
|
|
|
shareLinkToken: PropTypes.string,
|
|
|
|
enableFileDownload: PropTypes.bool
|
2019-01-09 04:10:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class RepoInfoBar extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.state = {
|
|
|
|
currentTag: null,
|
|
|
|
isListTaggedFileShow: false,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
onListTaggedFiles = (currentTag) => {
|
|
|
|
this.setState({
|
|
|
|
currentTag: currentTag,
|
2023-10-31 02:13:48 +00:00
|
|
|
isListTaggedFileShow: !this.state.isListTaggedFileShow
|
2019-01-09 04:10:33 +00:00
|
|
|
});
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-01-09 04:10:33 +00:00
|
|
|
|
|
|
|
onCloseDialog = () => {
|
|
|
|
this.setState({
|
|
|
|
isListTaggedFileShow: false
|
|
|
|
});
|
2023-09-13 00:40:50 +00:00
|
|
|
};
|
2019-01-09 04:10:33 +00:00
|
|
|
|
|
|
|
render() {
|
2024-03-25 09:22:01 +00:00
|
|
|
let { repoID, usedRepoTags, className } = this.props;
|
2022-03-14 08:48:57 +00:00
|
|
|
|
2019-01-09 04:10:33 +00:00
|
|
|
return (
|
2022-03-14 08:48:57 +00:00
|
|
|
<div className={`repo-info-bar ${className ? className : ''}`}>
|
2019-01-09 04:10:33 +00:00
|
|
|
{usedRepoTags.length > 0 && (
|
|
|
|
<ul className="used-tag-list">
|
|
|
|
{usedRepoTags.map((usedRepoTag) => {
|
|
|
|
return (
|
|
|
|
<li key={usedRepoTag.id} className="used-tag-item">
|
2024-07-18 03:58:42 +00:00
|
|
|
<span className="used-tag" style={{ backgroundColor: usedRepoTag.color }}></span>
|
2019-01-09 04:10:33 +00:00
|
|
|
<span className="used-tag-name" title={usedRepoTag.name}>{usedRepoTag.name}</span>
|
2021-09-27 06:44:38 +00:00
|
|
|
<button type="button" className="used-tag-files border-0 bg-transparent" onClick={this.onListTaggedFiles.bind(this, usedRepoTag)}>
|
2019-01-09 04:10:33 +00:00
|
|
|
{usedRepoTag.fileCount > 1 ? usedRepoTag.fileCount + ' files' : usedRepoTag.fileCount + ' file'}
|
2021-09-27 06:44:38 +00:00
|
|
|
</button>
|
2019-01-09 04:10:33 +00:00
|
|
|
</li>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</ul>
|
|
|
|
)}
|
|
|
|
{this.state.isListTaggedFileShow && (
|
|
|
|
<ModalPortal>
|
2019-01-18 06:50:42 +00:00
|
|
|
<ListTaggedFilesDialog
|
|
|
|
repoID={repoID}
|
|
|
|
currentTag={this.state.currentTag}
|
|
|
|
onClose={this.onCloseDialog}
|
|
|
|
toggleCancel={this.onListTaggedFiles}
|
2019-02-14 08:48:46 +00:00
|
|
|
updateUsedRepoTags={this.props.updateUsedRepoTags}
|
2019-04-21 02:21:48 +00:00
|
|
|
onFileTagChanged={this.props.onFileTagChanged}
|
2022-03-14 08:48:57 +00:00
|
|
|
shareLinkToken={this.props.shareLinkToken}
|
2022-03-15 02:53:16 +00:00
|
|
|
enableFileDownload={this.props.enableFileDownload}
|
2019-01-18 06:50:42 +00:00
|
|
|
/>
|
2019-01-09 04:10:33 +00:00
|
|
|
</ModalPortal>
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RepoInfoBar.propTypes = propTypes;
|
|
|
|
|
|
|
|
export default RepoInfoBar;
|