← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~ilasc/launchpad:access-token-link-git-reposiory-edit-menu into launchpad:master

 

Ioana Lasc has proposed merging ~ilasc/launchpad:access-token-link-git-reposiory-edit-menu into launchpad:master.

Commit message:
Add link to access tokens on GitRepositoryEditMenu

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~ilasc/launchpad/+git/launchpad/+merge/414399
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~ilasc/launchpad:access-token-link-git-reposiory-edit-menu into launchpad:master.
diff --git a/lib/lp/code/browser/configure.zcml b/lib/lp/code/browser/configure.zcml
index 33d0368..af6099f 100644
--- a/lib/lp/code/browser/configure.zcml
+++ b/lib/lp/code/browser/configure.zcml
@@ -915,6 +915,12 @@
         name="+delete"
         template="../templates/gitrepository-delete.pt"/>
     <browser:page
+        for="lp.services.auth.interfaces.IAccessTokenTarget"
+        name="+access-tokens"
+        permission="launchpad.Edit"
+        class="lp.services.auth.browser.AccessTokensView"
+        template="../../services/auth/templates/accesstokentarget-access-tokens.pt" />
+    <browser:page
         for="lp.code.interfaces.gitrepository.IGitRepository"
         class="lp.code.browser.gitrepository.GitRepositoryActivityView"
         permission="launchpad.Edit"
diff --git a/lib/lp/code/browser/gitrepository.py b/lib/lp/code/browser/gitrepository.py
index b8d7b3e..d47e0f5 100644
--- a/lib/lp/code/browser/gitrepository.py
+++ b/lib/lp/code/browser/gitrepository.py
@@ -268,6 +268,7 @@ class GitRepositoryEditMenu(NavigationMenu):
         "activity",
         "webhooks",
         "delete",
+        "access_tokens",
         ]
 
     @enabled_with_permission("launchpad.Edit")
@@ -302,6 +303,11 @@ class GitRepositoryEditMenu(NavigationMenu):
         text = "Delete repository"
         return Link("+delete", text, icon="trash-icon")
 
+    @enabled_with_permission("launchpad.Edit")
+    def access_tokens(self):
+        text = "Edit access tokens"
+        return Link("+access-tokens", text, icon="edit")
+
 
 class GitRepositoryContextMenu(ContextMenu, HasRecipesMenuMixin):
     """Context menu for `IGitRepository`."""
diff --git a/lib/lp/code/browser/tests/test_gitrepository.py b/lib/lp/code/browser/tests/test_gitrepository.py
index f065772..7e28c39 100644
--- a/lib/lp/code/browser/tests/test_gitrepository.py
+++ b/lib/lp/code/browser/tests/test_gitrepository.py
@@ -2269,3 +2269,19 @@ class TestGitRepositoryForkView(BrowserTestCase):
                 "field.owner": invalid_person.name,
                 "field.actions.fork": "Fork it"})
             self.assertEqual(0, self.getReposOwnedBy(invalid_person).count())
+
+
+class TestGitRepositoryAccessTokensView(BrowserTestCase):
+    layer = DatabaseFunctionalLayer
+
+    def test_repository_access_tokens_link(self):
+        # Most tests are in lp/services/auth/tests/test_browser.py
+        # This is only testing that the view is now linked
+        # and accessible from the GitRepositoryEditMenu.
+        repository = self.factory.makeGitRepository()
+        tokens_url = canonical_url(
+            repository, view_name="+access-tokens", rootsite="code")
+        browser = self.getViewBrowser(
+            repository, "+index", rootsite="code", user=repository.owner)
+        tokens_link = browser.getLink("Edit access tokens")
+        self.assertEqual(tokens_url, tokens_link.url)
diff --git a/lib/lp/services/auth/configure.zcml b/lib/lp/services/auth/configure.zcml
index c0446d6..f300218 100644
--- a/lib/lp/services/auth/configure.zcml
+++ b/lib/lp/services/auth/configure.zcml
@@ -31,12 +31,5 @@
         path_expression="string:+access-token/${id}"
         attribute_to_parent="target" />
 
-    <browser:page
-        for="lp.services.auth.interfaces.IAccessTokenTarget"
-        name="+access-tokens"
-        permission="launchpad.Edit"
-        class="lp.services.auth.browser.AccessTokensView"
-        template="templates/accesstokentarget-access-tokens.pt" />
-
     <webservice:register module="lp.services.auth.webservice" />
 </configure>