Skip to content

Commit

Permalink
Merge pull request #5041 from Shopify/1836-use-name-as-text
Browse files Browse the repository at this point in the history
Use name as link text insted of text property
  • Loading branch information
cameronbarker authored Dec 6, 2024
2 parents 2711cc2 + a077c93 commit 8335447
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
20 changes: 8 additions & 12 deletions packages/app/src/cli/services/admin-link/extension-to-toml.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('extension-to-toml', () => {
type: 'app_link',
draftVersion: {
context: 'COLLECTIONS#SHOW',
config: '{"text":"admin link label","url":"https://google.es"}',
config: '{"text":"Admin link label","url":"https://google.es"}',
},
}

Expand All @@ -30,11 +30,10 @@ describe('extension-to-toml', () => {
// Then
expect(got).toEqual(`[[extensions]]
type = "admin_link"
name = "Admin link title"
name = "Admin link label"
handle = "admin-link-title"
[[extensions.targeting]]
text = "admin link label"
url = "https://google.es"
target = "admin.collection-details.action.link"
`)
Expand All @@ -56,7 +55,7 @@ handle = "admin-link-title"
type: 'bulk_action',
draftVersion: {
context: 'PRODUCTS#ACTION',
config: '{"text":"bulk action label","url":"https://google.es/action/product?product_id=123#hash"}',
config: '{"text":"Bulk action label","url":"https://google.es/action/product?product_id=123#hash"}',
},
}

Expand All @@ -66,11 +65,10 @@ handle = "admin-link-title"
// Then
expect(got).toEqual(`[[extensions]]
type = "admin_link"
name = "Bulk action title"
name = "Bulk action label"
handle = "bulk-action-title"
[[extensions.targeting]]
text = "bulk action label"
url = "app://action/product?product_id=123#hash"
target = "admin.product-index.selection-action.link"
`)
Expand All @@ -91,7 +89,7 @@ handle = "bulk-action-title"
type: 'bulk_action',
draftVersion: {
context: 'PRODUCTS#ACTION',
config: '{"text":"bulk action label","url":"https://google.es/"}',
config: '{"text":"Bulk action label","url":"https://google.es/"}',
},
}

Expand All @@ -101,11 +99,10 @@ handle = "bulk-action-title"
// Then
expect(got).toEqual(`[[extensions]]
type = "admin_link"
name = "Bulk action title"
name = "Bulk action label"
handle = "bulk-action-title"
[[extensions.targeting]]
text = "bulk action label"
url = "app://"
target = "admin.product-index.selection-action.link"
`)
Expand All @@ -126,7 +123,7 @@ handle = "bulk-action-title"
type: 'bulk_action',
draftVersion: {
context: 'PRODUCTS#ACTION',
config: '{"text":"bulk action label","url":"https://google.es?foo=bar"}',
config: '{"text":"Bulk action label","url":"https://google.es?foo=bar"}',
},
}

Expand All @@ -136,11 +133,10 @@ handle = "bulk-action-title"
// Then
expect(got).toEqual(`[[extensions]]
type = "admin_link"
name = "Bulk action title"
name = "Bulk action label"
handle = "bulk-action-title"
[[extensions.targeting]]
text = "bulk action label"
url = "app://?foo=bar"
target = "admin.product-index.selection-action.link"
`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ export function buildTomlObject(
extensions: [
{
type: 'admin_link',
name: extension.title,
name: config.text,
handle: slugify(extension.title.substring(0, MAX_EXTENSION_HANDLE_LENGTH)),
targeting: [
{
text: config.text,
url: config.url,
target: contextToTarget(context),
},
Expand Down

0 comments on commit 8335447

Please sign in to comment.