feat: auto-create local workspace mirror for Gitea projects
- Opening /gitea-workspace auto-creates a local workspace with same name
- New Page/New Folder in remote context → saves to local mirror workspace
- Sidebar stays focused on remote workspace (🔗 icon, remote tree)
- local_ws_id passed to Alpine for API calls
- /api/local-workspace/items accepts workspace_id in body
This commit is contained in:
+18
-9
@@ -576,6 +576,7 @@
|
||||
pageTitle: '{% block page_title %}FlowDeck{% endblock %}',
|
||||
lastEdited: '{{ last_edited }}',
|
||||
workspaceKey: '{{ workspace_key }}',
|
||||
localWsId: {{ local_ws_id|default(0) }},
|
||||
currentView: 'home',
|
||||
contextMenu: { visible: false, x: 0, y: 0, pageId: null, pageName: '' },
|
||||
contextActions: {},
|
||||
@@ -875,16 +876,16 @@
|
||||
const name = prompt('File name:');
|
||||
if (!name || !name.trim()) return;
|
||||
const wk = this.workspaceKey || '';
|
||||
// Gitea/remote workspace: create file in the repo
|
||||
// Gitea/remote workspace: create local file in mirror workspace, keep remote focus
|
||||
if (wk.includes('/')) {
|
||||
const parts = wk.split('/');
|
||||
fetch('/api/gitea/projects/' + parts[0] + '/' + parts[1] + '/file', {
|
||||
method: 'PUT',
|
||||
const wsId = this.localWsId || 0;
|
||||
fetch('/api/local-workspace/items', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
|
||||
body: JSON.stringify({ path: name.trim() + '.md', content: '# ' + name.trim(), message: 'Create via FlowDeck' })
|
||||
body: JSON.stringify({ name: name.trim(), type: 'page', workspace_id: wsId })
|
||||
})
|
||||
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
|
||||
.then(data => { window.location.reload(); })
|
||||
.then(data => { window.location.href = `/pages/${data.id}`; })
|
||||
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
|
||||
return;
|
||||
}
|
||||
@@ -902,13 +903,21 @@
|
||||
const name = prompt('Folder name:');
|
||||
if (!name || !name.trim()) return;
|
||||
const wk = this.workspaceKey || '';
|
||||
// Gitea workspace: folders aren't a concept — just warn
|
||||
// Gitea workspace: create folder in local mirror workspace
|
||||
if (wk.includes('/')) {
|
||||
this.toast('Folders are not supported for remote workspaces. Use local workspace.', 'warning');
|
||||
const wsId = this.localWsId || 0;
|
||||
fetch('/api/local-workspace/items', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
|
||||
body: JSON.stringify({ name: name.trim(), type: 'folder', workspace_id: wsId })
|
||||
})
|
||||
.then(r => { if (!r.ok) throw new Error('Failed'); return r.json(); })
|
||||
.then(data => { this.toast('Folder created in local workspace', 'success'); })
|
||||
.catch(err => { this.toast('Failed: ' + err.message, 'error'); });
|
||||
return;
|
||||
}
|
||||
// Local workspace
|
||||
fetch('/api/local-workspace/items', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', 'X-CSRF-Token': this.getCsrfToken() },
|
||||
body: JSON.stringify({ name: name.trim(), type: 'folder' })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user