@molecule/app-settings-panel-vue 0.0.0-stage → 0.0.1-stage
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.
- package/LICENSE +202 -0
- package/README.md +781 -2
- package/dist/AccountSection.d.ts +23 -0
- package/dist/AccountSection.d.ts.map +1 -0
- package/dist/AccountSection.js +139 -0
- package/dist/AccountSection.js.map +1 -0
- package/dist/AppearanceSection.d.ts +20 -0
- package/dist/AppearanceSection.d.ts.map +1 -0
- package/dist/AppearanceSection.js +47 -0
- package/dist/AppearanceSection.js.map +1 -0
- package/dist/AuthSection.d.ts +30 -0
- package/dist/AuthSection.d.ts.map +1 -0
- package/dist/AuthSection.js +320 -0
- package/dist/AuthSection.js.map +1 -0
- package/dist/BillingSection.d.ts +51 -0
- package/dist/BillingSection.d.ts.map +1 -0
- package/dist/BillingSection.js +84 -0
- package/dist/BillingSection.js.map +1 -0
- package/dist/DevicesSection.d.ts +52 -0
- package/dist/DevicesSection.d.ts.map +1 -0
- package/dist/DevicesSection.js +171 -0
- package/dist/DevicesSection.js.map +1 -0
- package/dist/LogOutDeleteSection.d.ts +22 -0
- package/dist/LogOutDeleteSection.d.ts.map +1 -0
- package/dist/LogOutDeleteSection.js +129 -0
- package/dist/LogOutDeleteSection.js.map +1 -0
- package/dist/NotificationsSection.d.ts +27 -0
- package/dist/NotificationsSection.d.ts.map +1 -0
- package/dist/NotificationsSection.js +148 -0
- package/dist/NotificationsSection.js.map +1 -0
- package/dist/SettingsContainer.d.ts +39 -0
- package/dist/SettingsContainer.d.ts.map +1 -0
- package/dist/SettingsContainer.js +48 -0
- package/dist/SettingsContainer.js.map +1 -0
- package/dist/ThisDeviceSection.d.ts +21 -0
- package/dist/ThisDeviceSection.d.ts.map +1 -0
- package/dist/ThisDeviceSection.js +57 -0
- package/dist/ThisDeviceSection.js.map +1 -0
- package/dist/TiersUpgradeSection.d.ts +56 -0
- package/dist/TiersUpgradeSection.d.ts.map +1 -0
- package/dist/TiersUpgradeSection.js +218 -0
- package/dist/TiersUpgradeSection.js.map +1 -0
- package/dist/context.d.ts +25 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +20 -0
- package/dist/context.js.map +1 -0
- package/dist/index.d.ts +95 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +1 -0
- package/dist/pushToggle.d.ts +12 -0
- package/dist/pushToggle.d.ts.map +1 -0
- package/dist/pushToggle.js +11 -0
- package/dist/pushToggle.js.map +1 -0
- package/dist/types.d.ts +27 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/package.json +72 -4
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue billing section: the current plan label and the Upgrade navigation.
|
|
3
|
+
*
|
|
4
|
+
* Vue counterpart of `@molecule/app-settings-panel-react`'s
|
|
5
|
+
* `BillingSection` — the same DOM, callbacks and service calls.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { type VNodeChild } from 'vue';
|
|
10
|
+
/**
|
|
11
|
+
* Billing section — current plan + Upgrade button.
|
|
12
|
+
*
|
|
13
|
+
* Fetches `/api/billing/status` on mount and uses the returned plan
|
|
14
|
+
* name as a more accurate label than the parent-supplied default.
|
|
15
|
+
* The `plan` prop remains a fallback (e.g. for offline rendering or
|
|
16
|
+
* apps that don't expose `/billing/status`).
|
|
17
|
+
*
|
|
18
|
+
* The Upgrade button navigates to `upgradeTo` (default `/settings`).
|
|
19
|
+
* Pass `upgradeTo="/billing"` or `upgradeTo="/pricing"` if your app
|
|
20
|
+
* routes elsewhere. Apps with a multi-tier checkout flow should use
|
|
21
|
+
* `<TiersUpgradeSection>` instead.
|
|
22
|
+
*
|
|
23
|
+
* @returns The billing section component.
|
|
24
|
+
*/
|
|
25
|
+
export declare const BillingSection: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
26
|
+
/** Fallback plan label when the status endpoint is unavailable. */
|
|
27
|
+
plan: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
/** The route the Upgrade button navigates to. */
|
|
32
|
+
upgradeTo: {
|
|
33
|
+
type: StringConstructor;
|
|
34
|
+
default: string;
|
|
35
|
+
};
|
|
36
|
+
}>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
37
|
+
/** Fallback plan label when the status endpoint is unavailable. */
|
|
38
|
+
plan: {
|
|
39
|
+
type: StringConstructor;
|
|
40
|
+
default: string;
|
|
41
|
+
};
|
|
42
|
+
/** The route the Upgrade button navigates to. */
|
|
43
|
+
upgradeTo: {
|
|
44
|
+
type: StringConstructor;
|
|
45
|
+
default: string;
|
|
46
|
+
};
|
|
47
|
+
}>> & Readonly<{}>, {
|
|
48
|
+
plan: string;
|
|
49
|
+
upgradeTo: string;
|
|
50
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
51
|
+
//# sourceMappingURL=BillingSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BillingSection.d.ts","sourceRoot":"","sources":["../src/BillingSection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA6D,KAAK,UAAU,EAAE,MAAM,KAAK,CAAA;AAMhG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,cAAc;IAGvB,mEAAmE;;;;;IAKnE,iDAAiD;;;;;UAmCtC,UAAU;IAxCrB,mEAAmE;;;;;IAKnE,iDAAiD;;;;;;;;4EAqDnD,CAAA"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue billing section: the current plan label and the Upgrade navigation.
|
|
3
|
+
*
|
|
4
|
+
* Vue counterpart of `@molecule/app-settings-panel-react`'s
|
|
5
|
+
* `BillingSection` — the same DOM, callbacks and service calls.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { defineComponent, h, onMounted, onUnmounted, ref } from 'vue';
|
|
10
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
11
|
+
import { Button, Flex } from '@molecule/app-ui-vue';
|
|
12
|
+
import { useHttpClient, useRouter, useTranslation } from '@molecule/app-vue';
|
|
13
|
+
/**
|
|
14
|
+
* Billing section — current plan + Upgrade button.
|
|
15
|
+
*
|
|
16
|
+
* Fetches `/api/billing/status` on mount and uses the returned plan
|
|
17
|
+
* name as a more accurate label than the parent-supplied default.
|
|
18
|
+
* The `plan` prop remains a fallback (e.g. for offline rendering or
|
|
19
|
+
* apps that don't expose `/billing/status`).
|
|
20
|
+
*
|
|
21
|
+
* The Upgrade button navigates to `upgradeTo` (default `/settings`).
|
|
22
|
+
* Pass `upgradeTo="/billing"` or `upgradeTo="/pricing"` if your app
|
|
23
|
+
* routes elsewhere. Apps with a multi-tier checkout flow should use
|
|
24
|
+
* `<TiersUpgradeSection>` instead.
|
|
25
|
+
*
|
|
26
|
+
* @returns The billing section component.
|
|
27
|
+
*/
|
|
28
|
+
export const BillingSection = defineComponent({
|
|
29
|
+
name: 'BillingSection',
|
|
30
|
+
props: {
|
|
31
|
+
/** Fallback plan label when the status endpoint is unavailable. */
|
|
32
|
+
plan: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: 'Free',
|
|
35
|
+
},
|
|
36
|
+
/** The route the Upgrade button navigates to. */
|
|
37
|
+
upgradeTo: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: '/settings',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
setup(props) {
|
|
43
|
+
const cm = getClassMap();
|
|
44
|
+
const { t } = useTranslation();
|
|
45
|
+
const router = useRouter();
|
|
46
|
+
const http = useHttpClient();
|
|
47
|
+
const livePlan = ref(null);
|
|
48
|
+
// Refresh the current plan from the bonded entitlements/billing
|
|
49
|
+
// status endpoint on mount. Fire-and-forget; the prop-supplied
|
|
50
|
+
// `plan` is the fallback if the fetch fails.
|
|
51
|
+
let cancelled = false;
|
|
52
|
+
onMounted(() => {
|
|
53
|
+
http
|
|
54
|
+
.get('/api/billing/status')
|
|
55
|
+
.then((res) => {
|
|
56
|
+
if (cancelled)
|
|
57
|
+
return;
|
|
58
|
+
const body = res.data ?? res;
|
|
59
|
+
const name = body?.name;
|
|
60
|
+
if (typeof name === 'string' && name)
|
|
61
|
+
livePlan.value = name;
|
|
62
|
+
})
|
|
63
|
+
.catch((_error) => {
|
|
64
|
+
// fallback to the prop-supplied plan label
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
onUnmounted(() => {
|
|
68
|
+
cancelled = true;
|
|
69
|
+
});
|
|
70
|
+
return () => h('section', [
|
|
71
|
+
h('h3', { class: cm.cn(cm.sectionHeading, cm.sp('mb', 3)) }, [
|
|
72
|
+
t('settings.billing', undefined, { defaultValue: 'Billing' }),
|
|
73
|
+
]),
|
|
74
|
+
h(Flex, { align: 'center', justify: 'between' }, () => [
|
|
75
|
+
h('span', { class: cm.textSize('sm') }, [
|
|
76
|
+
t('settings.plan', undefined, { defaultValue: 'Plan: ' }),
|
|
77
|
+
h('strong', [livePlan.value ?? props.plan]),
|
|
78
|
+
]),
|
|
79
|
+
h(Button, { variant: 'outline', size: 'sm', onClick: () => router.navigate(props.upgradeTo) }, () => [t('settings.upgrade', undefined, { defaultValue: 'Upgrade' })]),
|
|
80
|
+
]),
|
|
81
|
+
]);
|
|
82
|
+
},
|
|
83
|
+
});
|
|
84
|
+
//# sourceMappingURL=BillingSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BillingSection.js","sourceRoot":"","sources":["../src/BillingSection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,SAAS,EAAE,WAAW,EAAY,GAAG,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AAA"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue devices section: the user's registered device list and its revoke flow.
|
|
3
|
+
*
|
|
4
|
+
* Vue counterpart of `@molecule/app-settings-panel-react`'s
|
|
5
|
+
* `DevicesSection` — the same DOM, callbacks and service calls.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { type PropType, type VNodeChild } from 'vue';
|
|
10
|
+
import type { Device } from './types.js';
|
|
11
|
+
/**
|
|
12
|
+
* Devices section — lists the user's registered devices and lets them
|
|
13
|
+
* revoke (sign out) any device other than the one they're currently using.
|
|
14
|
+
*
|
|
15
|
+
* Revoking deletes the device row (`DELETE /api/devices/:id`). The API's
|
|
16
|
+
* authorization layer enforces server-side revocation: it rejects that
|
|
17
|
+
* device's session the next time it makes a request (within the
|
|
18
|
+
* device-exists cache TTL), so the removed device is actually signed out —
|
|
19
|
+
* not just hidden from the list. The current device is labelled
|
|
20
|
+
* "This device" and is not revocable here (use Sign out for the current
|
|
21
|
+
* session). Recreates molecule v1's device-revocation behaviour.
|
|
22
|
+
*
|
|
23
|
+
* Apps that want a different trailing element per row can pass a
|
|
24
|
+
* `renderRowIcon` callback (which then replaces the built-in revoke
|
|
25
|
+
* control); pass `() => null` to suppress it entirely.
|
|
26
|
+
*
|
|
27
|
+
* @returns The devices section component.
|
|
28
|
+
*/
|
|
29
|
+
export declare const DevicesSection: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
30
|
+
/**
|
|
31
|
+
* Replaces each row's built-in trailing control with the node it returns
|
|
32
|
+
* for that device (`() => null` suppresses the control entirely).
|
|
33
|
+
*/
|
|
34
|
+
renderRowIcon: {
|
|
35
|
+
type: PropType<(device: Device) => VNodeChild>;
|
|
36
|
+
required: false;
|
|
37
|
+
default: undefined;
|
|
38
|
+
};
|
|
39
|
+
}>, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
40
|
+
/**
|
|
41
|
+
* Replaces each row's built-in trailing control with the node it returns
|
|
42
|
+
* for that device (`() => null` suppresses the control entirely).
|
|
43
|
+
*/
|
|
44
|
+
renderRowIcon: {
|
|
45
|
+
type: PropType<(device: Device) => VNodeChild>;
|
|
46
|
+
required: false;
|
|
47
|
+
default: undefined;
|
|
48
|
+
};
|
|
49
|
+
}>> & Readonly<{}>, {
|
|
50
|
+
renderRowIcon: (device: Device) => VNodeChild;
|
|
51
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
52
|
+
//# sourceMappingURL=DevicesSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevicesSection.d.ts","sourceRoot":"","sources":["../src/DevicesSection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAiC,KAAK,QAAQ,EAAiB,KAAK,UAAU,EAAE,MAAM,KAAK,CAAA;AAMlG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAExC;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,cAAc;IAGvB;;;OAGG;;cAEiB,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,UAAU,CAAC;;;;UAsGjD,UAAU;IA3GrB;;;OAGG;;cAEiB,QAAQ,CAAC,CAAC,MAAM,EAAE,MAAM,KAAK,UAAU,CAAC;;;;;4BAAtB,MAAM,KAAK,UAAU;4EA+J7D,CAAA"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue devices section: the user's registered device list and its revoke flow.
|
|
3
|
+
*
|
|
4
|
+
* Vue counterpart of `@molecule/app-settings-panel-react`'s
|
|
5
|
+
* `DevicesSection` — the same DOM, callbacks and service calls.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { defineComponent, h, onMounted, ref } from 'vue';
|
|
10
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
11
|
+
import { Button, Flex, Icon, Spinner } from '@molecule/app-ui-vue';
|
|
12
|
+
import { useHttpClient, useTranslation } from '@molecule/app-vue';
|
|
13
|
+
/**
|
|
14
|
+
* Devices section — lists the user's registered devices and lets them
|
|
15
|
+
* revoke (sign out) any device other than the one they're currently using.
|
|
16
|
+
*
|
|
17
|
+
* Revoking deletes the device row (`DELETE /api/devices/:id`). The API's
|
|
18
|
+
* authorization layer enforces server-side revocation: it rejects that
|
|
19
|
+
* device's session the next time it makes a request (within the
|
|
20
|
+
* device-exists cache TTL), so the removed device is actually signed out —
|
|
21
|
+
* not just hidden from the list. The current device is labelled
|
|
22
|
+
* "This device" and is not revocable here (use Sign out for the current
|
|
23
|
+
* session). Recreates molecule v1's device-revocation behaviour.
|
|
24
|
+
*
|
|
25
|
+
* Apps that want a different trailing element per row can pass a
|
|
26
|
+
* `renderRowIcon` callback (which then replaces the built-in revoke
|
|
27
|
+
* control); pass `() => null` to suppress it entirely.
|
|
28
|
+
*
|
|
29
|
+
* @returns The devices section component.
|
|
30
|
+
*/
|
|
31
|
+
export const DevicesSection = defineComponent({
|
|
32
|
+
name: 'DevicesSection',
|
|
33
|
+
props: {
|
|
34
|
+
/**
|
|
35
|
+
* Replaces each row's built-in trailing control with the node it returns
|
|
36
|
+
* for that device (`() => null` suppresses the control entirely).
|
|
37
|
+
*/
|
|
38
|
+
renderRowIcon: {
|
|
39
|
+
type: Function,
|
|
40
|
+
required: false,
|
|
41
|
+
default: undefined,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
setup(props) {
|
|
45
|
+
const cm = getClassMap();
|
|
46
|
+
const { t } = useTranslation();
|
|
47
|
+
const http = useHttpClient();
|
|
48
|
+
const devices = ref([]);
|
|
49
|
+
const loading = ref(true);
|
|
50
|
+
const confirmingId = ref(null);
|
|
51
|
+
const revokingId = ref(null);
|
|
52
|
+
/** Loads the device list; the section renders empty when unavailable. */
|
|
53
|
+
const load = async () => {
|
|
54
|
+
try {
|
|
55
|
+
// GET /api/devices responds with the ARRAY itself (see the device
|
|
56
|
+
// resource's query handler) — response.data IS the rows. This used to
|
|
57
|
+
// read `response.data.data`, which is always undefined for that shape,
|
|
58
|
+
// so the section rendered "No devices" for everyone.
|
|
59
|
+
const response = await http.get('/api/devices');
|
|
60
|
+
devices.value = Array.isArray(response.data) ? response.data : [];
|
|
61
|
+
}
|
|
62
|
+
catch (_error) {
|
|
63
|
+
// Devices endpoint is optional; the section renders empty when unavailable.
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
loading.value = false;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
onMounted(() => {
|
|
70
|
+
void load();
|
|
71
|
+
});
|
|
72
|
+
/**
|
|
73
|
+
* Revokes (signs out) a device and reloads the list; a failure keeps the
|
|
74
|
+
* row so the user can retry.
|
|
75
|
+
*
|
|
76
|
+
* @param id - The device row's id.
|
|
77
|
+
*/
|
|
78
|
+
const revoke = async (id) => {
|
|
79
|
+
revokingId.value = id;
|
|
80
|
+
try {
|
|
81
|
+
await http.delete(`/api/devices/${id}`);
|
|
82
|
+
confirmingId.value = null;
|
|
83
|
+
await load();
|
|
84
|
+
}
|
|
85
|
+
catch (_error) {
|
|
86
|
+
// Best-effort — keep the row so the user can retry the revoke.
|
|
87
|
+
}
|
|
88
|
+
finally {
|
|
89
|
+
revokingId.value = null;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Builds a row's trailing element: the caller's renderer, the
|
|
94
|
+
* current-device chevron, the confirm/cancel pair, or the revoke trigger.
|
|
95
|
+
*
|
|
96
|
+
* @param device - The row's device.
|
|
97
|
+
* @returns The trailing node, or null when suppressed.
|
|
98
|
+
*/
|
|
99
|
+
const trailing = (device) => {
|
|
100
|
+
if (props.renderRowIcon)
|
|
101
|
+
return props.renderRowIcon(device);
|
|
102
|
+
if (device.isCurrent) {
|
|
103
|
+
return h(Icon, { name: 'chevron-right', size: 16, className: cm.textSubtle });
|
|
104
|
+
}
|
|
105
|
+
if (confirmingId.value === device.id) {
|
|
106
|
+
return h(Flex, { align: 'center', gap: 'sm' }, () => [
|
|
107
|
+
h(Button, {
|
|
108
|
+
variant: 'ghost',
|
|
109
|
+
size: 'sm',
|
|
110
|
+
disabled: revokingId.value === device.id,
|
|
111
|
+
onClick: () => (confirmingId.value = null),
|
|
112
|
+
}, () => [t('common.cancel', undefined, { defaultValue: 'Cancel' })]),
|
|
113
|
+
h(Button, {
|
|
114
|
+
color: 'error',
|
|
115
|
+
size: 'sm',
|
|
116
|
+
loading: revokingId.value === device.id,
|
|
117
|
+
onClick: () => void revoke(device.id),
|
|
118
|
+
'data-mol-id': 'device-revoke-confirm',
|
|
119
|
+
}, () => [t('settings.signOutDevice', undefined, { defaultValue: 'Sign out' })]),
|
|
120
|
+
]);
|
|
121
|
+
}
|
|
122
|
+
return h(Button, {
|
|
123
|
+
variant: 'ghost',
|
|
124
|
+
size: 'sm',
|
|
125
|
+
onClick: () => (confirmingId.value = device.id),
|
|
126
|
+
'data-mol-id': 'device-revoke',
|
|
127
|
+
}, () => [t('settings.signOutDevice', undefined, { defaultValue: 'Sign out' })]);
|
|
128
|
+
};
|
|
129
|
+
return () => h('section', [
|
|
130
|
+
h(Flex, { align: 'center', gap: 'sm', className: cm.sp('mb', 3) }, () => [
|
|
131
|
+
h('h3', { class: cm.sectionHeading }, [
|
|
132
|
+
t('settings.devices', undefined, { defaultValue: 'Devices' }),
|
|
133
|
+
]),
|
|
134
|
+
loading.value ? h(Spinner, { size: 'xs' }) : null,
|
|
135
|
+
]),
|
|
136
|
+
devices.value.length > 0
|
|
137
|
+
? h('ul', { class: cm.stack(2) }, devices.value.map((device) => h('li', { key: device.id }, [
|
|
138
|
+
h(Flex, {
|
|
139
|
+
align: 'center',
|
|
140
|
+
justify: 'between',
|
|
141
|
+
className: cm.cn(cm.textSize('sm'), cm.sp('py', 1)),
|
|
142
|
+
}, () => [
|
|
143
|
+
h('span', [
|
|
144
|
+
device.name || device.platform,
|
|
145
|
+
device.isCurrent
|
|
146
|
+
? h('span', { class: cm.cn(cm.textSize('xs'), cm.textSubtle, cm.sp('ml', 2)) }, [
|
|
147
|
+
t('settings.thisDevice', undefined, {
|
|
148
|
+
defaultValue: 'This Device',
|
|
149
|
+
}),
|
|
150
|
+
])
|
|
151
|
+
: null,
|
|
152
|
+
]),
|
|
153
|
+
trailing(device),
|
|
154
|
+
]),
|
|
155
|
+
confirmingId.value === device.id
|
|
156
|
+
? h('p', { class: cm.cn(cm.textSize('xs'), cm.textMuted, cm.sp('mt', 1)) }, [
|
|
157
|
+
t('settings.revokeDeviceWarning', undefined, {
|
|
158
|
+
defaultValue: "This device's access will be revoked shortly. Sign it out?",
|
|
159
|
+
}),
|
|
160
|
+
])
|
|
161
|
+
: null,
|
|
162
|
+
])))
|
|
163
|
+
: !loading.value
|
|
164
|
+
? h('p', { class: cm.cn(cm.textSize('sm'), cm.textMuted) }, [
|
|
165
|
+
t('settings.noDevices', undefined, { defaultValue: 'No devices found' }),
|
|
166
|
+
])
|
|
167
|
+
: null,
|
|
168
|
+
]);
|
|
169
|
+
},
|
|
170
|
+
});
|
|
171
|
+
//# sourceMappingURL=DevicesSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DevicesSection.js","sourceRoot":"","sources":["../src/DevicesSection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,SAAS,EAA2B,GAAG,EAAmB,MAAM,KAAK,CAAA;AAElG,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAIjE;;;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,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE;4BACxE,CAAC,CAAC,8BAA8B,EAAE,SAAS,EAAE;gCAC3C,YAAY,EACV,4DAA4D;6BAC/D,CAAC;yBACH,CAAC;wBACJ,CAAC,CAAC,IAAI;iBACT,CAAC,CACH,CACF;gBACH,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK;oBACd,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,EAAE,EAAE;wBACxD,CAAC,CAAC,oBAAoB,EAAE,SAAS,EAAE,EAAE,YAAY,EAAE,kBAAkB,EAAE,CAAC;qBACzE,CAAC;oBACJ,CAAC,CAAC,IAAI;SACX,CAAC,CAAA;IACN,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue bottom actions section: Log out + Delete account over the container's
|
|
3
|
+
* panel context.
|
|
4
|
+
*
|
|
5
|
+
* Vue counterpart of `@molecule/app-settings-panel-react`'s
|
|
6
|
+
* `LogOutDeleteSection` — the same DOM, callbacks and service calls.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { type VNodeChild } from 'vue';
|
|
11
|
+
/**
|
|
12
|
+
* Bottom actions section — Log out + Delete account.
|
|
13
|
+
*
|
|
14
|
+
* Owns the delete-account modal internally (the trigger lives in the
|
|
15
|
+
* same section so the modal lives here too). Reads `onClose` from
|
|
16
|
+
* the `<SettingsContainer>` context to dismiss the panel after either
|
|
17
|
+
* action and navigates to `/login`.
|
|
18
|
+
*
|
|
19
|
+
* @returns The log out / delete account section component.
|
|
20
|
+
*/
|
|
21
|
+
export declare const LogOutDeleteSection: import("vue").DefineComponent<{}, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
22
|
+
//# sourceMappingURL=LogOutDeleteSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogOutDeleteSection.d.ts","sourceRoot":"","sources":["../src/LogOutDeleteSection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAqC,KAAK,UAAU,EAAE,MAAM,KAAK,CAAA;AAUxE;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,0CAgDjB,UAAU,yOA6EvB,CAAA"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue bottom actions section: Log out + Delete account over the container's
|
|
3
|
+
* panel context.
|
|
4
|
+
*
|
|
5
|
+
* Vue counterpart of `@molecule/app-settings-panel-react`'s
|
|
6
|
+
* `LogOutDeleteSection` — the same DOM, callbacks and service calls.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { defineComponent, h, ref } from 'vue';
|
|
11
|
+
import { serverErrorMessage } from '@molecule/app-http';
|
|
12
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
13
|
+
import { Alert, Button, Input, Modal } from '@molecule/app-ui-vue';
|
|
14
|
+
import { useAuth, useHttpClient, useRouter, useTranslation } from '@molecule/app-vue';
|
|
15
|
+
import { useSettingsPanelContext } from './context.js';
|
|
16
|
+
/**
|
|
17
|
+
* Bottom actions section — Log out + Delete account.
|
|
18
|
+
*
|
|
19
|
+
* Owns the delete-account modal internally (the trigger lives in the
|
|
20
|
+
* same section so the modal lives here too). Reads `onClose` from
|
|
21
|
+
* the `<SettingsContainer>` context to dismiss the panel after either
|
|
22
|
+
* action and navigates to `/login`.
|
|
23
|
+
*
|
|
24
|
+
* @returns The log out / delete account section component.
|
|
25
|
+
*/
|
|
26
|
+
export const LogOutDeleteSection = defineComponent({
|
|
27
|
+
name: 'LogOutDeleteSection',
|
|
28
|
+
setup() {
|
|
29
|
+
const cm = getClassMap();
|
|
30
|
+
const { t } = useTranslation();
|
|
31
|
+
const router = useRouter();
|
|
32
|
+
const { user, logout } = useAuth();
|
|
33
|
+
const http = useHttpClient();
|
|
34
|
+
const { onClose } = useSettingsPanelContext();
|
|
35
|
+
const showModal = ref(false);
|
|
36
|
+
const password = ref('');
|
|
37
|
+
const loading = ref(false);
|
|
38
|
+
const error = ref('');
|
|
39
|
+
/** Signs out, dismisses the panel and returns to the login route. */
|
|
40
|
+
const handleLogout = async () => {
|
|
41
|
+
await logout();
|
|
42
|
+
onClose();
|
|
43
|
+
router.navigate('/login');
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Submits the delete-account form; a refusal shows the server's message
|
|
47
|
+
* and keeps the modal open.
|
|
48
|
+
*
|
|
49
|
+
* @param event - The native form submit event.
|
|
50
|
+
*/
|
|
51
|
+
const handleDelete = async (event) => {
|
|
52
|
+
event.preventDefault();
|
|
53
|
+
loading.value = true;
|
|
54
|
+
error.value = '';
|
|
55
|
+
try {
|
|
56
|
+
await http.delete(`/api/users/${user.value?.id}`, { data: { password: password.value } });
|
|
57
|
+
await logout();
|
|
58
|
+
onClose();
|
|
59
|
+
router.navigate('/login');
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
error.value =
|
|
63
|
+
serverErrorMessage(err) ??
|
|
64
|
+
t('settings.failedToDeleteAccount', undefined, {
|
|
65
|
+
defaultValue: 'Failed to delete account.',
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
loading.value = false;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
return () => [
|
|
73
|
+
h('section', { class: cm.stack(3) }, [
|
|
74
|
+
h(Button, {
|
|
75
|
+
color: 'error',
|
|
76
|
+
fullWidth: true,
|
|
77
|
+
onClick: () => void handleLogout(),
|
|
78
|
+
'data-mol-id': 'user-menu-logout',
|
|
79
|
+
}, () => [t('settings.logOut', undefined, { defaultValue: 'Sign out' })]),
|
|
80
|
+
h(Button, {
|
|
81
|
+
variant: 'ghost',
|
|
82
|
+
fullWidth: true,
|
|
83
|
+
onClick: () => (showModal.value = true),
|
|
84
|
+
'data-mol-id': 'user-menu-delete-account',
|
|
85
|
+
}, () => [t('settings.deleteAccount', undefined, { defaultValue: 'Delete account' })]),
|
|
86
|
+
]),
|
|
87
|
+
h(Modal, {
|
|
88
|
+
open: showModal.value,
|
|
89
|
+
onClose: () => (showModal.value = false),
|
|
90
|
+
title: t('settings.deleteAccountModal.title', undefined, {
|
|
91
|
+
defaultValue: 'Delete Account',
|
|
92
|
+
}),
|
|
93
|
+
}, {
|
|
94
|
+
default: () => [
|
|
95
|
+
h('p', { class: cm.cn(cm.textSize('sm'), cm.textMuted, cm.sp('mb', 4)) }, [
|
|
96
|
+
t('settings.deleteAccountModal.warning', undefined, {
|
|
97
|
+
defaultValue: 'This action cannot be undone. Please enter your password to confirm.',
|
|
98
|
+
}),
|
|
99
|
+
]),
|
|
100
|
+
error.value
|
|
101
|
+
? h(Alert, { status: 'error', className: cm.sp('mb', 4) }, () => [error.value])
|
|
102
|
+
: null,
|
|
103
|
+
h('form', { onSubmit: handleDelete, class: cm.stack(4) }, [
|
|
104
|
+
h('div', [
|
|
105
|
+
h('label', { for: 'delete-pw', class: cm.formLabel }, t('settings.deleteAccountModal.password', undefined, {
|
|
106
|
+
defaultValue: 'Password',
|
|
107
|
+
})),
|
|
108
|
+
h(Input, {
|
|
109
|
+
id: 'delete-pw',
|
|
110
|
+
type: 'password',
|
|
111
|
+
value: password.value,
|
|
112
|
+
onChange: (e) => (password.value = e.target.value),
|
|
113
|
+
required: true,
|
|
114
|
+
}),
|
|
115
|
+
]),
|
|
116
|
+
h(Button, { type: 'submit', color: 'error', fullWidth: true, loading: loading.value }, () => [
|
|
117
|
+
loading.value
|
|
118
|
+
? t('settings.deleteAccountModal.deleting', undefined, {
|
|
119
|
+
defaultValue: 'Deleting...',
|
|
120
|
+
})
|
|
121
|
+
: t('settings.deleteAccount', undefined, { defaultValue: 'Delete account' }),
|
|
122
|
+
]),
|
|
123
|
+
]),
|
|
124
|
+
],
|
|
125
|
+
}),
|
|
126
|
+
];
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
//# sourceMappingURL=LogOutDeleteSection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LogOutDeleteSection.js","sourceRoot":"","sources":["../src/LogOutDeleteSection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC,EAAY,GAAG,EAAmB,MAAM,KAAK,CAAA;AAGxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAErF,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC;IACjD,IAAI,EAAE,qBAAqB;IAC3B,KAAK;QACH,MAAM,EAAE,GAAG,WAAW,EAAE,CAAA;QACxB,MAAM,EAAE,CAAC,EAAE,GAAG,cAAc,EAAE,CAAA;QAC9B,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;QAC1B,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,EAAe,CA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AsC,EAAE,SAAS,EAAE;oCACnD,YAAY,EAAE,aAAa;iCAC5B,CAAC;gCACJ,CAAC,CAAC,CAAC,CAAC,wBAAwB,EAAE,SAAS,EAAE,EAAE,YAAY,EAAE,gBAAgB,EAAE,CAAC;yBAC/E,CACF;qBACF,CAAC;iBACH;aACF,CACF;SACF,CAAA;IACH,CAAC;CACF,CAAC,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vue push-notification toggle section: the full receive-side enable chain
|
|
3
|
+
* over the shared current-device push helpers.
|
|
4
|
+
*
|
|
5
|
+
* Vue counterpart of `@molecule/app-settings-panel-react`'s
|
|
6
|
+
* `NotificationsSection` — the same DOM, callbacks and service calls.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { type VNodeChild } from 'vue';
|
|
11
|
+
/**
|
|
12
|
+
* Push-notification toggle section — the full receive-side enable chain:
|
|
13
|
+
* browser permission → runtime VAPID public key
|
|
14
|
+
* (`GET /api/devices/push/public-key`) → `pushManager.subscribe` with
|
|
15
|
+
* `applicationServerKey` → PATCH the subscription onto the current device
|
|
16
|
+
* row (`/api/devices/:id { pushSubscription, hasPushSubscription }`), which
|
|
17
|
+
* is where the api-side push fan-outs look for it.
|
|
18
|
+
*
|
|
19
|
+
* Initial state reflects SERVER truth (the current device row's
|
|
20
|
+
* `hasPushSubscription`), and every failure surfaces as an honest inline
|
|
21
|
+
* message — a dev build without a service worker fails fast instead of
|
|
22
|
+
* hanging the switch.
|
|
23
|
+
*
|
|
24
|
+
* @returns The notifications section component.
|
|
25
|
+
*/
|
|
26
|
+
export declare const NotificationsSection: import("vue").DefineComponent<{}, () => VNodeChild, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
27
|
+
//# sourceMappingURL=NotificationsSection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationsSection.d.ts","sourceRoot":"","sources":["../src/NotificationsSection.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAA6D,KAAK,UAAU,EAAE,MAAM,KAAK,CAAA;AAYhG;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,0CAwFlB,UAAU,yOAmCvB,CAAA"}
|