-
Notifications
You must be signed in to change notification settings - Fork 56
Add Settings intents to Admin intents API docs #3955
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6d9e6c7
Add Settings intents to Admin intents API docs
adambarrus 8cb4a35
Add JS example tabs for Settings intents and simplify descriptions
adambarrus f6e33d0
Add Location intents to Admin intents API docs
adambarrus dd9be3a
Use generic "Settings updated" message in settings intent examples
adambarrus 4bbd207
Fix lint error in intents.doc.ts description
adambarrus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
packages/ui-extensions/src/surfaces/admin/api/intents/examples/create-location.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const {intents} = useApi(TARGET); | ||
|
|
||
| const activity = await intents.invoke('create:shopify/Location'); | ||
|
|
||
| const response = await activity.complete; | ||
|
|
||
| if (response.code === 'ok') { | ||
| console.log('Location created:', response.data); | ||
| } |
35 changes: 35 additions & 0 deletions
35
packages/ui-extensions/src/surfaces/admin/api/intents/examples/create-location.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import {render} from 'preact'; | ||
| import {useState} from 'preact/hooks'; | ||
|
|
||
| export default async () => { | ||
| render(<Extension />, document.body); | ||
| }; | ||
|
|
||
| function Extension() { | ||
| const [result, setResult] = useState(null); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| const handleAction = async () => { | ||
| setLoading(true); | ||
|
|
||
| const activity = await shopify.intents.invoke('create:shopify/Location'); | ||
| const response = await activity.complete; | ||
|
|
||
| setResult(response); | ||
| setLoading(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <s-admin-block heading="Create Location"> | ||
| <s-button onClick={handleAction} disabled={loading}> | ||
| {loading ? 'Creating...' : 'Launch Location Creator'} | ||
| </s-button> | ||
| {result?.code === 'ok' && ( | ||
| <s-banner status="success">Location created successfully!</s-banner> | ||
| )} | ||
| {result?.code === 'closed' && ( | ||
| <s-text>Creation cancelled</s-text> | ||
| )} | ||
| </s-admin-block> | ||
| ); | ||
| } |
9 changes: 9 additions & 0 deletions
9
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-location-default.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const {intents} = useApi(TARGET); | ||
|
|
||
| const activity = await intents.invoke('edit:settings/LocationDefault'); | ||
|
|
||
| const response = await activity.complete; | ||
|
|
||
| if (response.code === 'ok') { | ||
| console.log('Settings updated:', response.data); | ||
| } |
35 changes: 35 additions & 0 deletions
35
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-location-default.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import {render} from 'preact'; | ||
| import {useState} from 'preact/hooks'; | ||
|
|
||
| export default async () => { | ||
| render(<Extension />, document.body); | ||
| }; | ||
|
|
||
| function Extension() { | ||
| const [result, setResult] = useState(null); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| const handleAction = async () => { | ||
| setLoading(true); | ||
|
|
||
| const activity = await shopify.intents.invoke('edit:settings/LocationDefault'); | ||
| const response = await activity.complete; | ||
|
|
||
| setResult(response); | ||
| setLoading(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <s-admin-block heading="Edit Default Location"> | ||
| <s-button onClick={handleAction} disabled={loading}> | ||
| {loading ? 'Editing...' : 'Launch Default Location Editor'} | ||
| </s-button> | ||
| {result?.code === 'ok' && ( | ||
| <s-banner status="success">Settings updated</s-banner> | ||
| )} | ||
| {result?.code === 'closed' && ( | ||
| <s-text>Edit default location cancelled</s-text> | ||
| )} | ||
| </s-admin-block> | ||
| ); | ||
| } |
11 changes: 11 additions & 0 deletions
11
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-location.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| const {intents} = useApi(TARGET); | ||
|
|
||
| const activity = await intents.invoke('edit:shopify/Location', { | ||
| value: 'gid://shopify/Location/123456789', | ||
| }); | ||
|
|
||
| const response = await activity.complete; | ||
|
|
||
| if (response.code === 'ok') { | ||
| console.log('Location updated:', response.data); | ||
| } |
41 changes: 41 additions & 0 deletions
41
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-location.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import {render} from 'preact'; | ||
| import {useState} from 'preact/hooks'; | ||
|
|
||
| export default async () => { | ||
| render(<Extension />, document.body); | ||
| }; | ||
|
|
||
| function Extension() { | ||
| const {data} = shopify; | ||
| const [result, setResult] = useState(null); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| const resourceId = data.selected[0]?.id || 'gid://shopify/Location/123456789'; | ||
|
|
||
| const handleAction = async () => { | ||
| setLoading(true); | ||
|
|
||
| const activity = await shopify.intents.invoke('edit:shopify/Location', { | ||
| value: resourceId, | ||
| }); | ||
|
|
||
| const response = await activity.complete; | ||
| setResult(response); | ||
| setLoading(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <s-admin-block heading="Edit Location"> | ||
| <s-text>Editing: {resourceId}</s-text> | ||
| <s-button onClick={handleAction} disabled={loading}> | ||
| {loading ? 'Opening...' : 'Edit Location'} | ||
| </s-button> | ||
| {result?.code === 'ok' && ( | ||
| <s-banner status="success">Location updated!</s-banner> | ||
| )} | ||
| {result?.code === 'closed' && ( | ||
| <s-text>Edit cancelled</s-text> | ||
| )} | ||
| </s-admin-block> | ||
| ); | ||
| } |
9 changes: 9 additions & 0 deletions
9
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-order-id-format.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const { intents } = useApi(TARGET); | ||
|
|
||
| const activity = await intents.invoke('edit:settings/OrderIdFormat'); | ||
|
|
||
| const response = await activity.complete; | ||
|
|
||
| if (response.code === 'ok') { | ||
| console.log('Settings updated:', response.data); | ||
| } |
35 changes: 35 additions & 0 deletions
35
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-order-id-format.jsx
|
adambarrus marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { render } from 'preact'; | ||
| import { useState } from 'preact/hooks'; | ||
|
|
||
| export default async () => { | ||
| render(<Extension />, document.body); | ||
| }; | ||
|
|
||
| function Extension() { | ||
| const [result, setResult] = useState(null); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| const handleAction = async () => { | ||
| setLoading(true); | ||
|
|
||
| const activity = await shopify.intents.invoke('edit:settings/OrderIdFormat'); | ||
| const response = await activity.complete; | ||
|
|
||
| setResult(response); | ||
| setLoading(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <s-admin-block heading="Edit Order ID Format"> | ||
| <s-button onClick={handleAction} disabled={loading}> | ||
| {loading ? 'Editing...' : 'Launch Order ID Format Editor'} | ||
| </s-button> | ||
| {result?.code === 'ok' && ( | ||
| <s-banner status="success">Settings updated</s-banner> | ||
| )} | ||
| {result?.code === 'closed' && ( | ||
| <s-text>Edit order ID format cancelled</s-text> | ||
| )} | ||
| </s-admin-block> | ||
| ); | ||
| } |
9 changes: 9 additions & 0 deletions
9
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-order-processing.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const { intents } = useApi(TARGET); | ||
|
|
||
| const activity = await intents.invoke('edit:settings/OrderProcessing'); | ||
|
|
||
| const response = await activity.complete; | ||
|
|
||
| if (response.code === 'ok') { | ||
| console.log('Settings updated:', response.data); | ||
| } |
35 changes: 35 additions & 0 deletions
35
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-order-processing.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { render } from 'preact'; | ||
| import { useState } from 'preact/hooks'; | ||
|
|
||
| export default async () => { | ||
| render(<Extension />, document.body); | ||
| }; | ||
|
|
||
| function Extension() { | ||
| const [result, setResult] = useState(null); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| const handleAction = async () => { | ||
| setLoading(true); | ||
|
|
||
| const activity = await shopify.intents.invoke('edit:settings/OrderProcessing'); | ||
| const response = await activity.complete; | ||
|
|
||
| setResult(response); | ||
| setLoading(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <s-admin-block heading="Edit Order Processing"> | ||
| <s-button onClick={handleAction} disabled={loading}> | ||
| {loading ? 'Editing...' : 'Launch Order Processing Editor'} | ||
| </s-button> | ||
| {result?.code === 'ok' && ( | ||
| <s-banner status="success">Settings updated</s-banner> | ||
| )} | ||
| {result?.code === 'closed' && ( | ||
| <s-text>Edit order processing cancelled</s-text> | ||
| )} | ||
| </s-admin-block> | ||
| ); | ||
| } |
9 changes: 9 additions & 0 deletions
9
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-store-defaults.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const { intents } = useApi(TARGET); | ||
|
|
||
| const activity = await intents.invoke('edit:settings/StoreDefaults'); | ||
|
|
||
| const response = await activity.complete; | ||
|
|
||
| if (response.code === 'ok') { | ||
| console.log('Store defaults updated:', response.data); | ||
| } |
35 changes: 35 additions & 0 deletions
35
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-store-defaults.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import { render } from 'preact'; | ||
| import { useState } from 'preact/hooks'; | ||
|
|
||
| export default async () => { | ||
| render(<Extension />, document.body); | ||
| }; | ||
|
|
||
| function Extension() { | ||
| const [result, setResult] = useState(null); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| const handleAction = async () => { | ||
| setLoading(true); | ||
|
|
||
| const activity = await shopify.intents.invoke('edit:settings/StoreDetails'); | ||
| const response = await activity.complete; | ||
|
|
||
| setResult(response); | ||
| setLoading(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <s-admin-block heading="Edit Store Details"> | ||
| <s-button onClick={handleAction} disabled={loading}> | ||
| {loading ? 'Editing...' : 'Launch Store Details Editor'} | ||
| </s-button> | ||
| {result?.code === 'ok' && ( | ||
| <s-banner status="success">Store details updated successfully!</s-banner> | ||
| )} | ||
| {result?.code === 'closed' && ( | ||
| <s-text>Edit store details cancelled</s-text> | ||
| )} | ||
| </s-admin-block> | ||
| ); | ||
| } |
9 changes: 9 additions & 0 deletions
9
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-store-details.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| const { intents } = useApi(TARGET); | ||
|
|
||
| const activity = await intents.invoke('edit:settings/StoreDetails'); | ||
|
|
||
| const response = await activity.complete; | ||
|
|
||
| if (response.code === 'ok') { | ||
| console.log('Store details updated:', response.data); | ||
| } |
37 changes: 37 additions & 0 deletions
37
packages/ui-extensions/src/surfaces/admin/api/intents/examples/edit-store-details.jsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import { render } from 'preact'; | ||
| import { useState } from 'preact/hooks'; | ||
|
|
||
| export default async () => { | ||
| render(<Extension />, document.body); | ||
| }; | ||
|
|
||
| function Extension() { | ||
| const [result, setResult] = useState(null); | ||
| const [loading, setLoading] = useState(false); | ||
|
|
||
| const handleAction = async () => { | ||
| setLoading(true); | ||
|
|
||
| const activity = await shopify.intents.invoke('edit:settings/StoreDetails'); | ||
| const response = await activity.complete; | ||
|
|
||
| setResult(response); | ||
| setLoading(false); | ||
| }; | ||
|
|
||
| return ( | ||
| <s-admin-block heading="Edit Store Details"> | ||
| <s-button onClick={handleAction} disabled={loading}> | ||
| {loading ? 'Editing...' : 'Launch Store Details Editor'} | ||
| </s-button> | ||
| {result?.code === 'ok' && ( | ||
| <s-banner status="success"> | ||
| Store details updated successfully! | ||
| </s-banner> | ||
| )} | ||
| {result?.code === 'closed' && ( | ||
| <s-text>Edit store details cancelled</s-text> | ||
| )} | ||
| </s-admin-block> | ||
| ); | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.