Giter VIP home page Giter VIP logo

vss-web-extension-sdk's Introduction

Visual Studio Services Web Extension SDK

Please refer to Azure DevOps Extension SDK instead of this repo!

Overview

Client SDK and TypeScript declare files for developing Visual Studio Team Services Extensions.

The core SDK script, VSS.SDK.js, enables web extensions to communicate to the host Team Services frame and to perform operations like initializing, notifying extension is loaded or getting context about the current page.

A previous version of the SDK was named vss-sdk. Make sure to switch to the new vss-web-extension-sdk name.

Get the SDK

  1. Download and install Node.js
  2. Run npm install vss-web-extension-sdk from the root of your extension project

This will place VSS.SDK.js and VSS.SDK.min.js in node_modules/vss-web-extension-sdk/lib/

Include the SDK script on your page

If you are developing a web extension, you will need to reference the SDK script from your HTML pages. For example:

<script src="lib/VSS.SDK.min.js"></script>

To ensure the SDK script is packaged with your extension, update your extension manifest (typically vss-extension.json) and add a new entry to files:

{
  "files": [
    {
      "path": "node_modules/vss-web-extension-sdk/lib",
      "addressable": true,
      "packagePath": "lib"
    }
  ]
}

Note: setting packagePath is optional, but results in a simpler path for referencing the SDK script from your HTML pages. Not setting a part name would have required you to reference the full path in your <script> tag (src="node_modules/vss-web-extension-sdk/lib/VSS.SDK.min.js")

Use the SDK

From your web extension's HTML page, include and initialize the VSS SDK like this:

<script>
  // Initialize
  VSS.init({
    usePlatformScripts: true,
    usePlatformStyles: true,
  });

  // Register callback to get called when initial handshake completed
  VSS.ready(function () {
    // Start using VSS
  });
</script>

Full API reference of VSS.SDK.js can be found at Core Client SDK page.

Types

Type definitions are provided for:

  • UI controls and client services (see typings/vss.d.ts)
  • REST clients and contracts for Build, Work, and Code (see typings/tfs.d.ts)
  • REST clients and contracts for Release Management (see typings/rmo.d.ts)

Dependency graph:

Dependency Graph

Consuming the types

From a TypeScript 2.5 or later project:

  • Set "moduleResolution": "node" in your tsconfig.json project file

See TypeScript Module Resolution for more details.

Alternatively, you can explicitly reference the types at the top of your TypeScript file(s):

/// <reference types="vss-web-extension-sdk" />

Organizing your web extension project

If you are developing a web extension for Visual Studio Team Service using TypeScript, we recommend the following organization:

Project structure

 |-- src
     |-- app.ts
     |-- some-module
         |-- a.ts
         |-- b.ts
 |-- static
     |-- css
         |-- main.css
     |-- images
         |-- logo.png
     |-- app.html
 |-- vss-extension.json
 |-- package.json
 |-- tsconfig.json
  1. Place TypeScript source files in src
  2. Place static content (CSS, images, HTML, etc) in static
    • This simplifes the process of packaging all necessary static content in your

TypeScript project file (tsconfig.json)

Defines the options for compiling your TypeScript files.

{
  "compilerOptions": {
    "module": "amd",
    "moduleResolution": "node",
    "target": "es5",
    "rootDir": "src/",
    "outDir": "dist/",
    "types": ["vss-web-extension-sdk"]
  }
}
  1. After compiling (tsc -p .), resulting .js files are placed in dist. For example, dist/app.js.

  2. If your code directly uses types from other @types modules, you will want to include the module(s) in your package.json and add them to the types array. See @types.

Learn more about tsconfig.json

NPM package manifest (package.json)

Declares the libraries (like the vss-web-extension-sdk) required to compile, package, and use your extension.

{
  /* other details like ID, version, etc are omitted */

  "scripts": {
    "build": "tsc -p .",
    "postbuild": "npm run package",
    "package": "tfx extension create",
    "gallery-publish": "tfx extension publish --rev-version",
    "clean": "rimraf ./dist && rimraf ./*.vsix"
  },
  "devDependencies": {
    "rimraf": "^2.5.4",
    "tfx-cli": "^0.3.45",
    "typescript": "^2.1.4"
  },
  "dependencies": {
    "@types/jquery": "^2.0.34",
    "@types/q": "0.0.32",
    "vss-web-extension-sdk": "^5.127.0"
  }
}
  1. scripts provides a convenient way to define common operations that you want to perform on your project, like compiling and packaging.

    • For example, to build (compile) and package your extension, run: npm run build. This runs build and postbuild. If you make a change that doesn't require compiling, you can package by simply running npm run package.
    • To package and publish directly to the Marketplace on build, change the postbuild script to run the gallery-publish script (instead of package). You can then run npm run build -- --token xxxxxx (where xxxx is you personal access token for publishing to the Marketplace) to build, package, and publish your extension.
  2. The dependencies on the @types for jquery and q are only necessary if your TypeScript code is directly referencing either of these types.

Learn more about package.json

Extension manifest (vss-extension.json)

{
    /* details omitted */
    "files": [
        {
            "path": "dist",
            "addressable": true
        },
        {
            "path": "static",
            "addressable": true
        },
        {
            "path": "node_modules/vss-web-extension-sdk/lib",
            "addressable": true,
            "packagePath": "lib"
        }
    ],
    "contributions": [
        {
            "id": "my-hub",
            "type": "ms.vss-web.hub",
            "properties": {
                "name": "Hub",
                "uri": "static/app.html"
            }
        }
    ]
}
  1. The compiled JavaScript files (placed into dist by your tsconfig.json) will be packaged into the dist folder of the extension package.

  2. The VSS SDK scripts will be packaged into the lib folder of the extension package.

Learn more about the extension manifest.

HTML page

<head>
  <script src="../lib/VSS.SDK.min.js"></script>
  <!--
        Alternatively, if the packagePath attribute is not set for this file in your extension manifest (see above), do this:
         <script src="../node_modules/vss-web-extension-sdk/lib/VSS.SDK.min.js"></script>
   -->
</head>

<body>
  <script type="text/javascript">

    // Initialize the VSS sdk
    VSS.init({
        usePlatformScripts: true,
        usePlatformStyles: true
    });

    VSS.require(["dist/app"], function (app) {
        ...
    });
  </script>
</body>

Code of Conduct

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

vss-web-extension-sdk's People

Contributors

arashmirhosseini avatar cschleiden avatar joergbattermann avatar kodeandgame avatar nikomix avatar nkirchem avatar nschonni avatar obvioussean avatar serkan-inci avatar t-hugs avatar willsmythe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vss-web-extension-sdk's Issues

Charts/Services with Typescript

Hello,

I'm trying to create an extension with this sdk, but I don't see any typescript definition file from Charts/Services. How can I use this API from TypeScript? I need to write my own d.ts ?

Thanks the help!

IContributedMenuItem Icon/CSSClass

Although the docs say that an IContributedMenuItem icon can be a CSS class, the icon string is only ever added as a URL, unless I am missing something.

If the functionality does not exist, I would like to have the cssClass property added to the menu-item-icon span for IContributedMenuItem. It should behave like the cssClass property of IMenuItemSpec. This will make it easier for devs to use the platform styles and "bowtie" icons in context menus.

VSS generated error messages could be improved

Consider the following code snippet...

<script type="text/javascript">
        VSS.init({
            explicitNotifyLoaded: true,
            usePlatformStyles: true,
            configureModuleLoader:true
        });

        VSS.require("TFS/Dashboards/WidgetHelpers", function (WidgetHelpers) {
            WidgetHelpers.IncludeWidgetStyles();
            VSS.register("ToolWidget", function () {
                return {
                    load: function (widgetSettings) {
                        var $title = $('h2.title');
                        $title.text('Hello World');

                        return WidgetHelpers.WidgetStatusHelper.Success();
                    }
                }
            });
            VSS.notifyLoadSucceeded();
        });
    </script>

This is a very typical boot up sequence for creating a VSTS Extension. Three main areas within VSS Support are VSS.Init, VSS.Require and VSS.Register. VSS.notifyLoadSucceded never fails but the others do fail. When VSS issues errors, the messages are cryptic and require super-human effort to find the root cause.

For example:

VSS.SDK.js:652 No handler found on any channel for message: {"id":1,"methodName":null,"instanceId":"ToolWidget","params":null,"jsonrpc":"2.0"}

This message says nothing to the end user regarding the root of the problem. The root cause being that the ID passed into VSS.Register was not found in the vss.extension.json contribution section.

the main choke points are VSS.Init, VSS.Require and VSS.Register all of them have to work together to run properly but if any one of the parms, is out of whack, it's good luck finding it time...

Issue with Number conversion in french

Using "TFS/WorkItemTracking/RestClient" to create new work items with

createWorkItem(document, project, type, validateOnly, bypassRules)

Example Patch Document:

[{
    "op": "add",
    "path": "/fields/Microsoft.VSTS.Scheduling.RemainingWork",
    "value": "0.5"
}]

When the browser's language is set to english, everything works as expected. However, if switching the browser's language to french, for example, I get the following error:

Error: TF401326
Invalid field status 'InvalidType' for field 'Microsoft.VSTS.Scheduling.RemainingWork'.

If I replace "0.5" with "0,5", the conversion works fine.
It will also work as expected if I replace "0.5" with 0.5.

In my case, the value used in the patch document comes from the Task Templates fields and is obtained by calling getTemplate(project, team, templateId) from the Preview API. The value returned by this method for the Microsoft.VSTS.Scheduling.RemainingWork field is a string which contains a Number.

When editing Task Templates, the required format for a floating point number is using a "." as decimal separator.

A workaround for this is to convert the value upfront and send 0.5 as a Number in the patch document.

Is it a bug or am I doing it wrong?

Transient error when using ExtensionDataService

I got the following error today which disappeared after logging out and then logging in again:

POST https://seidel.visualstudio.com/_apis/WebPlatformAuth/SessionToken 500 (Internal Server Error)

Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:52 TFS.WebApi.Exception: HostAuthorizationNotFound
    at d (https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:95:391)
    at https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:95:3207
    at g (https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:95:651)
    at https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:95:3140
    at l (https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:34:8126)
    at https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:34:8352
    at t.when (https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:34:3784)
    at t.u.promiseDispatch (https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:34:2828)
    at https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:34:1653
    at MessagePort.t (https://seidel.visualstudio.com/_public/_Bundling/Content?bundle=vss-bundle-common978688737-v7HiPjMNLnubSGxFOnlcY1g==:34:5777)

    responseText: "{"$id":"1","innerException":null,"message":"HostAuthorizationNotFound","typeName":"Microsoft.VisualStudio.Services.DelegatedAuthorization.SessionTokenCreateException, Microsoft.VisualStudio.Services.WebApi","typeKey":"SessionTokenCreateException","errorCode":0,"eventId":3000}"

For now I was only publishing to my account for testing, but I would love to understand the root cause to make sure it does not happen again after I publish to the marketplace.

404 when using ReleaseManagement/Core/RestClient

Hi,

I'm trying to use ReleaseManagement/Core/RestClient on my widget but it doesn't seem to work.

My code is like this

/// <reference types="vss-web-extension-sdk" />
import WidgetHelpers = require("TFS/Dashboards/WidgetHelpers")
import ReleaseManagementClient = require("ReleaseManagement/Core/RestClient")

export function initialize() {
    WidgetHelpers.IncludeWidgetStyles();
    VSS.register("EnvironmentOverviewWidget",  () => {
        const projectId = VSS.getWebContext().project.id;
        return {
            load: function (widgetSettings) {
                console.log(ReleaseManagementClient);
                console.log(ReleaseManagementClient.getClient);
                var $title = $("h2.title");
                $title.text(`Hello World: ${projectId}.`);

                return WidgetHelpers.WidgetStatusHelper.Success();
            }
        }
    });
    VSS.notifyLoadSucceeded();
}

Which results on console error: GET https://goenning.gallery.vsassets.io/_apis/public/gallery/publisher/goennin…VV0F2NG9YblNITmhEQ2FiQkpGWWNNdmp1bz0=/ReleaseManagement/Core/RestClient.js 404 ()

My vss-web-extension-sdk package is 2.113.0 and i have extension with scope vso.release.

Thanks!

Feature request: All updates/changes in a day

It would be great to be able to query for all updates to all work items for a given day or date range. Right now there are several hoops. I query for items that have a ChangedDate = whateverDay, then getWorkItems and getWorkItemUpdates, which gives me a workItemUpdate[][] that I have to then flatten. And then I have to filter the result by the whateverDay.

This is also incomplete because if an item has a ChangedDate after the day, but has updates for that day, then it won't catch them. I'm sure that I could string a dozen promises together to get close, but it would be great if there was a core method like getUpdatesForRange(startDay, endDay?, project?, team?) or even getWorkItemsByUpdatedDate(startDay, fields?, expand?, errorPolicy?).

Update the docs on visualstudio.com

I didn't see anywhere one visualstudio.com to report this, so I'm doing it here. The ReadMe on this repo is 1000x clearer with what's going on. However, when looking for examples of how to create this type of extension for VSTS you find this tutorial. That tutorial needs updated to reflect the readme, reference it, or something.

Thanks!

Support for Rest call_apis/policy/configurations in vss-web-extension-sdk

Do we have any doc on api implementation of policy/configurations of VSTS as part of vss-web-extension-sdk similar to VSTS REST CLIENTS

Digging in vss-web-extension-sdk/typings/vss.d.ts found below , but was not able to get success with implementation.

 declare module "VSS/OrganizationPolicy/RestClient" {
import Contracts = require("VSS/Organization/Contracts");
import VSS_Common_Contracts = require("VSS/WebApi/Contracts");
import VSS_WebApi = require("VSS/WebApi/RestClient");

Multiselect Grids

Grids have the option of being multiselect. How do I access all selected items? The documentation is not very helpful. Also, how can I perform an action when one or more items are selected? Not double-clicked, just selected or multi-selected.

Define is not Defined

Problem : Attempting to create simple hello world vsts extension. When it loads, I am seeing Define is not defined at load time. The js file will not fully load because of this error.

Internals

In my HTML I'm trying to load the dist/app.js file.

image

My TSConfig.json looks like this:
image

The file dist/app.js is found and the load is attempted, but Chrome shows me this error.

image

I've scoured the internet and cannot find a solution..
I tried npm install requirejs
I tried npm install amd-loader and put in this line (in app.ts) require("amd-loader");
I cannot change the module system to umd or commonjs because the extension SDK requires AMD

Compilation error with TypeScript 2.4

I tried to make use of this lib while having the latest TypeScript installed and the sources cannot be compiled. running into the following compilation issues:

node_modules/@types/react/index.d.ts(165,11): error TS2559: Type 'Component<P, S>' has no properties in common with type 'ComponentLifecycle<P, S>'.
typings/vss.d.ts(3463,14): error TS2559: Type 'TemplateViewModel' has no properties in common with type 'EnhancementOptions'.
typings/vss.d.ts(9965,14): error TS2415: Class 'ComboDateBehavior' incorrectly extends base class 'BaseComboBehavior'.
  Types of property 'getValue' are incompatible.
    Type '() => Date' is not assignable to type '<TValue>() => TValue'.
      Type 'Date' is not assignable to type 'TValue'.
typings/vss.d.ts(10050,14): error TS2415: Class 'ComboMultiValueBehavior' incorrectly extends base class 'ComboListBehavior'.
  Types of property 'getValue' are incompatible.
    Type '() => string[]' is not assignable to type '<TValue>() => TValue'.
      Type 'string[]' is not assignable to type 'TValue'.
typings/vss.d.ts(10224,14): error TS2417: Class static side 'typeof DialogO' incorrectly extends base class static side 'typeof AjaxPanelO'.
  Types of property 'create' are incompatible.
    Type '<T extends Dialog>(dialogType: new (options: any) => T, options?: any) => T' is not assignable to type '<TControl extends Control<any>, TOptions>(controlType: new (options: TOptions) => TControl, c
onta...'.
      Types of parameters 'dialogType' and 'controlType' are incompatible.
        Type 'new (options: TOptions) => TControl' is not assignable to type 'new (options: any) => Dialog'.
          Type 'TControl' is not assignable to type 'Dialog'.
            Type 'Control<any>' is not assignable to type 'Dialog'.
              Property '_specifiedMaxWidth' is missing in type 'Control<any>'.

I can confirm that with TypeScript versions 2.2.1 - 2.3 it works without issues. Could the lib be updated? If not, it might be a good thing to mentioned this in the readme.

Using rest api within build task

Hi ,
I haven't find a working tutorial regarding using vss-web-extension-sdk in build task , I created a build task using node.js , then install this module but when I use it in the .ts file . it's not working , is there any tutorials ?

getWorkItemRelations refresh issue

Hi, I've an extension that add, delete and show "HyperLinks" that there are in the "Links" tab of the Work item.
When I tested the removeWorkItemRelations() i noticed that my function that pickup the getWorkItemRelations retrieves the HyperLinks I just removed. If I see the Link's tab, its ok.
I implement a refresh button, but the result is the same.

Here is my code:

function refreshDataSource() { 
    getWorkItemFormService().then(function (service) {
        service.getWorkItemRelations().then(function (relations) {
            var dataSource = relations.filter(function (relation) { return relation.rel === "Hyperlink"; });

            debugger;
            console.debug('RelationShips returned: ' + dataSource.length);
        })
    });
}

There is a way I can force to get the updated list of relations?

Thanks!

Contributions of type ms.vss-web.action-provider do not work anymore

As of May 24th contributions of mentioned type do not show up in the expected places anymore. There was no change in the extension code (Last deployment April 10th).
There is no error message, no waning. Not in the marketplace publisher overview, not in the developer tools of the browser.

Older REST methods with new version

I'm attempting to support both TFS 2015 and VSTS/2017+, but I've hit a big snag. I want to read conversation history, which is done by:

  • getHistory() in SDK < v3
  • getComments() in SDK >= v3

Neither of those methods exist in the other SDK. Is there a way for me to get an instance of the older work item client? I see the WITClient.WorkItemTrackingHttpClient2_3 object but I don't know how to call getClient() on it.

getQueryTestsResults is returning Value cannot be null. ↵Parameter name: Results after updating from 1.x to 2.x

on version 1.102.0, I could get the the test results with getQueryTestsResults in "TFS/TestManagement/RestClient"
I only replace VSS.SDK.min.js with 2.109.1and 2.117.0 start getting an error message, of Value cannot be null.↵Parameter name: Results"

My source code :

var query ="Select * from TestResult  WHERE TestCaseId IN ( 99,103,103,104 ) ORDER BY CreationDate DESC"
  var q = { query: query, fields: undefined, resultsFilter: undefined, results: undefined };
            this.testClient.getTestResultsByQuery(q, this.context.projectId).then((data) =>{
                observer.next(data);
            });

I also replaced the code with

var query ="Select * from TestResult  WHERE TestCaseId IN ( 99,103,103,104 ) ORDER BY CreationDate DESC"
  var q = { query: query };
            this.testClient.getTestResultsByQuery(q, this.context.projectId).then((data) =>{
                observer.next(data);
            });

still getting the same error message.

 VSS.require(['VSS/Service', 'TFS/Build/RestClient', 'TFS/Core/RestClient', 'TFS/TestManagement/RestClient', 'TFS/VersionControl/GitRestClient', 'TFS/VersionControl/TfvcRestClient', 'TFS/Work/RestClient', 'TFS/WorkItemTracking/RestClient', 'TFS/Dashboards/RestClient',  "ReleaseManagement/Core/RestClient"],
                    (VSS_Service, BuildRestClient, CoreRestClient, TestManagementRestClient, GitRestClient, TfvcRestClient, workRestClient, workItemTrackingClient, dashboardsApi, RM_WebApi) => {


 var testManagementClient = TestManagementRestClient.getClient();

........
});

this is how I obtain the client (as there are multiple version of the client)

whenI inspect the packages in my Browser's developer tools
Version 1 is hitting:
https://mrtmrcn.visualstudio.com/521cb215-8aff-4cad-8f2a-4a65ce72c454/_apis/test/Results/Query
and this is where V 2.117 is hitting:
https://mrtmrcn.visualstudio.com/521cb215-8aff-4cad-8f2a-4a65ce72c454/_apis/test/Results

Error I am getting in V 2.117.0 and V 2.109 .1

https://mrtmrcn.visualstudio.com/521cb215-8aff-4cad-8f2a-4a65ce72c454/_apis/test/Results
$id:"1"
errorCode:0
eventId:0
innerException:null
message:"Value cannot be null.
↵Parameter name: Results"
typeKey:"ArgumentNullException"
typeName:"System.ArgumentNullException, mscorlib"

Access modifier error

I just cloned an extension that had been working, and now when I try to package it I receive the following error:

typings/globals/vss/index.d.ts(20666,14): error TS2415: Class 'Component<TProps, TState>' incorrectly extends base class 'React.Component<TProps, TState>'.
  Property 'componentDidMount' is protected in type 'Component<TProps, TState>' but public in type 'Component<TProps, TState>'.
typings/globals/vss/index.d.ts(20700,14): error TS2415: Class 'Component<TControl, TProps, TState>' incorrectly extends base class 'Component<TProps, TState>'.
  Property 'shouldComponentUpdate' is protected in type 'Component<TControl, TProps, TState>' but public in type 'Component<TProps, TState>'.

API method for changeset/commit info.

Is there an api method to get commits/changesets made to the team project for a specific time range ( ex : last 14 days/ or from a specific date). I am interested to know the number of commits made by each team member. I looked at the vss.d.ts , but could not find any! Nothing on the internet as well.

Scope for TFS/DistributedTask/TaskAgentRestClient or /_apis/distributedtask/tasks?api-version=3.0-preview.1

Hi Guys,
Looks like I need your help
I’m trying to query distributedtask in extension and getting 401 error regardless Using Rest or API
I tried all scopes mentioned here https://www.visualstudio.com/en-us/docs/integrate/extensions/develop/manifest
While I was able to get json from another REST clients, for instance VSS.require(["TFS/Core/RestClient"] or VSS.require(["TFS/Work/RestClient"]
So question is what is right scope for TFS/DistributedTask/TaskAgentRestClient ?

VSS.Require Not Loading File: Results in Uncaught TypeErrror : CheckBoxModel is not a contructor

ChartWidget does not appear to be loading modules, related to VSS.Require.

Uncaught TypeError; XYZ is not a constructor.

uncaughttypeerror

From this module...

mnovalue

Where M is an object, with nothing in it. But it should show the CheckBoxModel
m

M is a file named model.ts, and it contains this export of CheckBoxModel

cbm

The message is simply saying "cannot find this class/module", which is true, there's nothing in M.

TSConfig:

tsconfig

VSS Config Manifest
vssmanifest

The contributions and files sections show no errors (and are quite long)

Two widgets one for Configuration one for the Dashboard Chart. Each have this in HTML file:
require1

requre1

Chrome Dev Tools/Sources shows it the file is there:
sources

Clicking on that link shows the proper code in Chrome.
cbm

The stack trace from breakpoint just prior to the error being thrown.

callstack

Package.json file

pkg

NPM install put this version in Node_Modules section of project:

vss-web-extension-sdk-2.109.1

I cannot seem to find why this is happening. The Typescript project compiles with no problem and we are seeing the files delivered to the site per the images above. It seems to be that the require.js work is just not working. Please advise.

Add Quick Start Bubbles to SDK

It would be great for the SDK to allow extension developers to also utilize the standard popups (below). This would let us provide quick start info to extension users and notify them of extension updates while keeping with the VSTS look and feel.

quickstartbubble

Typo in README

Update your tfsconfig.json project file to set "moduleResolution": "node"

Should be:
Update your tsconfig.json project file to set "moduleResolution": "node"

Allow navigating to a hub from within an extension

In my extensions I want to provide links to other parts of VSTS, for example:

  1. User visits the dashboard and sees a custom widget (from my extension)
  2. User clicks a link "Go to current sprint board" on that widget
  3. Location of the host window changes to go the the current sprint board tab by the extension

Ive seen the HostNavigationService but as I understand I can only use it to reload the host window and get/manipulate the hash.

Would be happy if navigating was only supported to go to predefined locations instead of passing a raw path. At the moment the only workaround would be to hack together a full url manually and open it in a new window (target=_blank).

Am I missing something?

Thanks!

Grid not showing

If i create a grid with Controls.create i'm not able to see the Grid.
It exists because i can inspect it on the html, but is not visible. Editing the grid css class of the framework (and precisely the display: relative element) make it appear, but it's position is broken and is overlapping with it's header.
I tried with Firefox, Chrome and Internet Explorer, every browser show that problem.
Thanks

rmclient won't authenticate

I am trying to create a release summary extension. For this, I am using the ReleaseManagement/Core/RestClient in "vss-web-extension-sdk": "^2.109.1"

/// <reference types="vss-web-extension-sdk" />

"use strict";

import VSS_Common_Contracts = require("VSS/WebApi/Contracts");
import TFS_Release_Contracts = require("ReleaseManagement/Core/Contracts")
import RM_Client = require("ReleaseManagement/Core/RestClient")

var rmClient = RM_Client.getClient();
var c = VSS.getConfiguration();
c.onReleaseChanged(function (release : TFS_Release_Contracts.Release) {

    var webcontext = VSS.getWebContext();

    rmClient.getReleaseDefinition(webcontext.project.id, release.releaseDefinition.id).then(
        function (rel) 
        {
            console.log(rel.name);
        },
        function (error)
        {
            console.log(error);
        });
});

I am getting a 401 error though:

TF400813: Resource not available for anonymous access. Client authentication required.

What am I doing wrong?

VSTS work item callbacks

From documentation I found this callbacks:

  • onFieldChanged
  • onLoaded
  • onUnloaded
  • onSaved
  • onReset
  • onRefreshed

I'm interested in onSaved and it works fine if I use save button. But when I click "Save & close" this callback does not work at all. Is there any way to handle save&close event?

Can write to but not read ExtensionDataService

getValue() can't read from the ExtensionDataService, but can write to it. If I hit the API, I get the correct JSON back that I set, but in the extension when I try to get it the result is undefined.

const dataService = VSS.getService(VSS.ServiceIds.ExtensionData);

dataService.then((service: IExtensionDataService) => {
        service.setValue("extVar1", myVar1, { scopeType: "User" });
        service.setValue("extVar2", myVar2, { scopeType: "User" });
});

dataService.then((service: IExtensionDataService) => {
        service.getValue("extVar1", { scopeType: "User" }).then((result) => myVar3 = result);
        service.getValue("extVar2", { scopeType: "User" }).then((result) => myVar4 = result);
});

I even set a default value in the options and the results are still undefined. No errors in the console. This is installed on TFS 2017 U1.

Registering Objects in TFS2015 and 2017

I've been informed that a simple context menu item extension I've created does not work in TFS 2015, but does in 2017 and VSTS. I was able to trace it to

const extensionContext = VSS.getExtensionContext();

//some code

VSS.register(`${extensionContext.publisherId}.${extensionContext.extensionId}.my-contribution`, contribFunction);

In TFS 2015, I receive the error No handler found on any channel for message and the menu item does not appear. On 2017/VSTS it's fine. If I remove ${extensionContext.publisherId}.${extensionContext.extensionId}. and just keep the id simple it works in 2015 with no error, but on VSTS I receive the No handler found on any channel for message error but the context menu item still appears and works.

Is this expected behavior? Am I supposed to dynamically change the registered object id based on TFS version?

[bug] IContributedMenuItem.icon: cannot use image url

When childItems of IContributedMenuItem is type of IPromise<IContributedMenuItem[]> then the icon is ALWAYS treated as css class not as image url (so you cannot have icon as an image).

In this example I have menu item where icon is set to url and has child with exactly the same icon. The result will be as following:

  • "change state" menu item will have icon
  • "test child" will have empty icon because the generated html has set class to following <span class="icon menu-item-icon static/images/changeStatusAction.png" aria-hidden="true"></span>

To fix it I have to comment the Q line but I cannot do this in my project I need the IPromise.

menuHandler = (context: any) : IContributedMenuSource => {
return <IContributedMenuSource> {
	getMenuItems: (actionContext: any)  => {
		let subMenus = 
			// comment the Q and the icon will work
			Q(
				Array<IContributedMenuItem>( 
				{
					text: "test child",
					icon: "static/images/changeStatusAction.png",
				});
			);
		
		return new Array<IContributedMenuItem>(
			{
				text: "Change state",
				groupId: "modify",
				icon: "static/images/changeStatusAction.png",
				childItems: subMenus,
			}
		);
	}
};
}
VSS.register(VSS.getContribution().id, menuHandler);

Missing hub for "Build and Release" tab

Writing a new hub contribution, it is possible to attach it to the ms.vss-work-web.work-hub-group or ms.vss-code-web.code-hub-group but I can't find the hub name for the new "Build and Release" tab.

The documentation seems outdated as it mentions the now removed individual Build and Release hubs.

Getting TS2403 when transpiling

Hi,

I'm getting following errors when transpiling my app with VSS typings:

ERROR in \awesome-project\typings\globals\vss\index.d.ts
(214,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.

ERROR in \awesome-project\typings\globals\require\index.d.ts
(387,13): error TS2403: Subsequent variable declarations must have the same type.  Variable 'require' must be of type 'NodeRequire', but here has type 'Require'.

My typings:

{
  "globalDependencies": {
    "chai": "registry:dt/chai#3.4.0+20160601211834",
    "core-js": "registry:dt/core-js#0.0.0+20160602141332",
    "jquery": "registry:dt/jquery#1.10.0+20160704162008",
    "knockout": "registry:dt/knockout#0.0.0+20160512130947",
    "mocha": "registry:dt/mocha#2.2.5+20161028141524",
    "node": "registry:dt/node#6.0.0+20161121110008",
    "q": "registry:dt/q#0.0.0+20160613154756",
    "react": "registry:dt/react#0.14.0+20161124131900",
    "require": "registry:dt/require#2.1.20+20160919185614",
    "sinon": "registry:dt/sinon#1.16.0+20160924120326",
    "tfs": "npm:vss-web-extension-sdk/typings/tfs.d.ts",
    "vss": "npm:vss-web-extension-sdk/typings/vss.d.ts"
  },
  "dependencies": {
    "lodash": "registry:npm/lodash#4.0.0+20161015015725",
    "requirejs": "registry:npm/requirejs#2.2.0+20160319062357"
  }
}

Using "[email protected]"

Type definitions included as runtime dependencies

The fact that type definitions are included in the final package results in inability to use libraries with competing definitions in extension development with Typescript. Especially relevant in case of using any JSX framework other than React, such as Vue.
The only workaround is manual/scripted removal of the matching definition after the dependencies installation.

getChangeSets method does not respect the parameters passed in

I am using the client api to get the list of shelve sets. As per the documentation in this page
, the below code should return an array of items where each item's comment's max length will be 30 (since that is what i am passing to the method call). But apparently instead of using the 30, It is using maxChangeCount parameter value(which is 2). So with the below code i get items with comment of length 2 ! Also skip and top are also not working. I passed 7 to get only 7 items, but i am getting all the items!

var maxChangeCount = 2 ;
var includeDetails = true;
var includeWorkItems = true;
var maxCommentLength = 30;
var includeSourceRename = false;
var skip = 0;
var top = 7;
var projectId="my proj id here";
                  
client.getChangesets(projectId, maxChangeCount, includeDetails, includeWorkItems, 
                                                 maxCommentLength, includeSourceRename, skip, top)
    .then(function (data) {

        console.log(data.length);  // Number of items returned
        // Assume there is at least an item in the result array
        console.log(data[0].comment.length) //First item's comment length

    });
        

It is possible to navigate to a custom backlog tab page even though it should be invisible

I am working on an extension that adds a backlog tab page following the instructions here https://www.visualstudio.com/en-us/integrate/extensions/develop/add-backlog-tabs

The goal is to only make the tab page available if a certain condition is true:

VSS.register("backlogTabObject", {

          isInvisible: function(state) {
              return determinIfTabShouldBeInvisible(state);
          }
  });

The problem now is when I navigate to the my custom tab page and then navigate to an iteration where isInvisible returns true my custom tab page is still active even though the tab navigation link is not visible.

Is there any workarround or other solution to this problem?

How to redraw a chart control after changing widget configuration

I have created a custom widget for TFS 2017 on premises that uses a chart control to render some data.

export class RankingWidget implements IConfigurableWidget {
    public load(widgetSettings: WidgetSettings) {
        return this.drawChart(widgetSettings);
    }

    public reload(widgetSettings: WidgetSettings) {
        return this.drawChart(widgetSettings);
   }
}

The draw method is in charge of creating the chart and assigning the data to render.
The problem is that the reload method is not redrawing the instance of the chart that was created during the load method.

Also, there is no way to obtain the instance of the chart after using

 chartService.createChart($container, $chartOptions);

since createChart return void.

can anyone advise how to redraw the chart after changing the data inside the series: DataSeries of the CommonChartOptions

Updating Work Item patch operation fails from Chrome browser

I have a TFS extension that is using the sdk, I am attempting to associate a Work Item to a git Pull Request
(following this: https://www.visualstudio.com/en-us/docs/integrate/api/git/pull-requests/work-items)
I can send in the appropriate Patch operations and get it done, and it works when I run the extension in IE, however, when running through Chrome, it just seems to fail.
Watching the dev tools in both Chrome and IE, I can see the network calls to the api. I see two calls with the patch that return a 401.. In Chrome it ends there, in IE, a third call shows and works. Not sure why there is a difference.. Other API calls (to create or update the git Pull Request) work in both places, this patch to update the Work Item fails however.

Trying to perform an action after work item form is closed

In a custom hub, I am opening work items. What I want to do is wait for the work item to be closed (saved or not doesn't matter) and then perform an action. Here is an example:

import WITService = require("TFS/WorkItemTracking/Services");
const witService = WITService.WorkItemFormNavigationService.getService();

witService.then(service => service.openWorkItem(id));

Chaining .then() on service.openWorkItem(id) or anywhere else performs the action as soon as the work item form promise is fulfilled. What I want is something like the onUnload listener, but I would like to contain it to this hub. Does this functionality exist?

Failed to load resource : the server responded with a status of 404()

Using node_modules and AMD...

My configuration widget can't find VSS.SDK

failedtoload

The root cause of this is that the script source cannot be found and a get request is issued back to the server to retrieve it, it responds that it cannot find it.

Here's is the content of configuration.html
content

But the HelloWorld widget can find VSS.SDK, as it loads no problem

hello

When comparing the file sources in Chrome:

loader

The Project structure is:

project

And the vss-extension.json

{
  "manifestVersion": 1,
  "id": "HelloWorld",
  "version": "2.0.39",
  "name": "HelloWorld",
  "description": "A sample Visual Studio Services extension.",
  "publisher": "myName",
  "targets": [
    {
      "id": "Microsoft.VisualStudio.Services"
    }
  ],
  "icons": {
    "default": "images/logo.png"
  },
  "contributions": [
    {
      "id": "HelloWorld",
      "type": "ms.vss-dashboards-web.widget",
      "targets": [
        "ms.vss-dashboards-web.widget-catalog",
        ".HelloWorld.Configuration"
      ],
      "properties": {
        "name": "Hello World Widget 3 (with config)",
        "description": "My third widget which supports configuration.",
        "catalogIconUrl": "images/logo.png",
        "previewImageUrl": "images/logo.png",
        "uri": "HelloWorld.html",
        "supportedSizes": [
          {
            "rowSpan": 1,
            "columnSpan": 2
          }
        ],
        "supportedScopes": [
          "project_team"
        ]
      }
    },
    {
      "id": "HelloWorld.Configuration",
      "type": "ms.vss-dashboards-web.widget-configuration",
      "targets": [
        "ms.vss-dashboards-web.widget-configuration"
      ],
      "properties": {
        "name": "HelloWorldWidget Configuration",
        "description": "Configures HelloWorldWidget",        
        "uri": "templates/configuration.html"
      }
    }
  ],
  "scopes": [
    "vso.work"
  ],
  "files": [
    {
      "path": "HelloWorld.html",
      "addressable": true
    }, 
    {
      "path": "scripts",
      "addressable": true
    },
    {
      "path": "templates/configuration.html",
      "addressable": " true"
    },
    {
      "path": "node_modules/vss-web-extension-sdk/lib/VSS.SDK.js",
      "addressable": true
    }
  ]
}

I've tried altering the script src location many different times each without success. In the samples, all of the references are to bower and they are not using AMD to load. Perhaps this is root cause.

Systemjs loader instead of require

We would love to be able to leverage Angular 2 when building TFS/VSTS extensions but, unless I'm missing something, this doesn't appear to be currently possible. The integrated require loader can't load SystemJS modules defined by ng2 and attempting to bypass that loader and use SystemJS fails because it's not authenticating requests correctly with TFS. Would this be a feasible enhancement?

Tfvc client getChangesets broken since M97

Hi,

in the M97 update of tfs.d.ts, you've updated the signature of the getChangesets method (removing some arguements). It breaks retro compatibility with older Tfvc client and this doesn't match the documentation here:
https://www.visualstudio.com/en-us/docs/integrate/extensions/reference/client/api/tfs/versioncontrol/tfvcrestclient/tfvchttpclient2_2#method_getChangesets

Is it normal? I think the getChangesets signature mustn't be in CommonMethods2To3_1 since it has changed.

npm run build results in: TS2304: Cannot find name Iterable

When I run npm run build, this results in:

node_modules/@types/jquery/index.d.ts(2961,63): error TS2304: Cannot find name 'Iterable'.

It seems that some tsconfig.json settings are missing?
I found that if I add lib options for es2015 and dom then it compiles ok, but I don't know enough typescript to determine if this is the "right" solution:

"compilerOptions": {
"lib" : ["es2015","dom"]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.