Skip to content

Commit

Permalink
Add WAVE Analysis 'Fix in VS' Button (#54)
Browse files Browse the repository at this point in the history
* Add WAVE Analysis 'Fix in VS' Button

* Fix indent

---------

Co-authored-by: Ali Mohamad <alimohamad@microsoft.com>
  • Loading branch information
alimohamad and Ali Mohamad authored Nov 8, 2024
1 parent 87c5dea commit 3091115
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
10 changes: 7 additions & 3 deletions components/RunCard.renderActionsCell.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { Link } from 'azure-devops-ui/Link';
import * as React from 'react'
import { Result } from 'sarif'
import './RunCard.renderCell.scss'

import * as React from 'react'

import { ActionProps } from './Viewer.Types';
import { Link } from 'azure-devops-ui/Link';
import { Result } from 'sarif'

const emptyPng = require('./assets/empty.png')
const vsCodePng = require('./assets/vscode-icon.png')
const vsPng = require('./assets/vs-icon.png')

const images = {
empty: emptyPng,
vscode: vsCodePng,
vs: vsPng
}

function renderAction(props: ActionProps) {
Expand Down
25 changes: 16 additions & 9 deletions components/RunStore.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import {observable, autorun, computed, IObservableValue} from 'mobx'
import {Run, Result, Artifact} from 'sarif'
import {Artifact, Result, Run} from 'sarif'
import {IObservableValue, autorun, computed, observable} from 'mobx'
import {RepositoryDetails, ResultOrRuleOrMore, Rule} from './Viewer.Types'
import { getRepositoryDetailsFromRemoteUrl, isRepositoryDetailsComplete } from './getRepositoryDetailsFromRemoteUrl'

import {ITreeItem} from 'azure-devops-ui/Utilities/TreeItemProvider'
import {MobxFilter} from './FilterBar'
import {tryOr} from './try'
import {Rule, ResultOrRuleOrMore, RepositoryDetails} from './Viewer.Types'

import {SortOrder} from 'azure-devops-ui/Table'
import {ITreeItem} from 'azure-devops-ui/Utilities/TreeItemProvider'
import { getRepoUri } from './getRepoUri'
import { getRepositoryDetailsFromRemoteUrl, isRepositoryDetailsComplete } from './getRepositoryDetailsFromRemoteUrl'
import {tryOr} from './try'

declare module 'sarif' {
interface Run {
Expand Down Expand Up @@ -82,13 +81,21 @@ export class RunStore {
if (isRepositoryDetailsComplete(repoDetails) && buildId && artifactName && filePath) {
const fixInVsCodeAction = {
text: 'Fix in VS Code',
linkUrl: `https://waveanalysis.microsoft.com/import?buildId=${buildId}&artifactName=${artifactName}&filePath=${filePath}&organization=${repoDetails.organizationName}&project=${repoDetails.projectName}&repoName=${repoDetails.repositoryName}&runIndex=${run._index}&resultIndex=${resultIndex++}&source=1esscans`,
linkUrl: `https://waveanalysis.microsoft.com/vscode/import?buildId=${buildId}&artifactName=${artifactName}&filePath=${filePath}&organization=${repoDetails.organizationName}&project=${repoDetails.projectName}&repoName=${repoDetails.repositoryName}&runIndex=${run._index}&resultIndex=${resultIndex++}&source=1esscans`,
imageName: 'vscode',
className: 'vscode-action'
}

const fixInVsAction = {
text: 'Fix in Visual Studio',
linkUrl: `https://waveanalysis.microsoft.com/vs/import?buildId=${buildId}&artifactName=${artifactName}&filePath=${filePath}&organization=${repoDetails.organizationName}&project=${repoDetails.projectName}&repoName=${repoDetails.repositoryName}&runIndex=${run._index}&resultIndex=${resultIndex++}&source=1esscans`,
imageName: 'vs',
className: 'vs-action'
}

result.actions = [
fixInVsCodeAction
fixInVsCodeAction,
fixInVsAction
]
}

Expand Down
Binary file added components/assets/vs-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3091115

Please sign in to comment.