@mostajs/setup 2.1.35 → 2.1.36
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.
|
@@ -379,6 +379,7 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
|
|
|
379
379
|
const [adminConfig, setAdminConfig] = useState({ firstName: '', lastName: '', email: '', password: '', confirmPassword: '' });
|
|
380
380
|
const [seedOptions, setSeedOptions] = useState({});
|
|
381
381
|
const [availableSeeds, setAvailableSeeds] = useState([]);
|
|
382
|
+
const [seedStatus, setSeedStatus] = useState({});
|
|
382
383
|
const [availableModules, setAvailableModules] = useState([]);
|
|
383
384
|
const [selectedModules, setSelectedModules] = useState([]);
|
|
384
385
|
const [detectedModules, setDetectedModules] = useState([]);
|
|
@@ -959,7 +960,49 @@ export default function SetupWizard({ t: tProp, onComplete, endpoints = {}, dbNa
|
|
|
959
960
|
fontSize: 12, backgroundColor: '#f0f9ff', color: '#0369a1',
|
|
960
961
|
border: '1px solid #bae6fd', borderRadius: 16, padding: '4px 10px',
|
|
961
962
|
}, children: [mod.icon, " ", mod.label] }, key)) : null;
|
|
962
|
-
}) })] }), availableSeeds.length > 0 && (_jsxs("div", { style: S.summaryCard, children: [_jsx("div", { style: S.summaryTitle, children: t('setup.summary.seedTitle') }), _jsx("p", { style: { ...S.summaryText, marginBottom: 12 }, children: t('setup.summary.seedInfo') }), availableSeeds.map(seed => (_jsxs("div", { style: S.checkRow, children: [_jsx("input", { type: "checkbox", style: S.checkbox, checked: seedOptions[seed.key] ?? false, onChange: e => setSeedOptions({ ...seedOptions, [seed.key]: e.target.checked }), disabled: installing || !!installResult?.ok }), _jsxs("div", {
|
|
963
|
+
}) })] }), availableSeeds.length > 0 && (_jsxs("div", { style: S.summaryCard, children: [_jsx("div", { style: S.summaryTitle, children: t('setup.summary.seedTitle') }), _jsx("p", { style: { ...S.summaryText, marginBottom: 12 }, children: t('setup.summary.seedInfo') }), availableSeeds.map(seed => (_jsxs("div", { style: { ...S.checkRow, alignItems: 'center' }, children: [_jsx("input", { type: "checkbox", style: S.checkbox, checked: seedOptions[seed.key] ?? false, onChange: e => setSeedOptions({ ...seedOptions, [seed.key]: e.target.checked }), disabled: installing || !!installResult?.ok }), _jsxs("div", { style: { flex: 1 }, children: [_jsx("div", { style: { fontSize: 13, fontWeight: 500 }, children: seed.label }), _jsx("div", { style: { fontSize: 12, color: '#9ca3af' }, children: seed.description })] }), setupMode === 'net' && (_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 6 }, children: [_jsx("button", { style: {
|
|
964
|
+
padding: '3px 10px', borderRadius: 4, border: 'none', cursor: 'pointer',
|
|
965
|
+
fontSize: 12, fontWeight: 600,
|
|
966
|
+
backgroundColor: seedStatus[seed.key]?.ok ? '#d1fae5' : '#6366f1',
|
|
967
|
+
color: seedStatus[seed.key]?.ok ? '#065f46' : '#fff',
|
|
968
|
+
opacity: seedStatus[seed.key]?.sending ? 0.6 : 1,
|
|
969
|
+
}, disabled: seedStatus[seed.key]?.sending || !netUrl, onClick: async () => {
|
|
970
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: true } }));
|
|
971
|
+
try {
|
|
972
|
+
// Fetch the full seed definition from setup.json
|
|
973
|
+
const sjRes = await fetch(ep.setupJson);
|
|
974
|
+
const sjData = await sjRes.json();
|
|
975
|
+
const setupJson = sjData.config ? sjData : null;
|
|
976
|
+
// Find the seed in the raw setup.json
|
|
977
|
+
const rawRes = await fetch('/setup.json');
|
|
978
|
+
const rawJson = await rawRes.json();
|
|
979
|
+
const seedDef = (rawJson.seeds || []).find((s) => s.key === seed.key);
|
|
980
|
+
if (!seedDef) {
|
|
981
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: false, result: 'Seed non trouve dans setup.json', ok: false } }));
|
|
982
|
+
return;
|
|
983
|
+
}
|
|
984
|
+
// Send as seed-file format with just this one seed
|
|
985
|
+
const payload = { seeds: [seedDef] };
|
|
986
|
+
// Include RBAC if this is the first seed (roles/permissions needed)
|
|
987
|
+
if (rawJson.rbac)
|
|
988
|
+
payload.rbac = rawJson.rbac;
|
|
989
|
+
const res = await fetch(netUrl + '/api/seed-file', {
|
|
990
|
+
method: 'POST',
|
|
991
|
+
headers: { 'Content-Type': 'application/json' },
|
|
992
|
+
body: JSON.stringify(payload),
|
|
993
|
+
});
|
|
994
|
+
const data = await res.json();
|
|
995
|
+
if (data.ok) {
|
|
996
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: false, result: data.message, ok: true } }));
|
|
997
|
+
}
|
|
998
|
+
else {
|
|
999
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: false, result: data.error || 'Erreur', ok: false } }));
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
1002
|
+
catch (err) {
|
|
1003
|
+
setSeedStatus(prev => ({ ...prev, [seed.key]: { sending: false, result: err.message, ok: false } }));
|
|
1004
|
+
}
|
|
1005
|
+
}, children: seedStatus[seed.key]?.sending ? '...' : seedStatus[seed.key]?.ok ? '✓' : 'Envoyer' }), seedStatus[seed.key]?.result && (_jsx("span", { style: { fontSize: 11, color: seedStatus[seed.key]?.ok ? '#059669' : '#dc2626' }, children: seedStatus[seed.key]?.result }))] }))] }, seed.key)))] })), installResult && (_jsx("div", { style: S.alert(installResult.ok ? 'success' : 'error'), children: installResult.ok ? (_jsxs(_Fragment, { children: [_jsxs("div", { style: { fontWeight: 600, marginBottom: 4 }, children: ["\u2705 ", t('setup.summary.success')] }), _jsx("div", { children: t('setup.summary.successDesc') }), installResult.needsRestart && (_jsx("div", { style: { color: '#92400e', fontWeight: 500, marginTop: 8 }, children: t('setup.summary.needsRestart') }))] })) : (_jsxs("div", { children: ["\u274C ", installResult.error] })) })), installResult?.ok && (_jsxs("div", { style: { ...S.summaryCard, marginTop: 16 }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8, marginBottom: 12 }, children: [_jsx("span", { style: { fontSize: 18 }, children: "\uD83D\uDD0C" }), _jsx("div", { style: S.summaryTitle, children: "Cablage des modules" })] }), _jsx("div", { style: { fontSize: 13, color: '#6b7280', marginBottom: 12 }, children: "Cablez les modules pour injecter schemas, routes API, pages et permissions dans l'application." }), wireMessage && (_jsx("div", { style: S.alert(wireMessage.type), children: wireMessage.text })), wireLoading ? (_jsx("div", { style: { textAlign: 'center', padding: 12, color: '#6b7280' }, children: "Chargement..." })) : wireModules.length === 0 ? (_jsx("div", { style: { textAlign: 'center', padding: 12, color: '#9ca3af' }, children: "Aucun manifeste de cablage trouve" })) : (_jsx("div", { style: S.wireGrid, children: wireModules.map((mod) => (_jsxs("div", { style: S.wireCard(mod.installed), children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', justifyContent: 'space-between' }, children: [_jsxs("div", { style: { display: 'flex', alignItems: 'center', gap: 8 }, children: [_jsx("span", { style: S.wireStatus(mod.installed) }), _jsxs("span", { style: { fontWeight: 700, fontSize: 14 }, children: ["@mostajs/", mod.name] })] }), _jsx("span", { style: {
|
|
963
1006
|
fontSize: 10, fontWeight: 600, padding: '2px 6px', borderRadius: 4,
|
|
964
1007
|
backgroundColor: mod.type === 'business' ? '#dbeafe' : '#f3e8ff',
|
|
965
1008
|
color: mod.type === 'business' ? '#1e40af' : '#6b21a8',
|
package/package.json
CHANGED