Skip to content

Commit 8004ee0

Browse files
authored
Adding PDF Viewer sample (#569)
Adding PDF Viewer sample to the Typescript samples. This PDF Viewer sample allows pdfs to be viewed using a dashboard network extension. It makes use of extension-apis around settings, dialogs, and parameters. The sample adds support for testing using jest and adding React components from tableau-ui. Adding support for tableau-ui requires React versions to match so had to move this project's react from 17.0.2 to 16.8.6. React-types didn't have a 16.8.6 version so went with the previous version of 16.8.5.
1 parent 0629f28 commit 8004ee0

20 files changed

+9323
-2300
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ dist/
1515

1616
# Ignore IDE specific files
1717
.idea
18+
19+
# Ignore test coverage files
20+
coverage/

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,26 @@ If you want to use TypeScript to write your extensions, you can run a script tha
5656

5757
**npm run dev**
5858

59+
* To automatically build the TypeScript samples whenever code change.
60+
61+
**npm run build-watch**
62+
5963
For more information, see [Use TypeScript with the Extensions API](https://tableau.github.io/extensions-api/docs/core/trex_typescript).
6064

65+
#### Typescript Development in PdfViewer Sample
66+
67+
* To run tests for the PdfViewer sample.
68+
69+
**npm run test**
70+
71+
* To automatically run tests for the PdfViewer sample whenever code changes.
72+
73+
**npm run test-watch**
74+
75+
* To run test code coverage for the PdfViewer sample.
76+
77+
**npm run test-coverage**
78+
6179
### Sandboxed Extension Development Environment
6280

6381
Tableau is introducing development support for Sandboxed Extensions with Tableau 2019.3. Sandboxed Extensions run in a virtual sandbox and ensure the extension can’t make network calls outside of the hosting Tableau Server. The Extensions API SDK provides a local development environment that replicates the Tableau Hosting Cloud Service for Sandboxed Extensions. You can test your Sandboxed extensions locally with the same sandbox policies.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export const unconfiguredExtensionMessage = 'Add a PDF using \'Configure\' in the object menu.';
2+
export const urlInputText = 'Enter the URL for PDF';
3+
export const urlIsNotValidErrorMessage = 'URL is not valid, please add a different PDF using \'Configure\' in the object menu.';
4+
export const urlForPdf = 'URL for PDF';
5+
export const urlForPdfFailedToRender = 'PDF failed to render, please add a different PDF using \'Configure\' in the object menu.';
6+
export const okButton = 'OK';
7+
export const dropdownLabel = 'Optional Parameter';
8+
export const dropdownInputText = 'Insert';
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest manifest-version="0.1" xmlns="http://www.tableau.com/xml/extension_manifest">
3+
<dashboard-extension id="com.tableau.extensions.samples.pdfViewer" extension-version="0.1.0">
4+
<default-locale>en_US</default-locale>
5+
<name resource-id="name"/>
6+
<description>PDF Viewer</description>
7+
<author name="tableau" email="[email protected]" organization="tableau" website="https://www.tableau.com"/>
8+
<min-api-version>1.7</min-api-version>
9+
<source-location>
10+
<url>http://localhost:8765/Samples-Typescript/Dashboard/PdfViewer/pdfviewer.html</url>
11+
</source-location>
12+
<icon>iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAAB3RJTUUH4QgLDTYEcBRoeAAABp9JREFUeNrlm01sHEUWx//vVbs79gThjAd2iflIAkEcEARfEciBSYLEbbV8SJaDEpIAMQgkViuirA8IskKcdiEJX3G0C5dNpAVxQLIyiYw4YYIQBw4RBoMgBBIbCRtnOsx0vbcHd9sTZ3r8ge2p2bQ0B/+7unp+1dX/eX71ivL5TgAwAAQAxR/rsiYidvv2btq6ddcqVRwE8JCqgoigqgAAIvpKVbf29v51cHDwUxWRav2pWbdujcH04cUnPFc1EZGOjtv5hRdebv3tt9I+IupWVSaiGBxgJqhqlpnPj42NnchmsxpFUbX+mJORiE9E8eigorEzmohEHR23U1/fO63j47/+nYh2qqpJ4CcHg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Xy+M6mgrKzGWjU+Pp5nNq1xchEAWESsMcZYa4WZPVXtmseKjWvwF+cEK+vwkmosa22yNj8FlSxRz3Oh0kl4JCY4nyLEBWiuwk+a4PnzRXsZwk+ZIKlaam1dtSquvb1c4BONiJmzqvoiEe26zOA9ABER0X+I8CfVqcWE3wsPZnqf2ezq7n74Z5fhEQdCD4poNXgBcGEhAyKiH5TL5XOOwzMAZlWli+vtpwuPmflxAF/PdzYwM6dVajqkEQDLafBB4PdYa//d1OQ9parDc4WPD4n7dQG0lmbiJ6Uz4Z8oFsPhzZvv8ffs+Uu/MaYHwDdzhIeIYGLijFOFFymaXlQ9NbPeXkSijz/+xPT07DxGRI8T0bdzeRWMMbxy5WpxCDTdBIloSCR9s4G1loaGvsZzzz1zAsBjyUyoNRustXZGdUa9QWua4CPM/Krvp282KJVK3ueff6GHDx84bozZDWB4FhN0CbR2JLhly708PPytd+21qyNjTM2LiAiFwkDZ87xt1trXAATVZgMz77LWvpXPd85l20pdI0G21uratTfMCg8AhcJAOZNpucla+0AaPIBIRCYGB080hAl6ACAis15UreS8CrwFcLitLXu8UPgw2YvoAmjNSHDWJzUP+L5crm3vyMjoyMDAR67DT5ogZskJzhe+SilavUFrR4KYzglectGzzz4ZZTKZm4vF8NX/M/hEq7owwgCQybREvb37gmKxuBvAfcD0NpNKwwNwKJfLTpWfVoHnKl/CFU05fvoUN9D4ExWLIZ88+dkFIjoK4KsEXkSmBkBV/xsEwd6RkZ9H8/lOJiKN+7mkP1e1/wFtM6PWK/V/BwAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAxNy0wOC0xMVQxMzo1NDowNC0wNDowMMrC9wEAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMTctMDgtMTFUMTM6NTQ6MDQtMDQ6MDC7n0+9AAAAAElFTkSuQmCC</icon>
13+
<context-menu>
14+
<configure-context-menu-item />
15+
</context-menu>
16+
</dashboard-extension>
17+
<resources>
18+
<resource id="name">
19+
<text locale="en_US">PDF Viewer</text>
20+
</resource>
21+
</resources>
22+
</manifest>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import '@testing-library/jest-dom';
2+
import { PdfViewerComponent } from '../pdfViewerComponent';
3+
4+
PdfViewerComponent.initialize = jest.fn();
5+
6+
import '../pdfViewer';
7+
8+
describe('PdfViewer', () => {
9+
it('should call PdfViewerComponent.initialize' , async () => {
10+
expect(PdfViewerComponent.initialize).toBeCalledTimes(1);
11+
});
12+
});

0 commit comments

Comments
 (0)