Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-masks-joke.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/app': patch
---

Remove redundant Admin print action extension uniqueness validator
45 changes: 0 additions & 45 deletions packages/app/src/cli/models/app/loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,51 +509,6 @@ wrong = "property"
await expect(loadTestingApp()).rejects.toThrow(/Duplicated handle/)
})

test('throws an error if the app has more than one print action with the same target', async () => {
// Given
await writeConfig(appConfiguration)

const blockConfiguration = `
api_version = "2022-07"

[[extensions]]
type = "ui_extension"
name = "my_extension_1"
handle = "handle-1"
description = "custom description"

[[extensions.targeting]]
module = "./src/ActionExtension.js"
target = "admin.product-details.print-action.render"

[[extensions]]
type = "ui_extension"
handle = "handle-2"
name = "my_extension_2"
description = "custom description"

[[extensions.targeting]]
module = "./src/ActionExtension.js"
target = "admin.product-details.print-action.render"
`
await writeBlockConfig({
blockConfiguration,
name: 'my_extension_1',
})

// Create a temporary ActionExtension.js file
const extensionDirectory = joinPath(tmpDir, 'extensions', 'my_extension_1', 'src')
await mkdir(extensionDirectory)

const tempFilePath = joinPath(extensionDirectory, 'ActionExtension.js')
await writeFile(tempFilePath, '/* ActionExtension.js content */')

// When
await expect(loadTestingApp()).rejects.toThrow(
`A single target can't support two print action extensions from the same app. Point your extensions at different targets, or remove an extension.\n\nThe following extensions both target admin.product-details.print-action.render:\n · handle-1\n · handle-2`,
)
})

test('throws an error if the extension configuration is unified and doesnt include a handle', async () => {
// Given
await writeConfig(appConfiguration, {
Expand Down
37 changes: 0 additions & 37 deletions packages/app/src/cli/models/app/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {findConfigFiles} from '../../prompts/config.js'
import {WebhookSubscriptionSpecIdentifier} from '../extensions/specifications/app_config_webhook_subscription.js'
import {WebhooksSchema} from '../extensions/specifications/app_config_webhook_schemas/webhooks_schema.js'
import {loadLocalExtensionsSpecifications} from '../extensions/load-specifications.js'
import {UIExtensionSchemaType} from '../extensions/specifications/ui_extension.js'
import {patchAppHiddenConfigFile} from '../../services/app/patch-app-configuration-file.js'
import {getOrCreateAppConfigHiddenPath} from '../../utilities/app/config/hidden-app-config.js'
import {ApplicationURLs, generateApplicationURLs} from '../../services/dev/urls.js'
Expand Down Expand Up @@ -545,10 +544,6 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS
}
})

// Temporary code to validate that there is a single print action extension per target in an app.
// Should be replaced by core validation.
this.validatePrintActionExtensionsUniqueness(allExtensions)

return allExtensions
}

Expand Down Expand Up @@ -745,31 +740,6 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS
}
}

private validatePrintActionExtensionsUniqueness(allExtensions: ExtensionInstance[]) {
const duplicates: {[key: string]: ExtensionInstance[]} = {}

allExtensions
.filter((ext) => ext.type === 'ui_extension')
.forEach((extension) => {
const points = extension.configuration.extension_points as UIExtensionSchemaType['extension_points']
const targets = points.flatMap((point) => point.target).filter((target) => printTargets.includes(target))
targets.forEach((target) => {
const targetExtensions = duplicates[target] ?? []
targetExtensions.push(extension)
duplicates[target] = targetExtensions

if (targetExtensions.length > 1) {
const extensionHandles = ['', ...targetExtensions.map((ext) => ext.configuration.handle)].join('\n · ')
this.abortOrReport(
outputContent`A single target can't support two print action extensions from the same app. Point your extensions at different targets, or remove an extension.\n\nThe following extensions both target ${target}:${extensionHandles}`,
undefined,
extension.configurationPath,
)
}
})
})
}

private getDevApplicationURLs(currentConfiguration: TConfig, webs: Web[]): ApplicationURLs | undefined {
const previousDevUrls = this.previousApp?.devApplicationURLs
if (!previousDevUrls || !isCurrentAppSchema(currentConfiguration)) return previousDevUrls
Expand Down Expand Up @@ -1320,10 +1290,3 @@ export function isValidFormatAppConfigurationFileName(configName: string): confi
}
return false
}

const printTargets = [
'admin.order-details.print-action.render',
'admin.order-index.selection-print-action.render',
'admin.product-details.print-action.render',
'admin.product-index.selection-print-action.render',
]
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ export interface BuildManifest {

const missingExtensionPointsMessage = 'No extension targets defined, add a `targeting` field to your configuration'

export type UIExtensionSchemaType = zod.infer<typeof UIExtensionSchema>

export const UIExtensionSchema = BaseSchema.extend({
name: zod.string(),
type: zod.literal('ui_extension'),
Expand Down