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: make the requestForEffect optional #111

Merged
merged 1 commit into from
Aug 30, 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
1 change: 0 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
workspaces-update false
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/react-hooks": "^7.0.0",
"@trixtateam/phoenix-to-redux": "1.1.1",
"@trixtateam/phoenix-to-redux": "1.2.0",
"@types/debug": "4.1.5",
"@types/jest": "^26.0.20",
"@types/json-schema": "^7.0.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function TrixtaInteractionComponent({
debugMode = false,
instances,
...rest
}: // eslint-disable-next-line @typescript-eslint/no-explicit-any
ConnectProps & TrixtaInteractionComponentProps) {
}:
ConnectProps & TrixtaInteractionComponentProps) {
if (!hasRoleAccess) return null;
if (isNullOrEmpty(common)) return null;
if (isNullOrEmpty(instances) || !Array.isArray(instances)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function TrixtaReactionComponent({
roleName,
reactionName,
defaultComponent,
requestForEffect = false,
requestForEffect,
includeResponse = false,
errorEvent,
responseEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function TrixtaReactionResponseComponent({
roleName,
reactionName,
defaultComponent,
requestForEffect = false,
requestForEffect,
errorEvent,
responseEvent,
requestEvent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const useTrixtaReaction = <
>({
roleName,
reactionName,
requestForEffect = false,
requestForEffect,
debugMode = false,
loadingStatusRef,
onSuccess,
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/React/reducers/trixtaReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
{
const keyName = action.payload.keyName;
const type = action.payload.type;
const finalPayload: any = {

Check warning on line 423 in packages/core/src/React/reducers/trixtaReducer.ts

View workflow job for this annotation

GitHub Actions / Running project (14)

Unexpected any. Specify a different type

Check warning on line 423 in packages/core/src/React/reducers/trixtaReducer.ts

View workflow job for this annotation

GitHub Actions / Running project (14)

Unexpected any. Specify a different type
details: action.payload[type],
keyName,
instances: state[`${type}s`]?.[keyName]?.instances ?? undefined,
Expand All @@ -443,6 +443,7 @@
{
const reactionDetails = action.payload.trixtaReaction;
const keyName = action.payload.keyName;

if (!state.reactions[keyName]) {
draft.reactions[keyName] = getTrixtaReactionReducerStructure({
details: reactionDetails,
Expand Down
35 changes: 25 additions & 10 deletions packages/core/src/React/selectors/trixtaReactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,28 @@ export const selectTrixtaReactionResponseInstance = (
][props.instanceIndex]
: undefined;

function getInstanceList(
selectedReaction: TrixtaReaction | undefined,
requestForEffect: boolean | undefined,
) {
if (requestForEffect) {
return selectedReaction
? selectedReaction?.instances[
requestForEffect ? 'requestForEffect' : 'requestForResponse'
]
: [];
} else {
if (!selectedReaction?.instances) {
return [];
}
if (selectedReaction?.instances['requestForEffect'].length > 0) {
return selectedReaction?.instances['requestForEffect'];
} else {
return selectedReaction?.instances['requestForResponse'];
}
}
}

/**
* Selects the reactions[props.roleName:props.reactionName].instances
* for the given props.roleName , props.reactionName and returns the reaction instances for requestForEffect or requestForResponse
Expand All @@ -216,13 +238,8 @@ export const makeSelectTrixtaReactionResponseInstancesForRole = (): OutputParame
> =>
createSelector(
[selectTrixtaReactionStateSelector, selectTrixtaReactionTypeProp],
(selectedReaction, requestForEffect) => {
return selectedReaction
? selectedReaction?.instances[
requestForEffect ? 'requestForEffect' : 'requestForResponse'
]
: [];
},
(selectedReaction, requestForEffect) =>
getInstanceList(selectedReaction, requestForEffect),
);

/**
Expand All @@ -248,9 +265,7 @@ export const makesSelectTrixtaReactionResponseInstance = (): OutputParametricSel
selectTrixtaReactionInstanceIndexProp,
],
(selectedReaction, requestForEffect, instanceIndex) => {
return selectedReaction?.instances[
requestForEffect ? 'requestForEffect' : 'requestForResponse'
][instanceIndex];
return getInstanceList(selectedReaction, requestForEffect)[instanceIndex];
},
);

Expand Down
3 changes: 2 additions & 1 deletion packages/rjsf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"react-redux": ">=7.2.1",
"redux": "~4.1.2",
"redux-saga": ">=1.2.1",
"@trixtateam/trixta-js-core": "2.0.0-alpha.1",
"reselect": "~4.0.0"
},
"dependencies": {
Expand Down Expand Up @@ -160,7 +161,7 @@
"@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.7",
"@testing-library/react-hooks": "^7.0.0",
"@trixtateam/phoenix-to-redux": "1.1.1",
"@trixtateam/phoenix-to-redux": "1.2.0",
"@trixtateam/trixta-js-core": "2.0.0-alpha.1",
"@types/debug": "4.1.5",
"@types/jest": "^26.0.20",
Expand Down
2 changes: 1 addition & 1 deletion packages/rjsf/rollup.dev.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default {
dest: config.parsed.DEST_NODE_MODULES_FOLDER,
},
],
hook: 'closeBundle',
hook: 'buildEnd',
}),
],
};
20 changes: 4 additions & 16 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@
"jsx": "react",
"noEmit": true,
"target": "ESNext",
"lib": [
"DOM",
"DOM.Iterable",
"ESNext"
],
"lib": ["DOM", "DOM.Iterable", "ESNext"],
"allowJs": true,
"checkJs": false, // typecheck js files
"noImplicitAny": true,
Expand All @@ -33,19 +29,11 @@
"suppressImplicitAnyIndexErrors": true,
"resolveJsonModule": true,
"noFallthroughCasesInSwitch": true,
"types": [
"jest",
"@testing-library/jest-dom",
"node"
],
"types": ["jest", "@testing-library/jest-dom", "node"],
"typeRoots": [
"node_modules/@types"
]
"node_modules/@types"]
},
"include": [
"packages/*/src",
"packages/stories"
],
"include": ["packages/*/src", "packages/stories"],
"exclude": [
"node_modules",
"packages/*/node_modules",
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4993,10 +4993,10 @@
resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf"
integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A==

"@trixtateam/phoenix-to-redux@1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@trixtateam/phoenix-to-redux/-/phoenix-to-redux-1.1.1.tgz#06556b077c7f42c43a037d77c72075738c3dd017"
integrity sha512-7GDFo+EVJxzlMSNbsSF7qx+f3OgXaTaCZKiqZFp4GJVUuPuGlUAz+PEL7TwogW1nSU5GTcuaZYCyp1a2KMJ8vg==
"@trixtateam/phoenix-to-redux@1.2.0":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@trixtateam/phoenix-to-redux/-/phoenix-to-redux-1.2.0.tgz#ad0a1479c435fa5fdc665843eb9d1672a15bc18b"
integrity sha512-sa7eQuYy0+PBIWfMOuTXz/QacZQdAjh5Waxl06jt7BwNlIyXojkeDGDqXIcqfMXcrjSctVH/kDZydgxOvrjpAA==
dependencies:
immer "~9.0.6"
phoenix "~1.5.9"
Expand Down
Loading