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

Update React dependency to v18 #19

Merged
merged 2 commits into from
Dec 12, 2023
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
11,215 changes: 7,664 additions & 3,551 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@datagov-cz/assembly-line-shared",
"version": "0.3.3",
"version": "0.3.4",
"description": "Common front end components for Assembly Line",
"homepage": "https://github.com/datagov-cz/assembly-line-shared#readme",
"author": "KODI Team",
Expand Down Expand Up @@ -30,11 +30,11 @@
},
"devDependencies": {
"@types/jest": "^27.0.2",
"@types/node": "^16.10.3",
"@types/react": "^17.0.27",
"@types/node": "^20.10.0",
"@types/react": "^18.2.39",
"jest": "^27.2.4",
"microbundle": "^0.14.0",
"prettier": "^2.4.1",
"prettier": "^3.1.0",
"ts-jest": "^27.0.5",
"typescript": "^4.4.3"
},
Expand All @@ -54,6 +54,6 @@
"yaml": "^1.10.2"
},
"peerDependencies": {
"react": "^17.0.2"
"react": "^18.2.0"
}
}
2 changes: 1 addition & 1 deletion src/auth/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const useThrow = () => {
setState(() => {
throw error;
}),
[setState]
[setState],
);
return callback;
};
Expand Down
4 changes: 2 additions & 2 deletions src/auth/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const getOidcConfig = () => {
authority: COMPONENTS["al-auth-server"].url,
client_id: ID,
redirect_uri: `${URL}/oidc-signin-callback.html?forward_uri=${encodeForwardUri(
URL
URL,
)}`,
silent_redirect_uri: `${URL}/oidc-silent-callback.html`,
post_logout_redirect_uri: URL,
Expand All @@ -45,7 +45,7 @@ export const getOidcConfig = () => {
export const generateRedirectUri = (forwardUri: string) => {
const env = getEnvInstance();
return `${env.get(
"URL"
"URL",
)}/oidc-signin-callback.html?forward_uri=${encodeForwardUri(forwardUri)}`;
};

Expand Down
8 changes: 4 additions & 4 deletions src/env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const buildComponents = (windowConfig: Config) => {
const base64String = windowConfig.COMPONENTS;
// Use TextDecoder interface to properly decode UTF-8 characters
const yamlString = new TextDecoder("utf-8").decode(
Uint8Array.from(atob(base64String), (c) => c.charCodeAt(0))
Uint8Array.from(atob(base64String), (c) => c.charCodeAt(0)),
);
return parse(yamlString);
} catch (error: any) {
Expand All @@ -62,7 +62,7 @@ class Env<LocalVars extends string = never> {
const processEnv = getProcessEnv();
if (!processEnv) {
throw new Error(
`Trying to create Env instance before setting process.env to setProcessEnv`
`Trying to create Env instance before setting process.env to setProcessEnv`,
);
}
const config = getConfig();
Expand All @@ -72,7 +72,7 @@ class Env<LocalVars extends string = never> {

get(
name: LocalVars | keyof Config | keyof NetlifyConfig,
defaultValue?: string
defaultValue?: string,
): string {
// If URL var is required and the app runs on Netlify, feed it proper URL based on Netlify configuration
if (name === "URL" && this.env.NETLIFY === "true") {
Expand Down Expand Up @@ -109,7 +109,7 @@ let envInstance: Env;
* `const components = env.getComponents()`
*/
export const getEnvInstance = <LocalVars extends string = never>(
forceNewInstance?: true
forceNewInstance?: true,
) => {
if (!envInstance || forceNewInstance) {
envInstance = new Env();
Expand Down
4 changes: 2 additions & 2 deletions src/vocabulary-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ export function getVocabularyShortLabel(vocabularyIri: string) {
return !match
? null
: match.length == 1
? v.shortName
: v.shortName.replace("{id}", match[1]);
? v.shortName
: v.shortName.replace("{id}", match[1]);
})
.filter((v) => v);
return !vocabularies || vocabularies.length > 1 ? null : vocabularies[0];
Expand Down
28 changes: 14 additions & 14 deletions src/vocabulary-utils/vocabularyTypes.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
const vocabularyTypes = [
{
"regex": "^https://slovník.gov.cz/datový/([ěščřžýáíéóúůďťňa-z0-9-.]+)$",
"shortName": "D-SGoV-{id}"
regex: "^https://slovník.gov.cz/datový/([ěščřžýáíéóúůďťňa-z0-9-.]+)$",
shortName: "D-SGoV-{id}",
},
{
"regex": "^https://slovník.gov.cz/agendový/([a-z0-9-]+)$",
"shortName": "A-SGoV-{id}"
regex: "^https://slovník.gov.cz/agendový/([a-z0-9-]+)$",
shortName: "A-SGoV-{id}",
},
{
"regex": "^https://slovník.gov.cz/legislativní/sbírka/([0-9]+/[0-9]+)$",
"shortName": "L-SGoV-{id}"
regex: "^https://slovník.gov.cz/legislativní/sbírka/([0-9]+/[0-9]+)$",
shortName: "L-SGoV-{id}",
},
{
"regex": "^https://slovník.gov.cz/generický/([ěščřžýáíéóúůďťňa-z0-9-.]+$)",
"shortName": "G-SGoV-{id}"
regex: "^https://slovník.gov.cz/generický/([ěščřžýáíéóúůďťňa-z0-9-.]+$)",
shortName: "G-SGoV-{id}",
},
{
"regex": "^https://slovník.gov.cz/veřejný-sektor",
"shortName": "V-SGoV"
regex: "^https://slovník.gov.cz/veřejný-sektor",
shortName: "V-SGoV",
},
{
"regex": "^https://slovník.gov.cz/základní",
"shortName": "Z-SGoV"
}
]
regex: "^https://slovník.gov.cz/základní",
shortName: "Z-SGoV",
},
];

export default vocabularyTypes;
4 changes: 2 additions & 2 deletions test/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ al-issue-tracker:
url: https://github.com/datagov-cz/sgov-assembly-line/issues
meta:
new-bug: https://github.com/datagov-cz/sgov-assembly-line/issues/new?labels=bug&template=po-adavek-na-opravu.md&title=
new-feature: https://github.com/datagov-cz/sgov-assembly-line/issues/new?labels=enhancement&template=po-adavek-na-novou-funkcionalitu.md&title=`
new-feature: https://github.com/datagov-cz/sgov-assembly-line/issues/new?labels=enhancement&template=po-adavek-na-novou-funkcionalitu.md&title=`,
).toString("base64");

type WindowWithConfig = Window & { __config__: object };
Expand All @@ -68,7 +68,7 @@ describe("Env", () => {
expect(env.get("ID")).toEqual("example");
expect(env.get("URL")).toEqual("http://example.com");
expect(env.getComponents()["al-mission-control"].name).toEqual(
"Mission Control"
"Mission Control",
);
});

Expand Down
12 changes: 6 additions & 6 deletions test/vocabulary-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,42 @@ describe("Test vocabulary utils", () => {
test("V-SGoV label is returned correctly", () => {
const expectedOutput = "V-SGoV";
const output = getVocabularyShortLabel(
"https://slovník.gov.cz/veřejný-sektor"
"https://slovník.gov.cz/veřejný-sektor",
);
expect(output).toEqual(expectedOutput);
});
test("L-SGoV label is returned correctly", () => {
const expectedOutput = "L-SGoV-111/2009";
const output = getVocabularyShortLabel(
"https://slovník.gov.cz/legislativní/sbírka/111/2009"
"https://slovník.gov.cz/legislativní/sbírka/111/2009",
);
expect(output).toEqual(expectedOutput);
});
test("A-SGoV label is returned correctly", () => {
const expectedOutput = "A-SGoV-101";
const output = getVocabularyShortLabel(
"https://slovník.gov.cz/agendový/101"
"https://slovník.gov.cz/agendový/101",
);
expect(output).toEqual(expectedOutput);
});
test("D-SGoV label is returned correctly", () => {
const expectedOutput = "D-SGoV-turistický-cíl";
const output = getVocabularyShortLabel(
"https://slovník.gov.cz/datový/turistický-cíl"
"https://slovník.gov.cz/datový/turistický-cíl",
);
expect(output).toEqual(expectedOutput);
});
test("G-SGoV label is returned correctly", () => {
const expectedOutput = "G-SGoV-čas";
const output = getVocabularyShortLabel(
"https://slovník.gov.cz/generický/čas"
"https://slovník.gov.cz/generický/čas",
);
expect(output).toEqual(expectedOutput);
});
test("G-SGoV label can contain dot", () => {
const expectedOutput = "G-SGoV-a.b";
const output = getVocabularyShortLabel(
"https://slovník.gov.cz/generický/a.b"
"https://slovník.gov.cz/generický/a.b",
);
expect(output).toEqual(expectedOutput);
});
Expand Down
Loading