feat: added blog selection for existing blog
This commit is contained in:
@@ -111,6 +111,7 @@
|
||||
"Offline Gate": "Offline-Sperre",
|
||||
"Open": "Öffnen",
|
||||
"Open Data Folder": "Datenordner öffnen",
|
||||
"Open Existing Blog": "Bestehenden Blog öffnen",
|
||||
"Open in Browser": "Im Browser öffnen",
|
||||
"Opened URL": "URL geöffnet",
|
||||
"Orphan Files": "Verwaiste Dateien",
|
||||
@@ -133,6 +134,7 @@
|
||||
"Script": "Skript",
|
||||
"Scripts": "Skripte",
|
||||
"Select Project": "Projekt auswählen",
|
||||
"Select existing blog folder": "Bestehenden Blog-Ordner auswählen",
|
||||
"Settings": "Einstellungen",
|
||||
"Sidebar, tabs, panel, and assistant panes are inspectable DOM regions": "Seitenleiste, Tabs, Panel und Assistentenbereiche sind als DOM-Regionen inspizierbar",
|
||||
"Site Validation": "Website-Validierung",
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
"Offline Gate": "Offline Gate",
|
||||
"Open": "Open",
|
||||
"Open Data Folder": "Open Data Folder",
|
||||
"Open Existing Blog": "Open Existing Blog",
|
||||
"Open in Browser": "Open in Browser",
|
||||
"Opened URL": "Opened URL",
|
||||
"Orphan Files": "Orphan Files",
|
||||
@@ -133,6 +134,7 @@
|
||||
"Script": "Script",
|
||||
"Scripts": "Scripts",
|
||||
"Select Project": "Select Project",
|
||||
"Select existing blog folder": "Select existing blog folder",
|
||||
"Settings": "Settings",
|
||||
"Sidebar, tabs, panel, and assistant panes are inspectable DOM regions": "Sidebar, tabs, panel, and assistant panes are inspectable DOM regions",
|
||||
"Site Validation": "Site Validation",
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
"Offline Gate": "Bloqueo sin conexión",
|
||||
"Open": "Abrir",
|
||||
"Open Data Folder": "Abrir carpeta de datos",
|
||||
"Open Existing Blog": "Abrir blog existente",
|
||||
"Open in Browser": "Abrir en el navegador",
|
||||
"Opened URL": "URL abierta",
|
||||
"Orphan Files": "Archivos huérfanos",
|
||||
@@ -133,6 +134,7 @@
|
||||
"Script": "Script",
|
||||
"Scripts": "Scripts",
|
||||
"Select Project": "Seleccionar proyecto",
|
||||
"Select existing blog folder": "Seleccionar carpeta de blog existente",
|
||||
"Settings": "Configuración",
|
||||
"Sidebar, tabs, panel, and assistant panes are inspectable DOM regions": "La barra lateral, las pestañas, el panel y el asistente son regiones DOM inspeccionables",
|
||||
"Site Validation": "Validación del sitio",
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
"Offline Gate": "Verrou hors ligne",
|
||||
"Open": "Ouvrir",
|
||||
"Open Data Folder": "Ouvrir le dossier de données",
|
||||
"Open Existing Blog": "Ouvrir un blog existant",
|
||||
"Open in Browser": "Ouvrir dans le navigateur",
|
||||
"Opened URL": "URL ouverte",
|
||||
"Orphan Files": "Fichiers orphelins",
|
||||
@@ -133,6 +134,7 @@
|
||||
"Script": "Script",
|
||||
"Scripts": "Scripts",
|
||||
"Select Project": "Sélectionner un projet",
|
||||
"Select existing blog folder": "Sélectionner le dossier d’un blog existant",
|
||||
"Settings": "Paramètres",
|
||||
"Sidebar, tabs, panel, and assistant panes are inspectable DOM regions": "La barre latérale, les onglets, le panneau et l’assistant sont des régions DOM inspectables",
|
||||
"Site Validation": "Validation du site",
|
||||
|
||||
@@ -111,6 +111,7 @@
|
||||
"Offline Gate": "Blocco offline",
|
||||
"Open": "Apri",
|
||||
"Open Data Folder": "Apri cartella dati",
|
||||
"Open Existing Blog": "Apri blog esistente",
|
||||
"Open in Browser": "Apri nel browser",
|
||||
"Opened URL": "URL aperto",
|
||||
"Orphan Files": "File orfani",
|
||||
@@ -133,6 +134,7 @@
|
||||
"Script": "Script",
|
||||
"Scripts": "Script",
|
||||
"Select Project": "Seleziona progetto",
|
||||
"Select existing blog folder": "Seleziona la cartella di un blog esistente",
|
||||
"Settings": "Impostazioni",
|
||||
"Sidebar, tabs, panel, and assistant panes are inspectable DOM regions": "Barra laterale, schede, pannello e assistente sono regioni DOM ispezionabili",
|
||||
"Site Validation": "Validazione sito",
|
||||
|
||||
@@ -919,9 +919,12 @@ button {
|
||||
.project-dropdown-footer {
|
||||
padding: 8px;
|
||||
border-top: 1px solid rgba(255, 255, 255, 0.12);
|
||||
display: grid;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.create-project-btn {
|
||||
.create-project-btn,
|
||||
.existing-project-btn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
@@ -936,7 +939,8 @@ button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.create-project-btn:hover {
|
||||
.create-project-btn:hover,
|
||||
.existing-project-btn:hover {
|
||||
background-color: rgba(255, 255, 255, 0.18);
|
||||
}
|
||||
|
||||
|
||||
@@ -483,6 +483,12 @@ function bindEvents() {
|
||||
};
|
||||
});
|
||||
|
||||
root.querySelectorAll("[data-project-import]").forEach((button) => {
|
||||
button.onclick = () => {
|
||||
void importExistingProject();
|
||||
};
|
||||
});
|
||||
|
||||
root.querySelectorAll("[data-command='set-ui-language']").forEach((select) => {
|
||||
select.onchange = (event) => {
|
||||
setUiLanguage(event.target.value);
|
||||
@@ -677,8 +683,42 @@ async function fetchProjects() {
|
||||
}
|
||||
}
|
||||
|
||||
async function createProject() {
|
||||
const name = window.prompt(t("New project name"), t("New Project"));
|
||||
async function chooseProjectFolder() {
|
||||
try {
|
||||
const response = await fetch("/api/project-folder", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ prompt: t("Select existing blog folder") }),
|
||||
});
|
||||
|
||||
const payload = await response.json();
|
||||
|
||||
if (!response.ok || payload.status === "error") {
|
||||
appendOutputEntry(t("Open Existing Blog"), payload.error?.message || t("Command failed with HTTP %{status}", { status: response.status }));
|
||||
setPanelTab("output");
|
||||
render();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (payload.status === "cancel") {
|
||||
return null;
|
||||
}
|
||||
|
||||
return payload;
|
||||
} catch (error) {
|
||||
appendOutputEntry(t("Open Existing Blog"), error?.message || String(error));
|
||||
setPanelTab("output");
|
||||
render();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function createProject(options = {}) {
|
||||
const suggestedName = options.name ? String(options.name).trim() : "";
|
||||
const name = suggestedName || window.prompt(t("New project name"), t("New Project"));
|
||||
if (!name || !name.trim()) {
|
||||
return;
|
||||
}
|
||||
@@ -692,7 +732,11 @@ async function createProject() {
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({ name: name.trim() }),
|
||||
body: JSON.stringify({
|
||||
name: name.trim(),
|
||||
description: options.description,
|
||||
data_path: options.dataPath,
|
||||
}),
|
||||
});
|
||||
|
||||
const payload = await response.json();
|
||||
@@ -714,6 +758,27 @@ async function createProject() {
|
||||
}
|
||||
}
|
||||
|
||||
async function importExistingProject() {
|
||||
closeProjectMenu();
|
||||
|
||||
const selection = await chooseProjectFolder();
|
||||
|
||||
if (!selection) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (selection.existing_project_id) {
|
||||
await selectProject(selection.existing_project_id);
|
||||
return;
|
||||
}
|
||||
|
||||
await createProject({
|
||||
name: selection.name,
|
||||
description: selection.description,
|
||||
dataPath: selection.path,
|
||||
});
|
||||
}
|
||||
|
||||
async function selectProject(projectId) {
|
||||
if (!projectId || projectId === state.projects.active_project_id) {
|
||||
closeProjectMenu();
|
||||
@@ -1408,6 +1473,12 @@ function renderProjectDropdown() {
|
||||
${state.projects.projects.map((project) => renderProjectItem(project)).join("")}
|
||||
</div>
|
||||
<div class="project-dropdown-footer">
|
||||
<button class="existing-project-btn" data-project-import type="button">
|
||||
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
|
||||
<path d="M1.75 3A1.75 1.75 0 013.5 1.25h3.92c.46 0 .9.18 1.22.5l1.1 1.1c.09.1.22.15.35.15h2.41A1.75 1.75 0 0114.25 4.75v6.5A1.75 1.75 0 0112.5 13h-9A1.75 1.75 0 011.75 11.25v-8.5zm1.75-.25a.75.75 0 00-.75.75v8.5c0 .41.34.75.75.75h9c.41 0 .75-.34.75-.75v-6.5a.75.75 0 00-.75-.75h-2.41a1.7 1.7 0 01-1.06-.44l-1.1-1.1a.74.74 0 00-.52-.21H3.5z"></path>
|
||||
</svg>
|
||||
${escapeHtml(t("Open Existing Blog"))}
|
||||
</button>
|
||||
<button class="create-project-btn" data-project-create type="button">
|
||||
<svg width="14" height="14" viewBox="0 0 16 16" fill="currentColor">
|
||||
<path d="M14 7v1H8v6H7V8H1V7h6V1h1v6h6z"></path>
|
||||
|
||||
Reference in New Issue
Block a user