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(console): resources can inherit UI components of children #7123

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Chriscbr
Copy link
Contributor

Closes #7110

As a proposed solution to #7110, this change makes it possible for a parent resource to inherit the UI of one of its children. A child can be configured as the "default" by giving it the ID of "Default" or "Resource"...

pub class SpaceTable {
  table: dynamodb.Table;
  new() {
    this.table = new dynamodb.Table(
      attributes: [
        { name: "PK", type: "S" },
        { name: "SK", type: "S" },
      ],
      name: "SpacesTable",
      hashKey: "PK",
      rangeKey: "SK",
      timeToLiveAttribute: "expiresAt",
    ) as "Default"; // <--- set the id
  }
}

... or by explicitly setting setting the defaultChild on the resource's internal Node:

pub class SpaceTable {
  table: dynamodb.Table;
  new() {
    this.table = new dynamodb.Table(
      attributes: [
        { name: "PK", type: "S" },
        { name: "SK", type: "S" },
      ],
      name: "SpacesTable",
      hashKey: "PK",
      rangeKey: "SK",
      timeToLiveAttribute: "expiresAt",
    );
    nodeof(this).defaultChild = this.table; // <-- set the default child
  }
}

Checklist

  • Title matches Winglang's style guide
  • Description explains motivation and solution
  • Tests added (always)
  • Docs updated (only required for features)
  • Added pr/e2e-full label if this feature requires end-to-end testing

By submitting this pull request, I confirm that my contribution is made under the terms of the Wing Cloud Contribution License.

@Chriscbr Chriscbr requested a review from a team as a code owner September 13, 2024 18:29
Copy link

Thanks for opening this pull request! 🎉
Please consult the contributing guidelines for details on how to contribute to this project.
If you need any assistance, don't hesitate to ping the relevant owner over Discord.

Topic Owner
Wing SDK and standard library @chriscbr
Wing Console @skyrpex
Wing compiler and language design @chriscbr
VSCode extension and language server @chriscbr
Wing CLI @chriscbr
Documentation @boyney123
Examples @boyney123
Wing Playground @skyrpex

@Chriscbr
Copy link
Contributor Author

Working on adding docs...

Copy link
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

TBH I think this is something that should be handled in the Wing Console. I would keep it simple and basically just hoist all interaction panes of children onto their parents without much configuration.

At least as an initial step, I think it will address the use case with less friction.

@monadabot
Copy link
Contributor

Console preview environment is available at https://wing-console-pr-7123.fly.dev 🚀

Last Updated (UTC) 2024-09-13 18:37

@Chriscbr Chriscbr added the 🚧 pr/do-not-merge PRs with this label will not be automatically merged by mergify. label Sep 13, 2024
@monadabot
Copy link
Contributor

Benchmarks

Comparison to Baseline ⬜🟥⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜
Benchmark Before After Change
version 61ms±2.79 56ms±0.54 -5ms (-8.47%)⬜
functions_10.test.w -t sim 502ms±15.05 519ms±24.31 +17ms (+3.29%)🟥
functions_10.test.w -t tf-aws 2216ms±30.61 2181ms±14.35 -35ms (-1.58%)⬜
jsii_small.test.w -t sim 384ms±2.72 380ms±4.45 -4ms (-1.12%)⬜
jsii_small.test.w -t tf-aws 624ms±8.32 602ms±4.63 -21ms (-3.45%)⬜
functions_1.test.w -t sim 421ms±3.55 407ms±3.39 -14ms (-3.43%)⬜
functions_1.test.w -t tf-aws 860ms±6.75 838ms±5.58 -22ms (-2.6%)⬜
empty.test.w -t sim 379ms±4.29 369ms±3.73 -10ms (-2.65%)⬜
empty.test.w -t tf-aws 618ms±3.18 597ms±3.8 -21ms (-3.4%)⬜
hello_world.test.w -t sim 426ms±4.13 409ms±4.11 -17ms (-4.09%)⬜
hello_world.test.w -t tf-aws 1522ms±8.71 1487ms±6.93 -34ms (-2.26%)⬜
jsii_big.test.w -t sim 3014ms±13.28 2958ms±19.32 -56ms (-1.87%)⬜
jsii_big.test.w -t tf-aws 3242ms±16.61 3214ms±28.06 -29ms (-0.88%)⬜

⬜ Within 1.5 standard deviations
🟩 Faster, Above 1.5 standard deviations
🟥 Slower, Above 1.5 standard deviations

Benchmarks may vary outside of normal expectations, especially when running in GitHub Actions CI.

Results
name mean min max moe sd
version 56ms 55ms 57ms 1ms 1ms
functions_10.test.w -t sim 519ms 480ms 580ms 24ms 34ms
functions_10.test.w -t tf-aws 2181ms 2152ms 2208ms 14ms 20ms
jsii_small.test.w -t sim 380ms 368ms 387ms 4ms 6ms
jsii_small.test.w -t tf-aws 602ms 594ms 611ms 5ms 6ms
functions_1.test.w -t sim 407ms 397ms 413ms 3ms 5ms
functions_1.test.w -t tf-aws 838ms 822ms 850ms 6ms 8ms
empty.test.w -t sim 369ms 358ms 377ms 4ms 5ms
empty.test.w -t tf-aws 597ms 590ms 607ms 4ms 5ms
hello_world.test.w -t sim 409ms 399ms 417ms 4ms 6ms
hello_world.test.w -t tf-aws 1487ms 1469ms 1504ms 7ms 10ms
jsii_big.test.w -t sim 2958ms 2899ms 2983ms 19ms 27ms
jsii_big.test.w -t tf-aws 3214ms 3164ms 3278ms 28ms 39ms
Last Updated (UTC) 2024-09-13 18:43

@Chriscbr
Copy link
Contributor Author

I would keep it simple and basically just hoist all interaction panes of children onto their parents without much configuration.

Maybe only hoisting the interaction panes of children that aren't hidden? I think it's important we have some way for an application or library author to choose whether to "reveal" internal details like if they contain Redis caches or DynamoDB tables or S3 buckets inside.

I think I like your idea, simply hoisting stuff everything feels like a sane default

@Chriscbr Chriscbr marked this pull request as draft September 13, 2024 18:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🚧 pr/do-not-merge PRs with this label will not be automatically merged by mergify.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When using classes, show the resource tools in the console.
3 participants