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

🗳 387 adding gateways, slices, selectors and moving calculations to redux/selectors #390

Merged

Conversation

xoscar
Copy link
Collaborator

@xoscar xoscar commented May 2, 2022

This PR enables the addition of selectors and slices. It also moves the big calculations out of the component layer and into redux actions, async thunks.

Changes

  • Updates gateways.
  • Adds test result slice.
  • Adds selectors

Fixes

  • Removed unnecessary code and reduced complexity

Checklist

  • tested locally
  • added new dependencies
  • updated the docs
  • added a test

@xoscar xoscar linked an issue May 2, 2022 that may be closed by this pull request
@xoscar xoscar self-assigned this May 2, 2022
@xoscar xoscar added the frontend label May 2, 2022
@xoscar xoscar marked this pull request as ready for review May 2, 2022 15:56
}

return `Effects ${spanCount} spans`;
return `Affects ${spanCount} spans`;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo 😬

@@ -40,7 +40,7 @@ const CreateAssertionModal = ({testId, span, trace, open, onClose, assertion}: I
onClose();
}, [onClose]);

const effectedSpanCount = AssertionService.getEffectedSpansCount(trace, selectorList);
const affectedSpanCount = useAppSelector(AssertionSelectors.selectAffectedSpanCount(testId, resultId, selectorList));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved calculations to selectors

) || []
);
}, [targetSpan, test?.assertions, trace]);
const assertionsResultList = useAppSelector(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More selectors, less react code 😄

@@ -92,62 +87,50 @@ const Trace: React.FC<TraceProps> = ({testId, testResultId, onDismissTrace, onRu
);

useGuidedTour(GuidedTours.Trace);

useEffect(() => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving custom logic to hook "usePolling"


const {createAssertion, getAssertions, updateAssertion} = endpoints;

const AssertionGateway = () => ({
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Facade to facilitate the usage of the async thunk functions from the redux API slice


interface ITestResultListState {
resultListMap: Record<string, IAssertionResult[]>;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New slice that stores the result list info, in the future this will come from the BE

@@ -0,0 +1,45 @@
import {createSelector} from '@reduxjs/toolkit';

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selectors ✨

@xoscar xoscar merged commit 84963a7 into main May 2, 2022
@xoscar xoscar deleted the 387-post-mvp-improvements-move-calculations-to-reduxselectors branch May 2, 2022 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[POST MVP Improvements] Move Calculations to Redux/Selectors
1 participant