-
Notifications
You must be signed in to change notification settings - Fork 154
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
Update ui_extension to support Unified config #2349
Conversation
Thanks for your contribution! Depending on what you are working on, you may want to request a review from a Shopify team:
|
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lemonmade @davejcameron Should we support inheriting metafields and settings from the global?
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
Coverage report
Show files with reduced coverage 🔻
Test suite run success1297 tests passing in 637 suites. Report generated by 🧪jest coverage report action from cadea7a |
@vividviolet I think it would be nice to allow |
@lemonmade I just realize that there would be 3 levels of inheritance for Metafields for UI Extensions if we support setting it at the global, extension and extension.targetting level. Is that too confusing? |
I would definitely be fine with just having it inherit from |
Ok, I thought Function had @isaacroldan I think in summary these are all the fields that should be present, some of which need to be inherited either from the top-level or the extension-level. api_version = "2023-04"
name = "Google maps validation"
description = "Validates location on Google maps"
[[extensions]]
handle = "google-maps-function"
type = "function"
# inherits top-level global api_version if not set
# inherits top-level global name if not set
# inherits top-level global description if not set
[extensions.build]
command = "cargo wasi build --release"
path = "google-maps-function/dist/function.wasm"
[[extensions.targeting]]
export = "fetch"
input_query = "google-maps-function/fetch.input.graphql"
target = "purchase.validation.fetch"
[[extensions.targeting]]
export = "validate"
input_query = "google-maps-function/fetch.validate.graphql" target = "purchase.validation.validate"
[[extensions]]
handle = "google-maps-ui"
type = "ui-extension"
# inherits top-level global api_version if not set
# inherits top-level global name if not set
# inherits top-level global description if not set
[[extensions.metafields]]
namespace = "my-namespace"
key = "my-key"
[[extensions.targeting]]
module = "google-maps-ui/settings.jsx"
target = "purchase.validation.render-settings"
# inherits extension-level metafields if not set |
packages/app/src/cli/models/extensions/specifications/ui_extension.ts
Outdated
Show resolved
Hide resolved
Updated! The If using All other top-level fields are flattened and included in the config of each extension in the array when parsing it. (name, description, api_version...) I'll update the tests later today |
We detected some changes at either packages/*/src or packages/cli-kit/assets/cli-ruby/** and there are no updates in the .changeset. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing the extension point metafields unexpectedly overriding the extension level one. I tested this config
name = "action-extension"
api_version = "unstable"
[[extensions]]
type = "ui_extension"
[[metafields]]
namespace = "my-namespace"
key = "my-key"
[[metafields]]
namespace = "my-namespace"
key = "my-other-key"
[[extensions.targeting]]
target = "admin.product.item.block"
module = "./index.jsx"
[[extensions.targeting]]
target = "admin.product.index.action"
module = "./index.jsx"
[[extensions.metafields]]
namespace = "my-specific-namespace"
key = "my-specific-key"
I'm seeing this payload in the Dev Server
{
"extensions": [
{
"extensionPoints": [
{
"target": "admin.product.item.block",
"module": "./index.jsx",
"metafields": [
{
"namespace": "my-specific-namespace",
"key": "my-specific-key"
}
],
},
{
"target": "admin.product.index.action",
"module": "./index.jsx",
"metafields": [
{
"namespace": "my-specific-namespace",
"key": "my-specific-key"
}
],
}
],
"metafields": [
{
"namespace": "my-specific-namespace",
"key": "my-specific-key"
}
],
"type": "ui_extension",
"externalType": "ui_extension",
"uuid": "dev-4159f8c6-a95b-48e4-9102-d76d1933a392",
"surface": "all",
"title": "action-extension",
"apiVersion": "unstable",
"approvalScopes": []
},
]
},
}
This is what I would expect:
{
"extensions": [
{
"extensionPoints": [
{
"target": "admin.product.item.block",
"module": "./index.jsx",
"metafields": [
{
"namespace": "my-namespace",
"key": "my-key"
},
{
"namespace": "my-specific-namespace",
"key": "my-other-key"
}
],
},
{
"target": "admin.product.index.action",
"module": "./index.jsx",
"metafields": [
{
"namespace": "my-specific-namespace",
"key": "my-specific-key"
}
],
}
],
"metafields": [
{
"namespace": "my-namespace",
"key": "my-key"
},
{
"namespace": "my-namespace",
"key": "my-other-key"
}
],
"type": "ui_extension",
"externalType": "ui_extension",
"uuid": "dev-4159f8c6-a95b-48e4-9102-d76d1933a392",
"surface": "all",
"title": "action-extension",
"apiVersion": "unstable",
"approvalScopes": []
},
]
},
}
api_version: '2023-01' as const, | ||
name: 'UI Extension', | ||
type: 'ui_extension', | ||
metafields: [{namespace: 'test', key: 'test'}], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make sure that this stripped out of the payload when deploying/dev? We don't actually support this config at the extension level in the backend or front end. It's only supported in the TOML for convenience
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not included in the deployConfig for sure, not sure about how we build the dev
payload, but I didn't change that 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I will take care of that on the PR I'm working on to update the dev
payload to get rid of label
on extension points
api_version = "2022-10" | ||
|
||
[capabilities] | ||
api_access = true | ||
network_access = true | ||
block_progress = true | ||
|
||
[[extension_points]] | ||
target = "Checkout::Dynamic::Render" | ||
[[extensions]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just delete this template. We should be creating a new version of the Checkout extension in the template repo and expose it through Partner's instead of having it be tied to the CLI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it safe If I remove it in this PR then?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so? No one should be using this publicly for Checkout but we better ask @jamesvidler and @kumar303. They should be working on a new template soon for Checkout.
Bundles is using it but @kmdavis is working on a new template. We just need to merge the new template before the next release of the CLI goes out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No one is using this template publicly, yet. Though we have used to test things. Where would the new template be stored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd put it here and then update Partner's to make it available: https://github.com/Shopify/partners/blob/master/app/operations/apps/templates/specifications/v304600.rb
I think the config you posted is wrong @vividviolet, you are defining top-level metafields and extension-level metafields, but no target-level metafields. What happens is that extension-level override top-level, we can discuss if this is correct or they should be merged.
Does this make sense? let's discuss offline if not :) |
@isaacroldan you're correct, I got the TOML wrong. Using this works as expected name = "action-extension"
api_version = "internal"
[[extensions]]
type = "ui_extension"
[[extensions.metafields]]
namespace = "my-namespace"
key = "my-key"
[[extensions.metafields]]
namespace = "my-namespace"
key = "my-other-key"
[extensions.capabilities]
network_access = true
block_progress = true
api_access = true
[extensions.settings]
[[settings.fields]]
key = "field_key"
type = "boolean"
name = "field-name"
[[settings.fields]]
key = "field_key_2"
type = "number_integer"
name = "field-name-2"
[[extensions.targeting]]
target = "admin.product.item.block"
module = "./index.jsx"
[[extensions.targeting]]
target = "admin.product.index.action"
module = "./index.jsx"
[[extensions.targeting.metafields]]
namespace = "my-specific-namespace"
key = "my-specific-key" I think the only thing left to do is to drop support for setting the metafields at the top-level as this is a ui-extension concept only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tophat'd both dev
and deploy
- everything works as expected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tophatted this by generating a new extension with an app I already had in spin (and an existing extension) and it generated the new extension with the new config just fine.
I was also able to run pnpm shopify app dev
and see the extension render. 👍
What is strange though is that the other extension I have appears to be excluded now and ignored. Any idea what might be going on there? It's entirely possible the app structure is out of date, as I did not generate a new app.
This is the branch of the app I was using to test.
@jamesvidler Looks like your old extension is missing the |
Confirmed this was the issue I ran into. Adding the type in the "old config" made it work again. |
@isaacroldan @jamesvidler I'm good with remove the fallback for setting the |
WHY are these changes introduced?
Adds support for the new UI Extensions schema with the
targeting
field.WHAT is this pull request doing?
ui_extension
schema to support bothextension_instance
andtargeting
.extension_instance
ui_extension
template to follow unified configHow to test your changes?
ui_extension
(it'll have the old format)app info
should load both extensions without problems.Post-release steps
Measuring impact
How do we know this change was effective? Please choose one:
Checklist
dev
ordeploy
have been reflected in the internal flowchart.