Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: housekeeping #82

Merged
merged 22 commits into from
Jul 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/autodev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:

jobs:
autodev:
uses: Staffbase/gha-workflows/.github/workflows/template_autodev.yml@dont-check-private-key
uses: Staffbase/gha-workflows/.github/workflows/template_autodev.yml@v5.3.0
with:
comments: true
secrets:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
types: [published]

env:
NODE_VERSION: 16
NODE_VERSION: 20
DEPLOYMENT_KIND: widget
DEPLOYMENT_TARGET: weather
DEPLOYMENT_STATIC_FILES: staffbase.user-profile-client.min.js
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
name: CI Tests
env:
NODE_VERSION: 14
NODE_VERSION: 20
on:
push:
paths-ignore:
- '**.md'

jobs:
executing-tests:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04

steps:
- name: Checkout repository
Expand Down
1 change: 1 addition & 0 deletions samples/weather-forecast/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
{
"useBuiltIns": "usage",
"corejs": 3,
"targets": "> 0.25%, not dead, not ie < 11"
}
],
"@babel/preset-react",
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports = {
extends: [
"eslint:recommended",
"plugin:@typescript-eslint/recommended",
"plugin:prettier/recommended"
"prettier"
],
rules: {
"no-unused-vars": "off",
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ $ yarn install

## Building the form for configuration

This project uses [react-jsonschema-form](https://rjsf-team.github.io/react-jsonschema-form/) for configuring the widget properties. For more information consult their [documentation](https://react-jsonschema-form.readthedocs.io/en/latest/)
This project uses [react-jsonschema-form](https://rjsf-team.github.io/react-jsonschema-form/) for configuring the widget properties. For more information consult their [documentation](https://rjsf-team.github.io/react-jsonschema-form/docs/)
10 changes: 5 additions & 5 deletions samples/weather-forecast/dev/bootstrap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -47,7 +47,7 @@
const { name, value: attribute } = attr;
if (attribute) {
const key = name as keyof T;
acc[key] = fromDataUri<any>(attribute);

Check warning on line 50 in samples/weather-forecast/dev/bootstrap.ts

View workflow job for this annotation

GitHub Actions / executing-tests

Unexpected any. Specify a different type
}

return acc;
Expand All @@ -55,7 +55,7 @@
}

public parseConfig<T extends Record<string, unknown>>(
attributes: T
attributes: T,
): Record<string, string> {
return prepareAttributes(attributes);
}
Expand All @@ -69,14 +69,14 @@
const customElementName = externalBlockDefinition.blockDefinition.name;
const CustomElementClass = externalBlockDefinition.blockDefinition.factory(
FakeBaseClass,
WidgetApiMock
WidgetApiMock,
);
window.customElements.define(customElementName, CustomElementClass);

ReactDOM.render(
React.createElement(Config, {
blockDefinition: externalBlockDefinition.blockDefinition,
}),
document.getElementById("config")
document.getElementById("config"),
);
window.customElements.define(customElementName, CustomElementClass);
};
6 changes: 3 additions & 3 deletions samples/weather-forecast/dev/config.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -41,12 +41,11 @@ const Config: FC<Props> = ({ blockDefinition }) => {
aria-label={blockDefinition.label}
style={{
background: "rgb(247, 247, 247)",
cursor: "pointer",
height: "96px",
flex: "0 0 20%",
borderRadius: "3px",
padding: "0px",
margin: "0px",
margin: "5px 0px 0px 0px",
display: "flex",
alignItems: "center",
justifyContent: "center",
Expand All @@ -57,6 +56,7 @@ const Config: FC<Props> = ({ blockDefinition }) => {
height="28"
src={blockDefinition.iconUrl}
style={{ maxWidth: "80px" }}
alt={blockDefinition.label}
/>
<div
aria-hidden="true"
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/dev/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/dev/utils/DataUtil.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down
6 changes: 3 additions & 3 deletions samples/weather-forecast/dev/widget-api-mock/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -19,14 +19,14 @@ import {
getUserInformationByExternalId,
} from "./user";

import getIntegration from "./integrations";
import getIntegration from "./integrations"

const apiMock: WidgetApi = {
getIntegration,
getLegacyAppTheme,
getUserInformation,
getUserList,
getUserInformationByExternalId,
getIntegration
};

export default apiMock;
40 changes: 16 additions & 24 deletions samples/weather-forecast/dev/widget-api-mock/integrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,22 @@
* limitations under the License.
*/

import {
IntegrationInformation,
IntegrationStates,
IntegrationType,
} from "@staffbase/widget-sdk";
import {IntegrationInformation, IntegrationStates, IntegrationType} from '@staffbase/widget-sdk'

export default async (
_type: IntegrationType
): Promise<IntegrationInformation> => {
const date = new Date();
const expireDate = new Date();
export default async (_type: IntegrationType): Promise<IntegrationInformation> => {
const date = new Date();
const expireDate = new Date();

expireDate.setDate(date.getDate() + 1);
expireDate.setDate(date.getDate() + 1);

return {
status: IntegrationStates.AVAILABLE,
enabledFeatures: ["foo"],
supportedFeatures: ["foo"],
token: {
accessToken: "fooToken",
accessTokenExpiresAt: expireDate,
},
signIn: () => {
console.log("Sign in");
},
};
};
return {
status: IntegrationStates.AVAILABLE,
enabledFeatures: ['foo'],
supportedFeatures: ['foo'],
token: {
accessToken: "fooToken",
accessTokenExpiresAt: expireDate
},
signIn: () => { console.log('Sign in') }
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down
12 changes: 10 additions & 2 deletions samples/weather-forecast/dev/widget-api-mock/user.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand All @@ -19,8 +19,16 @@ import {

const user: SBUserProfile = {
id: "5c35e4feea2d15e6ffa8251d",
externalID: "abc123",
primaryEmail: "[email protected]",
primaryUsername: "lucy.liu",
firstName: "Lucy",
lastName: "Liu",
phoneNumber: "09124456",
publicEmailAddress: "[email protected]",
location: "New York",
position: "Sales Representative",
department: "Sales",
};

export const getUserInformation = async (
Expand All @@ -34,7 +42,7 @@ export const getUserInformationByExternalId = async (
export const getUserList = async (
_query: UserListRequestQuery
): Promise<UserListResponse> => ({
data: [{ ...user, id: "5c35e4feea2d15e6ffa8251d" }],
data: [user, {id: "5e43c6feca2d15e6afa8231d", firstName: "Tony", lastName: "Stark"}],
offset: 0,
limit: 1,
total: 1,
Expand Down
38 changes: 20 additions & 18 deletions samples/weather-forecast/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@staffbase/weather-forecast",
"version": "1.0.0",
"version": "1.0.1",
"description": "",
"scripts": {
"start": "webpack serve --open --config webpack.dev.ts",
Expand Down Expand Up @@ -39,31 +39,33 @@
"@babel/preset-typescript": "^7.24.7",
"@material-ui/core": "^4.12.4",
"@material-ui/icons": "^4.11.3",
"@rjsf/core": "5.18.5",
"@rjsf/utils": "5.18.5",
"@rjsf/material-ui": "5.18.5",
"@rjsf/validator-ajv8": "^5.18.4",
"@rjsf/core": "5.19.1",
"@rjsf/material-ui": "5.19.1",
"@rjsf/utils": "5.19.1",
"@rjsf/validator-ajv8": "^5.19.1",
"@svgr/webpack": "6.5.1",
"@testing-library/dom": "8.2.0",
"@testing-library/jest-dom": "5.14.1",
"@testing-library/react": "12.0.0",
"@testing-library/dom": "8.11.1",
"@testing-library/jest-dom": "5.15.0",
"@testing-library/react": "12.1.5",
"@testing-library/react-hooks": "7.0.2",
"@types/copy-webpack-plugin": "^8.0.1",
"@types/node": "16.7.10",
"@types/react": "^17.0.19",
"@types/react-dom": "^17.0.9",
"@types/jest": "^29.5.12",
"@types/json-schema": "^7.0.15",
"@types/node": "16.11.9",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@types/testing-library__jest-dom": "^5.14.9",
"@types/webpack": "5.28.5",
"@types/webpack-dev-server": "4.1.0",
"@typescript-eslint/eslint-plugin": "4.30.0",
"@typescript-eslint/parser": "4.30.0",
"@types/webpack-dev-server": "4.7.2",
"@typescript-eslint/eslint-plugin": "5.4.0",
"@typescript-eslint/parser": "5.4.0",
"@ungap/custom-elements": "1.3.0",
"babel-eslint": "10.1.0",
"babel-loader": "^8.2.2",
"copy-webpack-plugin": "^9.0.1",
"core-js": "3.37.1",
"eslint": "7.32.0",
"eslint": "8.3.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "4.0.0",
"file-loader": "^6.2.0",
"jest": "27.1.0",
"jest-json-schema": "^5.0.0",
Expand All @@ -73,11 +75,11 @@
"react-svg-loader": "^3.0.3",
"ts-loader": "^9.5.1",
"ts-node": "10.9.2",
"typescript": "^4.4.2",
"typescript": "4.5.2",
"url-loader": "^4.1.1",
"webpack": "^5.92.1",
"webpack-cli": "^4.8.0",
"webpack-dev-server": "^4.1.0",
"webpack-dev-server": "^4.5.0",
"webpack-merge": "^5.10.0"
},
"jest": {
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/api/mockData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/api/openGeoApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/api/openWeatherMapApi.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/api/useCity.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/api/useCity.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down
6 changes: 3 additions & 3 deletions samples/weather-forecast/src/api/useWeather.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -38,7 +38,7 @@ setLogger({
});

describe("useWeather", () => {
const endpoint = "https://api.openweathermap.org/data/2.5/onecall";
const endpoint = "https://api.openweathermap.org/data/3.0/onecall";
afterEach(() => {
queryClient.clear();
});
Expand Down Expand Up @@ -104,7 +104,7 @@ describe("useWeather", () => {
});

expect(result.current.error).toEqual(
new TypeError("Cannot read property 'map' of undefined")
new TypeError("Cannot read properties of undefined (reading 'map')")
);
expect(log).toHaveBeenCalledTimes(1);
});
Expand Down
4 changes: 2 additions & 2 deletions samples/weather-forecast/src/api/useWeather.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down Expand Up @@ -89,7 +89,7 @@ type ForecastOptions = {
const getWeather = async ({
queryKey: [, options],
}: QueryFunctionContext<[string, ForecastOptions]>) => {
const endpoint = "https://api.openweathermap.org/data/2.5/onecall";
const endpoint = "https://api.openweathermap.org/data/3.0/onecall";
const {
units = "standard",
lang = options.lang ?? "en",
Expand Down
2 changes: 1 addition & 1 deletion samples/weather-forecast/src/api/weatherIcon.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*!
* Copyright 2021, Staffbase GmbH and contributors.
* Copyright 2024, Staffbase GmbH and contributors.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
Expand Down
Loading
Loading