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

Fix/reset errors messages #1048

Merged
merged 3 commits into from
Oct 24, 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
4 changes: 2 additions & 2 deletions .github/actions/generic-ci-app/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'Build Application'
runs:
using: "composite"
using: 'composite'
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
node-version: 23
cache: npm
- name: 🏗️ Installing Dependencies
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/actions/generic-ci-documentation/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'Build Documentation'
runs:
using: "composite"
using: 'composite'
steps:
- uses: actions/setup-node@v4
with:
node-version: 22
node-version: 23
- name: 🏗️ Generate Astro Documentation
shell: bash
run: ./scripts/documentation-build.sh
Expand Down
10 changes: 6 additions & 4 deletions src/packages/auth/open-id-connect-auth/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import * as R from '../../auth/roles';
import { Collection } from '../../model/concepts/collection';
import { Concept } from '../../model/concepts/concept';

export const isAdmin = (roles: string[]) => roles.includes(R.ADMIN);

Expand All @@ -19,7 +21,7 @@ export const isConceptCreator = (
) => roles.includes(R.CONCEPTS_CREATOR) && stamp === conceptCreator;

export const filterConceptsToValidate = (
concepts: any[],
concepts: Concept[],
roles: string[],
stamp: string,
) =>
Expand All @@ -29,12 +31,12 @@ export const filterConceptsToValidate = (

export const isCollectionCreator = (
roles: string[],
stamp: string,
collectionCreator: string,
stamp?: string,
collectionCreator?: string,
) => roles.includes(R.COLLECTIONS_CREATOR) && stamp === collectionCreator;

export const filterCollectionsToValidate = (
collections: any[],
collections: Collection[],
roles: string[],
stamp: string,
) =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export const DumbCodelistPartialDetailEdit = ({

useTitle(D.codelistsPartialTitle, codelist?.labelLg1);

const resetErrorsMessages = () =>
setClientSideErrors({
...clientSideErrors,
errorMessage: [],
});

const handleParentCode = useCallback(
(code) => {
CodeListApi.getCodesListCodes(code, 1, 0).then((codes) => {
Expand All @@ -68,6 +74,7 @@ export const DumbCodelistPartialDetailEdit = ({
(parentCL) => parentCL.value === value,
).iriParent,
});
resetErrorsMessages();
handleParentCode(value);
},
[codelist, handleParentCode, globalCodeListOptions],
Expand Down Expand Up @@ -97,10 +104,7 @@ export const DumbCodelistPartialDetailEdit = ({
const handleChange = useCallback(
(e) => {
const { name, value } = e.target;
setClientSideErrors({
...clientSideErrors,
errorMessage: [],
});
resetErrorsMessages();

setCodelist({
...codelist,
Expand Down Expand Up @@ -194,9 +198,7 @@ export const DumbCodelistPartialDetailEdit = ({
onChange={handleChange}
disabled={updateMode}
aria-invalid={!!clientSideErrors.fields?.id}
aria-describedby={
clientSideErrors.fields?.id ? 'id-error' : null
}
aria-describedby={clientSideErrors.fields?.id ? 'id-error' : null}
/>
<ClientSideError
id="id-error"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,16 @@ export const DumbComponentDetailEdit = ({
}
}, [type, component, initialComponent]);

const resetErrorsMessages = () =>
setClientSideErrors({
...clientSideErrors,
errorMessage: [],
});

const handleChange = useCallback(
(e) => {
const { name, value } = e.target;
setClientSideErrors({
...clientSideErrors,
errorMessage: [],
});
resetErrorsMessages();
setComponent({
...component,
[name]: value,
Expand Down Expand Up @@ -264,6 +267,8 @@ export const DumbComponentDetailEdit = ({
},
{},
);

resetErrorsMessages();
setComponent({ ...newComponentWithoutAttributes, type: option });
};

Expand Down
6 changes: 4 additions & 2 deletions src/packages/utils/date-utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import { isDateIn, isOutOfDate, stringToDate } from './date-utils';
describe('is date in', () => {
it('returns true if the start and end dates are null', () => {
const toTest = '2017-06-25T10:51:47.812';
expect(isDateIn(toTest, null as any, null as any)).toBe(true);
expect(
isDateIn(toTest, null as unknown as Date, null as unknown as Date),
).toBe(true);
});

it('returns true if the dates match', () => {
Expand All @@ -23,7 +25,7 @@ describe('is date in', () => {

describe('has date passed', () => {
it('returns false if the end date is null', () => {
expect(isOutOfDate(null as any)).toBe(false);
expect(isOutOfDate(null as unknown as Date)).toBe(false);
});

it('returns false if the date has not passed', () => {
Expand Down