@collabdt/core 0.13.0 → 0.13.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.
- package/dist/core/components/organizationConfig/src/organizationConfigContent.d.ts.map +1 -1
- package/dist/core/components/organizationConfig/src/organizationConfigContent.js +5 -11
- package/dist/core/components/organizationConfig/src/organizationConfigContent.js.map +1 -1
- package/dist/core/components/viewers/viewerAccess.d.ts.map +1 -1
- package/dist/core/components/viewers/viewerAccess.js +2 -0
- package/dist/core/components/viewers/viewerAccess.js.map +1 -1
- package/dist/core/hooks/plugins/createPluginHooks.d.ts +2 -10
- package/dist/core/hooks/plugins/createPluginHooks.d.ts.map +1 -1
- package/dist/core/hooks/plugins/createPluginHooks.js +1 -2
- package/dist/core/hooks/plugins/createPluginHooks.js.map +1 -1
- package/dist/core/i18n/messages/en.json +0 -1
- package/dist/core/i18n/messages/es.json +0 -1
- package/dist/core/i18n/messages/fr.json +0 -1
- package/dist/core/utils/appContent.d.ts +4 -7
- package/dist/core/utils/appContent.d.ts.map +1 -1
- package/dist/core/utils/appContent.js +8 -3
- package/dist/core/utils/appContent.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organizationConfigContent.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/organizationConfig/src/organizationConfigContent.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"organizationConfigContent.d.ts","sourceRoot":"","sources":["../../../../../src/core/components/organizationConfig/src/organizationConfigContent.tsx"],"names":[],"mappings":"AAwDA,MAAM,CAAC,OAAO,UAAU,yBAAyB,gCAyShD"}
|
|
@@ -15,15 +15,13 @@ function CheckboxCard({
|
|
|
15
15
|
name,
|
|
16
16
|
value,
|
|
17
17
|
label,
|
|
18
|
-
defaultChecked = false
|
|
19
|
-
locked = false
|
|
18
|
+
defaultChecked = false
|
|
20
19
|
}) {
|
|
21
|
-
const [
|
|
22
|
-
const isChecked = locked ? true : checked;
|
|
20
|
+
const [isChecked, setChecked] = useState(defaultChecked);
|
|
23
21
|
return /* @__PURE__ */ jsxs(
|
|
24
22
|
"label",
|
|
25
23
|
{
|
|
26
|
-
className: `flex items-center gap-2.5 rounded-md border p-3 select-none transition-colors
|
|
24
|
+
className: `flex items-center gap-2.5 rounded-md border p-3 select-none transition-colors cursor-pointer ${isChecked ? "border-primary bg-primary/5 text-foreground" : "border-input hover:bg-muted/50 text-muted-foreground"}`,
|
|
27
25
|
children: [
|
|
28
26
|
/* @__PURE__ */ jsx(
|
|
29
27
|
"input",
|
|
@@ -32,9 +30,7 @@ function CheckboxCard({
|
|
|
32
30
|
name,
|
|
33
31
|
value,
|
|
34
32
|
checked: isChecked,
|
|
35
|
-
onChange: (e) =>
|
|
36
|
-
if (!locked) setChecked(e.target.checked);
|
|
37
|
-
},
|
|
33
|
+
onChange: (e) => setChecked(e.target.checked),
|
|
38
34
|
className: "sr-only"
|
|
39
35
|
}
|
|
40
36
|
),
|
|
@@ -103,7 +99,6 @@ function OrganizationConfigContent() {
|
|
|
103
99
|
{ value: "Es", label: t("langSpanish") }
|
|
104
100
|
];
|
|
105
101
|
const viewerOptions = [
|
|
106
|
-
{ value: "map", label: t("viewerMap"), defaultChecked: true, locked: true },
|
|
107
102
|
{ value: "bim", label: t("viewerBIM"), defaultChecked: true }
|
|
108
103
|
];
|
|
109
104
|
const dataOptions = [
|
|
@@ -199,8 +194,7 @@ function OrganizationConfigContent() {
|
|
|
199
194
|
name: "appContent",
|
|
200
195
|
value: opt.value,
|
|
201
196
|
label: opt.label,
|
|
202
|
-
defaultChecked: opt.defaultChecked
|
|
203
|
-
locked: opt.locked
|
|
197
|
+
defaultChecked: opt.defaultChecked
|
|
204
198
|
},
|
|
205
199
|
opt.value
|
|
206
200
|
)) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../src/core/components/organizationConfig/src/organizationConfigContent.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { motion } from 'framer-motion'\nimport { Check } from 'lucide-react'\nimport { useRouter } from 'next/navigation'\nimport { useTranslations } from 'next-intl'\nimport { useState } from 'react'\n\nimport { Button } from '../../ui/Button'\nimport { Card } from '../../ui/Card'\nimport { Input } from '../../ui/Input'\nimport { Textarea } from '../../ui/Textarea'\n\n// Reusable checkbox card used for both languages and feature toggles\nfunction CheckboxCard({\n name,\n value,\n label,\n defaultChecked = false,\n locked = false,\n}: {\n name: string\n value: string\n label: string\n defaultChecked?: boolean\n locked?: boolean\n}) {\n const [checked, setChecked] = useState(defaultChecked)\n const isChecked = locked ? true : checked\n\n return (\n <label\n className={`flex items-center gap-2.5 rounded-md border p-3 select-none transition-colors ${locked ? 'cursor-not-allowed opacity-70' : 'cursor-pointer'\n } ${isChecked\n ? 'border-primary bg-primary/5 text-foreground'\n : 'border-input hover:bg-muted/50 text-muted-foreground'\n }`}\n >\n <input\n type=\"checkbox\"\n name={name}\n value={value}\n checked={isChecked}\n onChange={(e) => { if (!locked) setChecked(e.target.checked) }}\n className=\"sr-only\"\n />\n <span\n className={`flex-shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${isChecked ? 'bg-primary border-primary' : 'border-input bg-background'\n }`}\n >\n {isChecked && <Check className=\"h-3 w-3 text-primary-foreground\" strokeWidth={3} />}\n </span>\n <span className=\"text-sm font-medium\">{label}</span>\n </label>\n )\n}\n\nexport default function OrganizationConfigContent() {\n const t = useTranslations('OrganizationConfig')\n const router = useRouter()\n\n const [error, setError] = useState<string | null>(null)\n const [loading, setLoading] = useState(false)\n\n function validateOrgName(name: string) {\n const regex = /^[a-z0-9.-]{3,63}$/\n return regex.test(name)\n }\n\n async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {\n e.preventDefault()\n setError(null)\n setLoading(true)\n\n const formData = new FormData(e.currentTarget)\n\n const orgLanguages = formData.getAll('orgLanguages').map(String)\n const appContent = formData.getAll('appContent').map(String)\n\n // Text inputs only, so a non-string entry (a File) means a malformed submit.\n const orgName = formData.get('orgName')\n\n const data = {\n orgName: typeof orgName === 'string' ? orgName : '',\n orgTitle: formData.get('orgTitle'),\n orgDescription: formData.get('orgDescription'),\n countrySubdivision: formData.get('countrySubdivision'),\n orgLanguages,\n appContent,\n adminName: formData.get('adminName'),\n adminEmail: formData.get('adminEmail'),\n adminPassword: formData.get('adminPassword'),\n }\n\n try {\n const res = await fetch('/api/setup', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(data),\n })\n\n const json = await res.json()\n\n if (res.ok && json.success) {\n router.push(`/${data.orgName}/auth/signin`)\n return\n }\n\n setError(json.error ?? 'Failed to initialize instance.')\n } catch {\n setError('Network error. Please try again.')\n } finally {\n setLoading(false)\n }\n }\n\n const languageOptions = [\n { value: 'En', label: t('langEnglish'), defaultChecked: true },\n { value: 'Fr', label: t('langFrench') },\n { value: 'Es', label: t('langSpanish') },\n ]\n\n const viewerOptions = [\n { value: 'map', label: t('viewerMap'), defaultChecked: true, locked: true },\n { value: 'bim', label: t('viewerBIM'), defaultChecked: true },\n ]\n\n const dataOptions = [\n { value: 'sites', label: t('dataSites'), defaultChecked: true },\n { value: 'buildings', label: t('dataBuildings'), defaultChecked: true },\n { value: 'files', label: t('dataFiles'), defaultChecked: true },\n ]\n\n\n return (\n <>\n <section className=\"min-h-screen py-32 relative flex items-center z-10\">\n <div className=\"container mx-auto px-6\">\n <motion.div\n initial={{ opacity: 0, y: 30 }}\n animate={{ opacity: 1, y: 0 }}\n className=\"max-w-5xl mx-auto\"\n >\n <div className=\"text-center mb-16 space-y-6\">\n <h1 className=\"text-4xl md:text-5xl font-bold\">{t('title')}</h1>\n <p className=\"text-lg text-muted-foreground max-w-3xl mx-auto\">\n {t('description')}\n </p>\n </div>\n\n <div className=\"grid lg:grid-cols-3 gap-8\">\n <Card className=\"lg:col-span-2 p-8\">\n <h3 className=\"text-2xl font-bold mb-6\">{t('setupTitle')}</h3>\n <p className=\"text-muted-foreground mb-8\">{t('setupDescription')}</p>\n\n <form onSubmit={(e) => void handleSubmit(e)} className=\"space-y-6\">\n\n {/* Org Name */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Organization Name</label>\n <Input\n name=\"orgName\"\n placeholder=\"my-org\"\n required\n minLength={3}\n maxLength={63}\n pattern=\"^[a-z0-9.-]+$\"\n />\n <p className=\"text-xs text-muted-foreground\">\n 3–63 characters. Lowercase letters, numbers, dots, and hyphens only.\n </p>\n </div>\n\n {/* Org Title */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Organization Title</label>\n <Input name=\"orgTitle\" placeholder=\"Organization Title\" required />\n </div>\n\n {/* Org Description */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Organization Description</label>\n <Textarea\n name=\"orgDescription\"\n placeholder=\"Organization Description\"\n rows={4}\n required\n />\n </div>\n\n {/* Country Subdivision */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Country Subdivision</label>\n <Input\n name=\"countrySubdivision\"\n placeholder=\"CA-ON\"\n required\n />\n <p className=\"text-xs text-muted-foreground\">\n ISO 3166-2 code for your organization's country and subdivision (e.g. CA-ON, US-NY).\n </p>\n </div>\n\n {/* Languages — checkbox cards */}\n <div className=\"flex flex-col gap-3\">\n <div>\n <label className=\"text-sm font-medium\">{t('languages')}</label>\n <p className=\"text-xs text-muted-foreground mt-0.5\">{t('languagesHint')}</p>\n </div>\n <div className=\"grid grid-cols-2 sm:grid-cols-3 gap-2\">\n {languageOptions.map((opt) => (\n <CheckboxCard\n key={opt.value}\n name=\"orgLanguages\"\n value={opt.value}\n label={opt.label}\n defaultChecked={opt.defaultChecked}\n />\n ))}\n </div>\n </div>\n\n {/* Features */}\n <div className=\"flex flex-col gap-5 border-t pt-6\">\n <div>\n <h4 className=\"font-semibold mb-1\">{t('featuresTitle')}</h4>\n <p className=\"text-xs text-muted-foreground\">{t('featuresDescription')}</p>\n </div>\n\n {/* 3D Viewers */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">{t('viewers3DTitle')}</label>\n <div className=\"grid grid-cols-2 sm:grid-cols-3 gap-2\">\n {viewerOptions.map((opt) => (\n <CheckboxCard\n key={opt.value}\n name=\"appContent\"\n value={opt.value}\n label={opt.label}\n defaultChecked={opt.defaultChecked}\n locked={opt.locked}\n />\n ))}\n </div>\n </div>\n\n {/* Data */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">{t('dataTitle')}</label>\n <div className=\"grid grid-cols-2 sm:grid-cols-3 gap-2\">\n {dataOptions.map((opt) => (\n <CheckboxCard\n key={opt.value}\n name=\"appContent\"\n value={opt.value}\n label={opt.label}\n defaultChecked={opt.defaultChecked}\n />\n ))}\n </div>\n </div>\n </div>\n\n {/* Admin Section */}\n <div className=\"border-t pt-6\">\n <h4 className=\"font-semibold mb-4\">Administrator Account</h4>\n\n <div className=\"grid sm:grid-cols-2 gap-4\">\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Admin Name</label>\n <Input name=\"adminName\" placeholder=\"Admin Name\" required />\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Admin Email</label>\n <Input\n name=\"adminEmail\"\n type=\"email\"\n placeholder=\"admin@example.com\"\n required\n />\n </div>\n </div>\n\n <div className=\"mt-4 flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Password</label>\n <Input\n name=\"adminPassword\"\n type=\"password\"\n placeholder=\"Password\"\n minLength={8}\n required\n />\n </div>\n </div>\n\n {error && (\n <div className=\"rounded-md border border-red-500/20 bg-red-500/10 p-4 text-sm text-red-500\">\n {error}\n </div>\n )}\n\n <Button\n type=\"submit\"\n size=\"lg\"\n className=\"gradient-button w-full\"\n disabled={loading}\n >\n {loading ? 'Initializing Instance...' : 'Initialize Instance'}\n </Button>\n </form>\n </Card>\n\n {/* Contact Info Card */}\n <div className=\"space-y-6\">\n <Card className=\"p-6 hover-card\">\n <h3 className=\"text-lg font-bold mb-3\">{t('contactInfoTitle')}</h3>\n <div className=\"space-y-4\">\n <div>\n <p className=\"text-sm text-muted-foreground mb-1\">{t('emailLabel')}</p>\n <a\n href=\"https://collabdt.org/En/contact\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-primary hover:underline font-medium text-sm\"\n >\n collabdt.org/contact\n </a>\n </div>\n <div>\n <p className=\"text-sm text-muted-foreground mb-1\">{t('websiteLabel')}</p>\n <a\n href=\"https://collabdt.org\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-primary hover:underline font-medium text-sm\"\n >\n collabdt.org\n </a>\n </div>\n </div>\n </Card>\n\n <Card className=\"p-6 hover-card bg-primary/5 border-primary/20\">\n <h3 className=\"text-lg font-bold mb-3\">{t('needHelpTitle')}</h3>\n <p className=\"text-sm text-muted-foreground mb-4\">\n {t('needHelpDescription')}\n </p>\n </Card>\n </div>\n </div>\n </motion.div>\n </div>\n </section>\n </>\n )\n}\n"],"mappings":";AAkCI,SAwGA,UAjGE,KAPF;AA7BJ,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AAEzB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,SAAS,gBAAgB;AAGzB,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AAAA,EACjB,SAAS;AACX,GAMG;AACD,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,cAAc;AACrD,QAAM,YAAY,SAAS,OAAO;AAElC,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,iFAAiF,SAAS,kCAAkC,gBACrI,IAAI,YACA,gDACA,sDACJ;AAAA,MAEF;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL;AAAA,YAC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qBAAC,SAAI,WAAU,aACb;AAAA,iCAAC,QAAK,WAAU,kBACd;AAAA,kCAAC,QAAG,WAAU,0BAA0B,YAAE,kBAAkB,GAAE;AAAA,cAC9D,qBAAC,SAAI,WAAU,aACb;AAAA,qCAAC,SACC;AAAA,sCAAC,OAAE,WAAU,sCAAsC,YAAE,YAAY,GAAE;AAAA,kBACnE;AAAA,oBAAC;AAAA;AAAA,sBACC,MAAK;AAAA,sBACL,QAAO;AAAA,sBACP,KAAI;AAAA,sBACJ,WAAU;AAAA,sBACX;AAAA;AAAA,kBAED;AAAA,mBACF;AAAA,gBACA,qBAAC,SACC;AAAA,sCAAC,OAAE,WAAU,sCAAsC,YAAE,cAAc,GAAE;AAAA,kBACrE;AAAA,oBAAC;AAAA;AAAA,sBACC,MAAK;AAAA,sBACL,QAAO;AAAA,sBACP,KAAI;AAAA,sBACJ,WAAU;AAAA,sBACX;AAAA;AAAA,kBAED;AAAA,mBACF;AAAA,iBACF;AAAA,eACF;AAAA,YAEA,qBAAC,QAAK,WAAU,iDACd;AAAA,kCAAC,QAAG,WAAU,0BAA0B,YAAE,eAAe,GAAE;AAAA,cAC3D,oBAAC,OAAE,WAAU,sCACV,YAAE,qBAAqB,GAC1B;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF,GACF,GACF,GACF;AAEJ;","names":["e"]}
|
|
1
|
+
{"version":3,"sources":["../../../../../src/core/components/organizationConfig/src/organizationConfigContent.tsx"],"sourcesContent":["'use client'\n\n// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { motion } from 'framer-motion'\nimport { Check } from 'lucide-react'\nimport { useRouter } from 'next/navigation'\nimport { useTranslations } from 'next-intl'\nimport { useState } from 'react'\n\nimport { Button } from '../../ui/Button'\nimport { Card } from '../../ui/Card'\nimport { Input } from '../../ui/Input'\nimport { Textarea } from '../../ui/Textarea'\n\n// Reusable checkbox card used for both languages and feature toggles\nfunction CheckboxCard({\n name,\n value,\n label,\n defaultChecked = false,\n}: {\n name: string\n value: string\n label: string\n defaultChecked?: boolean\n}) {\n const [isChecked, setChecked] = useState(defaultChecked)\n\n return (\n <label\n className={`flex items-center gap-2.5 rounded-md border p-3 select-none transition-colors cursor-pointer ${isChecked\n ? 'border-primary bg-primary/5 text-foreground'\n : 'border-input hover:bg-muted/50 text-muted-foreground'\n }`}\n >\n <input\n type=\"checkbox\"\n name={name}\n value={value}\n checked={isChecked}\n onChange={(e) => setChecked(e.target.checked)}\n className=\"sr-only\"\n />\n <span\n className={`flex-shrink-0 w-4 h-4 rounded border flex items-center justify-center transition-colors ${isChecked ? 'bg-primary border-primary' : 'border-input bg-background'\n }`}\n >\n {isChecked && <Check className=\"h-3 w-3 text-primary-foreground\" strokeWidth={3} />}\n </span>\n <span className=\"text-sm font-medium\">{label}</span>\n </label>\n )\n}\n\nexport default function OrganizationConfigContent() {\n const t = useTranslations('OrganizationConfig')\n const router = useRouter()\n\n const [error, setError] = useState<string | null>(null)\n const [loading, setLoading] = useState(false)\n\n function validateOrgName(name: string) {\n const regex = /^[a-z0-9.-]{3,63}$/\n return regex.test(name)\n }\n\n async function handleSubmit(e: React.FormEvent<HTMLFormElement>) {\n e.preventDefault()\n setError(null)\n setLoading(true)\n\n const formData = new FormData(e.currentTarget)\n\n const orgLanguages = formData.getAll('orgLanguages').map(String)\n const appContent = formData.getAll('appContent').map(String)\n\n // Text inputs only, so a non-string entry (a File) means a malformed submit.\n const orgName = formData.get('orgName')\n\n const data = {\n orgName: typeof orgName === 'string' ? orgName : '',\n orgTitle: formData.get('orgTitle'),\n orgDescription: formData.get('orgDescription'),\n countrySubdivision: formData.get('countrySubdivision'),\n orgLanguages,\n appContent,\n adminName: formData.get('adminName'),\n adminEmail: formData.get('adminEmail'),\n adminPassword: formData.get('adminPassword'),\n }\n\n try {\n const res = await fetch('/api/setup', {\n method: 'POST',\n headers: { 'Content-Type': 'application/json' },\n body: JSON.stringify(data),\n })\n\n const json = await res.json()\n\n if (res.ok && json.success) {\n router.push(`/${data.orgName}/auth/signin`)\n return\n }\n\n setError(json.error ?? 'Failed to initialize instance.')\n } catch {\n setError('Network error. Please try again.')\n } finally {\n setLoading(false)\n }\n }\n\n const languageOptions = [\n { value: 'En', label: t('langEnglish'), defaultChecked: true },\n { value: 'Fr', label: t('langFrench') },\n { value: 'Es', label: t('langSpanish') },\n ]\n\n const viewerOptions = [\n { value: 'bim', label: t('viewerBIM'), defaultChecked: true },\n ]\n\n const dataOptions = [\n { value: 'sites', label: t('dataSites'), defaultChecked: true },\n { value: 'buildings', label: t('dataBuildings'), defaultChecked: true },\n { value: 'files', label: t('dataFiles'), defaultChecked: true },\n ]\n\n\n return (\n <>\n <section className=\"min-h-screen py-32 relative flex items-center z-10\">\n <div className=\"container mx-auto px-6\">\n <motion.div\n initial={{ opacity: 0, y: 30 }}\n animate={{ opacity: 1, y: 0 }}\n className=\"max-w-5xl mx-auto\"\n >\n <div className=\"text-center mb-16 space-y-6\">\n <h1 className=\"text-4xl md:text-5xl font-bold\">{t('title')}</h1>\n <p className=\"text-lg text-muted-foreground max-w-3xl mx-auto\">\n {t('description')}\n </p>\n </div>\n\n <div className=\"grid lg:grid-cols-3 gap-8\">\n <Card className=\"lg:col-span-2 p-8\">\n <h3 className=\"text-2xl font-bold mb-6\">{t('setupTitle')}</h3>\n <p className=\"text-muted-foreground mb-8\">{t('setupDescription')}</p>\n\n <form onSubmit={(e) => void handleSubmit(e)} className=\"space-y-6\">\n\n {/* Org Name */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Organization Name</label>\n <Input\n name=\"orgName\"\n placeholder=\"my-org\"\n required\n minLength={3}\n maxLength={63}\n pattern=\"^[a-z0-9.-]+$\"\n />\n <p className=\"text-xs text-muted-foreground\">\n 3–63 characters. Lowercase letters, numbers, dots, and hyphens only.\n </p>\n </div>\n\n {/* Org Title */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Organization Title</label>\n <Input name=\"orgTitle\" placeholder=\"Organization Title\" required />\n </div>\n\n {/* Org Description */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Organization Description</label>\n <Textarea\n name=\"orgDescription\"\n placeholder=\"Organization Description\"\n rows={4}\n required\n />\n </div>\n\n {/* Country Subdivision */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Country Subdivision</label>\n <Input\n name=\"countrySubdivision\"\n placeholder=\"CA-ON\"\n required\n />\n <p className=\"text-xs text-muted-foreground\">\n ISO 3166-2 code for your organization's country and subdivision (e.g. CA-ON, US-NY).\n </p>\n </div>\n\n {/* Languages — checkbox cards */}\n <div className=\"flex flex-col gap-3\">\n <div>\n <label className=\"text-sm font-medium\">{t('languages')}</label>\n <p className=\"text-xs text-muted-foreground mt-0.5\">{t('languagesHint')}</p>\n </div>\n <div className=\"grid grid-cols-2 sm:grid-cols-3 gap-2\">\n {languageOptions.map((opt) => (\n <CheckboxCard\n key={opt.value}\n name=\"orgLanguages\"\n value={opt.value}\n label={opt.label}\n defaultChecked={opt.defaultChecked}\n />\n ))}\n </div>\n </div>\n\n {/* Features */}\n <div className=\"flex flex-col gap-5 border-t pt-6\">\n <div>\n <h4 className=\"font-semibold mb-1\">{t('featuresTitle')}</h4>\n <p className=\"text-xs text-muted-foreground\">{t('featuresDescription')}</p>\n </div>\n\n {/* 3D Viewers */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">{t('viewers3DTitle')}</label>\n <div className=\"grid grid-cols-2 sm:grid-cols-3 gap-2\">\n {viewerOptions.map((opt) => (\n <CheckboxCard\n key={opt.value}\n name=\"appContent\"\n value={opt.value}\n label={opt.label}\n defaultChecked={opt.defaultChecked}\n />\n ))}\n </div>\n </div>\n\n {/* Data */}\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">{t('dataTitle')}</label>\n <div className=\"grid grid-cols-2 sm:grid-cols-3 gap-2\">\n {dataOptions.map((opt) => (\n <CheckboxCard\n key={opt.value}\n name=\"appContent\"\n value={opt.value}\n label={opt.label}\n defaultChecked={opt.defaultChecked}\n />\n ))}\n </div>\n </div>\n </div>\n\n {/* Admin Section */}\n <div className=\"border-t pt-6\">\n <h4 className=\"font-semibold mb-4\">Administrator Account</h4>\n\n <div className=\"grid sm:grid-cols-2 gap-4\">\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Admin Name</label>\n <Input name=\"adminName\" placeholder=\"Admin Name\" required />\n </div>\n\n <div className=\"flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Admin Email</label>\n <Input\n name=\"adminEmail\"\n type=\"email\"\n placeholder=\"admin@example.com\"\n required\n />\n </div>\n </div>\n\n <div className=\"mt-4 flex flex-col gap-2\">\n <label className=\"text-sm font-medium\">Password</label>\n <Input\n name=\"adminPassword\"\n type=\"password\"\n placeholder=\"Password\"\n minLength={8}\n required\n />\n </div>\n </div>\n\n {error && (\n <div className=\"rounded-md border border-red-500/20 bg-red-500/10 p-4 text-sm text-red-500\">\n {error}\n </div>\n )}\n\n <Button\n type=\"submit\"\n size=\"lg\"\n className=\"gradient-button w-full\"\n disabled={loading}\n >\n {loading ? 'Initializing Instance...' : 'Initialize Instance'}\n </Button>\n </form>\n </Card>\n\n {/* Contact Info Card */}\n <div className=\"space-y-6\">\n <Card className=\"p-6 hover-card\">\n <h3 className=\"text-lg font-bold mb-3\">{t('contactInfoTitle')}</h3>\n <div className=\"space-y-4\">\n <div>\n <p className=\"text-sm text-muted-foreground mb-1\">{t('emailLabel')}</p>\n <a\n href=\"https://collabdt.org/En/contact\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-primary hover:underline font-medium text-sm\"\n >\n collabdt.org/contact\n </a>\n </div>\n <div>\n <p className=\"text-sm text-muted-foreground mb-1\">{t('websiteLabel')}</p>\n <a\n href=\"https://collabdt.org\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-primary hover:underline font-medium text-sm\"\n >\n collabdt.org\n </a>\n </div>\n </div>\n </Card>\n\n <Card className=\"p-6 hover-card bg-primary/5 border-primary/20\">\n <h3 className=\"text-lg font-bold mb-3\">{t('needHelpTitle')}</h3>\n <p className=\"text-sm text-muted-foreground mb-4\">\n {t('needHelpDescription')}\n </p>\n </Card>\n </div>\n </div>\n </motion.div>\n </div>\n </section>\n </>\n )\n}\n"],"mappings":";AA+BI,SAsGA,UAhGE,KANF;AA1BJ,SAAS,cAAc;AACvB,SAAS,aAAa;AACtB,SAAS,iBAAiB;AAC1B,SAAS,uBAAuB;AAChC,SAAS,gBAAgB;AAEzB,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,SAAS,gBAAgB;AAGzB,SAAS,aAAa;AAAA,EACpB;AAAA,EACA;AAAA,EACA;AAAA,EACA,iBAAiB;AACnB,GAKG;AACD,QAAM,CAAC,WAAW,UAAU,IAAI,SAAS,cAAc;AAEvD,SACE;AAAA,IAAC;AAAA;AAAA,MACC,WAAW,gGAAgG,YACrG,gDACA,sDACJ;AAAA,MAEF;AAAA;AAAA,UAAC;AAAA;AAAA,YACC,MAAK;AAAA,YACL;AAAA,YACA;AAAA,YACA,SAAS;AAAA,YACT,UAAU,CAAC,MAAM,WAAW,EAAE,OAAO,OAAO;AAAA,YAC5C,WAAU;AAAA;AAAA,QACZ;AAAA,QACA;AAAA,UAAC;AAAA;AAAA,YACC,WAAW,2FAA2F,YAAY,8BAA8B,4BAC9I;AAAA,YAED,uBAAa,oBAAC,SAAM,WAAU,mCAAkC,aAAa,GAAG;AAAA;AAAA,QACnF;AAAA,QACA,oBAAC,UAAK,WAAU,uBAAuB,iBAAM;AAAA;AAAA;AAAA,EAC/C;AAEJ;AAEe,SAAR,4BAA6C;AAClD,QAAM,IAAI,gBAAgB,oBAAoB;AAC9C,QAAM,SAAS,UAAU;AAEzB,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,IAAI;AACtD,QAAM,CAAC,SAAS,U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d;AAAA,kCAAC,QAAG,WAAU,0BAA0B,YAAE,eAAe,GAAE;AAAA,cAC3D,oBAAC,OAAE,WAAU,sCACV,YAAE,qBAAqB,GAC1B;AAAA,eACF;AAAA,aACF;AAAA,WACF;AAAA;AAAA;AAAA,EACF,GACF,GACF,GACF;AAEJ;","names":["e"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"viewerAccess.d.ts","sourceRoot":"","sources":["../../../../src/core/components/viewers/viewerAccess.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"viewerAccess.d.ts","sourceRoot":"","sources":["../../../../src/core/components/viewers/viewerAccess.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAe,MAAM,qBAAqB,CAAA;AAE/E;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,YAAY,CAAC,YAAY,CAAC,GAAG,OAAO,CAKlG"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { parsePluginViewerKey } from "../../plugins/host/pluginViewerKey";
|
|
2
|
+
import { ALWAYS_AVAILABLE_VIEWERS } from "../../utils/appContent";
|
|
2
3
|
function isViewerAllowed(viewer, appContent) {
|
|
3
4
|
if (parsePluginViewerKey(viewer) !== null) return true;
|
|
5
|
+
if (ALWAYS_AVAILABLE_VIEWERS.includes(viewer)) return true;
|
|
4
6
|
return appContent.length === 0 || appContent.includes(viewer);
|
|
5
7
|
}
|
|
6
8
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/components/viewers/viewerAccess.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { parsePluginViewerKey } from '../../plugins/host/pluginViewerKey'\n\nimport type { Organization, ViewerKey, ViewerNames } from '../../types/dbTypes'\n\n/**\n * Whether this organization may show the requested viewer. `appContent` is a Prisma enum and\n * can never hold a plugin key, so a plugin page is gated by enablement instead.\n */\nexport function isViewerAllowed(viewer: ViewerKey, appContent: Organization['appContent']): boolean {\n if (parsePluginViewerKey(viewer) !== null) return true\n\n return appContent.length === 0 || appContent.includes(viewer as ViewerNames)\n}\n"],"mappings":"AAGA,SAAS,4BAA4B;
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/components/viewers/viewerAccess.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { parsePluginViewerKey } from '../../plugins/host/pluginViewerKey'\nimport { ALWAYS_AVAILABLE_VIEWERS } from '../../utils/appContent'\n\nimport type { Organization, ViewerKey, ViewerNames } from '../../types/dbTypes'\n\n/**\n * Whether this organization may show the requested viewer. `appContent` is a Prisma enum and\n * can never hold a plugin key, so a plugin page is gated by enablement instead.\n */\nexport function isViewerAllowed(viewer: ViewerKey, appContent: Organization['appContent']): boolean {\n if (parsePluginViewerKey(viewer) !== null) return true\n if (ALWAYS_AVAILABLE_VIEWERS.includes(viewer as ViewerNames)) return true\n\n return appContent.length === 0 || appContent.includes(viewer as ViewerNames)\n}\n"],"mappings":"AAGA,SAAS,4BAA4B;AACrC,SAAS,gCAAgC;AAQlC,SAAS,gBAAgB,QAAmB,YAAiD;AAClG,MAAI,qBAAqB,MAAM,MAAM,KAAM,QAAO;AAClD,MAAI,yBAAyB,SAAS,MAAqB,EAAG,QAAO;AAErE,SAAO,WAAW,WAAW,KAAK,WAAW,SAAS,MAAqB;AAC7E;","names":[]}
|
|
@@ -1,16 +1,8 @@
|
|
|
1
1
|
import type { PluginInstallation, PluginRecord, PluginUserSetting } from '../../types/plugins';
|
|
2
2
|
import type { ApiAdapter } from '../ports/apiAdapter';
|
|
3
3
|
/**
|
|
4
|
-
* Enablement state for the plugins page.
|
|
5
|
-
*
|
|
6
|
-
* Both lists are small — bounded by the number of plugins a deployment has — so
|
|
7
|
-
* they are fetched whole and mutated by revalidation rather than by patching the
|
|
8
|
-
* cache. The page applies its own optimistic override on top, so the switch does
|
|
9
|
-
* not wait for the round trip.
|
|
10
|
-
*
|
|
11
|
-
* Writes are plain async functions, not `useSWRMutation`: every one of them is a
|
|
12
|
-
* per-plugin upsert triggered from a switch, and the mutation-hook-per-key shape
|
|
13
|
-
* the other domains use would mean one hook per plugin per control.
|
|
4
|
+
* Enablement state for the plugins page. Both lists are bounded by the plugin count, so they are
|
|
5
|
+
* fetched whole and revalidated; writes are plain async functions, not one `useSWRMutation` per plugin.
|
|
14
6
|
*/
|
|
15
7
|
export declare function createPluginHooks(adapter: ApiAdapter): {
|
|
16
8
|
usePluginInstallations: () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createPluginHooks.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/plugins/createPluginHooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAKrD
|
|
1
|
+
{"version":3,"file":"createPluginHooks.d.ts","sourceRoot":"","sources":["../../../../src/core/hooks/plugins/createPluginHooks.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAC9F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAKrD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,UAAU;;;;;;;;;;;iCA4Cf,MAAM,cAAc,MAAM;;;;QAe1D,4EAA4E;yBACrD,MAAM,SAAS,OAAO;4BAKnB,MAAM;;;kCApCF,MAAM,SAAS,OAAO,CAAC,kBAAkB,CAAC;qCAIvC,MAAM;iCAIV,MAAM,SAAS,OAAO,CAAC,iBAAiB,CAAC;;EAoC3E"}
|
|
@@ -49,8 +49,7 @@ function createPluginHooks(adapter) {
|
|
|
49
49
|
records: data != null ? data : [],
|
|
50
50
|
isLoading,
|
|
51
51
|
isError: error,
|
|
52
|
-
// Arrow properties, not method shorthand: callers destructure these
|
|
53
|
-
// method shorthand would imply a `this` they do not have.
|
|
52
|
+
// Arrow properties, not method shorthand: callers destructure these and have no `this`.
|
|
54
53
|
/** Create or replace one document. `key` is the plugin's own identifier. */
|
|
55
54
|
put: async (recordKey, value) => {
|
|
56
55
|
const saved = await adapter.putPluginRecord(pluginId, collection, recordKey, value);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/hooks/plugins/createPluginHooks.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport useSWR, { mutate } from 'swr'\n\nimport type { PluginInstallation, PluginRecord, PluginUserSetting } from '../../types/plugins'\nimport type { ApiAdapter } from '../ports/apiAdapter'\n\nconst INSTALLATIONS = ['pluginInstallations'] as const\nconst USER_SETTINGS = ['pluginUserSettings'] as const\n\n/**\n * Enablement state for the plugins page
|
|
1
|
+
{"version":3,"sources":["../../../../src/core/hooks/plugins/createPluginHooks.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport useSWR, { mutate } from 'swr'\n\nimport type { PluginInstallation, PluginRecord, PluginUserSetting } from '../../types/plugins'\nimport type { ApiAdapter } from '../ports/apiAdapter'\n\nconst INSTALLATIONS = ['pluginInstallations'] as const\nconst USER_SETTINGS = ['pluginUserSettings'] as const\n\n/**\n * Enablement state for the plugins page. Both lists are bounded by the plugin count, so they are\n * fetched whole and revalidated; writes are plain async functions, not one `useSWRMutation` per plugin.\n */\nexport function createPluginHooks(adapter: ApiAdapter) {\n const usePluginInstallations = () => {\n const { data, error, isLoading } = useSWR<PluginInstallation[]>(\n INSTALLATIONS,\n () => adapter.listPluginInstallations(),\n )\n\n return {\n installations: data ?? [],\n isLoading,\n isError: error,\n }\n }\n\n const usePluginUserSettings = () => {\n const { data, error, isLoading } = useSWR<PluginUserSetting[]>(\n USER_SETTINGS,\n () => adapter.listPluginUserSettings(),\n )\n\n return {\n userSettings: data ?? [],\n isLoading,\n isError: error,\n }\n }\n\n // Not a hook: the plugins page hands these to its `PluginsActions` port and calls them from event handlers.\n const pluginActions = {\n async setInstallation(pluginId: string, patch: Partial<PluginInstallation>) {\n await adapter.upsertPluginInstallation(pluginId, patch)\n await mutate(INSTALLATIONS)\n },\n async removeInstallation(pluginId: string) {\n await adapter.deletePluginInstallation(pluginId)\n await mutate(INSTALLATIONS)\n },\n async setUserSetting(pluginId: string, patch: Partial<PluginUserSetting>) {\n await adapter.upsertPluginUserSetting(pluginId, patch)\n await mutate(USER_SETTINGS)\n },\n }\n\n // `pluginId` comes from the plugin scope at the call site, never from the plugin itself.\n const usePluginRecords = (pluginId: string, collection: string) => {\n const key = pluginId && collection ? ['pluginRecords', pluginId, collection] as const : null\n\n const { data, error, isLoading } = useSWR<PluginRecord[]>(\n key,\n () => adapter.listPluginRecords(pluginId, collection),\n )\n\n const revalidate = () => (key ? mutate(key) : Promise.resolve())\n\n return {\n records: data ?? [],\n isLoading,\n isError: error,\n // Arrow properties, not method shorthand: callers destructure these and have no `this`.\n /** Create or replace one document. `key` is the plugin's own identifier. */\n put: async (recordKey: string, value: unknown) => {\n const saved = await adapter.putPluginRecord(pluginId, collection, recordKey, value)\n await revalidate()\n return saved\n },\n remove: async (recordKey: string) => {\n await adapter.deletePluginRecord(pluginId, collection, recordKey)\n await revalidate()\n },\n }\n }\n\n return { usePluginInstallations, usePluginUserSettings, usePluginRecords, pluginActions }\n}\n"],"mappings":"AAGA,OAAO,UAAU,cAAc;AAK/B,MAAM,gBAAgB,CAAC,qBAAqB;AAC5C,MAAM,gBAAgB,CAAC,oBAAoB;AAMpC,SAAS,kBAAkB,SAAqB;AACrD,QAAM,yBAAyB,MAAM;AACnC,UAAM,EAAE,MAAM,OAAO,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AW;AACjB,eAAO;AAAA,MACT;AAAA,MACA,QAAQ,OAAO,cAAsB;AACnC,cAAM,QAAQ,mBAAmB,UAAU,YAAY,SAAS;AAChE,cAAM,WAAW;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AAEA,SAAO,EAAE,wBAAwB,uBAAuB,kBAAkB,cAAc;AAC1F;","names":[]}
|
|
@@ -934,7 +934,6 @@
|
|
|
934
934
|
"featuresDescription": "Seleccione las funcionalidades a habilitar en su instancia",
|
|
935
935
|
"viewers3DTitle": "Visores 3D",
|
|
936
936
|
"dataTitle": "Datos",
|
|
937
|
-
"viewerMap": "Mapa",
|
|
938
937
|
"viewerBIM": "BIM",
|
|
939
938
|
"viewerPointCloud": "Nube de puntos",
|
|
940
939
|
"dataSites": "Sitios",
|
|
@@ -934,7 +934,6 @@
|
|
|
934
934
|
"featuresDescription": "Sélectionnez les fonctionnalités à activer dans votre instance",
|
|
935
935
|
"viewers3DTitle": "Visionneuses 3D",
|
|
936
936
|
"dataTitle": "Données",
|
|
937
|
-
"viewerMap": "Carte",
|
|
938
937
|
"viewerBIM": "BIM",
|
|
939
938
|
"viewerPointCloud": "Nuage de points",
|
|
940
939
|
"dataSites": "Sites",
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { ViewerNames } from '../types/dbTypes';
|
|
2
2
|
import type { Organization } from '../types/dbTypes';
|
|
3
|
+
/** Viewers every organization has, whatever its `appContent` says, so they are never stored in it. */
|
|
4
|
+
export declare const ALWAYS_AVAILABLE_VIEWERS: readonly ViewerNames[];
|
|
3
5
|
/**
|
|
4
|
-
* The viewers an organization
|
|
5
|
-
*
|
|
6
|
-
* An empty `appContent` means "not configured", which grants everything rather than nothing, so
|
|
7
|
-
* an organization that never set the field keeps the full app. The map is always included.
|
|
8
|
-
*
|
|
9
|
-
* Shared so every entry point into a viewer agrees: the sidebar and the map popover's tool row
|
|
10
|
-
* were drifting, and a tool that navigates somewhere the sidebar hides is a dead end.
|
|
6
|
+
* The viewers an organization can reach. An empty `appContent` means "not configured" and grants
|
|
7
|
+
* every optional viewer; the always-available ones are included either way.
|
|
11
8
|
*/
|
|
12
9
|
export declare function resolveAppContent(organization?: Organization | null): ViewerNames[];
|
|
13
10
|
/** Whether an organization can reach a viewer at all. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appContent.d.ts","sourceRoot":"","sources":["../../../src/core/utils/appContent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"appContent.d.ts","sourceRoot":"","sources":["../../../src/core/utils/appContent.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAA;AAE9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAEpD,sGAAsG;AACtG,eAAO,MAAM,wBAAwB,EAAE,SAAS,WAAW,EAI1D,CAAA;AAUD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,CAAC,EAAE,YAAY,GAAG,IAAI,GAAG,WAAW,EAAE,CAInF;AAED,yDAAyD;AACzD,wBAAgB,aAAa,CAC3B,YAAY,EAAE,YAAY,GAAG,IAAI,GAAG,SAAS,EAC7C,MAAM,EAAE,WAAW,GAClB,OAAO,CAET"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { ViewerNames } from "../types/dbTypes";
|
|
2
|
-
const
|
|
2
|
+
const ALWAYS_AVAILABLE_VIEWERS = [
|
|
3
|
+
ViewerNames.map,
|
|
3
4
|
ViewerNames.plugins,
|
|
5
|
+
ViewerNames.settings
|
|
6
|
+
];
|
|
7
|
+
const OPTIONAL_VIEWERS = [
|
|
4
8
|
ViewerNames.bim,
|
|
5
9
|
ViewerNames.sites,
|
|
6
10
|
ViewerNames.infrastructure,
|
|
@@ -10,13 +14,14 @@ const OPTIONAL_VIEWERS = [
|
|
|
10
14
|
function resolveAppContent(organization) {
|
|
11
15
|
var _a;
|
|
12
16
|
const configured = (_a = organization == null ? void 0 : organization.appContent) != null ? _a : [];
|
|
13
|
-
|
|
14
|
-
return [
|
|
17
|
+
const optional = configured.length === 0 ? OPTIONAL_VIEWERS : configured;
|
|
18
|
+
return [.../* @__PURE__ */ new Set([...ALWAYS_AVAILABLE_VIEWERS, ...optional])];
|
|
15
19
|
}
|
|
16
20
|
function hasAppContent(organization, viewer) {
|
|
17
21
|
return resolveAppContent(organization).includes(viewer);
|
|
18
22
|
}
|
|
19
23
|
export {
|
|
24
|
+
ALWAYS_AVAILABLE_VIEWERS,
|
|
20
25
|
hasAppContent,
|
|
21
26
|
resolveAppContent
|
|
22
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/core/utils/appContent.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { ViewerNames } from '../types/dbTypes'\n\nimport type { Organization } from '../types/dbTypes'\n\n/**
|
|
1
|
+
{"version":3,"sources":["../../../src/core/utils/appContent.ts"],"sourcesContent":["// SPDX-License-Identifier: AGPL-3.0-or-later\n// Copyright (C) 2025 Collab Digital Twins\n\nimport { ViewerNames } from '../types/dbTypes'\n\nimport type { Organization } from '../types/dbTypes'\n\n/** Viewers every organization has, whatever its `appContent` says, so they are never stored in it. */\nexport const ALWAYS_AVAILABLE_VIEWERS: readonly ViewerNames[] = [\n ViewerNames.map,\n ViewerNames.plugins,\n ViewerNames.settings,\n]\n\nconst OPTIONAL_VIEWERS: ViewerNames[] = [\n ViewerNames.bim,\n ViewerNames.sites,\n ViewerNames.infrastructure,\n ViewerNames.buildings,\n ViewerNames.files,\n]\n\n/**\n * The viewers an organization can reach. An empty `appContent` means \"not configured\" and grants\n * every optional viewer; the always-available ones are included either way.\n */\nexport function resolveAppContent(organization?: Organization | null): ViewerNames[] {\n const configured = organization?.appContent ?? []\n const optional = configured.length === 0 ? OPTIONAL_VIEWERS : (configured as ViewerNames[])\n return [...new Set([...ALWAYS_AVAILABLE_VIEWERS, ...optional])]\n}\n\n/** Whether an organization can reach a viewer at all. */\nexport function hasAppContent(\n organization: Organization | null | undefined,\n viewer: ViewerNames,\n): boolean {\n return resolveAppContent(organization).includes(viewer)\n}\n"],"mappings":"AAGA,SAAS,mBAAmB;AAKrB,MAAM,2BAAmD;AAAA,EAC9D,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACd;AAEA,MAAM,mBAAkC;AAAA,EACtC,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AAAA,EACZ,YAAY;AACd;AAMO,SAAS,kBAAkB,cAAmD;AA1BrF;AA2BE,QAAM,cAAa,kDAAc,eAAd,YAA4B,CAAC;AAChD,QAAM,WAAW,WAAW,WAAW,IAAI,mBAAoB;AAC/D,SAAO,CAAC,GAAG,oBAAI,IAAI,CAAC,GAAG,0BAA0B,GAAG,QAAQ,CAAC,CAAC;AAChE;AAGO,SAAS,cACd,cACA,QACS;AACT,SAAO,kBAAkB,YAAY,EAAE,SAAS,MAAM;AACxD;","names":[]}
|