Skip to content

Commit

Permalink
Bump to v1.8.0 and use 3.4.0 of iot-app-kit versions
Browse files Browse the repository at this point in the history
  • Loading branch information
fridgepoet committed Aug 29, 2023
2 parents f30ffb5 + 2948b81 commit 79cabe2
Show file tree
Hide file tree
Showing 11 changed files with 2,086 additions and 2,453 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
# Changelog

## 1.7.0

- Update grafana-aws-sdk to v0.19.1 to add `il-central-1` to the opt-in region list

## v1.6.3
- fix visibility of data overlays on parent objects
- add entity binding support
- fix raycast issues
- add support for selection events on data overlays

## v1.6.2
- Setting up sticky video controls for Video Player
- Error handling for Matterport scenes
Expand Down
3 changes: 2 additions & 1 deletion cspell.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"Unsubscribable",
"videoplayer",
"commitish",
"matterport"
"matterport",
"raycast"
]
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module github.com/grafana/grafana-iot-twinmaker-app
go 1.20

require (
github.com/aws/aws-sdk-go v1.44.179
github.com/aws/aws-sdk-go v1.44.323
github.com/google/uuid v1.3.0
github.com/gorilla/mux v1.8.0
github.com/grafana/grafana-aws-sdk v0.15.0
github.com/grafana/grafana-aws-sdk v0.19.1
github.com/grafana/grafana-plugin-sdk-go v0.161.0
github.com/magefile/mage v1.14.0
github.com/patrickmn/go-cache v2.1.0+incompatible
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj
github.com/aryann/difflib v0.0.0-20170710044230-e206f873d14a/go.mod h1:DAHtR1m6lCRdSC2Tm3DSWRPvIPr6xNKyeHdqDQSQT+A=
github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU=
github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.44.179 h1:2mLZYSRc6awtjfD3XV+8NbuQWUVOo03/5VJ0tPenMJ0=
github.com/aws/aws-sdk-go v1.44.179/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go v1.44.323 h1:97/dn93DWrN1VfhAWQ2tV+xuE6oO/LO9rSsEsuC4PLU=
github.com/aws/aws-sdk-go v1.44.323/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA=
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
Expand Down Expand Up @@ -259,8 +259,8 @@ github.com/gorilla/mux v1.7.3/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2z
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/grafana/grafana-aws-sdk v0.15.0 h1:ZOPHQcC5NUFi1bLTwnju91G0KmGh1z+qXOKj9nDfxNs=
github.com/grafana/grafana-aws-sdk v0.15.0/go.mod h1:rCXLYoMpPqF90U7XqgVJ1HIAopFVF0bB3SXBVEJIm3I=
github.com/grafana/grafana-aws-sdk v0.19.1 h1:5GBiOv2AgdyjwlgAX+dtgPtXU4FgMTD9rfQUPQseEpQ=
github.com/grafana/grafana-aws-sdk v0.19.1/go.mod h1:ntq2NDH12Y2Fkbc6fozpF8kYsJM9k6KNr+Xfo5w3/iM=
github.com/grafana/grafana-plugin-sdk-go v0.94.0/go.mod h1:3VXz4nCv6wH5SfgB3mlW39s+c+LetqSCjFj7xxPC5+M=
github.com/grafana/grafana-plugin-sdk-go v0.161.0 h1:UjVjRGQ5cuT4Ok30qUeLW2OhQhx9Whuz9Oz/1KsBvVM=
github.com/grafana/grafana-plugin-sdk-go v0.161.0/go.mod h1:dPhljkVno3Bg/ZYafMrR/BfYjtCRJD2hU2719Nl3QzM=
Expand Down
Binary file removed libs/aws-iot-twinmaker-grafana-utils-1.0.0.tgz
Binary file not shown.
Binary file added libs/aws-iot-twinmaker-grafana-utils-2.0.0.tgz
Binary file not shown.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "grafana-iot-twinmaker-app",
"version": "1.6.2",
"version": "1.8.0",
"description": "Grafana IoT TwinMaker App Plugin",
"scripts": {
"build": "webpack -c webpack.config.ts --env production",
Expand Down Expand Up @@ -92,11 +92,11 @@
"@aws-sdk/client-kinesis-video": "3.327.0",
"@aws-sdk/client-kinesis-video-archived-media": "3.327.0",
"@aws-sdk/client-s3": "3.327.0",
"@iot-app-kit/core": "7.1.0",
"@iot-app-kit/react-components": "7.1.0",
"@iot-app-kit/scene-composer": "7.1.0",
"@iot-app-kit/source-iottwinmaker": "7.1.0",
"aws-iot-twinmaker-grafana-utils": "file:libs/aws-iot-twinmaker-grafana-utils-1.0.0.tgz",
"@iot-app-kit/core": "3.4.0",
"@iot-app-kit/react-components": "3.4.0",
"@iot-app-kit/scene-composer": "3.4.0",
"@iot-app-kit/source-iottwinmaker": "3.4.0",
"aws-iot-twinmaker-grafana-utils": "file:libs/aws-iot-twinmaker-grafana-utils-2.0.0.tgz",
"aws-sdk": "^2.978.0",
"query-string": "^7.0.1",
"react-use": "^17.3.1",
Expand Down
4 changes: 2 additions & 2 deletions src/panels/oldStuffFromDatasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ export class OldDatasourceStuff {

const awsConfig = getAwsConfig(ds.getTokens, ds.getTokensV3, ds.instanceSettings.jsonData.defaultRegion);
this.awsTMQEConfig = getAwsTMQEConfig(ds.getTokensV3, ds.instanceSettings.jsonData.defaultRegion);
const endpoint = ds.instanceSettings.jsonData.endpoint;
if (endpoint && awsConfig.iotTwinMaker && this.awsTMQEConfig.iotTwinMaker) {
const endpoint = ds.instanceSettings.jsonData.endpoint || undefined; // if endpoint is empty string, prefer undefined
if ((endpoint || endpoint === undefined) && awsConfig.iotTwinMaker && this.awsTMQEConfig.iotTwinMaker) {
awsConfig.iotTwinMaker.endpoint = endpoint;
this.awsTMQEConfig.iotTwinMaker.endpoint = endpoint;
}
Expand Down
6 changes: 3 additions & 3 deletions src/panels/scene-viewer/SceneViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
IWidgetClickEvent,
ISelectionChangedEvent,
useSceneComposerApi,
ITagData
} from '@iot-app-kit/scene-composer';

const valueTypeToDataType: Record<ValueType, DataType> = {
Expand Down Expand Up @@ -137,7 +138,7 @@ export const SceneViewer = (props: SceneViewerPropsFromParent) => {
const anchorData =
objectData.additionalComponentData?.[
objectData.componentTypes.findIndex((type) => type === KnownComponentType.Tag)
];
] as ITagData | undefined;

if (anchorData) {
const targetLink = getValidHttpUrl(anchorData.navLink);
Expand All @@ -152,8 +153,7 @@ export const SceneViewer = (props: SceneViewerPropsFromParent) => {
const anchorData =
objectData.additionalComponentData?.[
objectData.componentTypes.findIndex((type) => type === KnownComponentType.Tag)
];

] as ITagData | undefined;
if (objectData.nodeRef && anchorData) {
const dashboardId = anchorData?.navLink?.params?.[MERGE_DASHBOARD_TARGET_ID_KEY];
mergeDashboard(dashboardId).then((options) => {
Expand Down
51 changes: 51 additions & 0 deletions src/panels/tests/sdkInit.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ jest.doMock('@grafana/runtime', () => ({
import { TwinMakerUxSDK } from 'aws-iot-twinmaker-grafana-utils';
import { DataQuery, DataSourceApi, DataSourceJsonData } from '@grafana/data';
import { configureSdkWithDataSource, DataSourceParams } from '../sdkInit';
import * as commonFuncs from 'common/datasourceSrv';
import * as awsConfig from '../awsConfig';

// mock these imports
jest.mock('common/datasourceSrv', () => ({
getTwinMakerDatasource: jest.fn(),
}));

jest.mock('../awsConfig', () => ({
getAwsConfig: jest.fn(),
getAwsTMQEConfig: jest.fn(),
}));

describe('sdkInit', () => {
describe('configureSdkWithDataSource', () => {
Expand Down Expand Up @@ -40,5 +52,44 @@ describe('sdkInit', () => {
expect(mockUxSdk.awsStore.createAwsCombinedReducer).toBeCalledTimes(2);
expect(mockUxSdk.awsStore.subscribeAwsStoreUpdate).toBeCalledTimes(2);
});

it('should properly set endpoint on configured twinmaker datasource when endpoint is defined', async () => {
// mocks
jest.spyOn(TwinMakerUxSDK.prototype, 'setAwsConfig').mockImplementationOnce(() => {});
(awsConfig.getAwsConfig as jest.Mock).mockReturnValueOnce({ iotTwinMaker: { endpoint: 'https://test' } });
(awsConfig.getAwsTMQEConfig as jest.Mock).mockReturnValueOnce({ iotTwinMaker: { endpoint: 'https://test' } });

// getTwinmakerDatasource with endpoint
(commonFuncs.getTwinMakerDatasource as jest.Mock).mockReturnValueOnce({
instanceSettings: {
jsonData: {
workspaceId: 1,
endpoint: 'https://test',
},
},
});
const response = await configureSdkWithDataSource('twinmaker1');
expect(response?.awsConfig.iotTwinMaker?.endpoint).toBe('https://test');
});

it('should properly set endpoint to undefined when endpoint is empty string', async () => {
// mocks
jest.spyOn(TwinMakerUxSDK.prototype, 'setAwsConfig').mockImplementation(() => {});
(awsConfig.getAwsConfig as jest.Mock).mockReturnValue({ iotTwinMaker: { endpoint: '' } });
(awsConfig.getAwsTMQEConfig as jest.Mock).mockReturnValue({ iotTwinMaker: { endpoint: '' } });

// getTwinMakerDatasource with empty string endpoint
(commonFuncs.getTwinMakerDatasource as jest.Mock).mockReturnValueOnce({
instanceSettings: {
jsonData: {
workspaceId: 1,
endpoint: '',
},
},
});

const response = await configureSdkWithDataSource('twinmaker2');
expect(response?.awsConfig.iotTwinMaker?.endpoint).toBe(undefined);
});
});
});
Loading

0 comments on commit 79cabe2

Please sign in to comment.