Skip to content
This repository has been archived by the owner on Jan 11, 2023. It is now read-only.

[Source Tabs] context menu copy source url + view source #1336

Closed
jasonLaster opened this issue Nov 29, 2016 · 6 comments
Closed

[Source Tabs] context menu copy source url + view source #1336

jasonLaster opened this issue Nov 29, 2016 · 6 comments

Comments

@jasonLaster
Copy link
Contributor

jasonLaster commented Nov 29, 2016

Users should be able to right click on a source tab and either copy the source url to their clipboard or open the source in a new tab. Screenshots below

Patch 1: adding the context menu items

diff --git a/src/components/SourceTabs.js b/src/components/SourceTabs.js
index 20a7e8e..bafd76f 100644
--- a/src/components/SourceTabs.js
+++ b/src/components/SourceTabs.js
@@ -106,6 +106,14 @@ const SourceTabs = React.createClass({
       }
     };

+    function copyToTheClipbloard(url) {
+      // need to research https://clipboardjs.com
+    }
+
+    function viewSource(url) {
+      // need to research
+    }
+
     const closeAllTabsMenuItem = {
       id: "node-menu-close-all-tabs",
       label: closeAllTabsLabel,
@@ -114,12 +122,31 @@ const SourceTabs = React.createClass({
       click: () => closeTabs(tabs)
     };

+    const copySourceUrl = {
+      id: "node-menu-close-tabs-to-right",
+      label: closeTabsToRightLabel,
+      accesskey: "R",
+      disabled: false,
+      click: () => copyToTheClipboard(tab.url)
+    };
+
+    const viewSource = {
+      id: "node-menu-close-all-tabs",
+      label: closeAllTabsLabel,
+      accesskey: "A",
+      disabled: false,
+      click: () => viewSource(tab.url)
+    };
+
     showMenu(e, buildMenu([
       { item: closeTabMenuItem },
       { item: closeOtherTabsMenuItem, hidden: () => tabs.size === 1 },
       { item: closeTabsToRightMenuItem, hidden: () =>
          tabs.some((t, i) => t === tab && (tabs.size - 1) === i) },
-      { item: closeAllTabsMenuItem }
+      { item: closeAllTabsMenuItem },
+      { type: "separator" },
+      { item: copySourceUrl },
+      { item: viewSource }
     ]));
   },

patch 2: connecting the items to panel functions

  • this will require adding some modules to m-c
  • it's sufficient for this PR to just add the shim modules and we can add the devtools-modules later

https://gist.github.com/jasonLaster/fdae80aad9c6391c98206eee7318b0cd

curl https://gist.githubusercontent.com/jasonLaster/fdae80aad9c6391c98206eee7318b0cd/raw/9f83e83e37c537c13830e7ac1aec15e0c29a64c1/foo.diff | git apply

privileges

Firefox Sources

screen shot 2016-11-28 at 7 11 19 pm

Chrome Tab

screen shot 2016-11-28 at 7 10 59 pm

@arthur801031
Copy link
Contributor

@jasonLaster I will take a look at it :)

@jasonLaster
Copy link
Contributor Author

Great!

Two things:

  1. Lets try and land this incrementally - as in lets restrict to first pass to just patch 1 which ignores the panel.
  2. I found this article on using the clipboard - https://hacks.mozilla.org/2015/09/flash-free-clipboard-for-the-web/. It should just work for you in the click handler!

@arthur801031
Copy link
Contributor

Hi @jasonLaster

I got patch 1 working, but for the clipboard function, I'm using the copyString function from https://dxr.mozilla.org/mozilla-central/source/devtools/shared/platform/content/clipboard.js, which you provided in your post under the privileges section.

I will make a PR right now. Thank you! :)

@jasonLaster
Copy link
Contributor Author

jasonLaster commented Dec 9, 2016 via email

@arthur801031
Copy link
Contributor

@jasonLaster

Please check. Thank you!

@jasonLaster
Copy link
Contributor Author

Closing this issue as we've done the copy source url feature. I'll open a new more focused issue for viewing source later. It's less important though and there's plenty of other work to go around.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants