killbill-aviate 2.6.0.pre.4 → 2.6.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 04c757576e28f29bf5cefa3ddba08e5d53ae37f7e2b9c17e9ab7ec6ea2d46a03
4
- data.tar.gz: a22610126ff87c8f1383e511ebc7b349d58a305fce6a9e5a897a6390108fbe10
3
+ metadata.gz: b3446aebec7a74a1e043bc9105b8ac2181adc4564c7ba611047d53bd43d38dab
4
+ data.tar.gz: e7abecab78943c5616a7b8849d9072d8bb1dccd6d9c5c5da8dc5522728977aa6
5
5
  SHA512:
6
- metadata.gz: 031af30f897ca1d47947a9fe6194538a2da0c7a10a746b08eb9e87d9bf7edb9902cdc318b135d377d4033e66926c088087e65462fdd5bcda6c1d1f7e4893d181
7
- data.tar.gz: 851ec47e099055681c08fe39103c5811e74499ddc73c62dc560afe1686d954347abc18cd507fba107013f50051d28c312203f1a4fb8e29e7485a80786ed6e9cb
6
+ metadata.gz: f7f4443b487ce5d281b49ca59024fc96fbe43ab2e1bbdbd363f94b39cc71cf5da8dfba40d25697185d6ad4a3f4e55749060ea0828dcb56077bfbdfb910e5e474
7
+ data.tar.gz: 23582ae87facc98848943a62dda9dd8dd1d3a41dd3efa1fe132f6243d738469367546b181c02b1f4c8112a1a6ba98bb946984ef3aea936503a5e854f70d0c94f
data/README.md CHANGED
@@ -22,6 +22,66 @@ This app lets you:
22
22
  * Apply payments to one or multiple invoices.
23
23
  * Identify invoice line items that are unpaid (e.g. if the customer is disputing a subset of the invoice).
24
24
 
25
+ Sidebar
26
+ -------
27
+
28
+ When the user is signed into Aviate, every Kaui page (and every Aviate page) is rendered within the Aviate sidebar
29
+ (same navigation as the Aviate web app), itself rendered within the host layout (`Aviate.layout`, e.g. Kaui's layout).
30
+ Kaui keeps its URLs, controllers and layout: nothing is mirrored under another path. The Kaui navbar (search, create
31
+ account, tenant, user menu, logout) stays on top of the page, to the right of the sidebar; only its logo is hidden, since the
32
+ sidebar shows the Aviate logo. On small screens the sidebar becomes an off-canvas menu.
33
+
34
+ The Billing Operations links point to the Kaui pages. Kaui lists subscriptions per account, so Subscriptions goes through
35
+ `/aviate/subscriptions` (it only redirects), which makes the same choice as the managed "getting started" flow: it opens
36
+ the subscriptions of the first account created in the tenant (Kaui shows the newest accounts first, so it is the last row of its
37
+ accounts table), or the new subscription form while that account has none, or the new account form when there is no
38
+ account yet. The other links point to the Aviate web apps (the hosted Aviate unless configured, see below).
39
+
40
+ ### When is the sidebar displayed
41
+
42
+ | `SSO_SIDE_BAR` | Behavior |
43
+ |-------------------|--------------------------------------------------------------------------------------------------|
44
+ | `true` (default) | Only for users signed into Aviate: the session flag below is set, or the `jwt_token` cookie of the Aviate plugin sign-in is present. Kaui-only users keep the plain Kaui layout, and so does a local Kaui, where there is no Aviate SSO. |
45
+ | `false` | For everyone, with no SSO check. Use it to try the sidebar locally, or on a self-hosted deployment (no Aviate SSO). |
46
+
47
+ The setting is read at boot, from the `aviate.sso_side_bar` system property first, then from the `SSO_SIDE_BAR` environment variable, and only `false` (any case) turns the SSO condition off: unset, empty or any other value
48
+ keeps it, so a typo never displays the sidebar to every user. A host initializer can set it in code instead:
49
+
50
+ ```ruby
51
+ # config/initializers/aviate.rb
52
+ Aviate.sso_sidebar = false # true (default): only for users signed into Aviate; false: for everyone
53
+ ```
54
+
55
+ The Aviate SSO sets the flag: once the Aviate token has been verified and the Kaui session created, the host must
56
+ store `session[:aviate_sso] = true` (`Aviate::SSO_SESSION_KEY`). The flag is dropped with the session, i.e. on sign-out.
57
+
58
+ ### Links to the Aviate web apps
59
+
60
+ Each base URL is read at boot from a JVM system property first, then from an environment variable (the order Kaui
61
+ uses for its own settings). On a WAR deployment, set the system properties next to the other `-Dkaui.*` ones, in
62
+ `CATALINA_OPTS`; in a container or any other setup, set the environment variables (include any sub-path, no trailing
63
+ slash needed):
64
+
65
+ | System property | Environment variable | Links | Default (hosted Aviate) |
66
+ |--------------------------|--------------------------|--------------------------------------------------|--------------------------------------|
67
+ | `aviate.base.main_url` | `AVIATE_BASE_MAIN_URL` | Onboarding | `https://aviate.killbill.io` |
68
+ | `aviate.base.admin_url` | `AVIATE_BASE_ADMIN_URL` | Catalog, Plugins, Invoices, Email, Settings, API | `https://aviate.killbill.io/admin` |
69
+ | `aviate.base.quote_url` | `AVIATE_BASE_QUOTE_URL` | Revenue section, Quote template | `https://aviate.killbill.io/quote` |
70
+ | `aviate.base.health_url` | `AVIATE_BASE_HEALTH_URL` | Health | `https://aviate.killbill.io/health` |
71
+
72
+ ```
73
+ # Tomcat, e.g. a staging Aviate (CATALINA_OPTS)
74
+ -Daviate.base.main_url=https://dev.aviate.killbill.dev -Daviate.base.admin_url=https://dev.aviate.killbill.dev/admin \
75
+ -Daviate.base.quote_url=https://dev.aviate.killbill.dev/quote -Daviate.base.health_url=https://dev.aviate.killbill.dev/health
76
+ ```
77
+
78
+ A setting that is not set at all falls back to the hosted Aviate (`https://aviate.killbill.io`), so a Kaui used with the
79
+ hosted Aviate needs no configuration. In development, an unset setting falls back to the local aviate-dev ports
80
+ (`http://localhost:5173`, `:5174/admin`, `:5175/quote`, `:5177/health`) instead. A setting that is set to an empty value
81
+ (`-Daviate.base.quote_url=` or `AVIATE_BASE_QUOTE_URL=`) disables the link. A self-hosted Aviate, served from another
82
+ origin than the hosted one, must set all four. A host initializer can still override `Aviate.sidebar_base_urls`
83
+ (hash with the keys `main`, `admin`, `quote` and `health`).
84
+
25
85
  Getting Started
26
86
  ---------------
27
87
 
@@ -40,3 +100,9 @@ For integrate run with [killbill-admin-ui-standalone](https://github.com/killbil
40
100
  # gem 'killbill-aviate'
41
101
  gem 'killbill-aviate', :path => '../killbill-aviate-ui'
42
102
  ```
103
+
104
+ When you install Aviate in a Kaui, also configure the base URLs of the Aviate web apps unless it uses the hosted Aviate
105
+ (`https://aviate.killbill.io`, the default): `aviate.base.main_url`, `aviate.base.admin_url`, `aviate.base.quote_url` and
106
+ `aviate.base.health_url` (system properties), or `AVIATE_BASE_MAIN_URL`, `AVIATE_BASE_ADMIN_URL`, `AVIATE_BASE_QUOTE_URL`
107
+ and `AVIATE_BASE_HEALTH_URL` (environment variables). A staging environment, or a self-hosted Aviate, needs all four, and
108
+ Kaui must be restarted for them to apply. See [Links to the Aviate web apps](#links-to-the-aviate-web-apps).
@@ -0,0 +1,99 @@
1
+ // Aviate layout: behavior of the sidebar shell (see aviate/layouts/sidebar/_shell.html.erb).
2
+ // Linked by the shell itself so it also runs within host layouts. Dependency-free and idempotent.
3
+ (function () {
4
+ 'use strict';
5
+
6
+ // Same storage key and defaults as MainNavigation.vue
7
+ var SECTIONS_STORAGE_KEY = 'aviate-sidebar-sections';
8
+
9
+ function loadSections() {
10
+ try {
11
+ var stored = window.localStorage.getItem(SECTIONS_STORAGE_KEY);
12
+ if (stored) return JSON.parse(stored) || {};
13
+ } catch (e) {
14
+ // ignore malformed data / unavailable storage
15
+ }
16
+ return {};
17
+ }
18
+
19
+ function saveSections(sections) {
20
+ try {
21
+ window.localStorage.setItem(SECTIONS_STORAGE_KEY, JSON.stringify(sections));
22
+ } catch (e) {
23
+ // ignore unavailable storage
24
+ }
25
+ }
26
+
27
+ function initSections(sidebar) {
28
+ var sections = loadSections();
29
+
30
+ sidebar.querySelectorAll('[data-aviate-sidebar-section]').forEach(function (section) {
31
+ var key = section.getAttribute('data-aviate-sidebar-section');
32
+ var toggle = section.querySelector('[data-aviate-sidebar-section-toggle]');
33
+
34
+ function apply(open) {
35
+ section.classList.toggle('is-collapsed', !open);
36
+ toggle.setAttribute('aria-expanded', open ? 'true' : 'false');
37
+ }
38
+
39
+ apply(sections[key] !== false);
40
+ toggle.addEventListener('click', function () {
41
+ var open = section.classList.contains('is-collapsed');
42
+ sections[key] = open;
43
+ saveSections(sections);
44
+ apply(open);
45
+ });
46
+ });
47
+ }
48
+
49
+ function initOffCanvas(shell, sidebar) {
50
+ var openButton = shell.querySelector('[data-aviate-sidebar-open]');
51
+
52
+ function setOpen(open) {
53
+ shell.classList.toggle('is-sidebar-open', open);
54
+ document.body.classList.toggle('aviate-sidebar-scroll-locked', open);
55
+ if (openButton) openButton.setAttribute('aria-expanded', open ? 'true' : 'false');
56
+ if (open) {
57
+ var firstLink = sidebar.querySelector('a, button');
58
+ if (firstLink) firstLink.focus();
59
+ } else if (openButton && sidebar.contains(document.activeElement)) {
60
+ openButton.focus();
61
+ }
62
+ }
63
+
64
+ if (openButton) {
65
+ openButton.addEventListener('click', function () { setOpen(true); });
66
+ }
67
+ shell.querySelectorAll('[data-aviate-sidebar-close]').forEach(function (el) {
68
+ el.addEventListener('click', function () { setOpen(false); });
69
+ });
70
+ document.addEventListener('keydown', function (event) {
71
+ if (event.key === 'Escape' && shell.classList.contains('is-sidebar-open')) setOpen(false);
72
+ });
73
+
74
+ var desktop = window.matchMedia('(min-width: 62rem)');
75
+ var onBreakpointChange = function () { if (desktop.matches) setOpen(false); };
76
+ if (desktop.addEventListener) {
77
+ desktop.addEventListener('change', onBreakpointChange);
78
+ } else if (desktop.addListener) {
79
+ desktop.addListener(onBreakpointChange);
80
+ }
81
+ }
82
+
83
+ function init() {
84
+ var shell = document.querySelector('[data-aviate-shell]');
85
+ if (!shell || shell.getAttribute('data-aviate-initialized') === 'true') return;
86
+ var sidebar = shell.querySelector('[data-aviate-sidebar]');
87
+ if (!sidebar) return;
88
+ shell.setAttribute('data-aviate-initialized', 'true');
89
+
90
+ initSections(sidebar);
91
+ initOffCanvas(shell, sidebar);
92
+ }
93
+
94
+ if (document.readyState === 'loading') {
95
+ document.addEventListener('DOMContentLoaded', init);
96
+ } else {
97
+ init();
98
+ }
99
+ })();
@@ -0,0 +1,431 @@
1
+ /*
2
+ * Aviate layout: sidebar shell displayed on every Aviate page (see aviate/layouts/aviate_sidebar).
3
+ * Linked by the shell itself (not by aviate_application.css), so that it is also loaded when the
4
+ * engine renders within a host layout such as KAUI's.
5
+ *
6
+ * Mirrors the Sidebar / MainNavigation components of @killbill/vue-aviate-components. Colors and
7
+ * typography only use the design tokens of killbill-assets-ui (assets/tokens.css); no token is redefined.
8
+ */
9
+
10
+ /* Host layout integration: the shell is full-bleed (no host card margin, no host background around it) */
11
+ .auth-container:has(> .aviate-shell),
12
+ .aviate-application-container:has(> .aviate-shell) {
13
+ overflow: visible;
14
+ padding-left: 0;
15
+ padding-right: 0;
16
+ }
17
+
18
+ body:has(.aviate-shell) {
19
+ background-color: var(--kb-surface-container-lowest);
20
+ }
21
+
22
+ /*
23
+ * Kaui centers its pages in fixed-width wrappers (.container 75rem, .kaui-container 80rem, and 80rem on the wallets and
24
+ * payment pages). Next to the sidebar they leave a wide empty band on both sides of the page on large screens, so the
25
+ * page uses the whole width left by the sidebar instead (the shell content already provides the padding).
26
+ */
27
+ body:has(.aviate-shell) .container,
28
+ body:has(.aviate-shell) .kaui-container,
29
+ body:has(.aviate-shell) .wallets-index .wallets,
30
+ body:has(.aviate-shell) .payments-show .payments {
31
+ max-width: none;
32
+ }
33
+
34
+ /*
35
+ * The host navbar (search, create account, tenant, user menu, logout) stays on top of the page content: only its
36
+ * logo is hidden, since the sidebar already shows the Aviate logo.
37
+ * !important: the Kaui navbar wrapper uses the Bootstrap utility class d-flex, which is itself !important.
38
+ */
39
+ body:has(.aviate-shell) > header div:has(> a > img[alt='Kill Bill Logo']) {
40
+ display: none !important;
41
+ }
42
+
43
+ /* Large screens: the sidebar is fixed and as tall as the window; the navbar, alerts, page and footer sit to its right */
44
+ @media (min-width: 62rem) {
45
+ body:has(.aviate-shell) {
46
+ padding-left: 16rem;
47
+ }
48
+ }
49
+
50
+ .aviate-icon-sprite {
51
+ position: absolute;
52
+ width: 0;
53
+ height: 0;
54
+ overflow: hidden;
55
+ }
56
+
57
+ .aviate-shell {
58
+ display: flex;
59
+ align-items: stretch;
60
+ min-height: 100vh;
61
+ background-color: var(--kb-surface-container-lowest);
62
+ text-align: left;
63
+ }
64
+
65
+ .aviate-shell-main {
66
+ display: flex;
67
+ flex: 1 1 auto;
68
+ flex-direction: column;
69
+ min-width: 0;
70
+ }
71
+
72
+ .aviate-shell-content {
73
+ flex: 1 1 auto;
74
+ min-width: 0;
75
+ padding: 1.5rem 1.5rem 2.5rem;
76
+ }
77
+
78
+ /* ── Sidebar ─────────────────────────────────────────────────────── */
79
+
80
+ .aviate-sidebar {
81
+ position: fixed;
82
+ top: 0;
83
+ bottom: 0;
84
+ left: 0;
85
+ z-index: 1030;
86
+ display: flex;
87
+ flex-direction: column;
88
+ width: 16rem;
89
+ height: 100vh;
90
+ height: 100dvh;
91
+ background-color: var(--kb-surface-container-lowest);
92
+ border-right: 0.0625rem solid var(--kb-outline-primary);
93
+ }
94
+
95
+ .aviate-sidebar-header {
96
+ display: flex;
97
+ align-items: center;
98
+ padding: 1.5rem;
99
+ }
100
+
101
+ .aviate-sidebar-logo-link {
102
+ display: inline-flex;
103
+ align-items: center;
104
+ }
105
+
106
+ .aviate-sidebar-logo {
107
+ width: auto;
108
+ height: 2rem;
109
+ }
110
+
111
+ .aviate-sidebar-close {
112
+ display: none;
113
+ }
114
+
115
+ .aviate-sidebar-nav {
116
+ flex: 1 1 auto;
117
+ overflow-y: auto;
118
+ padding: 0.5rem 0;
119
+ }
120
+
121
+ .aviate-sidebar-nav::-webkit-scrollbar {
122
+ width: 0.5rem;
123
+ }
124
+
125
+ .aviate-sidebar-nav::-webkit-scrollbar-track {
126
+ background-color: var(--kb-surface-container);
127
+ }
128
+
129
+ .aviate-sidebar-nav::-webkit-scrollbar-thumb {
130
+ background-color: var(--kb-outline-secondary);
131
+ border-radius: 9999px;
132
+ }
133
+
134
+ .aviate-sidebar-nav::-webkit-scrollbar-thumb:hover {
135
+ background-color: var(--kb-outline-tertiary);
136
+ }
137
+
138
+ .aviate-sidebar ul.aviate-sidebar-list {
139
+ display: flex;
140
+ flex-direction: column;
141
+ gap: 0.25rem;
142
+ margin: 0.25rem 0 0;
143
+ padding: 0;
144
+ list-style: none;
145
+ }
146
+
147
+ .aviate-sidebar ul.aviate-sidebar-primary {
148
+ margin: 0;
149
+ padding: 0 1rem 1rem;
150
+ }
151
+
152
+ .aviate-sidebar-section {
153
+ padding: 0 1rem 1rem;
154
+ }
155
+
156
+ .aviate-sidebar-section-toggle {
157
+ display: flex;
158
+ align-items: center;
159
+ justify-content: space-between;
160
+ width: 100%;
161
+ padding: 0.5rem 0.75rem;
162
+ border: 0;
163
+ border-radius: 0.375rem;
164
+ background: transparent;
165
+ font: var(--kb-label-medium);
166
+ color: var(--kb-on-surface-secondary);
167
+ text-transform: uppercase;
168
+ transition: background-color 0.2s;
169
+ }
170
+
171
+ .aviate-sidebar-section-toggle:hover {
172
+ background-color: var(--kb-surface-container-low);
173
+ }
174
+
175
+ .aviate-sidebar-chevron {
176
+ width: 1rem;
177
+ height: 1rem;
178
+ color: var(--kb-on-surface-tertiary);
179
+ transform: rotate(180deg);
180
+ transition: transform 0.2s;
181
+ }
182
+
183
+ .aviate-sidebar-section.is-collapsed .aviate-sidebar-chevron {
184
+ transform: none;
185
+ }
186
+
187
+ .aviate-sidebar-section.is-collapsed .aviate-sidebar-list {
188
+ display: none;
189
+ }
190
+
191
+ .aviate-sidebar .aviate-sidebar-link {
192
+ display: flex;
193
+ align-items: center;
194
+ width: 100%;
195
+ padding: 0.5rem 0.75rem;
196
+ border-radius: 0.375rem;
197
+ font: var(--kb-body-medium);
198
+ color: var(--kb-on-surface-primary);
199
+ text-decoration: none;
200
+ transition: background-color 0.2s, color 0.2s;
201
+ }
202
+
203
+ .aviate-sidebar a.aviate-sidebar-link:hover,
204
+ .aviate-sidebar a.aviate-sidebar-link:focus-visible {
205
+ background-color: var(--kb-surface-container);
206
+ color: var(--kb-on-surface-primary);
207
+ text-decoration: none;
208
+ }
209
+
210
+ .aviate-sidebar .aviate-sidebar-link.is-active {
211
+ background-color: var(--kb-surface-container);
212
+ font: var(--kb-title-small);
213
+ }
214
+
215
+ .aviate-sidebar-icon {
216
+ flex-shrink: 0;
217
+ width: 1.25rem;
218
+ height: 1.25rem;
219
+ margin-right: 0.75rem;
220
+ color: var(--kb-on-surface-quaternary);
221
+ }
222
+
223
+ .aviate-sidebar-link.is-active .aviate-sidebar-icon {
224
+ color: var(--kb-primary-pressed);
225
+ }
226
+
227
+ .aviate-sidebar-link.is-locked {
228
+ cursor: not-allowed;
229
+ opacity: 0.75;
230
+ }
231
+
232
+ .aviate-sidebar-link.is-disabled {
233
+ cursor: not-allowed;
234
+ opacity: 0.5;
235
+ }
236
+
237
+ .aviate-sidebar-trailing-icon {
238
+ flex-shrink: 0;
239
+ width: 1rem;
240
+ height: 1rem;
241
+ margin-left: auto;
242
+ color: var(--kb-on-surface-quaternary);
243
+ }
244
+
245
+ .aviate-sidebar-truncate {
246
+ min-width: 0;
247
+ overflow: hidden;
248
+ text-overflow: ellipsis;
249
+ white-space: nowrap;
250
+ }
251
+
252
+ /* Small-screen top bar (hidden on desktop) */
253
+
254
+ .aviate-shell-topbar {
255
+ display: none;
256
+ }
257
+
258
+ .aviate-sidebar-backdrop {
259
+ display: none;
260
+ }
261
+
262
+ /* ── Responsive: off-canvas sidebar ─────────────────────────────── */
263
+
264
+ @media (max-width: 61.9375rem) {
265
+ .aviate-shell-topbar {
266
+ position: sticky;
267
+ top: 0;
268
+ z-index: 1020;
269
+ display: flex;
270
+ align-items: center;
271
+ gap: 0.75rem;
272
+ padding: 0.75rem 1rem;
273
+ background-color: var(--kb-surface-container-lowest);
274
+ border-bottom: 0.0625rem solid var(--kb-outline-primary);
275
+ }
276
+
277
+ .aviate-shell-topbar-logo .aviate-sidebar-logo {
278
+ height: 1.75rem;
279
+ }
280
+
281
+ .aviate-sidebar-toggle {
282
+ display: inline-flex;
283
+ flex-shrink: 0;
284
+ align-items: center;
285
+ justify-content: center;
286
+ width: 2.5rem;
287
+ height: 2.5rem;
288
+ padding: 0;
289
+ border: 0.0625rem solid var(--kb-outline-secondary);
290
+ border-radius: 0.5rem;
291
+ background-color: var(--kb-surface-container-lowest);
292
+ color: var(--kb-on-surface-secondary);
293
+ }
294
+
295
+ .aviate-sidebar-toggle:hover {
296
+ background-color: var(--kb-surface-container-low);
297
+ }
298
+
299
+ .aviate-sidebar-toggle-icon,
300
+ .aviate-sidebar-close-icon {
301
+ flex-shrink: 0;
302
+ width: 1.25rem;
303
+ height: 1.25rem;
304
+ }
305
+
306
+ .aviate-sidebar {
307
+ position: fixed;
308
+ top: 0;
309
+ bottom: 0;
310
+ left: 0;
311
+ z-index: 1045;
312
+ height: 100vh;
313
+ height: 100dvh;
314
+ transform: translateX(-100%);
315
+ visibility: hidden;
316
+ transition: transform 0.2s ease, visibility 0s linear 0.2s;
317
+ }
318
+
319
+ .aviate-shell.is-sidebar-open .aviate-sidebar {
320
+ transform: none;
321
+ visibility: visible;
322
+ transition: transform 0.2s ease;
323
+ box-shadow: 0 1.25rem 1.5625rem -0.3125rem rgba(0, 0, 0, 0.1), 0 0.5rem 0.625rem -0.375rem rgba(0, 0, 0, 0.1);
324
+ }
325
+
326
+ .aviate-sidebar-close {
327
+ display: inline-flex;
328
+ margin-left: auto;
329
+ padding: 0.25rem;
330
+ border: 0;
331
+ border-radius: 0.375rem;
332
+ background: transparent;
333
+ color: var(--kb-on-surface-tertiary);
334
+ }
335
+
336
+ .aviate-sidebar-close:hover {
337
+ color: var(--kb-on-surface-secondary);
338
+ }
339
+
340
+ .aviate-shell.is-sidebar-open .aviate-sidebar-backdrop {
341
+ position: fixed;
342
+ inset: 0;
343
+ z-index: 1040;
344
+ display: block;
345
+ background-color: var(--kb-neutral-800);
346
+ opacity: 0.4;
347
+ }
348
+
349
+ .aviate-shell-content {
350
+ padding: 1rem;
351
+ }
352
+ }
353
+
354
+ body.aviate-sidebar-scroll-locked {
355
+ overflow: hidden;
356
+ }
357
+
358
+ @media (prefers-reduced-motion: reduce) {
359
+ .aviate-sidebar,
360
+ .aviate-sidebar-chevron {
361
+ transition: none !important;
362
+ }
363
+ }
364
+
365
+ /* ── Billing operations pages (account picker & account context) ── */
366
+
367
+ .aviate-select-account-icon {
368
+ width: 1.25rem;
369
+ height: 1.25rem;
370
+ color: var(--kb-on-surface-secondary);
371
+ }
372
+
373
+ .aviate-select-account-hint,
374
+ .aviate-invoice-hint {
375
+ font: var(--kb-body-medium);
376
+ color: var(--kb-on-surface-secondary);
377
+ }
378
+
379
+ .aviate-invoice-hint {
380
+ margin-bottom: 0;
381
+ }
382
+
383
+ a.aviate-select-account-create,
384
+ a.aviate-selected-account-change {
385
+ font: var(--kb-label-large);
386
+ color: var(--kb-primary);
387
+ text-decoration: none;
388
+ }
389
+
390
+ a.aviate-select-account-create:hover,
391
+ a.aviate-selected-account-change:hover {
392
+ color: var(--kb-primary-hover);
393
+ }
394
+
395
+ .aviate-selected-account {
396
+ display: flex;
397
+ align-items: center;
398
+ justify-content: space-between;
399
+ gap: 1rem;
400
+ margin-bottom: 1rem;
401
+ padding: 0.75rem 1rem;
402
+ background-color: var(--kb-surface-container-low);
403
+ border: 0.0625rem solid var(--kb-outline-primary);
404
+ border-radius: 0.5rem;
405
+ }
406
+
407
+ .aviate-selected-account-details {
408
+ display: flex;
409
+ flex-wrap: wrap;
410
+ align-items: baseline;
411
+ gap: 0.25rem 0.75rem;
412
+ min-width: 0;
413
+ }
414
+
415
+ .aviate-selected-account-label {
416
+ font: var(--kb-label-medium);
417
+ color: var(--kb-on-surface-tertiary);
418
+ text-transform: uppercase;
419
+ }
420
+
421
+ a.aviate-selected-account-name {
422
+ font: var(--kb-title-small);
423
+ color: var(--kb-on-surface-primary);
424
+ text-decoration: none;
425
+ overflow-wrap: anywhere;
426
+ }
427
+
428
+ .aviate-selected-account-meta {
429
+ font: var(--kb-body-small);
430
+ color: var(--kb-on-surface-tertiary);
431
+ }
@@ -17,8 +17,9 @@ module Aviate
17
17
  Rails.logger.warn "#{error.class} #{error.message}. #{error.backtrace.join("\n")}"
18
18
  end
19
19
 
20
+ # The Aviate pages use the same sidebar condition as the Kaui pages (see Aviate::SidebarLayout)
20
21
  def layout
21
- Aviate.config[:layout]
22
+ aviate_sidebar? ? Aviate::SidebarLayout::SIDEBAR_LAYOUT : Aviate.config[:layout]
22
23
  end
23
24
 
24
25
  def current_tenant_user
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Aviate
4
+ # Target of the Subscriptions item of the sidebar. Kaui has no page listing the subscriptions of every account (they
5
+ # are listed per account), so this follows what the Aviate "getting started" flow does on the managed Kaui
6
+ # (GettingStartedController#subscriptions_new): it uses the first account created in the tenant (Kill Bill lists
7
+ # the accounts by ascending record_id; Kaui shows the newest first, so it is the last row of its accounts table) and
8
+ # opens its subscriptions, or the new subscription form while it has none. It only redirects: no Kaui page is copied.
9
+ class SubscriptionsController < EngineController
10
+ def index
11
+ redirect_to subscriptions_target
12
+ rescue StandardError => e
13
+ flash[:error] = as_string(e)
14
+ redirect_to kaui_engine.accounts_path
15
+ end
16
+
17
+ private
18
+
19
+ def subscriptions_target
20
+ options = options_for_klient
21
+ account = Kaui::Account.list_or_search(nil, 0, 1, options).first
22
+ if account.nil?
23
+ flash[:notice] = t('aviate.subscriptions.no_account')
24
+ return kaui_engine.new_account_path
25
+ end
26
+
27
+ bundles = Kaui::Account.paginated_bundles(account.account_id, 0, 1, 'NONE', options)
28
+ if bundles.blank?
29
+ kaui_engine.new_subscription_path(account_id: account.account_id, product_category: 'BASE')
30
+ else
31
+ kaui_engine.account_bundles_path(account.account_id)
32
+ end
33
+ end
34
+ end
35
+ end
@@ -151,7 +151,7 @@ module Aviate
151
151
  "#{KillBillClient::Model::Catalog::KILLBILL_API_CATALOG_PREFIX}/phase",
152
152
  {
153
153
  subscriptionId: subscription.subscription_id,
154
- requestedDate: start_date.to_s
154
+ requestedDate: phase_requested_date(subscription, start_date)
155
155
  },
156
156
  cached_options
157
157
  )
@@ -193,6 +193,25 @@ module Aviate
193
193
  nil
194
194
  end
195
195
 
196
+ # The catalog phase API rejects a requestedDate before the subscription start date-time
197
+ # ("<date> is before the subscription start date"). A plain date is interpreted as
198
+ # midnight, which is before the actual start time on the subscription's first day:
199
+ # fall forward to the subscription start in that case.
200
+ def phase_requested_date(subscription, start_date)
201
+ requested = start_date.in_time_zone('UTC')
202
+ subscription_start = parse_kb_datetime(subscription.start_date)
203
+ requested = subscription_start if subscription_start.present? && subscription_start > requested
204
+ requested.strftime('%Y-%m-%dT%H:%M:%S')
205
+ end
206
+
207
+ def parse_kb_datetime(date_str)
208
+ return nil if date_str.blank?
209
+
210
+ Time.iso8601(date_str.to_s).utc
211
+ rescue ArgumentError
212
+ nil
213
+ end
214
+
196
215
  def fetch_all_samples(subscription_id, unit_types, start_date, end_date, cached_options)
197
216
  samples_by_unit = {}
198
217
  from = start_date.to_s