@api-client/ui 0.0.11 → 0.0.13

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 (242) hide show
  1. package/.eslintrc +8 -0
  2. package/demo/elements/authorization/cc.ts +56 -27
  3. package/demo/elements/index.html +3 -0
  4. package/demo/elements/store/file-picker.html +15 -0
  5. package/demo/elements/store/file-picker.ts +134 -0
  6. package/demo/elements/store/index.html +19 -0
  7. package/demo/store/StorePlugin.js +1 -0
  8. package/dist/bindings/base/FileBindings.d.ts +4 -0
  9. package/dist/bindings/base/FileBindings.d.ts.map +1 -1
  10. package/dist/bindings/base/FileBindings.js +21 -1
  11. package/dist/bindings/base/FileBindings.js.map +1 -1
  12. package/dist/bindings/base/StoreBindings.d.ts +6 -17
  13. package/dist/bindings/base/StoreBindings.d.ts.map +1 -1
  14. package/dist/bindings/base/StoreBindings.js +15 -60
  15. package/dist/bindings/base/StoreBindings.js.map +1 -1
  16. package/dist/bindings/web/WebFileBindings.js +1 -1
  17. package/dist/bindings/web/WebFileBindings.js.map +1 -1
  18. package/dist/define/http/certificate-add.d.ts +9 -0
  19. package/dist/define/http/certificate-add.d.ts.map +1 -0
  20. package/dist/define/http/certificate-add.js +10 -0
  21. package/dist/define/http/certificate-add.js.map +1 -0
  22. package/dist/define/store/file-picker.d.ts +9 -0
  23. package/dist/define/store/file-picker.d.ts.map +1 -0
  24. package/dist/define/store/file-picker.js +10 -0
  25. package/dist/define/store/file-picker.js.map +1 -0
  26. package/dist/define/{files → store}/share-file.d.ts +1 -1
  27. package/dist/define/store/share-file.d.ts.map +1 -0
  28. package/dist/define/{files → store}/share-file.js +2 -2
  29. package/dist/define/store/share-file.js.map +1 -0
  30. package/dist/define/ui/ui-segmented-button-set.d.ts +1 -1
  31. package/dist/define/ui/ui-segmented-button-set.d.ts.map +1 -1
  32. package/dist/define/ui/ui-segmented-button-set.js.map +1 -1
  33. package/dist/elements/authorization/ui/CC.styles.d.ts.map +1 -1
  34. package/dist/elements/authorization/ui/CC.styles.js +4 -9
  35. package/dist/elements/authorization/ui/CC.styles.js.map +1 -1
  36. package/dist/elements/authorization/ui/CcAuthorization.d.ts +14 -29
  37. package/dist/elements/authorization/ui/CcAuthorization.d.ts.map +1 -1
  38. package/dist/elements/authorization/ui/CcAuthorization.js +67 -158
  39. package/dist/elements/authorization/ui/CcAuthorization.js.map +1 -1
  40. package/dist/elements/http/CertificateAdd.element.d.ts +91 -0
  41. package/dist/elements/http/CertificateAdd.element.d.ts.map +1 -0
  42. package/dist/elements/http/CertificateAdd.element.js +389 -0
  43. package/dist/elements/http/CertificateAdd.element.js.map +1 -0
  44. package/dist/elements/http/CertificateAdd.styles.d.ts +3 -0
  45. package/dist/elements/http/CertificateAdd.styles.d.ts.map +1 -0
  46. package/dist/elements/http/CertificateAdd.styles.js +61 -0
  47. package/dist/elements/http/CertificateAdd.styles.js.map +1 -0
  48. package/dist/elements/project/ProjectRunReport.d.ts +2 -1
  49. package/dist/elements/project/ProjectRunReport.d.ts.map +1 -1
  50. package/dist/elements/project/ProjectRunReport.js.map +1 -1
  51. package/dist/elements/store/FilePicker.element.d.ts +87 -0
  52. package/dist/elements/store/FilePicker.element.d.ts.map +1 -0
  53. package/dist/elements/store/FilePicker.element.js +263 -0
  54. package/dist/elements/store/FilePicker.element.js.map +1 -0
  55. package/dist/elements/store/FilePicker.styles.d.ts +3 -0
  56. package/dist/elements/store/FilePicker.styles.d.ts.map +1 -0
  57. package/dist/elements/store/FilePicker.styles.js +73 -0
  58. package/dist/elements/store/FilePicker.styles.js.map +1 -0
  59. package/dist/elements/store/FilesLib.d.ts +10 -0
  60. package/dist/elements/store/FilesLib.d.ts.map +1 -0
  61. package/dist/elements/store/FilesLib.js +38 -0
  62. package/dist/elements/store/FilesLib.js.map +1 -0
  63. package/dist/elements/{files/ShareFile.d.ts → store/ShareFile.element.d.ts} +1 -1
  64. package/dist/elements/store/ShareFile.element.d.ts.map +1 -0
  65. package/dist/elements/{files/ShareFile.js → store/ShareFile.element.js} +1 -1
  66. package/dist/elements/store/ShareFile.element.js.map +1 -0
  67. package/dist/elements/store/ShareFile.styles.d.ts.map +1 -0
  68. package/dist/elements/{files → store}/ShareFile.styles.js.map +1 -1
  69. package/dist/events/EventTypes.d.ts +7 -7
  70. package/dist/events/EventTypes.d.ts.map +1 -1
  71. package/dist/events/EventTypes.js +8 -7
  72. package/dist/events/EventTypes.js.map +1 -1
  73. package/dist/events/Events.d.ts +7 -1
  74. package/dist/events/Events.d.ts.map +1 -1
  75. package/dist/events/Events.js +2 -0
  76. package/dist/events/Events.js.map +1 -1
  77. package/dist/events/FilesystemEvents.d.ts +8 -0
  78. package/dist/events/FilesystemEvents.d.ts.map +1 -0
  79. package/dist/events/FilesystemEvents.js +59 -0
  80. package/dist/events/FilesystemEvents.js.map +1 -0
  81. package/dist/events/HttpClientEvents.d.ts +0 -2
  82. package/dist/events/HttpClientEvents.d.ts.map +1 -1
  83. package/dist/events/HttpClientEvents.js +0 -2
  84. package/dist/events/HttpClientEvents.js.map +1 -1
  85. package/dist/events/StoreEvents.d.ts +8 -1
  86. package/dist/events/StoreEvents.d.ts.map +1 -1
  87. package/dist/events/StoreEvents.js +19 -0
  88. package/dist/events/StoreEvents.js.map +1 -1
  89. package/dist/http-client/idb/Arc18DataUpgrade.d.ts +0 -8
  90. package/dist/http-client/idb/Arc18DataUpgrade.d.ts.map +1 -1
  91. package/dist/http-client/idb/Arc18DataUpgrade.js +11 -206
  92. package/dist/http-client/idb/Arc18DataUpgrade.js.map +1 -1
  93. package/dist/http-client/store/StoreBroadcast.d.ts +0 -5
  94. package/dist/http-client/store/StoreBroadcast.d.ts.map +1 -1
  95. package/dist/http-client/store/StoreBroadcast.js +0 -7
  96. package/dist/http-client/store/StoreBroadcast.js.map +1 -1
  97. package/dist/lib/files/FileUtils.d.ts +9 -0
  98. package/dist/lib/files/FileUtils.d.ts.map +1 -0
  99. package/dist/lib/files/FileUtils.js +13 -0
  100. package/dist/lib/files/FileUtils.js.map +1 -0
  101. package/dist/mixins/RouteMixin.d.ts +4 -0
  102. package/dist/mixins/RouteMixin.d.ts.map +1 -1
  103. package/dist/mixins/RouteMixin.js +1 -0
  104. package/dist/mixins/RouteMixin.js.map +1 -1
  105. package/dist/pages/ApplicationScreen.d.ts +1 -1
  106. package/dist/pages/ApplicationScreen.d.ts.map +1 -1
  107. package/dist/pages/ApplicationScreen.js +4 -2
  108. package/dist/pages/ApplicationScreen.js.map +1 -1
  109. package/dist/pages/api-client/ApiClient.screen.d.ts +4 -6
  110. package/dist/pages/api-client/ApiClient.screen.d.ts.map +1 -1
  111. package/dist/pages/api-client/ApiClient.screen.js +39 -31
  112. package/dist/pages/api-client/ApiClient.screen.js.map +1 -1
  113. package/dist/pages/api-client/ApiClient.styles.d.ts.map +1 -1
  114. package/dist/pages/api-client/ApiClient.styles.js +0 -12
  115. package/dist/pages/api-client/ApiClient.styles.js.map +1 -1
  116. package/dist/pages/api-client/Authenticate.screen.d.ts +1 -1
  117. package/dist/pages/api-client/Authenticate.screen.d.ts.map +1 -1
  118. package/dist/pages/api-client/Authenticate.screen.js +2 -2
  119. package/dist/pages/api-client/Authenticate.screen.js.map +1 -1
  120. package/dist/pages/api-client/pages/Files.page.d.ts +6 -35
  121. package/dist/pages/api-client/pages/Files.page.d.ts.map +1 -1
  122. package/dist/pages/api-client/pages/Files.page.js +45 -141
  123. package/dist/pages/api-client/pages/Files.page.js.map +1 -1
  124. package/dist/pages/api-client/pages/Shared.page.d.ts +1 -5
  125. package/dist/pages/api-client/pages/Shared.page.d.ts.map +1 -1
  126. package/dist/pages/api-client/pages/Shared.page.js +1 -40
  127. package/dist/pages/api-client/pages/Shared.page.js.map +1 -1
  128. package/dist/pages/demo/DemoPage.d.ts +7 -0
  129. package/dist/pages/demo/DemoPage.d.ts.map +1 -1
  130. package/dist/pages/demo/DemoPage.js +14 -0
  131. package/dist/pages/demo/DemoPage.js.map +1 -1
  132. package/dist/store/FileSystem.d.ts +90 -0
  133. package/dist/store/FileSystem.d.ts.map +1 -0
  134. package/dist/store/FileSystem.js +260 -0
  135. package/dist/store/FileSystem.js.map +1 -0
  136. package/dist/styles/global-styles.d.ts.map +1 -1
  137. package/dist/styles/global-styles.js +7 -0
  138. package/dist/styles/global-styles.js.map +1 -1
  139. package/dist/ui/button/SegmentedButtonsSet.d.ts +14 -0
  140. package/dist/ui/button/SegmentedButtonsSet.d.ts.map +1 -1
  141. package/dist/ui/button/SegmentedButtonsSet.js.map +1 -1
  142. package/dist/ui/icons/Icons.d.ts +2 -1
  143. package/dist/ui/icons/Icons.d.ts.map +1 -1
  144. package/dist/ui/icons/Icons.js +1 -0
  145. package/dist/ui/icons/Icons.js.map +1 -1
  146. package/dist/ui/list/UiDropdownList.d.ts +9 -1
  147. package/dist/ui/list/UiDropdownList.d.ts.map +1 -1
  148. package/dist/ui/list/UiDropdownList.js +39 -17
  149. package/dist/ui/list/UiDropdownList.js.map +1 -1
  150. package/dist/ui/list/UiList.d.ts +6 -1
  151. package/dist/ui/list/UiList.d.ts.map +1 -1
  152. package/dist/ui/list/UiList.js +24 -9
  153. package/dist/ui/list/UiList.js.map +1 -1
  154. package/dist/ui/notification/SnackNotifications.d.ts +1 -0
  155. package/dist/ui/notification/SnackNotifications.d.ts.map +1 -1
  156. package/dist/ui/notification/SnackNotifications.js +7 -0
  157. package/dist/ui/notification/SnackNotifications.js.map +1 -1
  158. package/dist/ui/table/DataTable.d.ts +4 -0
  159. package/dist/ui/table/DataTable.d.ts.map +1 -1
  160. package/dist/ui/table/DataTable.js +23 -1
  161. package/dist/ui/table/DataTable.js.map +1 -1
  162. package/package.json +1 -1
  163. package/src/bindings/base/FileBindings.ts +25 -1
  164. package/src/bindings/base/StoreBindings.ts +16 -73
  165. package/src/bindings/web/WebFileBindings.ts +1 -1
  166. package/src/define/http/certificate-add.ts +12 -0
  167. package/src/define/store/file-picker.ts +12 -0
  168. package/src/define/{files → store}/share-file.ts +2 -2
  169. package/src/define/ui/ui-segmented-button-set.ts +1 -1
  170. package/src/elements/authorization/ui/CC.styles.ts +4 -9
  171. package/src/elements/authorization/ui/CcAuthorization.ts +67 -167
  172. package/src/elements/http/CertificateAdd.element.ts +443 -0
  173. package/src/elements/http/CertificateAdd.styles.ts +61 -0
  174. package/src/elements/project/ProjectRunReport.ts +2 -1
  175. package/src/elements/store/FilePicker.element.ts +297 -0
  176. package/src/elements/store/FilePicker.styles.ts +73 -0
  177. package/src/elements/store/FilesLib.ts +32 -0
  178. package/src/events/EventTypes.ts +8 -7
  179. package/src/events/Events.ts +2 -0
  180. package/src/events/FilesystemEvents.ts +63 -0
  181. package/src/events/HttpClientEvents.ts +0 -2
  182. package/src/events/StoreEvents.ts +21 -1
  183. package/src/http-client/idb/Arc18DataUpgrade.ts +84 -84
  184. package/src/http-client/store/StoreBroadcast.ts +0 -8
  185. package/src/lib/files/FileUtils.ts +12 -0
  186. package/src/mixins/RouteMixin.ts +8 -1
  187. package/src/pages/ApplicationScreen.ts +5 -3
  188. package/src/pages/api-client/ApiClient.screen.ts +42 -33
  189. package/src/pages/api-client/ApiClient.styles.ts +0 -12
  190. package/src/pages/api-client/Authenticate.screen.ts +2 -2
  191. package/src/pages/api-client/pages/Files.page.ts +48 -164
  192. package/src/pages/api-client/pages/Shared.page.ts +2 -40
  193. package/src/pages/demo/DemoPage.ts +17 -0
  194. package/src/store/FileSystem.ts +325 -0
  195. package/src/styles/global-styles.ts +7 -0
  196. package/src/ui/button/SegmentedButtonsSet.ts +16 -1
  197. package/src/ui/icons/Icons.ts +2 -1
  198. package/src/ui/list/UiDropdownList.ts +44 -17
  199. package/src/ui/list/UiList.ts +26 -10
  200. package/src/ui/notification/SnackNotifications.ts +8 -0
  201. package/src/ui/table/DataTable.ts +29 -3
  202. package/test/elements/http/BodyFormdataEditorElement.test.ts +458 -454
  203. package/test/elements/http/BodyMultipartEditorElement.test.ts +609 -605
  204. package/test/elements/http/BodyRawEditorElement.test.ts +60 -56
  205. package/test/elements/http/CertificateAdd.test.ts +430 -0
  206. package/test/elements/store/FilePicker.test.ts +241 -0
  207. package/test/env.js +3 -0
  208. package/test/events/EventTypes.test.ts +0 -22
  209. package/test/helpers/StoreHelper.ts +390 -0
  210. package/test/helpers/UiMock.ts +19 -2
  211. package/tsconfig.eslint.json +3 -1
  212. package/web-test-runner.config.mjs +50 -3
  213. package/dist/define/files/share-file.d.ts.map +0 -1
  214. package/dist/define/files/share-file.js.map +0 -1
  215. package/dist/elements/files/ShareFile.d.ts.map +0 -1
  216. package/dist/elements/files/ShareFile.js.map +0 -1
  217. package/dist/elements/files/ShareFile.styles.d.ts.map +0 -1
  218. package/dist/events/http-client/models/CertificatesEvents.d.ts +0 -12
  219. package/dist/events/http-client/models/CertificatesEvents.d.ts.map +0 -1
  220. package/dist/events/http-client/models/CertificatesEvents.js +0 -18
  221. package/dist/events/http-client/models/CertificatesEvents.js.map +0 -1
  222. package/dist/http-client/idb/AuthDataModel.d.ts +0 -60
  223. package/dist/http-client/idb/AuthDataModel.d.ts.map +0 -1
  224. package/dist/http-client/idb/AuthDataModel.js +0 -150
  225. package/dist/http-client/idb/AuthDataModel.js.map +0 -1
  226. package/dist/http-client/idb/HostsModel.d.ts +0 -25
  227. package/dist/http-client/idb/HostsModel.d.ts.map +0 -1
  228. package/dist/http-client/idb/HostsModel.js +0 -82
  229. package/dist/http-client/idb/HostsModel.js.map +0 -1
  230. package/dist/http-client/idb/LegacyMockedStore.d.ts +0 -214
  231. package/dist/http-client/idb/LegacyMockedStore.d.ts.map +0 -1
  232. package/dist/http-client/idb/LegacyMockedStore.js +0 -486
  233. package/dist/http-client/idb/LegacyMockedStore.js.map +0 -1
  234. package/src/events/http-client/models/CertificatesEvents.ts +0 -23
  235. package/src/http-client/idb/AuthDataModel.ts +0 -175
  236. package/src/http-client/idb/HostsModel.ts +0 -125
  237. package/src/http-client/idb/LegacyMockedStore.ts +0 -544
  238. package/test/apic-ui.test.ts +0 -31
  239. /package/dist/elements/{files → store}/ShareFile.styles.d.ts +0 -0
  240. /package/dist/elements/{files → store}/ShareFile.styles.js +0 -0
  241. /package/src/elements/{files/ShareFile.ts → store/ShareFile.element.ts} +0 -0
  242. /package/src/elements/{files → store}/ShareFile.styles.ts +0 -0
@@ -1,14 +1,14 @@
1
1
  /* eslint-disable class-methods-use-this */
2
2
  import 'pouchdb/dist/pouchdb.js';
3
- import { get, set } from 'idb-keyval';
4
- import { IAuthorizationData, IHostRule, HostRuleKind, } from '@api-client/core/build/browser.js'; // Certificate, HttpProject
5
- import { ARCAuthData, HostRule as LegacyHostRule } from '@api-client/core/build/legacy.js'; // Normalizer, ARCProject, ARCSavedRequest, ARCCertificateIndex, ARCRequestCertificate,
3
+ import { get } from 'idb-keyval';
4
+ // import { IAuthorizationData, IHostRule, HostRuleKind, } from '@api-client/core/build/browser.js'; // Certificate, HttpProject
5
+ // import { ARCAuthData, HostRule as LegacyHostRule } from '@api-client/core/build/legacy.js'; // Normalizer, ARCProject, ARCSavedRequest, ARCCertificateIndex, ARCRequestCertificate,
6
6
  // import { LegacyBodyProcessor } from './LegacyBodyProcessor.js';
7
7
  // import { HistoryModel } from './HistoryModel.js';
8
8
  // import { ProjectModel } from './ProjectModel.js';
9
- import { AuthDataModel } from './AuthDataModel.js';
9
+ // import { AuthDataModel } from './AuthDataModel.js';
10
10
  // import { CertificateModel } from './CertificateModel.js';
11
- import { HostsModel } from './HostsModel.js';
11
+ // import { HostsModel } from './HostsModel.js';
12
12
 
13
13
  const upgradeKey = 'CHL5v3fUMx';
14
14
 
@@ -27,38 +27,38 @@ export default class Arc18DataUpgrade {
27
27
  }
28
28
 
29
29
  static async runIfNeeded(): Promise<void> {
30
- const needed = await Arc18DataUpgrade.needsUpgrade();
31
- if (!needed) {
32
- return undefined;
33
- }
34
- const instance = new Arc18DataUpgrade();
35
- return instance.run();
30
+ // const needed = await Arc18DataUpgrade.needsUpgrade();
31
+ // if (!needed) {
32
+ // return undefined;
33
+ // }
34
+ // const instance = new Arc18DataUpgrade();
35
+ // return instance.run();
36
36
  }
37
37
 
38
- /**
39
- * Sets a flag sealing the upgrade. Next call to the `run()` will result with no operation.
40
- */
41
- async seal(): Promise<void> {
42
- await set(upgradeKey, true);
43
- }
38
+ // /**
39
+ // * Sets a flag sealing the upgrade. Next call to the `run()` will result with no operation.
40
+ // */
41
+ // async seal(): Promise<void> {
42
+ // await set(upgradeKey, true);
43
+ // }
44
44
 
45
- async run(): Promise<void> {
46
- await this.upgradeHistory();
47
- // await this.upgradeProjects();
48
- // await this.upgradeSaved();
49
- await this.upgradeAuthData();
50
- // await this.upgradeCertificates();
51
- await this.hostRules();
45
+ // async run(): Promise<void> {
46
+ // await this.upgradeHistory();
47
+ // await this.upgradeProjects();
48
+ // await this.upgradeSaved();
49
+ // await this.upgradeAuthData();
50
+ // await this.upgradeCertificates();
51
+ // await this.hostRules();
52
52
 
53
- await this.seal();
54
- }
53
+ // await this.seal();
54
+ // }
55
55
 
56
- async upgradeHistory(): Promise<void> {
57
- const sourceDb = new PouchDB('history-requests');
58
- await sourceDb.compact();
59
- // const targetDb = new HistoryModel();
60
- // await this._upgradeHistoryPage(sourceDb, targetDb);
61
- }
56
+ // async upgradeHistory(): Promise<void> {
57
+ // const sourceDb = new PouchDB('history-requests');
58
+ // await sourceDb.compact();
59
+ // const targetDb = new HistoryModel();
60
+ // await this._upgradeHistoryPage(sourceDb, targetDb);
61
+ // }
62
62
 
63
63
  // async upgradeProjects(): Promise<void> {
64
64
  // const projectsDb = new PouchDB<ARCProject>('legacy-projects');
@@ -128,32 +128,32 @@ export default class Arc18DataUpgrade {
128
128
  // await targetDb.put(project.toJSON());
129
129
  // }
130
130
 
131
- async upgradeAuthData(): Promise<void> {
132
- const src = new PouchDB<ARCAuthData>('auth-data');
133
- const response = await src.allDocs({ include_docs: true });
134
- const items: IAuthorizationData[] = [];
135
- response.rows.forEach(item => {
136
- const { doc } = item;
137
- if (!doc) {
138
- return;
139
- }
140
- const transformed: IAuthorizationData = {
141
- key: doc._id,
142
- };
143
- if (doc.domain) {
144
- transformed.domain = doc.domain;
145
- }
146
- if (doc.password) {
147
- transformed.password = doc.password;
148
- }
149
- if (doc.password) {
150
- transformed.password = doc.password;
151
- }
152
- items.push(transformed);
153
- });
154
- const model = new AuthDataModel();
155
- await model.putBulk(items);
156
- }
131
+ // async upgradeAuthData(): Promise<void> {
132
+ // const src = new PouchDB<ARCAuthData>('auth-data');
133
+ // const response = await src.allDocs({ include_docs: true });
134
+ // const items: IAuthorizationData[] = [];
135
+ // response.rows.forEach(item => {
136
+ // const { doc } = item;
137
+ // if (!doc) {
138
+ // return;
139
+ // }
140
+ // const transformed: IAuthorizationData = {
141
+ // key: doc._id,
142
+ // };
143
+ // if (doc.domain) {
144
+ // transformed.domain = doc.domain;
145
+ // }
146
+ // if (doc.password) {
147
+ // transformed.password = doc.password;
148
+ // }
149
+ // if (doc.password) {
150
+ // transformed.password = doc.password;
151
+ // }
152
+ // items.push(transformed);
153
+ // });
154
+ // const model = new AuthDataModel();
155
+ // await model.putBulk(items);
156
+ // }
157
157
 
158
158
  // protected async _upgradeHistoryPage(sourceDb: PouchDB.Database, targetDb: HistoryModel, lastKey?: string): Promise<void> {
159
159
  // const opts: PouchDB.Core.AllDocsOptions | PouchDB.Core.AllDocsWithinRangeOptions = {
@@ -216,30 +216,30 @@ export default class Arc18DataUpgrade {
216
216
  // await model.putBulk(upgrades);
217
217
  // }
218
218
 
219
- async hostRules(): Promise<void> {
220
- const srcDb = new PouchDB<LegacyHostRule>('host-rules');
221
- const response = await srcDb.allDocs({ include_docs: true });
222
- const items: IHostRule[] = [];
223
- response.rows.forEach(item => {
224
- const { doc } = item;
225
- if (!doc) {
226
- return;
227
- }
228
- const transformed: IHostRule = {
229
- kind: HostRuleKind,
230
- from: doc.from,
231
- to: doc.to,
232
- key: doc._id,
233
- };
234
- if (doc.comment) {
235
- transformed.comment = doc.comment;
236
- }
237
- if (typeof doc.enabled === 'boolean') {
238
- transformed.enabled = doc.enabled;
239
- }
240
- items.push(transformed);
241
- });
242
- const model = new HostsModel();
243
- await model.putBulk(items);
244
- }
219
+ // async hostRules(): Promise<void> {
220
+ // const srcDb = new PouchDB<LegacyHostRule>('host-rules');
221
+ // const response = await srcDb.allDocs({ include_docs: true });
222
+ // const items: IHostRule[] = [];
223
+ // response.rows.forEach(item => {
224
+ // const { doc } = item;
225
+ // if (!doc) {
226
+ // return;
227
+ // }
228
+ // const transformed: IHostRule = {
229
+ // kind: HostRuleKind,
230
+ // from: doc.from,
231
+ // to: doc.to,
232
+ // key: doc._id,
233
+ // };
234
+ // if (doc.comment) {
235
+ // transformed.comment = doc.comment;
236
+ // }
237
+ // if (typeof doc.enabled === 'boolean') {
238
+ // transformed.enabled = doc.enabled;
239
+ // }
240
+ // items.push(transformed);
241
+ // });
242
+ // const model = new HostsModel();
243
+ // await model.putBulk(items);
244
+ // }
245
245
  }
@@ -55,14 +55,6 @@ export class StoreBroadcast {
55
55
  return '/store/history/ws';
56
56
  }
57
57
 
58
- /**
59
- * The path used to construct a `BroadcastChannel` (or similar)
60
- * to communicate changes between contexts for the Certificates store.
61
- */
62
- static get certificates(): string {
63
- return '/store/certificates';
64
- }
65
-
66
58
  /**
67
59
  * The path used to construct a `BroadcastChannel` (or similar)
68
60
  * to communicate changes between contexts for the History store.
@@ -0,0 +1,12 @@
1
+ export class FileUtils {
2
+ /**
3
+ * Reads the last segment of the file path and returns it as a file name.
4
+ *
5
+ * @param path THe file path.
6
+ */
7
+ static getFileName(path: string): string {
8
+ const delimiter = path.includes('/') ? '/' : '\\';
9
+ const last = path.split(delimiter).pop();
10
+ return last || '';
11
+ }
12
+ }
@@ -101,6 +101,11 @@ export declare class RouteMixinInterface {
101
101
  */
102
102
  static get routes(): IRoute[];
103
103
 
104
+ /**
105
+ * The current route parameters. This is the same what is passed to the route handler.
106
+ */
107
+ protected currentRoute?: IRouteResult;
108
+
104
109
  /**
105
110
  * Initializes the routing.
106
111
  */
@@ -119,6 +124,8 @@ export function RouteMixin<T extends Constructor<Object>>(superClass: T): Constr
119
124
  return []
120
125
  }
121
126
 
127
+ protected currentRoute?: IRouteResult;
128
+
122
129
  constructor(...args: any[]) {
123
130
  super(...args);
124
131
  this._routeHandler = this._routeHandler.bind(this);
@@ -159,7 +166,7 @@ export function RouteMixin<T extends Constructor<Object>>(superClass: T): Constr
159
166
  argument.params = params;
160
167
  }
161
168
  }
162
-
169
+ this.currentRoute = argument;
163
170
  this._callRoute(activeRoute, argument);
164
171
  if (activeRoute.title) {
165
172
  document.title = activeRoute.title;
@@ -144,7 +144,9 @@ export abstract class ApplicationScreen extends RouteMixin(RenderableMixin(Event
144
144
  window.onunhandledrejection = this.unhandledRejectionHandler.bind(this);
145
145
  this.initMediaQueries();
146
146
  this.initStoreChange();
147
- this.configBroadcast.addEventListener('message', this.handleConfigBroadcast.bind(this))
147
+ this.configBroadcast.addEventListener('message', this.handleConfigBroadcast.bind(this));
148
+ // this will use the system-default theme until config is read.
149
+ this.themeActiveCallback();
148
150
  }
149
151
 
150
152
  /**
@@ -325,7 +327,7 @@ export abstract class ApplicationScreen extends RouteMixin(RenderableMixin(Event
325
327
  * Called from the initialize store init flow when the user is not authenticated
326
328
  * and the auth screen is rendered.
327
329
  */
328
- protected async _authHandler(): Promise<void> {
330
+ protected async handleAuthenticate(): Promise<void> {
329
331
  const { store } = this.bindings;
330
332
  await store.auth.authenticate({ updateEnvironment: true });
331
333
  this.authenticated = true;
@@ -509,7 +511,7 @@ export abstract class ApplicationScreen extends RouteMixin(RenderableMixin(Event
509
511
  <div class="auth-required-screen">
510
512
  <h1 class="display-large">Authentication required</h1>
511
513
  <p class="body-large">You are not authenticated. To continue, please, authenticate your account.</p>
512
- <ui-button type="tonal" @click="${this._authHandler}">Authenticate</ui-button>
514
+ <ui-button type="tonal" @click="${this.handleAuthenticate}">Authenticate</ui-button>
513
515
  </div>
514
516
  `;
515
517
  }
@@ -6,6 +6,7 @@ import { IRoute, IRouteResult } from '../../mixins/RouteMixin.js';
6
6
  import pageStyles from './ApiClient.styles.js';
7
7
  import globalStyles from '../../styles/global-styles.js';
8
8
  import typography from '../../styles/m3/typography.module.js';
9
+ import surface from '../../styles/m3/surface.module.js';
9
10
  import dialogStyles from '../../styles/m3/dialog.module.js';
10
11
  import { navigate } from '../../lib/route.js';
11
12
  import { reactive } from '../../lib/decorators.js';
@@ -27,6 +28,7 @@ import '../../define/ui/ui-icon-button.js';
27
28
  import '../../define/ui/ui-text-field.js';
28
29
  import '../../define/ui/ui-dropdown-list.js';
29
30
  import '../../define/ui/ui-divider.js';
31
+ import '../../define/http/certificate-add.js';
30
32
 
31
33
  export interface PageInit extends ApplicationInit {
32
34
  idb: HttpClientStoreBindings;
@@ -48,11 +50,12 @@ export default class ApiClientScreen extends ApplicationScreen {
48
50
  { pattern: '/shared/(?<key>.*)', method: 'sharedRoute', name: 'Shares', title: 'Shared with you' },
49
51
  { pattern: '/trash', method: 'trashRoute', name: 'Trash', title: 'Trash' },
50
52
  { pattern: '/settings', method: 'settingsRoute', name: 'Settings', title: 'Settings' },
53
+ { pattern: '/certificates/add/?(?<parent>.*)', method: 'addCertRoute', name: 'Add certificate', title: 'Add certificate' },
51
54
  ];
52
55
  }
53
56
 
54
57
  static get styles(): CSSResult[] {
55
- return [globalStyles, pageStyles, typography, dialogStyles, DataTable.styles];
58
+ return [globalStyles, pageStyles, typography, dialogStyles, DataTable.styles, surface];
56
59
  }
57
60
 
58
61
  /**
@@ -99,8 +102,6 @@ export default class ApiClientScreen extends ApplicationScreen {
99
102
 
100
103
  protected settings = new SettingsPage(this);
101
104
 
102
- filesChannel = new BroadcastChannel(StoreBroadcast.files);
103
-
104
105
  spacesChannel = new BroadcastChannel(StoreBroadcast.spaces);
105
106
 
106
107
  trashChannel = new BroadcastChannel(StoreBroadcast.trash);
@@ -136,7 +137,6 @@ export default class ApiClientScreen extends ApplicationScreen {
136
137
  await this.bindings.store.observeTrash();
137
138
  }
138
139
  await this.loadUser();
139
- this.filesChannel.addEventListener('message', this.fileMetaMessageHandler.bind(this));
140
140
  this.spacesChannel.addEventListener('message', this.spacesMessageHandler.bind(this));
141
141
  this.trashChannel.addEventListener('message', this.trashMessageHandler.bind(this));
142
142
  this.initializeRouting();
@@ -146,8 +146,8 @@ export default class ApiClientScreen extends ApplicationScreen {
146
146
  reset(): void {
147
147
  this.spaces = [];
148
148
  this.spacesCursor = undefined;
149
- this.files.resetList();
150
- this.shared.resetList();
149
+ this.files.fs.resetList();
150
+ this.shared.fs.resetList();
151
151
  this.trash.resetList();
152
152
  }
153
153
 
@@ -249,16 +249,16 @@ export default class ApiClientScreen extends ApplicationScreen {
249
249
  this.bindings.store.space = this.selectedSpace;
250
250
 
251
251
  this.render();
252
- this.files.resetList();
253
- this.shared.resetList();
252
+ this.files.fs.resetList();
253
+ this.shared.fs.resetList();
254
254
  this.trash.resetList();
255
255
  if (this.page === 'files') {
256
- this.files.readFiles();
256
+ this.files.fs.debounceQuery();
257
257
  navigate('files'); // remove any folder info
258
258
  } else if (this.page === 'trash') {
259
259
  this.trash.readFiles();
260
260
  } else if (this.page === 'shared') {
261
- this.shared.readFiles();
261
+ this.shared.fs.debounceQuery();
262
262
  }
263
263
  this.storeLastSpaceKey(this.selectedSpace);
264
264
  }
@@ -279,18 +279,6 @@ export default class ApiClientScreen extends ApplicationScreen {
279
279
  this.spacesCursor = cursor;
280
280
  }
281
281
 
282
- /**
283
- * A handler for the broadcast channel message which informs about changes to files meta.
284
- * The function distributes changes between pages
285
- */
286
- protected fileMetaMessageHandler(e: MessageEvent): void {
287
- const event = e.data as BroadcastEvent;
288
- if (event.space === this.selectedSpace) {
289
- this.files.handleFileEvent(event);
290
- }
291
- this.shared.handleFileEvent(event);
292
- }
293
-
294
282
  protected trashMessageHandler(e: MessageEvent): void {
295
283
  const event = e.data as BroadcastEvent;
296
284
  if (event.space !== this.selectedSpace) {
@@ -343,13 +331,13 @@ export default class ApiClientScreen extends ApplicationScreen {
343
331
  this.resetRoute();
344
332
  this.page = 'files';
345
333
  const folder = info.params && info.params.key as string | undefined;
346
- const folderChanged = this.files.folder !== folder;
334
+ const folderChanged = this.files.fs.parent !== folder;
347
335
  if (folderChanged) {
348
- this.files.folder = folder;
349
- this.files.resetList();
336
+ this.files.fs.parent = folder;
337
+ this.files.fs.resetList();
350
338
  }
351
- if (!this.files.files.length || folderChanged) {
352
- this.files.readFiles();
339
+ if (!this.files.fs.files.length || folderChanged) {
340
+ this.files.fs.debounceQuery();
353
341
  }
354
342
  }
355
343
 
@@ -357,13 +345,13 @@ export default class ApiClientScreen extends ApplicationScreen {
357
345
  this.resetRoute();
358
346
  this.page = 'shared';
359
347
  const folder = info.params && info.params.key as string | undefined;
360
- const folderChanged = this.shared.folder !== folder;
348
+ const folderChanged = this.shared.fs.parent !== folder;
361
349
  if (folderChanged) {
362
- this.shared.folder = folder;
363
- this.shared.resetList();
350
+ this.shared.fs.parent = folder;
351
+ this.shared.fs.resetList();
364
352
  }
365
- if (!this.shared.files.length || folderChanged) {
366
- this.shared.readFiles();
353
+ if (!this.shared.fs.files.length || folderChanged) {
354
+ this.shared.fs.debounceQuery();
367
355
  }
368
356
  }
369
357
 
@@ -380,6 +368,15 @@ export default class ApiClientScreen extends ApplicationScreen {
380
368
  this.page = 'settings';
381
369
  }
382
370
 
371
+ protected addCertRoute(): void {
372
+ this.resetRoute();
373
+ this.page = 'add-cert';
374
+ }
375
+
376
+ protected handleCertificateClose(): void {
377
+ window.history.back();
378
+ }
379
+
383
380
  protected mainNavHandler(e: Event): void {
384
381
  const target = e.target as HTMLElement;
385
382
  const { page } = target.dataset;
@@ -637,7 +634,7 @@ export default class ApiClientScreen extends ApplicationScreen {
637
634
  protected override mainTemplate(): TemplateResult {
638
635
  return html`
639
636
  <main class="body-medium">
640
- <div class="content">
637
+ <div class="content surface1">
641
638
  ${this.renderPage()}
642
639
  </div>
643
640
  </main>
@@ -653,6 +650,7 @@ export default class ApiClientScreen extends ApplicationScreen {
653
650
  case 'shared': return this.shared.render();
654
651
  case 'trash': return this.trash.render();
655
652
  case 'settings': return this.settings.render();
653
+ case 'add-cert': return this.renderAddCertificate();
656
654
  default: return this.render404();
657
655
  }
658
656
  }
@@ -739,4 +737,15 @@ export default class ApiClientScreen extends ApplicationScreen {
739
737
  </dialog>
740
738
  `;
741
739
  }
740
+
741
+ protected renderAddCertificate(): TemplateResult {
742
+ const { currentRoute, currentSpace } = this;
743
+ const parent = currentRoute && currentRoute.params && currentRoute.params.parent as string | undefined;
744
+ const space = currentSpace && currentSpace.key;
745
+ return html`
746
+ <h2 class="headline-small">Add Certificate</h2>
747
+ <p class="body-medium">Import a certificate to use it in your HTTP projects. Note, imported certificate cannot be changed.</p>
748
+ <certificate-add .folder="${parent}" .space="${space}" @close="${this.handleCertificateClose}"></certificate-add>
749
+ `;
750
+ }
742
751
  }
@@ -174,8 +174,6 @@ main {
174
174
 
175
175
  main .content {
176
176
  padding: 20px;
177
- position: relative;
178
- z-index: 0;
179
177
  border-radius: inherit;
180
178
 
181
179
  flex: 1;
@@ -184,16 +182,6 @@ main .content {
184
182
 
185
183
  overflow: hidden;
186
184
  }
187
-
188
- main .content::before {
189
- content: '';
190
- background-color: var(--md-sys-color-primary);
191
- opacity: .05;
192
- position: absolute;
193
- inset: 0;
194
- border-radius: inherit;
195
- }
196
-
197
185
  main .content > * {
198
186
  position: relative;
199
187
  z-index: 1;
@@ -66,7 +66,7 @@ export default class AuthenticateScreen extends ApplicationScreen {
66
66
  return env;
67
67
  }
68
68
 
69
- protected handleAuthenticate(): void {
69
+ protected async handleAuth(): Promise<void> {
70
70
  const { environment } = this;
71
71
  if (!environment) {
72
72
  this.environmentError = 'Environment information not found. Go back to the previous page.';
@@ -146,7 +146,7 @@ export default class AuthenticateScreen extends ApplicationScreen {
146
146
  <div class="action">
147
147
  <ui-button
148
148
  type="filled"
149
- @click="${this.handleAuthenticate}"
149
+ @click="${this.handleAuth}"
150
150
  >Authenticate</ui-button>
151
151
  </div>
152
152
  `;