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

Thoughts about LinkedElement #161

Closed
5 tasks done
zepumph opened this issue Apr 8, 2020 · 15 comments
Closed
5 tasks done

Thoughts about LinkedElement #161

zepumph opened this issue Apr 8, 2020 · 15 comments

Comments

@zepumph
Copy link
Member

zepumph commented Apr 8, 2020

From discussion with @pixelzoom and @arouinfar.

The chief complaint is that, since a linked element takes its phetioFeatured from the core element. This means that for certain changes when changing a model Property to be phetioFeatured and then committing the overrides. The overrides will then alter the baseline of linkedElements' phetioFeatured.

@zepumph zepumph self-assigned this Apr 8, 2020
@pixelzoom
Copy link
Contributor

pixelzoom commented Apr 8, 2020

To be clear about why this is high priority... The current state of things requires grunt update to be run when changing metadata in Studio. You can't simply change overrides.js, because you might have change an element that is linked to elsewhere. And designers are not set up to deal with grunt update.

@zepumph
Copy link
Member Author

zepumph commented Apr 8, 2020

I think that the easiest solution would be to omit phetioFeatured. Perhaps something like:

Index: js/PhetioObject.js
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- js/PhetioObject.js	(revision d382effd3ea79df74285669e9df685adeed4f38c)
+++ js/PhetioObject.js	(date 1586386551251)
@@ -646,6 +646,11 @@
 
     super( options );
 
+    if ( this.phetioBaselineMetadata ) {
+      assert && assert( this.phetioBaselineMetadata.hasOwnProperty( 'phetioFeatured' ) );
+      delete this.phetioBaselineMetadata.phetioFeatured;
+    }
+
     // @public (read-only)
     this.element = coreElement;
   }

zepumph added a commit to phetsims/balloons-and-static-electricity that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/energy-skate-park-basics that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/energy-forms-and-changes that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/gravity-force-lab-basics that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/forces-and-motion-basics that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/states-of-matter-basics that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/capacitor-lab-basics that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/resistance-in-a-wire that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/molecules-and-light that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/atomic-interactions that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/graphing-quadratics that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/charges-and-fields that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/blackbody-spectrum that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/gravity-and-orbits that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/gravity-force-lab that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/natural-selection that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/projectile-motion that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/energy-skate-park that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/states-of-matter that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/wave-on-a-string that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/john-travoltage that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/ph-scale-basics that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/gas-properties that referenced this issue Apr 16, 2020
zepumph added a commit to phetsims/concentration that referenced this issue Apr 16, 2020
@zepumph zepumph self-assigned this Jun 17, 2020
@zepumph
Copy link
Member Author

zepumph commented Jun 17, 2020

Today the phet-io team found an issue with LinkedElement.getMetadata as it pertains to declarative APIs in https://github.com/phetsims/phet-io/issues/1657. I don't think that they should be deleting phetioFeatured from the list, but instead, now that we no longer have baseline files or grunt update commands, we can likely get the phetioFeatured value from the coreElement again.

  • assigning to myself to implement.

@samreid
Copy link
Member

samreid commented Jun 23, 2020

I read through #161 (comment) and the mentioned commits and did not see any problems. However, since this issue we have eliminated baseline files and it seems like a good idea to run this past @zepumph to see if that changes how we proceed for this issue. Perhaps the preceding comment is part of that.

Also, reducing priority based on the comment in #161 (comment)

@zepumph
Copy link
Member Author

zepumph commented Aug 28, 2020

Most everything has been put into side issues, but I want to discuss #161 (comment) in person with @samreid before calling it a day on this issue.

@zepumph
Copy link
Member Author

zepumph commented Aug 28, 2020

@samreid and I think that it will be easiest to add this complexity to the Studio side. There we will make sure that overrides with match for the element and linked element.

  1. add back in phetioFeatured to LinkedElement
  2. assert that phetioFeatured is the same as the core (once both have overrides applied)
  3. Add logic to studio to make sure that metadata updated in one is updated in the other.

@zepumph
Copy link
Member Author

zepumph commented Aug 25, 2022

Over in phetsims/axon#408 (comment) we determined that we do NOT want LinkedElements to support API calls forwarding to their core elements.

@zepumph zepumph removed their assignment Mar 3, 2023
@samreid samreid self-assigned this Mar 27, 2023
@samreid
Copy link
Member

samreid commented Mar 27, 2023

We are improving the overrides process in https://github.com/phetsims/phet-io/issues/1873. That will eliminate problems listed above like:

This means that for certain changes when changing a model Property to be phetioFeatured and then committing the overrides. The overrides will then alter the baseline of linkedElements' phetioFeatured.

From the above:

add back in phetioFeatured to LinkedElement

That code looks like this:

  public constructor( coreElement: LinkableElement, providedOptions?: LinkedElementOptions ) {
    assert && assert( !!coreElement, 'coreElement should be defined' );

    const options = optionize<LinkedElementOptions, EmptySelfOptions, PhetioObjectOptions>()( {
      phetioType: LinkedElementIO,
      phetioState: true
    }, providedOptions );

    // References cannot be changed by PhET-iO
    assert && assert( !options.hasOwnProperty( 'phetioReadOnly' ), 'phetioReadOnly set by LinkedElement' );
    options.phetioReadOnly = true;

    // By default, this linked element's baseline value is the overridden value of the coreElement. This allows
    // the them to be in sync by default, but also allows the linked element to be overridden in studio.
    assert && assert( !options.hasOwnProperty( 'phetioFeatured' ), 'phetioFeatured set by LinkedElement' );
    options.phetioFeatured = coreElement.phetioFeatured;

assert that phetioFeatured is the same as the core (once both have overrides applied)

That is already set on the last line of the snippet above.

Add logic to studio to make sure that metadata updated in one is updated in the other.

As long as designers know that doesn't auto update, that seems OK, especially given our direction in https://github.com/phetsims/phet-io/issues/1873. Therefore I think this issue can be closed.

@samreid samreid closed this as completed Mar 27, 2023
@phet-dev phet-dev reopened this May 4, 2023
@phet-dev
Copy link
Contributor

phet-dev commented May 4, 2023

Reopening because there is a TODO marked for this issue.

@zepumph zepumph closed this as completed May 4, 2023
@zepumph
Copy link
Member Author

zepumph commented May 16, 2023

We forgot about #161 (comment), which we ran into over in https://github.com/phetsims/studio/issues/303. Reopening.

@zepumph
Copy link
Member Author

zepumph commented May 16, 2023

Alright. This is now back in the API files. Yay!

@zepumph zepumph closed this as completed May 16, 2023
@samreid samreid reopened this May 17, 2023
@samreid
Copy link
Member

samreid commented May 17, 2023

Reopening based on https://github.com/phetsims/studio/issues/303

@zepumph
Copy link
Member Author

zepumph commented May 18, 2023

From conversations yesterday, we are going to proceed with these commits. They are built into the RC of GO, so we will know if there is any trouble as we go into testing. Closing

@zepumph zepumph closed this as completed May 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants