Compare commits

..

1 Commits

2 changed files with 31 additions and 18 deletions

View File

@ -99,6 +99,7 @@ export const ModuleBuilderTabContent: React.FC = () => {
const [creatingModule, setCreatingModule] = useState(false);
const [exportingZip, setExportingZip] = useState(false);
const [syncingRepo, setSyncingRepo] = useState(false);
const [syncRepoEnabled, setSyncRepoEnabled] = useState(false);
const [showExportMenu, setShowExportMenu] = useState(false);
const [categories, setCategories] = useState<BuilderCategorySummary[]>([]);
@ -157,6 +158,10 @@ export const ModuleBuilderTabContent: React.FC = () => {
useEffect(() => {
fetchModules();
moduleBuilderService
.getConfig()
.then((cfg) => setSyncRepoEnabled(Boolean(cfg?.sync_repo_enabled)))
.catch(() => setSyncRepoEnabled(false));
}, []);
// Compute active module object
@ -1273,25 +1278,27 @@ export const ModuleBuilderTabContent: React.FC = () => {
</div>
</button>
<button
type="button"
onClick={() => {
setShowExportMenu(false);
handleSyncContentRepo();
}}
disabled={syncingRepo}
className="w-full text-left px-3.5 py-2.5 hover:bg-emerald-50/50 flex items-start gap-2.5 transition-colors group"
>
<UploadCloud className="h-4 w-4 text-emerald-600 mt-0.5 shrink-0" />
<div>
<div className="text-xs font-bold text-slate-800 group-hover:text-emerald-600">
Sync to Server Repository
{syncRepoEnabled && (
<button
type="button"
onClick={() => {
setShowExportMenu(false);
handleSyncContentRepo();
}}
disabled={syncingRepo}
className="w-full text-left px-3.5 py-2.5 hover:bg-emerald-50/50 flex items-start gap-2.5 transition-colors group"
>
<UploadCloud className="h-4 w-4 text-emerald-600 mt-0.5 shrink-0" />
<div>
<div className="text-xs font-bold text-slate-800 group-hover:text-emerald-600">
Sync to Server Repository
</div>
<div className="text-[10px] text-slate-400">
Compile and write directly to server content repository
</div>
</div>
<div className="text-[10px] text-slate-400">
Compile and write directly to server content repository
</div>
</div>
</button>
</button>
)}
<div className="my-1 border-t border-slate-100" />

View File

@ -219,6 +219,12 @@ export const moduleBuilderService = {
return res.data;
},
// Feature config
async getConfig(): Promise<{ sync_repo_enabled: boolean }> {
const res = await api.get('/api/admin/module-builder/config');
return res.data;
},
// Import JSON
async importModuleJson(moduleCode: string, contents: any[]): Promise<any> {
const res = await api.post(`/api/admin/module-builder/${moduleCode}/import-json`, { contents });