@jumoo/usync 17.6.0 → 17.6.1-prerelease.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,6 @@
1
1
  import { LitElement, nothing } from '@umbraco-cms/backoffice/external/lit';
2
2
  import { USyncActionView } from '@jumoo/uSync';
3
+ import { uSyncPreviewSource } from '@jumoo/uSync';
3
4
  declare const uSyncResultsView_base: import("@umbraco-cms/backoffice/extension-api").HTMLElementConstructor<import("@umbraco-cms/backoffice/element-api").UmbElement> & typeof LitElement;
4
5
  export declare class uSyncResultsView extends uSyncResultsView_base {
5
6
  #private;
@@ -7,6 +8,11 @@ export declare class uSyncResultsView extends uSyncResultsView_base {
7
8
  results: Array<USyncActionView> | undefined;
8
9
  hideResultBar: boolean;
9
10
  hideActions: boolean;
11
+ /**
12
+ * where the details dialog gets previews from, leave it unset to preview
13
+ * items from this site's uSync folders (see uSyncDetailsModalData).
14
+ */
15
+ previewSource?: uSyncPreviewSource;
10
16
  showAll: boolean;
11
17
  changeCount: number;
12
18
  groupBy<T>(arr: T[], fn: (item: T) => any): Record<string, T[]>;
@@ -99,6 +99,7 @@ _uSyncResultsView_showDetail = async function _uSyncResultsView_showDetail(e) {
99
99
  data: {
100
100
  item: e.action,
101
101
  items: __classPrivateFieldGet(this, _uSyncResultsView_instances, "m", _uSyncResultsView_visibleItems).call(this),
102
+ previewSource: this.previewSource,
102
103
  showActions: (item) => !this.hideActions &&
103
104
  (item.change == ChangeType.CREATE ||
104
105
  item.change == ChangeType.UPDATE ||
@@ -171,6 +172,9 @@ __decorate([
171
172
  __decorate([
172
173
  property({ type: Boolean })
173
174
  ], uSyncResultsView.prototype, "hideActions", void 0);
175
+ __decorate([
176
+ property({ attribute: false })
177
+ ], uSyncResultsView.prototype, "previewSource", void 0);
174
178
  __decorate([
175
179
  state()
176
180
  ], uSyncResultsView.prototype, "showAll", void 0);
@@ -180,11 +180,16 @@ _uSyncDetailsModalElement_loadPreview = async function _uSyncDetailsModalElement
180
180
  const item = this._item;
181
181
  if (!item?.handler || !item.key)
182
182
  return;
183
+ const source = this.data?.previewSource;
184
+ if (source === false)
185
+ return;
183
186
  // only some handlers support previews, the rest return a 404
184
187
  // and the modal shows the diff on its own. we leave _tab alone
185
188
  // so a user who picked the diff stays on it as they move through.
186
189
  this._loading = true;
187
- const { data } = await __classPrivateFieldGet(this, _uSyncDetailsModalElement_repository, "f").getPreview(item.handler, item.key);
190
+ const data = source
191
+ ? await source(item).catch(() => undefined)
192
+ : (await __classPrivateFieldGet(this, _uSyncDetailsModalElement_repository, "f").getPreview(item.handler, item.key)).data;
188
193
  // moving through the list quickly can return previews out of order,
189
194
  // so drop anything that isn't for the item we are now showing.
190
195
  if (item !== this._item)
@@ -1,5 +1,13 @@
1
1
  import { UmbModalToken } from '@umbraco-cms/backoffice/modal';
2
- import { USyncActionView } from '@jumoo/uSync';
2
+ import { SyncItemPreviewResponse, USyncActionView } from '@jumoo/uSync';
3
+ /**
4
+ * where the details dialog gets the preview of an item from.
5
+ *
6
+ * - `false`: no preview, the dialog shows just the diff.
7
+ * - a function: the caller loads it, for items that aren't in this site's
8
+ * uSync folders (e.g. a sync pack). return undefined when there isn't one.
9
+ */
10
+ export type uSyncPreviewSource = false | ((item: USyncActionView) => Promise<SyncItemPreviewResponse | undefined>);
3
11
  export interface uSyncDetailsModalData {
4
12
  item: USyncActionView;
5
13
  /**
@@ -12,6 +20,11 @@ export interface uSyncDetailsModalData {
12
20
  * to the previous / next item in the list.
13
21
  */
14
22
  items?: Array<USyncActionView>;
23
+ /**
24
+ * where the preview comes from, when it's not set the dialog previews
25
+ * the item from this site's uSync folders.
26
+ */
27
+ previewSource?: uSyncPreviewSource;
15
28
  }
16
29
  export interface uSyncDetailsModalValue {
17
30
  result: boolean;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "homepage": "https://jumoo.co.uk/uSync",
9
9
  "license": "MPL-2.0",
10
10
  "type": "module",
11
- "version": "17.6.0",
11
+ "version": "17.6.1-prerelease.18",
12
12
  "main": "./dist/usync.js",
13
13
  "types": "./dist/index.d.ts",
14
14
  "module": "./dist/usync.js",