Bug 25475 - upload.pl should provide a "Copy link" option
Summary: upload.pl should provide a "Copy link" option
Status: RESOLVED DUPLICATE of bug 27594
Alias: None
Product: Koha
Classification: Unclassified
Component: Tools (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: David Cook
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-05-13 06:46 UTC by David Cook
Modified: 2021-02-25 04:46 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 25475: add "Copy link" button to upload.pl (3.76 KB, patch)
2020-05-14 02:05 UTC, David Cook
Details | Diff | Splinter Review
Bug 25475: add "Copy link" button to upload.pl (3.82 KB, patch)
2020-10-06 11:46 UTC, PTFS Europe Sandboxes
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description David Cook 2020-05-13 06:46:52 UTC
It's really difficult to use /cgi-bin/koha/tools/upload.pl to upload arbitrary files. If we had a "Copy link" button, it would make it easier to upload files and then use them in content/news sections.
Comment 1 David Cook 2020-05-14 02:05:39 UTC
Created attachment 104858 [details] [review]
Bug 25475: add "Copy link" button to upload.pl

This patch adds a "Copy link" button to /cgi-bin/koha/tools/upload.pl.

It will create a modal that displays a URL like the following:
http://kohadev.myDNSname.org:8080/cgi-bin/koha/opac-retrieve-file.pl?
id=beb928969032f980056ea8269bc816fe
Users can then copy the URL from that modal.

If the browser supports the Clipboard API, the URL is also written to
the browser's clipboard, making manually copying from the modal redundant.

Test plan:
0) Apply patch
1) Go to http://localhost:8081/cgi-bin/koha/tools/upload.pl
2) Upload a file with the "Allow public downloads" box checked
3) Note the "Copy link" button in the "Actions" column
4) Click "Copy link"
5) Note that a modal is created with contents like the following:
http://kohadev.myDNSname.org:8080/cgi-bin/koha/opac-retrieve-file.pl?
id=beb928969032f980056ea8269bc816fe
5b) If you're using a modern browser, try Ctrl+V somewhere and note
that the URL has already been copied to your clipboard
6) Manually highlight the text in the modal and Ctrl+C
7) Click outside the modal
8) Paste the URL somewhere useful like a system preference or News item
9) Profit
Comment 2 PTFS Europe Sandboxes 2020-10-06 11:46:30 UTC
Created attachment 111296 [details] [review]
Bug 25475: add "Copy link" button to upload.pl

This patch adds a "Copy link" button to /cgi-bin/koha/tools/upload.pl.

It will create a modal that displays a URL like the following:
http://kohadev.myDNSname.org:8080/cgi-bin/koha/opac-retrieve-file.pl?
id=beb928969032f980056ea8269bc816fe
Users can then copy the URL from that modal.

If the browser supports the Clipboard API, the URL is also written to
the browser's clipboard, making manually copying from the modal redundant.

Test plan:
0) Apply patch
1) Go to http://localhost:8081/cgi-bin/koha/tools/upload.pl
2) Upload a file with the "Allow public downloads" box checked
3) Note the "Copy link" button in the "Actions" column
4) Click "Copy link"
5) Note that a modal is created with contents like the following:
http://kohadev.myDNSname.org:8080/cgi-bin/koha/opac-retrieve-file.pl?
id=beb928969032f980056ea8269bc816fe
5b) If you're using a modern browser, try Ctrl+V somewhere and note
that the URL has already been copied to your clipboard
6) Manually highlight the text in the modal and Ctrl+C
7) Click outside the modal
8) Paste the URL somewhere useful like a system preference or News item
9) Profit

Signed-off-by: Sally <sally.healey@cheshiresharedservices.gov.uk>
Comment 3 Sally 2020-10-06 11:49:05 UTC
This works but perhaps someone else wants to test the automatic link copying using a HTTPS site?
 
The sandbox I was using doesn't have an SSL certificate, so the link wasn't automatically copied to the clipboard, because Clipboard API isn't supported on HTTP.
Comment 4 David Cook 2020-10-07 04:23:35 UTC
Comment on attachment 111296 [details] [review]
Bug 25475: add "Copy link" button to upload.pl

Review of attachment 111296 [details] [review]:
-----------------------------------------------------------------

::: koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt
@@ +431,5 @@
> +                    var popup = '<div class="modal fade"><div class="modal-dialog"><div class="modal-content"><div class="modal-body">'+res+'</div></div></div></div>'
> +                    $(popup).modal();
> +                }
> +
> +                console.log(res);

Oops. That's a bit of debugging code that shouldn't be there.
Comment 5 David Cook 2020-10-07 04:24:29 UTC
(In reply to Sally from comment #3)
> This works but perhaps someone else wants to test the automatic link copying
> using a HTTPS site?
>  
> The sandbox I was using doesn't have an SSL certificate, so the link wasn't
> automatically copied to the clipboard, because Clipboard API isn't supported
> on HTTP.

As far as I know, that shouldn't be an issue. I tested this using a HTTP site.

What browser did you use and what exact issue did you have?
Comment 6 Sally 2020-10-07 12:45:51 UTC
(In reply to David Cook from comment #5)
> 
> As far as I know, that shouldn't be an issue. I tested this using a HTTP
> site.
> 
> What browser did you use and what exact issue did you have?

The problem is this:

5b) If you're using a modern browser, try Ctrl+V somewhere and note
that the URL has already been copied to your clipboard 

(If the browser supports the Clipboard API, the URL is also written to the browser's clipboard, making manually copying from the modal redundant.)

This doesn't happen for me on the sandbox - I had to manually copy the link from the modal, because Ctrl+V still retains my previous clipboard contents.

The web browser is Chrome 86.
Comment 7 David Cook 2020-10-08 02:11:34 UTC
(In reply to Sally from comment #6)
> (In reply to David Cook from comment #5)
> > 
> > As far as I know, that shouldn't be an issue. I tested this using a HTTP
> > site.
> > 
> > What browser did you use and what exact issue did you have?
> 
> The problem is this:
> 
> 5b) If you're using a modern browser, try Ctrl+V somewhere and note
> that the URL has already been copied to your clipboard 
> 
> (If the browser supports the Clipboard API, the URL is also written to the
> browser's clipboard, making manually copying from the modal redundant.)
> 
> This doesn't happen for me on the sandbox - I had to manually copy the link
> from the modal, because Ctrl+V still retains my previous clipboard contents.
> 
> The web browser is Chrome 86.

Hmm that's interesting. It should've worked for you. Maybe I'll have to test this one again...
Comment 8 Katrin Fischer 2020-10-15 22:48:46 UTC
 FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt
   OK	  filters
   FAIL	  forbidden patterns
		forbidden pattern: console.log (line 435)

I believe the line can just be removed?
Comment 9 Katrin Fischer 2020-10-15 22:49:43 UTC
Please also see comment #7 :)
Comment 10 David Cook 2020-10-16 00:13:25 UTC
(In reply to Katrin Fischer from comment #8)
>  FAIL	koha-tmpl/intranet-tmpl/prog/en/modules/tools/upload.tt
>    OK	  filters
>    FAIL	  forbidden patterns
> 		forbidden pattern: console.log (line 435)
> 
> I believe the line can just be removed?

Yep. Just haven't gotten around to it yet heh.
Comment 11 Tomás Cohen Arazi 2020-10-19 17:41:59 UTC
I don't think we should add workarounds for old browsers.
I'd just keep the feature for supported browsers.
Comment 12 David Cook 2020-10-19 23:10:00 UTC
(In reply to Tomás Cohen Arazi from comment #11)
> I don't think we should add workarounds for old browsers.
> I'd just keep the feature for supported browsers.

Hmm, I suppose that would be all right.
Comment 13 David Cook 2021-02-25 04:46:56 UTC

*** This bug has been marked as a duplicate of bug 27594 ***