winglang / wing

A programming language for the cloud ☁️ A unified programming model, combining infrastructure and runtime code into one language ⚡
https://winglang.io
Other
5.06k stars 198 forks source link

feat(console): resources can inherit UI components of children #7123

Closed Chriscbr closed 1 month ago

Chriscbr commented 2 months ago

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

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

github-actions[bot] commented 2 months ago

Thanks for opening this pull request! :tada: 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 commented 2 months ago

Working on adding docs...

monadabot commented 2 months ago

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

Last Updated (UTC) 2024-09-13 18:37
monadabot commented 2 months ago

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 commented 2 months ago

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

github-actions[bot] commented 1 month ago

Hi,

This PR has not seen activity in 20 days. Therefore, we are marking the PR as stale for now. It will be closed after 7 days. If you need help with the PR, do not hesitate to reach out in the winglang community Discord. Feel free to re-open this PR when it is still relevant and ready to be worked on again. Thanks!