@jumoo/usync 18.2.0 → 19.0.0-beta01

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.
Files changed (45) hide show
  1. package/LICENCE +372 -372
  2. package/README.md +10 -10
  3. package/dist/api/sdk.gen.js +5 -1
  4. package/dist/api/types.gen.d.ts +18 -1
  5. package/dist/components/usync-action-box.js +71 -71
  6. package/dist/components/usync-change-detail.js +409 -409
  7. package/dist/components/usync-change-view.js +49 -49
  8. package/dist/components/usync-progress-box.js +113 -113
  9. package/dist/components/usync-result-row.js +65 -65
  10. package/dist/components/usync-results-group-view.js +63 -63
  11. package/dist/components/usync-results-view.js +64 -64
  12. package/dist/components/usync-sync-file-info-view.js +10 -10
  13. package/dist/conditions/new-section.condition.js +16 -2
  14. package/dist/constants.js +1 -1
  15. package/dist/dialogs/details-modal-element.js +45 -45
  16. package/dist/dialogs/error-modal-element.js +22 -22
  17. package/dist/dialogs/legacy-modal-element.d.ts +11 -5
  18. package/dist/dialogs/legacy-modal-element.js +90 -38
  19. package/dist/dialogs/single-import-modal.element.js +31 -31
  20. package/dist/icons/svg/logo.js +20 -20
  21. package/dist/lang/files/da-dk.js +13 -13
  22. package/dist/lang/files/de-de.js +13 -13
  23. package/dist/lang/files/en-us.js +13 -13
  24. package/dist/lang/files/es-es.js +13 -13
  25. package/dist/lang/files/fr-fr.js +13 -13
  26. package/dist/lang/files/nl-nl.js +13 -13
  27. package/dist/repository/SyncAction.respositoy.d.ts +2 -1
  28. package/dist/repository/SyncAction.respositoy.js +3 -2
  29. package/dist/repository/sources/SyncMigration.source.d.ts +1 -1
  30. package/dist/repository/sources/SyncMigration.source.js +2 -2
  31. package/dist/signalr/signalr.context.js +5 -5
  32. package/dist/tree/usync.menu-element.js +8 -8
  33. package/dist/workspace/components/usync-action-button.js +53 -53
  34. package/dist/workspace/components/usync-file-picker.element.js +33 -33
  35. package/dist/workspace/components/usync-file-upload.element.js +25 -25
  36. package/dist/workspace/dialogs/import-modal.element.js +22 -22
  37. package/dist/workspace/views/addons/addons.element.js +97 -97
  38. package/dist/workspace/views/default/default.element.js +186 -186
  39. package/dist/workspace/views/legacy/legacy.element.js +87 -91
  40. package/dist/workspace/views/settings/components/usyncSettingItem.element.js +38 -38
  41. package/dist/workspace/views/settings/settings.element.js +124 -124
  42. package/dist/workspace/workspace.context.d.ts +1 -1
  43. package/dist/workspace/workspace.context.js +2 -2
  44. package/dist/workspace/workspace.element.js +16 -16
  45. package/package.json +77 -77
@@ -52,37 +52,37 @@ let uSyncResultsView = class uSyncResultsView extends UmbElementMixin(LitElement
52
52
  const groupChanges = groups[key].filter((r) => r.change !== ChangeType.NO_CHANGE).length ?? 0;
53
53
  if (groupChanges === 0 && !this.showAll)
54
54
  continue;
55
- const groupHtml = html `<usync-result-group
56
- .groupName=${key}
57
- .results=${groups[key]}
58
- .showAll=${this.showAll}
55
+ const groupHtml = html `<usync-result-group
56
+ .groupName=${key}
57
+ .results=${groups[key]}
58
+ .showAll=${this.showAll}
59
59
  @show-detail=${__classPrivateFieldGet(this, _uSyncResultsView_instances, "m", _uSyncResultsView_showDetail)}></usync-result-group> `;
60
60
  groupsHtml.push(groupHtml);
61
61
  }
62
62
  return this.changeCount == 0 && !this.showAll
63
- ? html `
64
- ${this.renderResultBar(this.results?.length || 0, this.changeCount)}
65
- <div class="empty">
66
- <umb-localize key="uSync_noChange"></umb-localize>
67
- </div>
63
+ ? html `
64
+ ${this.renderResultBar(this.results?.length || 0, this.changeCount)}
65
+ <div class="empty">
66
+ <umb-localize key="uSync_noChange"></umb-localize>
67
+ </div>
68
68
  `
69
- : html `<div id="result-box">
70
- ${this.renderResultBar(this.results?.length || 0, this.changeCount)}
71
- ${groupsHtml}
69
+ : html `<div id="result-box">
70
+ ${this.renderResultBar(this.results?.length || 0, this.changeCount)}
71
+ ${groupsHtml}
72
72
  </div>`;
73
73
  }
74
74
  renderResultBar(count, changes) {
75
75
  if (this.hideResultBar)
76
76
  return nothing;
77
77
  const localKey = changes === 0 ? 'uSync_noChangeCount' : 'uSync_changeCount';
78
- return html `<div class="result-header">
79
- <uui-toggle
80
- .label=${this.localize.termOrDefault('uSync_showAll', 'Show all items')}
81
- ?checked=${this.showAll}
82
- @change=${__classPrivateFieldGet(this, _uSyncResultsView_instances, "m", _uSyncResultsView_toggleShowAll)}></uui-toggle>
83
- <umb-localize .key=${localKey} .args=${[count, changes]}
84
- >${changes}/${count} items</umb-localize
85
- >
78
+ return html `<div class="result-header">
79
+ <uui-toggle
80
+ .label=${this.localize.termOrDefault('uSync_showAll', 'Show all items')}
81
+ ?checked=${this.showAll}
82
+ @change=${__classPrivateFieldGet(this, _uSyncResultsView_instances, "m", _uSyncResultsView_toggleShowAll)}></uui-toggle>
83
+ <umb-localize .key=${localKey} .args=${[count, changes]}
84
+ >${changes}/${count} items</umb-localize
85
+ >
86
86
  </div>`;
87
87
  }
88
88
  };
@@ -110,50 +110,50 @@ _uSyncResultsView_showDetail = async function _uSyncResultsView_showDetail(e) {
110
110
  if (!data)
111
111
  return;
112
112
  };
113
- uSyncResultsView.styles = css `
114
- :host {
115
- display: block;
116
- margin: var(--uui-size-space-4) 0;
117
- display: flex;
118
- flex-direction: column;
119
- gap: var(--uui-size-space-4);
120
- }
121
-
122
- #result-box {
123
- display: flex;
124
- flex-direction: column;
125
- gap: var(--uui-size-space-4);
126
- }
127
-
128
- uui-table {
129
- position: relative;
130
- z-index: 100;
131
- }
132
-
133
- .result-header {
134
- display: flex;
135
- justify-content: space-between;
136
- padding: var(--uui-size-space-4);
137
- border: 1px solid var(--uui-color-border);
138
- border-radius: var(--uui-border-radius);
139
- padding: var(--uui-size-space-4);
140
- }
141
-
142
- .result-header h3 {
143
- margin: 0;
144
- padding: 0;
145
- }
146
-
147
- .empty {
148
- padding: var(--uui-size-20);
149
- font-size: var(--uui-type-h5-size);
150
- text-align: center;
151
- font-weight: 900;
152
- }
153
-
154
- .error {
155
- background-color: #fce4ec;
156
- }
113
+ uSyncResultsView.styles = css `
114
+ :host {
115
+ display: block;
116
+ margin: var(--uui-size-space-4) 0;
117
+ display: flex;
118
+ flex-direction: column;
119
+ gap: var(--uui-size-space-4);
120
+ }
121
+
122
+ #result-box {
123
+ display: flex;
124
+ flex-direction: column;
125
+ gap: var(--uui-size-space-4);
126
+ }
127
+
128
+ uui-table {
129
+ position: relative;
130
+ z-index: 100;
131
+ }
132
+
133
+ .result-header {
134
+ display: flex;
135
+ justify-content: space-between;
136
+ padding: var(--uui-size-space-4);
137
+ border: 1px solid var(--uui-color-border);
138
+ border-radius: var(--uui-border-radius);
139
+ padding: var(--uui-size-space-4);
140
+ }
141
+
142
+ .result-header h3 {
143
+ margin: 0;
144
+ padding: 0;
145
+ }
146
+
147
+ .empty {
148
+ padding: var(--uui-size-20);
149
+ font-size: var(--uui-type-h5-size);
150
+ text-align: center;
151
+ font-weight: 900;
152
+ }
153
+
154
+ .error {
155
+ background-color: #fce4ec;
156
+ }
157
157
  `;
158
158
  __decorate([
159
159
  property({ type: Array })
@@ -30,8 +30,8 @@ _uSyncSyncFileInfoView_renderHmacMismatch = function _uSyncSyncFileInfoView_rend
30
30
  return nothing;
31
31
  if (this._syncFileInfo.hmacMatch)
32
32
  return nothing;
33
- return html `<div class="banner">
34
- <umb-localize key="uSync_hmacMismatch"></umb-localize>
33
+ return html `<div class="banner">
34
+ <umb-localize key="uSync_hmacMismatch"></umb-localize>
35
35
  </div>`;
36
36
  };
37
37
  _uSyncSyncFileInfoView_renderFormatMismatch = function _uSyncSyncFileInfoView_renderFormatMismatch() {
@@ -39,17 +39,17 @@ _uSyncSyncFileInfoView_renderFormatMismatch = function _uSyncSyncFileInfoView_re
39
39
  return nothing;
40
40
  if (this._syncFileInfo.isCurrent)
41
41
  return nothing;
42
- return html `<div class="banner">
43
- <umb-localize key="uSync_formatMismatch"></umb-localize>
42
+ return html `<div class="banner">
43
+ <umb-localize key="uSync_formatMismatch"></umb-localize>
44
44
  </div>`;
45
45
  };
46
46
  uSyncSyncFileInfoView.styles = [
47
- css `
48
- .banner {
49
- padding: var(--uui-size-space-2) var(--uui-size-space-4);
50
- margin: 0 0 var(--uui-size-space-4);
51
- background-color: var(--uui-color-surface);
52
- }
47
+ css `
48
+ .banner {
49
+ padding: var(--uui-size-space-2) var(--uui-size-space-4);
50
+ margin: 0 0 var(--uui-size-space-4);
51
+ background-color: var(--uui-color-surface);
52
+ }
53
53
  `,
54
54
  ];
55
55
  __decorate([
@@ -9,10 +9,11 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _SyncNewSectionCondition_instances, _SyncNewSectionCondition_currentSection, _SyncNewSectionCondition_allSections, _SyncNewSectionCondition_checkPermission;
12
+ var _SyncNewSectionCondition_instances, _SyncNewSectionCondition_currentSection, _SyncNewSectionCondition_allSections, _SyncNewSectionCondition_userSections, _SyncNewSectionCondition_checkPermission;
13
13
  import { UmbExtensionsManifestInitializer, } from '@umbraco-cms/backoffice/extension-api';
14
14
  import { UmbConditionBase, umbExtensionsRegistry, } from '@umbraco-cms/backoffice/extension-registry';
15
15
  import { UMB_SECTION_CONTEXT } from '@umbraco-cms/backoffice/section';
16
+ import { UMB_CURRENT_USER_CONTEXT } from '@umbraco-cms/backoffice/current-user';
16
17
  import { USYNC_SECTION_ALIAS } from '../tree/constants';
17
18
  export class SyncNewSectionCondition extends UmbConditionBase {
18
19
  constructor(host, args) {
@@ -20,10 +21,19 @@ export class SyncNewSectionCondition extends UmbConditionBase {
20
21
  _SyncNewSectionCondition_instances.add(this);
21
22
  _SyncNewSectionCondition_currentSection.set(this, void 0);
22
23
  _SyncNewSectionCondition_allSections.set(this, void 0);
24
+ _SyncNewSectionCondition_userSections.set(this, void 0);
23
25
  new UmbExtensionsManifestInitializer(this, umbExtensionsRegistry, 'section', () => true, async (sections) => {
24
26
  __classPrivateFieldSet(this, _SyncNewSectionCondition_allSections, sections.map((section) => section.alias), "f");
25
27
  this.permitted = __classPrivateFieldGet(this, _SyncNewSectionCondition_instances, "m", _SyncNewSectionCondition_checkPermission).call(this);
26
28
  }, 'uSyncAllSectionsManifestFilter');
29
+ this.consumeContext(UMB_CURRENT_USER_CONTEXT, (_context) => {
30
+ if (!_context)
31
+ return;
32
+ this.observe(_context.allowedSections, (_sections) => {
33
+ __classPrivateFieldSet(this, _SyncNewSectionCondition_userSections, _sections, "f");
34
+ this.permitted = __classPrivateFieldGet(this, _SyncNewSectionCondition_instances, "m", _SyncNewSectionCondition_checkPermission).call(this);
35
+ });
36
+ });
27
37
  this.consumeContext(UMB_SECTION_CONTEXT, (_context) => {
28
38
  if (!_context)
29
39
  return;
@@ -34,7 +44,7 @@ export class SyncNewSectionCondition extends UmbConditionBase {
34
44
  });
35
45
  }
36
46
  }
37
- _SyncNewSectionCondition_currentSection = new WeakMap(), _SyncNewSectionCondition_allSections = new WeakMap(), _SyncNewSectionCondition_instances = new WeakSet(), _SyncNewSectionCondition_checkPermission = function _SyncNewSectionCondition_checkPermission() {
47
+ _SyncNewSectionCondition_currentSection = new WeakMap(), _SyncNewSectionCondition_allSections = new WeakMap(), _SyncNewSectionCondition_userSections = new WeakMap(), _SyncNewSectionCondition_instances = new WeakSet(), _SyncNewSectionCondition_checkPermission = function _SyncNewSectionCondition_checkPermission() {
38
48
  if (!__classPrivateFieldGet(this, _SyncNewSectionCondition_currentSection, "f"))
39
49
  return false;
40
50
  if (!__classPrivateFieldGet(this, _SyncNewSectionCondition_allSections, "f"))
@@ -44,5 +54,9 @@ _SyncNewSectionCondition_currentSection = new WeakMap(), _SyncNewSectionConditio
44
54
  return true;
45
55
  if (__classPrivateFieldGet(this, _SyncNewSectionCondition_currentSection, "f") === USYNC_SECTION_ALIAS)
46
56
  return true;
57
+ // the section exists, but this user hasn't been given it, so keep
58
+ // showing uSync in settings (the api allows settings or usync access).
59
+ if (__classPrivateFieldGet(this, _SyncNewSectionCondition_userSections, "f") && !__classPrivateFieldGet(this, _SyncNewSectionCondition_userSections, "f").includes(USYNC_SECTION_ALIAS))
60
+ return true;
47
61
  return false;
48
62
  };
package/dist/constants.js CHANGED
@@ -4,7 +4,7 @@ const _constants = {
4
4
  icon: 'icon-infinity',
5
5
  menuName: 'Syncronisation',
6
6
  menuAlias: 'usync.menu',
7
- version: '17.x',
7
+ version: '18.x',
8
8
  conditions: {
9
9
  legacy: 'usync.legacy.condition',
10
10
  },
@@ -23,39 +23,39 @@ let uSyncDetailsModalElement = class uSyncDetailsModalElement extends UmbModalBa
23
23
  // });
24
24
  }
25
25
  render() {
26
- return html `
27
- <umb-body-layout headline="Changes : ${this.data?.item.name ?? ''}">
28
- <div class="layout">
29
- <uui-box style="--uui-box-default-padding: 0;">
30
- <div class="headline">
31
- <div>
32
- <h3><umb-localize key="uSync_detailHeadline"></umb-localize></h3>
33
- <umb-localize key="uSync_detailHeader"></umb-localize>
34
- </div>
35
- <div>${this.renderActions()}</div>
36
- </div>
37
- </uui-box>
38
- <usync-change-view .item=${this.data?.item}></usync-change-view>
39
- </div>
40
- <div slot="actions">
41
- <uui-button
42
- id="cancel"
43
- .label=${this.localize.term('general_close')}
44
- look="outline"
45
- @click="${__classPrivateFieldGet(this, _uSyncDetailsModalElement_instances, "m", _uSyncDetailsModalElement_onClose)}"></uui-button>
46
- </div>
47
- </umb-body-layout>
26
+ return html `
27
+ <umb-body-layout headline="Changes : ${this.data?.item.name ?? ''}">
28
+ <div class="layout">
29
+ <uui-box style="--uui-box-default-padding: 0;">
30
+ <div class="headline">
31
+ <div>
32
+ <h3><umb-localize key="uSync_detailHeadline"></umb-localize></h3>
33
+ <umb-localize key="uSync_detailHeader"></umb-localize>
34
+ </div>
35
+ <div>${this.renderActions()}</div>
36
+ </div>
37
+ </uui-box>
38
+ <usync-change-view .item=${this.data?.item}></usync-change-view>
39
+ </div>
40
+ <div slot="actions">
41
+ <uui-button
42
+ id="cancel"
43
+ .label=${this.localize.term('general_close')}
44
+ look="outline"
45
+ @click="${__classPrivateFieldGet(this, _uSyncDetailsModalElement_instances, "m", _uSyncDetailsModalElement_onClose)}"></uui-button>
46
+ </div>
47
+ </umb-body-layout>
48
48
  `;
49
49
  }
50
50
  renderActions() {
51
51
  if (!this.data?.showActions)
52
52
  return nothing;
53
- return html ` <uui-button
54
- id="import"
55
- type="button"
56
- look="outline"
57
- .state=${this.importState}
58
- .label=${this.localize.termOrDefault('uSync_importSingle', 'Import')}
53
+ return html ` <uui-button
54
+ id="import"
55
+ type="button"
56
+ look="outline"
57
+ .state=${this.importState}
58
+ .label=${this.localize.termOrDefault('uSync_importSingle', 'Import')}
59
59
  @click="${__classPrivateFieldGet(this, _uSyncDetailsModalElement_instances, "m", _uSyncDetailsModalElement_onImport)}"></uui-button>`;
60
60
  }
61
61
  };
@@ -78,23 +78,23 @@ _uSyncDetailsModalElement_onImport = async function _uSyncDetailsModalElement_on
78
78
  _uSyncDetailsModalElement_onClose = function _uSyncDetailsModalElement_onClose() {
79
79
  this.modalContext?.reject();
80
80
  };
81
- uSyncDetailsModalElement.styles = css `
82
- .layout {
83
- display: flex;
84
- flex-direction: column;
85
- gap: var(--uui-size-space-4);
86
- }
87
-
88
- .headline {
89
- display: flex;
90
- justify-content: space-between;
91
- padding: var(--uui-size-space-4);
92
- align-items: center;
93
- }
94
-
95
- .headline h3 {
96
- margin: 0;
97
- }
81
+ uSyncDetailsModalElement.styles = css `
82
+ .layout {
83
+ display: flex;
84
+ flex-direction: column;
85
+ gap: var(--uui-size-space-4);
86
+ }
87
+
88
+ .headline {
89
+ display: flex;
90
+ justify-content: space-between;
91
+ padding: var(--uui-size-space-4);
92
+ align-items: center;
93
+ }
94
+
95
+ .headline h3 {
96
+ margin: 0;
97
+ }
98
98
  `;
99
99
  __decorate([
100
100
  state()
@@ -19,18 +19,18 @@ let uSyncErrorModalElement = class uSyncErrorModalElement extends UmbModalBaseEl
19
19
  }
20
20
  render() {
21
21
  const headline = `Error: ${this.data?.action.name ?? ''} [${this.data?.action.itemType}]`;
22
- return html `<umb-body-layout .headline=${headline}>
23
- <strong>
24
- <umb-localize key="uSync_errorHeader"></umb-localize>
25
- </strong>
26
- <div class="error">${this.data?.action.message}</div>
27
- <div slot="actions">
28
- <uui-button
29
- id="cancel"
30
- look="outline"
31
- .label=${this.localize.term('general_close')}
32
- @click="${__classPrivateFieldGet(this, _uSyncErrorModalElement_instances, "m", _uSyncErrorModalElement_onClose)}"></uui-button>
33
- </div>
22
+ return html `<umb-body-layout .headline=${headline}>
23
+ <strong>
24
+ <umb-localize key="uSync_errorHeader"></umb-localize>
25
+ </strong>
26
+ <div class="error">${this.data?.action.message}</div>
27
+ <div slot="actions">
28
+ <uui-button
29
+ id="cancel"
30
+ look="outline"
31
+ .label=${this.localize.term('general_close')}
32
+ @click="${__classPrivateFieldGet(this, _uSyncErrorModalElement_instances, "m", _uSyncErrorModalElement_onClose)}"></uui-button>
33
+ </div>
34
34
  </umb-body-layout>`;
35
35
  }
36
36
  };
@@ -38,16 +38,16 @@ _uSyncErrorModalElement_instances = new WeakSet();
38
38
  _uSyncErrorModalElement_onClose = function _uSyncErrorModalElement_onClose() {
39
39
  this.modalContext?.reject();
40
40
  };
41
- uSyncErrorModalElement.styles = css `
42
- umb-body-layout {
43
- max-width: 450px;
44
- }
45
-
46
- .error {
47
- padding: 10px;
48
- font-family: monospace;
49
- color: red;
50
- }
41
+ uSyncErrorModalElement.styles = css `
42
+ umb-body-layout {
43
+ max-width: 450px;
44
+ }
45
+
46
+ .error {
47
+ padding: 10px;
48
+ font-family: monospace;
49
+ color: red;
50
+ }
51
51
  `;
52
52
  uSyncErrorModalElement = __decorate([
53
53
  customElement('usync-error-modal')
@@ -1,13 +1,19 @@
1
1
  import { nothing } from '@umbraco-cms/backoffice/external/lit';
2
2
  import { UmbModalBaseElement, UmbModalToken } from '@umbraco-cms/backoffice/modal';
3
3
  import { SyncLegacyCheckResponse } from '@jumoo/uSync';
4
- export declare class uSyncLegacyModalElement extends UmbModalBaseElement<SyncLegacyCheckResponse, string> {
4
+ export interface uSyncLegacyModalValue {
5
+ /** ids of the migrations to run as the legacy folder is copied. */
6
+ migrations: Array<string>;
7
+ }
8
+ /**
9
+ * confirms copying the legacy folder, and lets the user choose which migrations to run on the files.
10
+ */
11
+ export declare class uSyncLegacyModalElement extends UmbModalBaseElement<SyncLegacyCheckResponse, uSyncLegacyModalValue> {
5
12
  #private;
13
+ _skipped: Set<string>;
6
14
  render(): import("lit-html").TemplateResult<1>;
7
- renderLegacyFolder(folder: string | null | undefined): typeof nothing | import("lit-html").TemplateResult<1>;
8
- renderLegacyTypes(legacyTypes: Array<string> | undefined): typeof nothing | import("lit-html").TemplateResult<1>;
9
- renderCopy(): import("lit-html").TemplateResult<1>;
15
+ renderMigrations(migrations: SyncLegacyCheckResponse['migrations']): typeof nothing | import("lit-html").TemplateResult<1>;
10
16
  static styles: import("lit").CSSResult;
11
17
  }
12
18
  export default uSyncLegacyModalElement;
13
- export declare const USYNC_LEGACY_MODAL: UmbModalToken<SyncLegacyCheckResponse, string>;
19
+ export declare const USYNC_LEGACY_MODAL: UmbModalToken<SyncLegacyCheckResponse, uSyncLegacyModalValue>;
@@ -9,62 +9,114 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
9
9
  if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
10
10
  return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
11
11
  };
12
- var _uSyncLegacyModalElement_instances, _uSyncLegacyModalElement_onClose;
13
- import { css, customElement, html, nothing } from '@umbraco-cms/backoffice/external/lit';
12
+ var _uSyncLegacyModalElement_instances, _uSyncLegacyModalElement_onClose, _uSyncLegacyModalElement_onCopy, _uSyncLegacyModalElement_onToggleMigration;
13
+ import { css, customElement, html, nothing, state } from '@umbraco-cms/backoffice/external/lit';
14
14
  import { UmbModalBaseElement, UmbModalToken } from '@umbraco-cms/backoffice/modal';
15
+ /**
16
+ * confirms copying the legacy folder, and lets the user choose which migrations to run on the files.
17
+ */
15
18
  let uSyncLegacyModalElement = class uSyncLegacyModalElement extends UmbModalBaseElement {
16
19
  constructor() {
17
20
  super(...arguments);
18
21
  _uSyncLegacyModalElement_instances.add(this);
22
+ // migrations are all on until the user turns one off.
23
+ this._skipped = new Set();
19
24
  }
20
25
  render() {
21
- return html `
22
- <umb-body-layout headline="Legacy uSync folder detected">
23
- <div class="content">
24
- ${this.renderLegacyFolder(this.data?.legacyFolder)}
25
- ${this.renderLegacyTypes(this.data?.legacyTypes)} ${this.renderCopy()}
26
- </div>
27
- <div slot="actions">
28
- <uui-button id="cancel" label="close" @click=${__classPrivateFieldGet(this, _uSyncLegacyModalElement_instances, "m", _uSyncLegacyModalElement_onClose)}>
29
- ${this.localize.term('general_close')}
30
- </uui-button>
31
- </div>
32
- </umb-body-layout>
26
+ const version = this.data?.latestVersion;
27
+ const migrations = this.data?.migrations ?? [];
28
+ return html `
29
+ <umb-body-layout
30
+ .headline=${this.localize.termOrDefault('uSync_legacyCopyTitle', 'Overwrite files', version)}>
31
+ <div class="content">
32
+ <p>
33
+ ${this.localize.termOrDefault('uSync_legacyCopyContent', 'Are you sure you want to overwrite the contents of the folder with the legacy uSync folder files?', this.data?.latestFolder)}
34
+ </p>
35
+ ${this.renderMigrations(migrations)}
36
+ </div>
37
+ <div slot="actions">
38
+ <uui-button
39
+ id="cancel"
40
+ label="cancel"
41
+ @click=${__classPrivateFieldGet(this, _uSyncLegacyModalElement_instances, "m", _uSyncLegacyModalElement_onClose)}>${this.localize.term('general_cancel')}</uui-button>
42
+ <uui-button id="copy" label="copy" look="primary" color="danger" @click=${__classPrivateFieldGet(this, _uSyncLegacyModalElement_instances, "m", _uSyncLegacyModalElement_onCopy)}
43
+ >${migrations.length > 0 && migrations.some((m) => !this._skipped.has(m.id))
44
+ ? 'Migrate and copy'
45
+ : 'Copy'}</uui-button
46
+ >
47
+ </div>
48
+ </umb-body-layout>
33
49
  `;
34
50
  }
35
- renderLegacyFolder(folder) {
36
- return folder === undefined || folder === null
37
- ? nothing
38
- : html `${this.localize.termOrDefault('uSync.legacyInfo', 'uSync has found a legacy uSync folder', folder)}`;
39
- }
40
- renderLegacyTypes(legacyTypes) {
41
- if (legacyTypes == undefined || legacyTypes.length == 0) {
51
+ renderMigrations(migrations) {
52
+ if (migrations.length == 0) {
42
53
  return nothing;
43
54
  }
44
- const legacyTypeHtml = this.data?.legacyTypes.map((datatype) => {
45
- return html `<li>${datatype}</li>`;
46
- });
47
- return html `<div>
48
- ${this.localize.termOrDefault('uSync.legacyObsolete', 'Obsolete DataTypes', legacyTypeHtml)}
49
- </div>`;
50
- }
51
- renderCopy() {
52
- return html `${this.localize.termOrDefault('uSync.legacyCopy', 'Copy to uSync folder', this.data?.legacyFolder ?? 'uSync/v15')} `;
55
+ return html `
56
+ <uui-box headline="Migrations">
57
+ <p>
58
+ These changes can be made to the files as they are copied, so the import that
59
+ follows uses the current editors.
60
+ </p>
61
+ ${migrations.map((migration) => html `
62
+ <div class="migration">
63
+ <uui-checkbox
64
+ label=${migration.name}
65
+ ?checked=${!this._skipped.has(migration.id)}
66
+ @change=${(e) => __classPrivateFieldGet(this, _uSyncLegacyModalElement_instances, "m", _uSyncLegacyModalElement_onToggleMigration).call(this, migration.id, e.target.checked)}
67
+ >${migration.name} (${migration.count})</uui-checkbox
68
+ >
69
+ <div class="migration-description">${migration.description}</div>
70
+ ${migration.notice
71
+ ? html `<div class="migration-notice">${migration.notice}</div>`
72
+ : nothing}
73
+ </div>
74
+ `)}
75
+ </uui-box>
76
+ `;
53
77
  }
54
78
  };
55
79
  _uSyncLegacyModalElement_instances = new WeakSet();
56
80
  _uSyncLegacyModalElement_onClose = function _uSyncLegacyModalElement_onClose() {
57
81
  this.modalContext?.reject();
58
82
  };
59
- uSyncLegacyModalElement.styles = css `
60
- .content {
61
- margin: -10px 0;
62
- }
63
-
64
- em {
65
- color: var(--uui-color-positive);
66
- }
83
+ _uSyncLegacyModalElement_onCopy = function _uSyncLegacyModalElement_onCopy() {
84
+ const migrations = (this.data?.migrations ?? [])
85
+ .map((migration) => migration.id)
86
+ .filter((id) => !this._skipped.has(id));
87
+ this.modalContext?.setValue({ migrations });
88
+ this.modalContext?.submit();
89
+ };
90
+ _uSyncLegacyModalElement_onToggleMigration = function _uSyncLegacyModalElement_onToggleMigration(id, checked) {
91
+ const skipped = new Set(this._skipped);
92
+ if (checked)
93
+ skipped.delete(id);
94
+ else
95
+ skipped.add(id);
96
+ this._skipped = skipped;
97
+ };
98
+ uSyncLegacyModalElement.styles = css `
99
+ .content {
100
+ max-width: 520px;
101
+ }
102
+
103
+ .migration {
104
+ margin-bottom: var(--uui-size-space-3);
105
+ }
106
+
107
+ .migration-description,
108
+ .migration-notice {
109
+ margin-left: var(--uui-size-space-6);
110
+ }
111
+
112
+ .migration-notice {
113
+ color: var(--uui-color-text-alt);
114
+ font-size: var(--uui-type-small-size);
115
+ }
67
116
  `;
117
+ __decorate([
118
+ state()
119
+ ], uSyncLegacyModalElement.prototype, "_skipped", void 0);
68
120
  uSyncLegacyModalElement = __decorate([
69
121
  customElement('usync-legacy-modal')
70
122
  ], uSyncLegacyModalElement);