Skip to content

Commit

Permalink
fix: can't modify display attributes of non-wing constructs (#6641)
Browse files Browse the repository at this point in the history
Fixes #6629 

## Checklist

- [ ] Title matches [Winglang's style guide](https://www.winglang.io/contributing/start-here/pull_requests#how-are-pull-request-titles-formatted)
- [ ] 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](https://github.com/winglang/wing/blob/main/CONTRIBUTION_LICENSE.md)*.
  • Loading branch information
eladcon authored Jun 5, 2024
1 parent fb0d00e commit 97dac4b
Show file tree
Hide file tree
Showing 39 changed files with 1,362 additions and 10 deletions.
3 changes: 2 additions & 1 deletion examples/tests/valid/bring_cdktf.test.w
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
bring "@cdktf/provider-aws" as aws;
bring "cdktf" as cdktf;

new aws.s3Bucket.S3Bucket(
let bucket = new aws.s3Bucket.S3Bucket(
bucketPrefix: "hello",
versioning: {
enabled: true,
mfaDelete: true,
},
) as "Bucket";
nodeof(bucket).color = "pink";

class Foo {
new() {
Expand Down
9 changes: 1 addition & 8 deletions libs/wingsdk/src/core/tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as fs from "fs";
import * as path from "path";
import { IConstruct } from "constructs";
import { App } from "./app";
import { IResource, Node, Resource } from "../std";
import { Node } from "../std";
import { VisualComponent } from "../ui/base";
import { Colors, isOfTypeColors } from "../ui/colors";

Expand Down Expand Up @@ -220,14 +220,7 @@ export function synthesizeTree(app: App, outdir: string) {
);
}

function isIResource(construct: IConstruct): construct is IResource {
return construct instanceof Resource;
}

function synthDisplay(construct: IConstruct): DisplayInfo | undefined {
if (!isIResource(construct)) {
return;
}
const display = Node.of(construct);

const ui: UIComponent[] = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports[`provides raw tree data 1`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down
16 changes: 16 additions & 0 deletions libs/wingsdk/test/target-sim/__snapshots__/api.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -645,6 +646,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -970,6 +972,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -1296,6 +1299,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -1622,6 +1626,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -1948,6 +1953,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -2417,6 +2423,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -2759,6 +2766,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -3093,6 +3101,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -3422,6 +3431,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -3875,6 +3885,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -4330,6 +4341,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -4655,6 +4667,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -4989,6 +5002,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -5315,6 +5329,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -5494,6 +5509,7 @@ exports[`create an api 1`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ exports[`can add file in preflight 2`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -390,6 +391,7 @@ exports[`can add object in preflight 2`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -545,6 +547,7 @@ exports[`create a bucket 1`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -710,6 +713,7 @@ exports[`get invalid object throws an error 2`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ exports[`create a counter 1`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -499,6 +500,7 @@ exports[`dec 2`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -758,6 +760,7 @@ exports[`inc 2`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -1017,6 +1020,7 @@ exports[`key dec 2`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -1276,6 +1280,7 @@ exports[`key inc 2`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -1533,6 +1538,7 @@ exports[`key set to new value 2`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -1790,6 +1796,7 @@ exports[`set to new value 2`] = `
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,7 @@ bucket: (function() {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "HelloWorld",
"path": "root/HelloWorld",
},
Expand All @@ -546,6 +547,7 @@ bucket: (function() {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -328,6 +329,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -499,6 +501,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -672,6 +675,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -833,6 +837,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down Expand Up @@ -1124,6 +1129,7 @@ exports.handler = async function(event) {
"fqn": "constructs.Construct",
"version": "10.3.0",
},
"display": {},
"id": "root",
"path": "root",
},
Expand Down
Loading

0 comments on commit 97dac4b

Please sign in to comment.