From 20fac9afc72e66885aa96c733016635d79f930cb Mon Sep 17 00:00:00 2001 From: llj Date: Fri, 26 Jul 2019 11:39:46 +0800 Subject: [PATCH 1/3] [publish a library] fixup (#3920) --- frontend/src/components/dialog/wiki-select-dialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/src/components/dialog/wiki-select-dialog.js b/frontend/src/components/dialog/wiki-select-dialog.js index 1959a4029e..bccc0b5bb0 100644 --- a/frontend/src/components/dialog/wiki-select-dialog.js +++ b/frontend/src/components/dialog/wiki-select-dialog.js @@ -68,7 +68,7 @@ class WikiSelectDialog extends React.Component { return ( - {gettext('icon')} + {Utils.getLibIconTitle(repo)} {repo.repo_name} {moment(repo.last_modified).fromNow()} From a0a73cfc1ec6aed594e4ed0baee702a28fe1ea96 Mon Sep 17 00:00:00 2001 From: Michael An <2331806369@qq.com> Date: Fri, 26 Jul 2019 14:13:51 +0800 Subject: [PATCH 2/3] change i18n path (#3921) --- frontend/src/i18n.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/src/i18n.js b/frontend/src/i18n.js index 6d60035d02..40289fe618 100644 --- a/frontend/src/i18n.js +++ b/frontend/src/i18n.js @@ -1,7 +1,6 @@ import i18n from 'i18next'; import XHR from 'i18next-xhr-backend'; - -let siteRoot = window.app.config.siteRoot; +import { mediaUrl } from './utils/constants'; i18n .use(XHR) @@ -14,7 +13,7 @@ i18n whitelist: ['en', 'zh-CN', 'fr', 'de', 'cs', 'es', 'es-AR', 'es-MX', 'ru'], backend: { - loadPath: siteRoot + 'media/assets/frontend/locales/{{ lng }}/{{ ns }}.json', + loadPath: mediaUrl + 'assets/frontend/locales/{{ lng }}/{{ ns }}.json', // loadPath: '/media/locales/{{lng}}/{{ns}}.json', }, From e50d408782443083aa2092c24f1c2acf4a373b31 Mon Sep 17 00:00:00 2001 From: zxj96 <35951769+zxj96@users.noreply.github.com> Date: Fri, 26 Jul 2019 14:55:09 +0800 Subject: [PATCH 3/3] add files thumbnail (#3903) --- .../dirent-list-view/dirent-list-item.js | 21 ++--- .../dirent-list-view/dirent-list-view.js | 27 +++++++ .../draggable/dirents-dragged-preview.js | 79 +++++++++++++++++++ 3 files changed, 117 insertions(+), 10 deletions(-) create mode 100644 frontend/src/components/draggable/dirents-dragged-preview.js diff --git a/frontend/src/components/dirent-list-view/dirent-list-item.js b/frontend/src/components/dirent-list-view/dirent-list-item.js index 6882a57744..9131ae4b23 100644 --- a/frontend/src/components/dirent-list-view/dirent-list-item.js +++ b/frontend/src/components/dirent-list-view/dirent-list-item.js @@ -50,6 +50,7 @@ const propTypes = { enableDirPrivateShare: PropTypes.bool.isRequired, showDirentDetail: PropTypes.func.isRequired, onItemsMove: PropTypes.func.isRequired, + onShowDirentsDraggablePreview: PropTypes.func, }; class DirentListItem extends React.Component { @@ -362,14 +363,11 @@ class DirentListItem extends React.Component { if (Utils.isIEBrower()) { return false; } - e.dataTransfer.effectAllowed = 'move'; - if (e.dataTransfer && e.dataTransfer.setDragImage) { - e.dataTransfer.setDragImage(this.refs.drag_icon, 15, 15); - } - let { selectedDirentList } = this.props; if (selectedDirentList.length > 0 && selectedDirentList.includes(this.props.dirent)) { // drag items and selectedDirentList include item + this.props.onShowDirentsDraggablePreview(); + e.dataTransfer.setDragImage(this.refs.empty_content, 0, 0); // Show an empty content let selectedList = selectedDirentList.map(item => { let nodeRootPath = this.getDirentPath(item); let dragStartItemData = {nodeDirent: item, nodeParentPath: this.props.path, nodeRootPath: nodeRootPath}; @@ -380,6 +378,10 @@ class DirentListItem extends React.Component { return ; } + if (e.dataTransfer && e.dataTransfer.setDragImage) { + e.dataTransfer.setDragImage(this.refs.drag_icon, 15, 15); + } + let nodeRootPath = this.getDirentPath(this.props.dirent); let dragStartItemData = {nodeDirent: this.props.dirent, nodeParentPath: this.props.path, nodeRootPath: nodeRootPath}; dragStartItemData = JSON.stringify(dragStartItemData); @@ -426,6 +428,8 @@ class DirentListItem extends React.Component { } if (this.props.dirent.type === 'dir') { e.stopPropagation(); + } else { + return; } let dragStartItemData = e.dataTransfer.getData('applicaiton/drag-item-info'); dragStartItemData = JSON.parse(dragStartItemData); @@ -451,10 +455,6 @@ class DirentListItem extends React.Component { return; } - if (dropItemData.type !== 'dir') { - return; - } - // copy the dirent to it's child. eg: A/B -> A/B/C if (dropItemData.type === 'dir' && nodeDirent.type === 'dir') { if (nodeParentPath !== this.props.path) { @@ -590,7 +590,7 @@ class DirentListItem extends React.Component { } {dirent.is_locked && {gettext('locked')}} +
diff --git a/frontend/src/components/dirent-list-view/dirent-list-view.js b/frontend/src/components/dirent-list-view/dirent-list-view.js index fc1cb5f2f9..d5eb438139 100644 --- a/frontend/src/components/dirent-list-view/dirent-list-view.js +++ b/frontend/src/components/dirent-list-view/dirent-list-view.js @@ -17,6 +17,7 @@ import CopyDirentDialog from '../dialog/copy-dirent-dialog'; import DirentListItem from './dirent-list-item'; import ContextMenu from '../context-menu/context-menu'; import { hideMenu, showMenu } from '../context-menu/actions'; +import DirentsDraggedPreview from '../draggable/dirents-dragged-preview'; const propTypes = { path: PropTypes.string.isRequired, @@ -69,6 +70,7 @@ class DirentListView extends React.Component { isMutipleOperation: true, activeDirent: null, isListDropTipShow: false, + isShowDirentsDraggablePreview: false, }; this.enteredCounter = 0; // Determine whether to enter the child element to avoid dragging bubbling bugs。 @@ -567,6 +569,9 @@ class DirentListView extends React.Component { } this.enteredCounter++; if (this.enteredCounter !== 0) { + if (this.state.isListDropTipShow) { + return ; + } this.setState({isListDropTipShow: true}); } } @@ -619,6 +624,18 @@ class DirentListView extends React.Component { this.props.onItemMove(this.props.currentRepoInfo, nodeDirent, this.props.path, nodeParentPath); } + onShowDirentsDraggablePreview = () => { + this.setState({ + isShowDirentsDraggablePreview: true, + }); + } + + onHideDirentsDraggablePreview = () => { + this.setState({ + isShowDirentsDraggablePreview: false + }); + } + render() { const { direntList, sortBy, sortOrder } = this.props; @@ -694,6 +711,7 @@ class DirentListView extends React.Component { getDirentItemMenuList={this.getDirentItemMenuList} showDirentDetail={this.props.showDirentDetail} onItemsMove={this.props.onItemsMove} + onShowDirentsDraggablePreview={this.onShowDirentsDraggablePreview} /> ); })} @@ -714,6 +732,15 @@ class DirentListView extends React.Component { id={'dirents-menu'} onMenuItemClick={this.onDirentsMenuItemClick} /> + {this.state.isShowDirentsDraggablePreview && + + + + } {this.state.isImagePopupOpen && ( { + this.element.style.opacity = 0; + this.props.onHideDirentsDraggablePreview(); + } + + handleDragOver = (event) => { + if (Utils.isIEBrower()) { + return false; + } + event.preventDefault(); + event.dataTransfer.dropEffect = 'move'; + + this.element.style.top = event.clientY + 'px'; + this.element.style.left = event.clientX + 'px'; + } + + handleDrop = (event) => { + this.element.style.opacity = 0; + this.props.onHideDirentsDraggablePreview(); + } + + render() { + let{ selectedDirentList } = this.props; + const inlineStyle = { + position: 'absolute', + opacity: 1, + pointerEvents: 'none', + display: 'block', + left: '-9999px', + top: '-9999px', + zIndex: 101, + maxHeight: document.documentElement.clientHeight, + overflow: 'hidden' + }; + return ( +
this.element = element}> + {selectedDirentList.map((dirent, index) => { + let iconUrl = Utils.getDirentIcon(dirent); + return ( +
+ {dirent.encoded_thumbnail_src ? + : + + } +
+ ); + })} +
+ ); + } +} + +DirentsDraggedPreview.propTypes = propTypes; + +export default DirentsDraggedPreview;