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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swag/swag-extension-store",
"version": "4.1.1",
"version": "5.0.0",
"description": "SWAG Extension Store",
"type": "shopware-platform-plugin",
"license": "MIT",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,28 @@ export default {
template,

// we have to add the extensionStoreLicensesService for the checkout example
inject: ['extensionStoreChannelService'],
inject: [
'extensionStoreChannelService',
'systemConfigApiService',
],

data() {
return {

storeUrl: null,
};
},

created() {
async created() {
this.extensionStoreChannelService.register();

try {
// TODO: find other way to store the iframe URL
const config = await this.systemConfigApiService.getValues('SwagExtensionStore.config');

this.storeUrl = config['SwagExtensionStore.config.iframeUrl'];

} catch (e) {
// Fallback to default store URL if config fetch fails
}
},
};
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{% block sw_extension_store_index %}
<sw-iframe-renderer style="height: 100%;" src="http://localhost:3000" location-id="" />
<sw-iframe-renderer
style="height: 100%;"
:src="storeUrl"
location-id=""
/>
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,20 @@ Shopware.Component.register(
() => import('SwagExtensionStore/module/sw-extension-store/page/sw-extension-store-index'),
);

async function createWrapper(channelService = null) {
async function createWrapper(channelService = null, systemConfigService = null) {
if (channelService === null) {
channelService = {
register: jest.fn(),
};
}
if (systemConfigService === null) {
systemConfigService = {
getValues: jest.fn().mockResolvedValue({
'SwagExtensionStore.config.iframeUrl': 'https://store.shopware.com',
}),
};
}

return mount(await Shopware.Component.build('sw-extension-store-index'), {
props: {},
global: {
Expand All @@ -29,6 +37,7 @@ async function createWrapper(channelService = null) {
},
provide: {
extensionStoreChannelService: channelService,
systemConfigApiService: systemConfigService,
},
},
});
Expand All @@ -49,4 +58,14 @@ describe('SwagExtensionStore/module/sw-extension-store/page/sw-extension-store-i

expect(channelService.register).toBeCalled();
});

it ('should fetch the store URL from system config', async () => {
const systemConfigService = {
getValues: jest.fn(),
};

await createWrapper(null, systemConfigService);

expect(systemConfigService.getValues).toBeCalledWith('SwagExtensionStore.config');
});
});
11 changes: 11 additions & 0 deletions src/Resources/config/config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/shopware/shopware/trunk/src/Core/System/SystemConfig/Schema/config.xsd">
<card>
<title>Extension Store</title>
<input-field type="text">
<name>iframeUrl</name>
<label>iFrame URL</label>
</input-field>
</card>
</config>
Loading