Skip to content
Merged
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
10 changes: 7 additions & 3 deletions frontend/public/components/utils/firehose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ const processReduxId = ({k8s}, props) => {
}

if (!isList) {
Copy link
Member

Choose a reason for hiding this comment

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

Ah, OK. I see now. We didn't have proper support for optional with individual resources, only lists.

const stuff = k8s.get(reduxID);
return stuff ? stuff.toJS() : {};
let stuff = k8s.get(reduxID);
if (stuff) {
stuff = stuff.toJS();
stuff.optional = props.optional;
}
return stuff || {};
Copy link
Member

@atiratree atiratree Jun 13, 2019

Choose a reason for hiding this comment

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

can we use the same approach which is used for lists?

const data = k8s.getIn([reduxID, 'data']);

 return {
    data: data && data.toJS(), 
    loadError: k8s.getIn([reduxID, 'loadError']),	
    loaded: k8s.getIn([reduxID, 'loaded']),
    optional: props.optional,
    ignoreIfMissing: props.ignoreIfMissing,
};

This way we can optionally swap the toJS with only immutables once they are needed in the future.

Copy link
Contributor Author

@mareklibra mareklibra Jun 13, 2019

Choose a reason for hiding this comment

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

Actually the stuff is not the response received from API but already a wrapper around it, please see

return state.mergeIn([id], {

Copy link
Member

Choose a reason for hiding this comment

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

I know, but it will be easier to extend for adding a support of raw immutables

Copy link
Member

Choose a reason for hiding this comment

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

meaning that toJS may not be used at all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If this is needed, I propose to do it in a follow-up.
It would require refactoring of code around the reducer and this is unrelated to original need behind this PR.

}

const data = k8s.getIn([reduxID, 'data']);
Expand Down Expand Up @@ -208,6 +212,6 @@ Firehose.propTypes = {
selector: PropTypes.object,
fieldSelector: PropTypes.string,
isList: PropTypes.bool,
optional: PropTypes.bool,
optional: PropTypes.bool, // do not block children-rendering while resource is still being loaded; do not fail if resource is missing (404)
})).isRequired,
};