Some fixes around environments

This commit is contained in:
Gregory Schier
2024-12-21 11:04:49 -08:00
parent c1d5881167
commit 61d094d9fd
20 changed files with 95 additions and 46 deletions

View File

@@ -1220,6 +1220,7 @@ async fn cmd_create_cookie_jar(
#[tauri::command]
async fn cmd_create_environment(
workspace_id: &str,
environment_id: Option<&str>,
name: &str,
variables: Vec<EnvironmentVariable>,
w: WebviewWindow,
@@ -1228,6 +1229,7 @@ async fn cmd_create_environment(
&w,
Environment {
workspace_id: workspace_id.to_string(),
environment_id: environment_id.map(|s| s.to_string()),
name: name.to_string(),
variables,
..Default::default()

View File

@@ -7233,12 +7233,14 @@ function pluginHookImport(ctx, contents) {
};
const workspacesToImport = parsed.resources.filter(isWorkspace);
for (const workspaceToImport of workspacesToImport) {
console.log("IMPORT WORKSPACE", workspaceToImport);
resources.workspaces.push({
id: convertId(workspaceToImport._id),
createdAt: new Date(workspacesToImport.created ?? Date.now()).toISOString().replace("Z", ""),
updatedAt: new Date(workspacesToImport.updated ?? Date.now()).toISOString().replace("Z", ""),
model: "workspace",
name: workspaceToImport.name
name: workspaceToImport.name,
description: workspacesToImport.description
});
const environmentsToImport = parsed.resources.filter(
(r) => isEnvironment(r)
@@ -7294,6 +7296,7 @@ function importFolder(f, workspaceId) {
updatedAt: new Date(f.updated ?? Date.now()).toISOString().replace("Z", ""),
folderId: f.parentId === workspaceId ? null : convertId(f.parentId),
workspaceId: convertId(workspaceId),
description: f.description ?? null,
model: "folder",
name: f.name
};
@@ -7311,6 +7314,7 @@ function importGrpcRequest(r, workspaceId, sortPriority = 0) {
model: "grpc_request",
sortPriority,
name: r.name,
description: r.description ?? null,
url: convertSyntax(r.url),
service,
method,
@@ -7377,6 +7381,7 @@ function importHttpRequest(r, workspaceId, sortPriority = 0) {
model: "http_request",
sortPriority,
name: r.name,
description: r.description ?? null,
url: convertSyntax(r.url),
body,
bodyType,

View File

@@ -145931,6 +145931,7 @@ function pluginHookImport(_ctx, contents) {
workspaceId: workspace.id,
folderId,
name: v.name,
description: v.description,
method: r.method || "GET",
url,
urlParameters,

View File

@@ -98,6 +98,7 @@ function pluginHookImport(_ctx, contents) {
workspaceId: workspace.id,
folderId,
name: v.name,
description: v.description,
method: r.method || "GET",
url,
urlParameters,

View File

@@ -152,6 +152,7 @@ pub async fn list_workspaces<R: Runtime>(mgr: &impl Manager<R>) -> Result<Vec<Wo
let (sql, params) = Query::select()
.from(WorkspaceIden::Table)
.column(Asterisk)
.order_by(WorkspaceIden::Name, Order::Asc)
.build_rusqlite(SqliteQueryBuilder);
let mut stmt = db.prepare(sql.as_str())?;
let items = stmt.query_map(&*params.as_params(), |row| row.try_into())?;
@@ -746,7 +747,7 @@ pub async fn list_environments<R: Runtime>(
.from(EnvironmentIden::Table)
.cond_where(Expr::col(EnvironmentIden::WorkspaceId).eq(workspace_id))
.column(Asterisk)
.order_by(EnvironmentIden::CreatedAt, Order::Desc)
.order_by(EnvironmentIden::Name, Order::Asc)
.build_rusqlite(SqliteQueryBuilder);
let mut stmt = db.prepare(sql.as_str())?;
let items = stmt.query_map(&*params.as_params(), |row| row.try_into())?;
@@ -757,6 +758,7 @@ pub async fn list_environments<R: Runtime>(
environments.iter().find(|e| e.environment_id == None && e.workspace_id == workspace_id);
if let None = base_environment {
info!("Creating base environment for {workspace_id}");
let base_environment = upsert_environment(
window,
Environment {
@@ -766,7 +768,6 @@ pub async fn list_environments<R: Runtime>(
},
)
.await?;
info!("Created base environment for {workspace_id}");
environments.push(base_environment);
}