Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'copy to clipboard' button on datasets #10529

Merged
merged 9 commits into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 43 additions & 5 deletions client/src/mvc/dataset/dataset-li.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import faIconButton from "ui/fa-icon-button";
import BASE_MVC from "mvc/base-mvc";
import _l from "utils/localization";
import { mountNametags } from "components/Nametags";
import { Toast } from "ui/toast";

var logNamespace = "dataset";
/*==============================================================================
Expand Down Expand Up @@ -257,7 +258,11 @@ export var DatasetListItemView = _super.extend(
case STATES.OK:
case STATES.FAILED_METADATA:
case STATES.ERROR:
return [this._renderDownloadButton(), this._renderShowParamsButton()];
return [
this._renderDownloadButton(),
this._renderClipboardButton(),
this._renderShowParamsButton(),
];
}
return [this._renderShowParamsButton()];
},
Expand Down Expand Up @@ -286,15 +291,48 @@ export var DatasetListItemView = _super.extend(
},
});
},
isPurged: function () {
// don't show anything if the data's been purged
return !!(this.model.get("purged") || !this.model.hasData());
},
/** Render icon-button/popupmenu to download the data (and/or the associated meta files (bai, etc.)) for this.
* @returns {jQuery} rendered DOM
*/
_renderClipboardButton: function () {
const isUnsharable =
this.model.attributes.permissions &&
this.model.attributes.permissions.access.length === 1 &&
this.model.attributes.permissions.access.includes(getGalaxyInstance().user.id);

var urls = this.model.urls;
if (!this.isPurged() && urls.download) {
let title = _l("Copy link");
let style = "";
if (isUnsharable) {
title = _l("Preferences restrict sharing");
style = "opacity: 0.3";
}
return faIconButton({
faIcon: "fa-chain",
style: style,
title: title,
onclick: function () {
if (!isUnsharable)
navigator.clipboard.writeText(`${window.location.origin}${urls.download}`).then(() => {
Toast.info("Link is copied to your clipboard");
});
else {
Toast.warning("Dataset is not sharable");
}
},
});
}
},
/** Render icon-button/popupmenu to download the data (and/or the associated meta files (bai, etc.)) for this.
* @returns {jQuery} rendered DOM
*/
_renderDownloadButton: function () {
// don't show anything if the data's been purged
if (this.model.get("purged") || !this.model.hasData()) {
return null;
}
if (this.isPurged()) return null;

// return either: a popupmenu with links to download assoc. meta files (if there are meta files)
// or a single download icon-button (if there are no meta files)
Expand Down
4 changes: 2 additions & 2 deletions client/src/mvc/tool/tool-form-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ export default FormBase.extend({
tooltip: "View available options",
});
menu_button.addMenu({
icon: "fa-share",
title: _l("Get link"),
icon: "fa-chain",
title: _l("Copy link"),
onclick: function () {
if (navigator.clipboard) {
navigator.clipboard
Expand Down
2 changes: 2 additions & 0 deletions client/src/ui/fa-icon-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ var faIconButton = (options) => {
// could go with something less specific here - like 'html'
'<span class="fa ',
options.faIcon,
'" style="',
options.style,
'"></span>',
"</a>",
].join("");
Expand Down
3 changes: 3 additions & 0 deletions lib/galaxy/selenium/navigates_galaxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,9 @@ def history_panel_click_item_title(self, hid, **kwds):
details_component = item_component.details
details_displayed = details_component.is_displayed
item_component.title.wait_for_and_click()
# for i in range(88888):
# self.sleep_for(WAIT_TYPES.UX_RENDER)

if kwds.get("wait", False):
if details_displayed:
details_component.wait_for_absent_or_hidden()
Expand Down