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

feat(xo-web/render-xo-item): simpler item components #3547

Merged
merged 2 commits into from
Dec 3, 2018

Conversation

pdonias
Copy link
Member

@pdonias pdonias commented Oct 17, 2018

See #2605

Check list

Check items when done or if not relevant

  • PR reference the relevant issue (e.g. Fixes #007)
  • if UI changes, a screenshot has been added to the PR
  • CHANGELOG:
    • enhancement/bug fix entry added
    • list of packages to release updated (${name} v${new version})
  • documentation updated

Process

  1. create a PR as soon as possible
  2. mark it as WiP: (Work in Progress) if not ready to be merged
  3. when you want a review, add a reviewer
  4. if necessary, update your PR, and re- add a reviewer

object: PropTypes.object.isRequired,
return (
<span>
<Icon icon='network' /> {network.name_label}
Copy link
Contributor

Choose a reason for hiding this comment

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

why u delete this:

 {pool && `(${pool.name_label || pool.id})`}

Copy link
Member Author

Choose a reason for hiding this comment

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

It's in the pool component.

return (
<span>
<Icon icon='disk' /> {vdi.name_label}
{vdi.name_description && <span> ({vdi.name_description})</span>}
Copy link
Contributor

Choose a reason for hiding this comment

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

why you didn't display the SR instead description?

Copy link
Member Author

Choose a reason for hiding this comment

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

I kept it as it was. I'm not trying to change the behaviour in this PR.

@pdonias pdonias force-pushed the pierre-render-xo-item branch 3 times, most recently from 0b3662a to 77d9882 Compare November 6, 2018 08:51
@pdonias pdonias requested a review from badrAZ November 30, 2018 13:04
@pdonias pdonias changed the title WiP: feat(xo-web/render-xo-item): simplify (demutualize) multiple item com… feat(xo-web/render-xo-item): simpler item components Nov 30, 2018
])

SrItem.propTypes = XO_ITEM_PROP_TYPES
VmTemplate.propTypes = {
id: PropTypes.string.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

self property ?

])

SrItem.propTypes = XO_ITEM_PROP_TYPES
VmTemplate.propTypes = {
id: PropTypes.string.isRequired,
Copy link
Contributor

Choose a reason for hiding this comment

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

self property ?

const getHost = createGetObject()
return {
host: getHost,
pool: createGetObject(createSelector(getHost, host => host.$pool)),
Copy link
Contributor

Choose a reason for hiding this comment

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

host can be undefined.

// ===================================================================

export const Sr = decorate([
connectStore(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

  connectStore(() => {
    const getSr = (state, props) => createGetObject()(state, props, props.self)
    return {
      sr: getSr,
      container: createGetObject(
        createSelector(
          getSr,
          (sr = {}) => sr.$container
        )
      ),
    }
  })

Copy link
Member Author

Choose a reason for hiding this comment

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

(state, props) => createGetObject()(state, props, props.self) would create a new selector (thus invalidate the cache) on each call.

RemoteItem.propTypes = XO_ITEM_PROP_TYPES
Sr.propTypes = {
id: PropTypes.string.isRequired,
link: PropTypes.bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

self ?

const getObject = createGetObject()
// FIXME: props.self ugly workaround to get object as a self user
return (state, props) => ({
vdi: getObject(state, props, props.self),
Copy link
Contributor

Choose a reason for hiding this comment

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

You can make it inline.

Copy link
Member Author

Choose a reason for hiding this comment

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

You mean inline getObject? We want to use the same selector for all the component's lifetime.

Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, you're right, we don't want create a function on each call.

return (state, props) => ({
// true to bypass permissions as a self user
sr: getSr(state, props, true),
network: getObject(state, props, props.self),
Copy link
Contributor

Choose a reason for hiding this comment

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

same here.

@pdonias pdonias requested a review from badrAZ December 3, 2018 09:43
const getObject = createGetObject()
// FIXME: props.self ugly workaround to get object as a self user
return (state, props) => ({
vdi: getObject(state, props, props.self),
Copy link
Contributor

Choose a reason for hiding this comment

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

My bad, you're right, we don't want create a function on each call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants