Skip to content

Commit 54bcbb5

Browse files
committed
42083 V14: Integrations (Shopify)
- Update generated API - Update property picker name - add vite config
1 parent 8f51154 commit 54bcbb5

File tree

11 files changed

+62
-59
lines changed

11 files changed

+62
-59
lines changed

src/Umbraco.Cms.Integrations.Commerce.Shopify.Core/Api/Management/Controllers/ShopifyControllerBase.cs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,5 @@ protected HttpRequestMessage CreateRequest(string accessToken)
4343
requestMessage.Headers.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
4444
return requestMessage;
4545
}
46-
47-
public IActionResult OAuth(string code)
48-
{
49-
return new ContentResult
50-
{
51-
Content = string.IsNullOrEmpty(code)
52-
? JavascriptResponse.Fail("Authorization process failed.")
53-
: JavascriptResponse.Ok(code),
54-
ContentType = "text/html"
55-
};
56-
}
5746
}
5847
}

src/Umbraco.Cms.Integrations.Commerce.Shopify.Core/Services/ShopifyService.cs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ public class ShopifyService : IShopifyService
3939

4040
private readonly ShopifyOAuthSettings _oauthSettings;
4141

42-
#if NETCOREAPP
4342
private readonly ILogger<ShopifyService> _umbCoreLogger;
44-
#else
45-
private readonly ILogger _umbCoreLogger;
46-
#endif
4743

4844
private readonly ITokenService _tokenService;
4945

@@ -53,7 +49,6 @@ public class ShopifyService : IShopifyService
5349
// Access to the client within the class is via ClientFactory(), allowing us to mock the responses in tests.
5450
public static Func<HttpClient> ClientFactory = () => Client;
5551

56-
#if NETCOREAPP
5752
public ShopifyService(ILogger<ShopifyService> logger,
5853
IOptions<ShopifySettings> options, IOptions<ShopifyOAuthSettings> oauthOptions,
5954
ITokenService tokenService)
@@ -73,25 +68,6 @@ public ShopifyService(ILogger<ShopifyService> logger,
7368

7469
_tokenService = tokenService;
7570
}
76-
#else
77-
public ShopifyService(ILogger logger, ITokenService tokenService)
78-
{
79-
var resolver = new JsonPropertyRenameContractResolver();
80-
resolver.RenameProperty(typeof(ResponseDto<ProductsListDto>), "Result", "products");
81-
82-
_serializerSettings = new JsonSerializerSettings
83-
{
84-
ContractResolver = resolver
85-
};
86-
87-
_settings = new ShopifySettings(ConfigurationManager.AppSettings);
88-
_oauthSettings = new ShopifyOAuthSettings(ConfigurationManager.AppSettings);
89-
90-
_umbCoreLogger = logger;
91-
92-
_tokenService = tokenService;
93-
}
94-
#endif
9571

9672
public EditorSettings GetApiConfiguration()
9773
{
@@ -301,19 +277,11 @@ private void Log(ShopifyLogLevel logLevel, string message)
301277
{
302278
if (logLevel == ShopifyLogLevel.Error)
303279
{
304-
#if NETCOREAPP
305280
_umbCoreLogger.LogError(message);
306-
#else
307-
_umbCoreLogger.Error<ShopifyService>(message);
308-
#endif
309281
}
310282
else if (logLevel == ShopifyLogLevel.Information)
311283
{
312-
#if NETCOREAPP
313284
_umbCoreLogger.LogInformation(message);
314-
#else
315-
_umbCoreLogger.Info<ShopifyService>(message: message);
316-
#endif
317285
}
318286
}
319287
}

src/Umbraco.Cms.Integrations.Commerce.Shopify/Client/index.html

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
77
<title>Vite + Lit + TS</title>
88
<link rel="stylesheet" href="./src/index.css" />
9-
<script type="module" src="/src/my-element.ts"></script>
109
</head>
1110
<body>
1211
<my-element>

src/Umbraco.Cms.Integrations.Commerce.Shopify/Client/src/generated/models.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11

22

3+
export type ConfigurationTypeModel = {
4+
readonly value: string
5+
};
6+
7+
export type EditorSettingsModel = {
8+
isValid: boolean
9+
type: ConfigurationTypeModel
10+
};
11+
312
export enum EventMessageTypeModel {
413
DEFAULT = 'Default',
514
INFO = 'Info',
@@ -78,9 +87,9 @@ GetListByIds: {
7887

7988

8089
responses: {
81-
CheckConfiguration: any
90+
CheckConfiguration: EditorSettingsModel
8291
,GetAccessToken: string
83-
,GetAuthorizationUrl: any
92+
,GetAuthorizationUrl: string
8493
,GetList: ResponseDtoProductsListDtoModel
8594
,GetListByIds: ResponseDtoProductsListDtoModel
8695
,RevokeAccessToken: string

src/Umbraco.Cms.Integrations.Commerce.Shopify/Client/src/generated/services.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { ShopifyData } from './models';
66
export class ShopifyService {
77

88
/**
9-
* @returns any OK
9+
* @returns unknown OK
1010
* @throws ApiError
1111
*/
1212
public static checkConfiguration(): CancelablePromise<ShopifyData['responses']['CheckConfiguration']> {
@@ -35,7 +35,7 @@ export class ShopifyService {
3535
}
3636

3737
/**
38-
* @returns any OK
38+
* @returns string OK
3939
* @throws ApiError
4040
*/
4141
public static getAuthorizationUrl(): CancelablePromise<ShopifyData['responses']['GetAuthorizationUrl']> {
@@ -74,7 +74,7 @@ export class ShopifyService {
7474
requestBody
7575
} = data;
7676
return __request(OpenAPI, {
77-
method: 'POST',
77+
method: 'GET',
7878
url: '/umbraco/shopify/management/api/v1/get-list-by-ids',
7979
body: requestBody,
8080
mediaType: 'application/json',

src/Umbraco.Cms.Integrations.Commerce.Shopify/Client/src/modal/shopify-modal.element.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import {
55
} from "@umbraco-cms/backoffice/notification";
66
import type { UUIInputEvent } from "@umbraco-cms/backoffice/external/uui";
77
import type { ShopifyServiceStatus } from "../models/shopify-service.model.js";
8-
import type { ShopifyPickerModalData, ShopifyPickerModalValue } from "./shopify.modal-token.js";
8+
import type { ShopifyProductPickerModalData, ShopifyProductPickerModalValue } from "./shopify.modal-token.js";
99
import type { ProductsListDtoModel } from "../generated";
1010
import { SHOPIFY_CONTEXT_TOKEN } from "../context/shopify.context.js";
1111

1212
const elementName = "shopify-modal";
1313

14-
export default class ShopifyModalElement extends UmbModalBaseElement<ShopifyPickerModalData, ShopifyPickerModalValue>{
14+
export default class ShopifyModalElement extends UmbModalBaseElement<ShopifyProductPickerModalData, ShopifyProductPickerModalValue>{
1515

1616
}

src/Umbraco.Cms.Integrations.Commerce.Shopify/Client/src/modal/shopify.modal-token.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import { UmbModalToken } from "@umbraco-cms/backoffice/modal";
22
import type { ProductDtoModel } from "../generated";
33

4-
export type ShopifyPickerModalData = {
4+
export type ShopifyProductPickerModalData = {
55
headline: string;
66
}
77

8-
export type ShopifyPickerModalValue = {
8+
export type ShopifyProductPickerModalValue = {
99
products: ProductDtoModel;
1010
}
1111

12-
export const SHOPIFY_MODAL_TOKEN = new UmbModalToken<ShopifyPickerModalData, ShopifyPickerModalValue>("Shopify.Modal", {
12+
export const SHOPIFY_MODAL_TOKEN = new UmbModalToken<ShopifyProductPickerModalData, ShopifyProductPickerModalValue>("Shopify.Modal", {
1313
modal: {
1414
type: "sidebar",
1515
size: "small"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { UmbElementMixin } from "@umbraco-cms/backoffice/element-api";
2+
import { LitElement, customElement, html, property, state, when } from "@umbraco-cms/backoffice/external/lit";
3+
import { UMB_NOTIFICATION_CONTEXT, type UmbNotificationColor} from "@umbraco-cms/backoffice/notification";
4+
import { ConfigDescription, type ShopifyOAuthSetup, type ShopifyServiceStatus } from "../models/shopify-service.model";
5+
import { SHOPIFY_CONTEXT_TOKEN } from "../context/shopify.context";
6+
import type { OAuthRequestDtoModel } from "../generated";
7+
8+
const elementName = "shopify-authorization";
9+
10+
@customElement(elementName)
11+
export class ShopifyAuthorizationElement extends UmbElementMixin(LitElement){
12+
#shopifyContext!: typeof SHOPIFY_CONTEXT_TOKEN.TYPE;
13+
14+
render() {
15+
return html`
16+
<div><span>Authentication</span></div>
17+
`;
18+
}
19+
}

src/Umbraco.Cms.Integrations.Commerce.Shopify/Client/src/property-editor/manifests.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export const propertyEditorUiManifest : ManifestPropertyEditorUi = {
44
type: "propertyEditorUi",
55
alias: "Shopify.PropertyEditorUi.ProductPicker",
66
name: "Shopify Product Picker Property Editor UI",
7-
js: () => import("./shopify-picker-property-editor.element.js"),
8-
elementName: "shopify-picker",
7+
js: () => import("./shopify-product-picker-property-editor.element.js"),
8+
elementName: "shopify-product-picker",
99
meta: {
1010
label: "Shopify Product Picker",
1111
icon: "icon-handshake",
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { SHOPIFY_CONTEXT_TOKEN } from "../context/shopify.context";
1010
import type { ProductDtoModel } from "../generated/models";
1111

1212
const elementName = "shopify-picker";
13-
export class ShopifyPickerPropertyEditor extends UmbElementMixin(LitElement){
13+
export class ShopifyProductPickerPropertyEditor extends UmbElementMixin(LitElement){
1414
#modalManagerContext?: typeof UMB_MODAL_MANAGER_CONTEXT.TYPE;
1515
#shopifyContext!: typeof SHOPIFY_CONTEXT_TOKEN.TYPE;
1616

@@ -108,10 +108,10 @@ export class ShopifyPickerPropertyEditor extends UmbElementMixin(LitElement){
108108
}
109109

110110

111-
export default ShopifyPickerPropertyEditor;
111+
export default ShopifyProductPickerPropertyEditor;
112112

113113
declare global {
114114
interface HTMLElementTagNameMap {
115-
[elementName]: ShopifyPickerPropertyEditor;
115+
[elementName]: ShopifyProductPickerPropertyEditor;
116116
}
117117
}

0 commit comments

Comments
 (0)