Skip to content

Commit

Permalink
Merge pull request #19 from dfreiberger/dfreiberger/fix-link-issue
Browse files Browse the repository at this point in the history
Fix issue where branch is not included in page route
  • Loading branch information
dfreiberger authored Jun 1, 2024
2 parents 96c5bd7 + 97d98e6 commit 19cb8a1
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This unofficial extension allows previewing of Beckhoff TwinCAT 3 files within Azure DevOps. The source code is available on [GitHub](https://github.com/dfreiberger/tc-preview-extension).

It currently supports the `.TcPOU`, `.TcDUT`, `.TcGVL` and `.TcIO` file extensions. Only Structured Text (ST) is supported, so any sections of the code that are in another format such as LD, FBD or UML will not be displayed.
It currently supports the `.TcPOU`, `.TcDUT`, `.TcGVL` and `.TcIO` file extensions.

To see a preview of a file, open it from `Repos > Files` and select the Preview tab. You can also see previews within pull requests or from the search view.

Expand All @@ -12,6 +12,14 @@ It is also possible to copy a link to a specific section of code by clicking the

Pull requests are welcome.

## Limitations

Only Structured Text (ST) is supported, so any sections of the code that are in another format such as LD, FBD or UML will not be displayed.

The Copy link feature only works for the default branch, or for branches that have been actively selected by choosing them in the branch dropdown first before copying the link. This appears to be a limitation of Azure DevOps and the same issue is present when copying links to normal source files.

![Image of select branch dropdown](img/branch_selection.png "Select branch dropdown")

## Development

To develop locally, create an Azure DevOps organization and publish this extension in dev mode to it.
Expand Down
Binary file added img/branch_selection.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 7 additions & 2 deletions src/preview/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Header } from "azure-devops-ui/Header";
import { Page } from "azure-devops-ui/Page";
import { SurfaceBackground, SurfaceContext } from "azure-devops-ui/Surface";

import { CommonServiceIds, IHostNavigationService, IHostPageLayoutService, IExtensionDataManager, IProjectPageService, IExtensionDataService, ILocationService } from "azure-devops-extension-api";
import { CommonServiceIds, IHostNavigationService, IExtensionDataManager, ILocationService } from "azure-devops-extension-api";
import { CoreRestClient } from "azure-devops-extension-api/Core";


Expand Down Expand Up @@ -55,7 +55,12 @@ class PreviewContent extends React.Component<{}, IPreviewState> {
const queryParams = await navigationService.getQueryParams();
const pageRoute = await navigationService.getPageRoute();

const routeUrl = `${hostBaseUrl}${pageRoute.routeValues.project}/_git/${pageRoute.routeValues.GitRepositoryName}?path=${queryParams.path}&_a=${queryParams._a}`

var routeUrl = `${hostBaseUrl}${pageRoute.routeValues.project}/_git/${pageRoute.routeValues.GitRepositoryName}?path=${queryParams.path}&_a=${queryParams._a}`;

if (queryParams.version !== undefined) {
routeUrl += `&version=${queryParams.version}`;
}

this.setState({ xml : xmlDoc, parentUrl: routeUrl, urlParams: queryParams });
}
Expand Down
2 changes: 1 addition & 1 deletion vss-extension.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"manifestVersion": 1,
"version": "0.1.26",
"version": "0.1.28",
"name": "TcPreview",
"description": "An extension for viewing TwinCAT files in Azure DevOps",
"publisher": "dfreiberger",
Expand Down

0 comments on commit 19cb8a1

Please sign in to comment.