@conduction/nextcloud-vue 2.120.0 → 2.121.0

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 (72) hide show
  1. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js +53 -1
  2. package/dist/esm/components/CnIndexPage/CnIndexPage.vue2.js.map +1 -1
  3. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js +546 -523
  4. package/dist/esm/components/CnIndexPage/CnIndexPage.vue3.js.map +1 -1
  5. package/dist/esm/components/CnIndexPage/useNamedSource.js +9 -0
  6. package/dist/esm/components/CnIndexPage/useNamedSource.js.map +1 -1
  7. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js +9 -0
  8. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue.js.map +1 -0
  9. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js +214 -0
  10. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue2.js.map +1 -0
  11. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js +125 -0
  12. package/dist/esm/components/CnReadinessChecklist/CnReadinessChecklist.vue3.js.map +1 -0
  13. package/dist/esm/components/CnSchemaRulesWidget/CnSchemaRulesWidget.vue.js +9 -0
  14. package/dist/esm/components/CnSchemaRulesWidget/CnSchemaRulesWidget.vue.js.map +1 -0
  15. package/dist/esm/components/CnSchemaRulesWidget/CnSchemaRulesWidget.vue2.js +163 -0
  16. package/dist/esm/components/CnSchemaRulesWidget/CnSchemaRulesWidget.vue2.js.map +1 -0
  17. package/dist/esm/components/CnSchemaRulesWidget/CnSchemaRulesWidget.vue3.js +131 -0
  18. package/dist/esm/components/CnSchemaRulesWidget/CnSchemaRulesWidget.vue3.js.map +1 -0
  19. package/dist/esm/components/CnSchemaRulesWidget/schemaRules.js +127 -0
  20. package/dist/esm/components/CnSchemaRulesWidget/schemaRules.js.map +1 -0
  21. package/dist/esm/components/CnSearchIndexStatus/CnSearchIndexStatus.vue.js +9 -0
  22. package/dist/esm/components/CnSearchIndexStatus/CnSearchIndexStatus.vue.js.map +1 -0
  23. package/dist/esm/components/CnSearchIndexStatus/CnSearchIndexStatus.vue2.js +82 -0
  24. package/dist/esm/components/CnSearchIndexStatus/CnSearchIndexStatus.vue2.js.map +1 -0
  25. package/dist/esm/components/CnSearchIndexStatus/CnSearchIndexStatus.vue3.js +61 -0
  26. package/dist/esm/components/CnSearchIndexStatus/CnSearchIndexStatus.vue3.js.map +1 -0
  27. package/dist/esm/components/CnSearchIndexStatus/searchIndexStatus.js +60 -0
  28. package/dist/esm/components/CnSearchIndexStatus/searchIndexStatus.js.map +1 -0
  29. package/dist/esm/components/CnShippedConfigurationSection/CnShippedConfigurationSection.vue.js +10 -0
  30. package/dist/esm/components/CnShippedConfigurationSection/CnShippedConfigurationSection.vue.js.map +1 -0
  31. package/dist/esm/components/CnShippedConfigurationSection/CnShippedConfigurationSection.vue2.js +226 -0
  32. package/dist/esm/components/CnShippedConfigurationSection/CnShippedConfigurationSection.vue2.js.map +1 -0
  33. package/dist/esm/components/CnShippedConfigurationSection/CnShippedConfigurationSection.vue3.js +126 -0
  34. package/dist/esm/components/CnShippedConfigurationSection/CnShippedConfigurationSection.vue3.js.map +1 -0
  35. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js +42 -32
  36. package/dist/esm/components/CnWidgetGrid/registerDashboardWidgets.js.map +1 -1
  37. package/dist/esm/composables/indexSources.js +116 -16
  38. package/dist/esm/composables/indexSources.js.map +1 -1
  39. package/dist/esm/index.js +4 -0
  40. package/dist/esm/index.js.map +1 -1
  41. package/dist/esm/l10n/en.json.js +42 -1
  42. package/dist/esm/l10n/en.json.js.map +1 -1
  43. package/dist/esm/l10n/nl.json.js +42 -1
  44. package/dist/esm/l10n/nl.json.js.map +1 -1
  45. package/dist/esm/library-style.js +1 -1
  46. package/dist/esm/nextcloud-vue.css +147 -0
  47. package/dist/esm/utils/libraryWidgetKeys.js +1 -0
  48. package/dist/esm/utils/libraryWidgetKeys.js.map +1 -1
  49. package/dist/nextcloud-vue.cjs.js +14135 -12578
  50. package/dist/nextcloud-vue.cjs.js.map +2 -2
  51. package/dist/nextcloud-vue.css +147 -0
  52. package/l10n/en.json +42 -1
  53. package/l10n/nl.json +42 -1
  54. package/package.json +1 -1
  55. package/src/components/CnIndexPage/CnIndexPage.vue +74 -3
  56. package/src/components/CnIndexPage/useNamedSource.js +9 -0
  57. package/src/components/CnReadinessChecklist/CnReadinessChecklist.vue +335 -0
  58. package/src/components/CnReadinessChecklist/index.js +9 -0
  59. package/src/components/CnSchemaRulesWidget/CnSchemaRulesWidget.vue +300 -0
  60. package/src/components/CnSchemaRulesWidget/index.js +10 -0
  61. package/src/components/CnSchemaRulesWidget/schemaRules.js +123 -0
  62. package/src/components/CnSearchIndexStatus/CnSearchIndexStatus.vue +160 -0
  63. package/src/components/CnSearchIndexStatus/index.js +10 -0
  64. package/src/components/CnSearchIndexStatus/searchIndexStatus.js +56 -0
  65. package/src/components/CnShippedConfigurationSection/CnShippedConfigurationSection.vue +328 -0
  66. package/src/components/CnShippedConfigurationSection/index.js +9 -0
  67. package/src/components/CnWidgetGrid/registerDashboardWidgets.js +10 -0
  68. package/src/components/index.js +4 -0
  69. package/src/composables/indexSources.js +116 -16
  70. package/src/css/index-page.css +7 -0
  71. package/src/index.js +4 -0
  72. package/src/utils/libraryWidgetKeys.js +1 -0
@@ -37,6 +37,7 @@ import CnRelatedObjectsWidgetForm from '../CnRelatedObjectsWidgetForm/CnRelatedO
37
37
  import CnRetentionWidget from '../CnRetentionWidget/CnRetentionWidget.vue'
38
38
  import CnSavedViewWidget2 from '../CnSavedViewWidget/CnSavedViewWidget.vue'
39
39
  import CnSavedViewWidgetForm2 from '../CnSavedViewWidgetForm/CnSavedViewWidgetForm.vue'
40
+ import CnSchemaRulesWidget from '../CnSchemaRulesWidget/CnSchemaRulesWidget.vue'
40
41
  import CnStackedBarWidget from '../CnStackedBarWidget/CnStackedBarWidget.vue'
41
42
  import CnStackedBarWidgetForm from '../CnStackedBarWidgetForm/CnStackedBarWidgetForm.vue'
42
43
  import CnStagesWidget from '../CnStagesWidget/CnStagesWidget.vue'
@@ -311,6 +312,15 @@ registerDashboardWidget('retention', {
311
312
  ownsTitle: true,
312
313
  })
313
314
 
315
+ registerDashboardWidget('schema-rules', {
316
+ renderer: CnSchemaRulesWidget,
317
+ form: null,
318
+ defaultContent: { register: '', schema: '', objectId: '' },
319
+ displayName: 'Schema rules',
320
+ icon: 'ScaleBalance',
321
+ surfaces: ['detail-page'],
322
+ })
323
+
314
324
  registerDashboardWidget('plan', {
315
325
  renderer: CnPlanWidget,
316
326
  form: null,
@@ -464,3 +464,7 @@ export { CnBrandStripe } from './CnBrandStripe/index.js'
464
464
  export { CnDuplicateWarning } from './CnDuplicateWarning/index.js'
465
465
  export { CnEndpointNotice } from './CnEndpointNotice/index.js'
466
466
  export { CnCountTablesReport } from './CnCountTablesReport/index.js'
467
+ export { CnShippedConfigurationSection } from './CnShippedConfigurationSection/index.js'
468
+ export { CnSearchIndexStatus } from './CnSearchIndexStatus/index.js'
469
+ export { CnSchemaRulesWidget } from './CnSchemaRulesWidget/index.js'
470
+ export { CnReadinessChecklist } from './CnReadinessChecklist/index.js'
@@ -737,6 +737,14 @@ function readRowsPath(body, path) {
737
737
  return String(path).split('.').reduce((value, key) => (value && typeof value === 'object' ? value[key] : undefined), body)
738
738
  }
739
739
 
740
+ /**
741
+ * The `sourceConfig` keys the endpoint source reads itself; every other key
742
+ * goes along as a query parameter.
743
+ *
744
+ * @type {Array<string>}
745
+ */
746
+ const ENDPOINT_SOURCE_KEYS = ['url', 'rowsPath', 'totalPath', 'searchParam', 'searchFields', 'notePath', 'noteText', 'refusedText']
747
+
740
748
  /**
741
749
  * The endpoint source: rows from an app's own endpoint
742
750
  * (`entitySource: "endpoint"`), for a list that is not OpenRegister objects,
@@ -759,25 +767,46 @@ function readRowsPath(body, path) {
759
767
  * request with that tab's filter, its total read at `sourceConfig.totalPath`
760
768
  * (`total` by default), else the number of rows the answer holds.
761
769
  *
770
+ * Three more keys shape what the page says around the rows:
771
+ * - `searchParam`: the page's search box sends its term as this parameter
772
+ * (`sender`), so the endpoint does the searching.
773
+ * - `notePath` and `noteText`: a value read off the answer (`filterOrder`) and
774
+ * the sentence it is said in ("Filters run in this order: {order}", its one
775
+ * placeholder taking the value); a list
776
+ * is joined with commas. Shown above the rows.
777
+ * - `refusedText`: what a refused load (403) says when the endpoint gave no
778
+ * `message` of its own. A refusal is not an empty list, so the page shows it
779
+ * instead of the rows, and a failed load is not one either.
780
+ * - `searchFields`: the filters the endpoint takes, in the same shape a
781
+ * registered source declares them (`{ status: { param: 'status', single:
782
+ * true } }`), so a filter strip or sidebar on the page narrows the
783
+ * endpoint's query.
784
+ *
785
+ * @param {object} [declared] The page's `sourceConfig`, for `searchParam` and `searchFields`.
786
+ * @param {object} [context] The page's helpers; `translate` is the app's catalogue.
762
787
  * @return {object} The source adapter.
763
788
  * @spec openspec/changes/index-endpoint-source/specs/index-page/spec.md#requirement-an-index-page-can-list-rows-from-an-app-endpoint
764
789
  */
765
- function endpointSource() {
766
- const state = reactive({ rows: [], loading: false })
790
+ function endpointSource(declared = {}, context = {}) {
791
+ const state = reactive({ rows: [], loading: false, refusal: '', failed: false, note: '' })
792
+ const translate = typeof context.translate === 'function' ? context.translate : (text) => text
793
+ const searchParam = typeof declared.searchParam === 'string' && declared.searchParam !== '' ? declared.searchParam : null
794
+ const searchFields = declared.searchFields && typeof declared.searchFields === 'object' && !Array.isArray(declared.searchFields) ? declared.searchFields : null
767
795
  let seq = 0
768
796
  let warned = false
769
797
 
770
798
  /**
771
- * The query parameters for a config: every key but the url and the paths,
772
- * empty values left out, a list joined by commas.
799
+ * The query parameters for a config: every key but the source's own
800
+ * (`url`, the paths, the texts), empty values left out, a list joined by
801
+ * commas.
773
802
  *
774
- * @param {object} rest The config without `url`, `rowsPath` and `totalPath`.
803
+ * @param {object} config The config.
775
804
  * @return {object} The parameters.
776
805
  */
777
- const paramsOf = (rest) => {
806
+ const paramsOf = (config) => {
778
807
  const params = {}
779
- for (const [key, value] of Object.entries(rest)) {
780
- if (value === undefined || value === null || value === '') {
808
+ for (const [key, value] of Object.entries(config)) {
809
+ if (ENDPOINT_SOURCE_KEYS.includes(key) || value === undefined || value === null || value === '') {
781
810
  continue
782
811
  }
783
812
  params[key] = Array.isArray(value) ? value.join(',') : (typeof value === 'object' ? JSON.stringify(value) : value)
@@ -797,15 +826,61 @@ function endpointSource() {
797
826
  return typeof url === 'string' && url !== '' && !Object.hasOwn(config, 'entitySource')
798
827
  }
799
828
 
829
+ /**
830
+ * The note read off an answer, in the page's sentence.
831
+ *
832
+ * @param {object} body The response body.
833
+ * @param {string} [path] Where the value sits.
834
+ * @param {string} [text] The sentence, with one `{placeholder}` where the value goes.
835
+ * @return {string} The note, or '' when there is nothing to say.
836
+ */
837
+ const noteOf = (body, path, text) => {
838
+ if (!path || !body || typeof body !== 'object' || Array.isArray(body)) {
839
+ return ''
840
+ }
841
+ const raw = readRowsPath(body, path)
842
+ const value = Array.isArray(raw) ? raw.filter((v) => v !== null && v !== undefined && v !== '').join(', ') : (raw === null || raw === undefined ? '' : String(raw))
843
+ if (value === '') {
844
+ return ''
845
+ }
846
+ return text ? translate(text).replace(/\{\w+\}/, value) : value
847
+ }
848
+
849
+ /**
850
+ * The sentence a refused load is said in: the endpoint's own, else the
851
+ * page's, else the library's.
852
+ *
853
+ * @param {object} body The refusal's body.
854
+ * @param {string} [text] The page's `refusedText`.
855
+ * @return {string} The sentence.
856
+ */
857
+ const refusalOf = (body, text) => {
858
+ if (body && typeof body.message === 'string' && body.message.trim() !== '') {
859
+ return body.message
860
+ }
861
+ return text ? translate(text) : t('nextcloud-vue', 'You may not read this list.')
862
+ }
863
+
800
864
  return {
865
+ /**
866
+ * The parameter the page's search term is sent as, or null when this
867
+ * endpoint takes no search.
868
+ */
869
+ searchParam,
870
+
871
+ /**
872
+ * The page filters this endpoint takes, and the parameter each becomes.
873
+ */
874
+ searchFields,
875
+
801
876
  /**
802
877
  * Fetch the rows.
803
878
  *
804
879
  * @param {object} config The page's source config with the tab filter merged in.
805
- * @return {Promise<void>} Resolves when loaded; a failed request leaves no rows and rethrows.
880
+ * @return {Promise<void>} Resolves when loaded or refused; a failed request leaves no rows and rethrows.
806
881
  */
807
882
  load: async (config) => {
808
- const { url, rowsPath, totalPath, ...rest } = config || {}
883
+ const { url, rowsPath, notePath, noteText, refusedText } = config || {}
809
884
  const mine = ++seq
810
885
  if (!requestable(config)) {
811
886
  state.rows = []
@@ -817,7 +892,7 @@ function endpointSource() {
817
892
  }
818
893
  return
819
894
  }
820
- const params = paramsOf(rest)
895
+ const params = paramsOf(config)
821
896
  state.loading = true
822
897
  try {
823
898
  const { default: axios } = await import('@nextcloud/axios')
@@ -826,12 +901,22 @@ function endpointSource() {
826
901
  const rows = Array.isArray(body) ? body : readRowsPath(body, rowsPath || 'results')
827
902
  if (mine === seq) {
828
903
  state.rows = Array.isArray(rows) ? rows : []
904
+ state.refusal = ''
905
+ state.failed = false
906
+ state.note = noteOf(body, notePath, noteText)
829
907
  }
830
908
  } catch (error) {
831
- if (mine === seq) {
832
- state.rows = []
909
+ if (mine !== seq) {
910
+ return
911
+ }
912
+ state.rows = []
913
+ state.note = ''
914
+ const refused = error && error.response && error.response.status === 403
915
+ state.refusal = refused ? refusalOf(error.response.data, refusedText) : ''
916
+ state.failed = !refused
917
+ if (!refused) {
918
+ throw error
833
919
  }
834
- throw error
835
920
  } finally {
836
921
  if (mine === seq) {
837
922
  state.loading = false
@@ -850,9 +935,9 @@ function endpointSource() {
850
935
  if (!requestable(config)) {
851
936
  return Number.NaN
852
937
  }
853
- const { url, rowsPath, totalPath, ...rest } = config
938
+ const { url, rowsPath, totalPath } = config
854
939
  const { default: axios } = await import('@nextcloud/axios')
855
- const res = await axios.get(generateUrl(url), { params: paramsOf(rest) })
940
+ const res = await axios.get(generateUrl(url), { params: paramsOf(config) })
856
941
  const body = res ? res.data : null
857
942
  const total = body && typeof body === 'object' && !Array.isArray(body) ? readRowsPath(body, totalPath || 'total') : undefined
858
943
  if (typeof total === 'number' && Number.isFinite(total)) {
@@ -871,6 +956,21 @@ function endpointSource() {
871
956
  * @return {boolean} Whether a load is in flight.
872
957
  */
873
958
  loading: () => state.loading,
959
+
960
+ /**
961
+ * @return {string} The sentence the last load was refused with, or ''.
962
+ */
963
+ refusal: () => state.refusal,
964
+
965
+ /**
966
+ * @return {boolean} Whether the last load failed for another reason than a refusal.
967
+ */
968
+ failed: () => state.failed,
969
+
970
+ /**
971
+ * @return {string} The note read off the last answer, or ''.
972
+ */
973
+ note: () => state.note,
874
974
  }
875
975
  }
876
976
 
@@ -222,6 +222,13 @@
222
222
  color: var(--color-text-maxcontrast);
223
223
  }
224
224
 
225
+ /* A note the named source read off its answer, above the rows. */
226
+ .cn-index-page__source-note {
227
+ margin: 0 0 8px;
228
+ color: var(--color-text-maxcontrast);
229
+ font-size: 0.9em;
230
+ }
231
+
225
232
  .cn-index-page__scope-heading {
226
233
  display: flex;
227
234
  flex-direction: column;
package/src/index.js CHANGED
@@ -275,6 +275,7 @@ export {
275
275
  CnQuicklinksWidget,
276
276
  CnQuicklinksWidgetForm,
277
277
  CnRadioCardsWidget,
278
+ CnReadinessChecklist,
278
279
  CnRecordListWidget,
279
280
  CnRedactionEditor,
280
281
  CnReferencePreview,
@@ -304,6 +305,8 @@ export {
304
305
  CnSavedViewWidgetForm,
305
306
  CnSaveViewDialog,
306
307
  CnSchemaFormDialog,
308
+ CnSchemaRulesWidget,
309
+ CnSearchIndexStatus,
307
310
  CnSearchPage,
308
311
  CnSearchSelect,
309
312
  CnSectionsWidget,
@@ -315,6 +318,7 @@ export {
315
318
  CnSettingsPage,
316
319
  CnSettingsSection,
317
320
  CnSetupWizard,
321
+ CnShippedConfigurationSection,
318
322
  CnSignatureCapture,
319
323
  CnSpendAnalyticsWidget,
320
324
  CnSpendAnalyticsWidgetForm,
@@ -151,6 +151,7 @@ export const DASHBOARD_CATALOG_WIDGET_KEYS = Object.freeze([
151
151
  'retention',
152
152
  'saved-view',
153
153
  'saved-views',
154
+ 'schema-rules',
154
155
  'sections',
155
156
  'settings-form',
156
157
  'spend-analytics',