This repository was archived by the owner on Jan 17, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 285
Add a sample extension for the new repo service #109
Open
cadewey
wants to merge
6
commits into
microsoft:master
Choose a base branch
from
cadewey:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8a42051
Add a sample extension for the new repo service
cadewey b26af23
Update HTML layout and screenshot
cadewey 5d22a10
PR feedback
cadewey e1acfd9
Make the manifest explicitly look for scripts/app.js
cadewey 39d595b
Update extension details.md
cadewey bb4322d
Move details to readme.md
cadewey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| <html> | ||
| <head> | ||
| <title>Repository Information</title> | ||
| <script src="node_modules/vss-web-extension-sdk/lib/VSS.SDK.js"></script> | ||
| <style> | ||
| h2 { | ||
| font-weight: 400; | ||
| } | ||
|
|
||
| pre { | ||
| font-size: 14px; | ||
| line-height: 1.3em; | ||
| } | ||
|
|
||
| </style> | ||
| </head> | ||
|
|
||
| <body style="padding-left: 20px; padding-top: 20px; overflow-y: auto; background-color: #eee"> | ||
|
|
||
| <h2>Repository Information</h2> | ||
| <pre id="context-display"></pre> | ||
|
|
||
| <script type="text/javascript"> | ||
| VSS.init({ | ||
| usePlatformScripts: true, | ||
| usePlatformStyles: true | ||
| }); | ||
|
|
||
| VSS.require(["scripts/app"], function (app) { | ||
| app.execute(); | ||
| }); | ||
| </script> | ||
|
|
||
| <div id="repository-info-view"> | ||
| <h3>ID</h2> | ||
| <p id="repository-id"></p> | ||
| <h3>Name</h2> | ||
| <p id="repository-name"></p> | ||
| <h3>URL</h2> | ||
| <p id="repository-url"></p> | ||
| </div> | ||
| </body> | ||
| </html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| { | ||
| "name": "repository-info-extension", | ||
| "version": "1.0.0", | ||
| "description": "Provides an example for accessing the currently selected repository from an extension.", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/Microsoft/vsts-extension-samples/tree/master/repository-info-extension" | ||
| }, | ||
| "author": "Microsoft", | ||
| "dependencies": { | ||
| "vss-web-extension-sdk": "^5.140.0" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| This extension is an example of how to access information about the user's currently selected repository from an extension. Note: this information will only be accessible on pages that are within the "code" hub, including new pages that may be added by the extension (as in this example). | ||
|
|
||
| ## Building | ||
|
|
||
| This extension is built using NodeJS with the [typescript](https://github.com/Microsoft/TypeScript) and [tfs-cli](https://github.com/Microsoft/tfs-cli) packages. Once those are installed, open a command prompt at the extension's root and run: | ||
|
|
||
| 1. `npm install` | ||
| 2. `tsc` | ||
| 3. `tfx extension create` | ||
|
|
||
| ## Screenshot | ||
|
|
||
|  |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| /// <reference path='../node_modules/vss-web-extension-sdk/typings/tfs.d.ts' /> | ||
|
|
||
| import TFS_VC_Services = require("TFS/VersionControl/Services"); | ||
|
|
||
| export async function execute() { | ||
| const svc = await TFS_VC_Services.VersionControlRepositoryService.getService(); | ||
| const repo = await svc.getCurrentGitRepository(); | ||
| let idContainer = document.getElementById("repository-id"); | ||
| let nameContainer = document.getElementById("repository-name"); | ||
| let urlContainer = document.getElementById("repository-url"); | ||
| idContainer.innerHTML = repo.id; | ||
| nameContainer.innerHTML = repo.name; | ||
| urlContainer.innerHTML = repo.url; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "module": "amd", | ||
| "sourceMap": false | ||
| }, | ||
| "exclude": [ | ||
| "node_modules" | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| { | ||
| "manifestVersion": 1, | ||
| "id": "repository-info-extension", | ||
| "version": "1.0.0", | ||
| "name": "Repository Information Sample", | ||
| "description": "Provides an example for accessing the currently selected repository from an extension.", | ||
| "publisher": "ms-samples", | ||
| "public": true, | ||
| "categories": [ | ||
| "Developer samples", | ||
| "Code" | ||
| ], | ||
| "links": { | ||
| "learn": { | ||
| "uri": "https://github.com/Microsoft/vso-extension-samples" | ||
| } | ||
| }, | ||
| "icons": { | ||
| "default": "images/fabrikam-logo.png" | ||
| }, | ||
| "targets": [ | ||
| { | ||
| "id": "Microsoft.VisualStudio.Services" | ||
| } | ||
| ], | ||
| "content": { | ||
| "details": { | ||
| "path": "readme.md" | ||
| } | ||
| }, | ||
| "branding": { | ||
| "color": "rgb(190, 39, 3)", | ||
| "theme": "dark" | ||
| }, | ||
| "files": [ | ||
| { | ||
| "path": "scripts/app.js", | ||
| "addressable": true | ||
| }, | ||
| { | ||
| "path": "images", | ||
| "addressable": true | ||
| }, | ||
| { | ||
| "path": "context.html", | ||
| "addressable": true | ||
| }, | ||
| { | ||
| "path": "node_modules/vss-web-extension-sdk/lib", | ||
| "addressable": true | ||
| } | ||
| ], | ||
| "contributions": [ | ||
| { | ||
| "id": "repository-info-hub", | ||
| "type": "ms.vss-web.hub", | ||
| "description": "Custom hub in the Code hub group that displays information about the currently active Git repository.", | ||
| "targets": [ | ||
| "ms.vss-code-web.code-hub-group" | ||
| ], | ||
| "properties": { | ||
| "name": "Repository Information", | ||
| "order": 100, | ||
| "uri": "context.html" | ||
| } | ||
| } | ||
| ] | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.