mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-01-19 18:17:58 +01:00
Compare commits
9 Commits
v2023.3.0
...
v2023.4.0-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0290aba982 | ||
|
|
0bafc4e4f5 | ||
|
|
9a36f94279 | ||
|
|
1d8e66179e | ||
|
|
fda6d16d8e | ||
|
|
c4737916df | ||
|
|
919465cdbb | ||
|
|
de3730fa4f | ||
|
|
aff26fdd46 |
5
.github/workflows/artifacts.yml
vendored
5
.github/workflows/artifacts.yml
vendored
@@ -17,9 +17,8 @@ jobs:
|
||||
target: x86_64-apple-darwin
|
||||
- os: windows-2022
|
||||
target: x86_64-pc-windows-msvc
|
||||
# # Re-enable Linux when context menu is supported
|
||||
# - os: ubuntu-20.04
|
||||
# target: x86_64-unknown-linux-gnu
|
||||
- os: ubuntu-20.04
|
||||
target: x86_64-unknown-linux-gnu
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
node_modules/
|
||||
dist/
|
||||
out/
|
||||
.prettierrc.cjs
|
||||
|
||||
18
package-lock.json
generated
18
package-lock.json
generated
@@ -41,7 +41,7 @@
|
||||
"react-helmet-async": "^1.3.0",
|
||||
"react-router-dom": "^6.8.1",
|
||||
"react-use": "^17.4.0",
|
||||
"tauri-plugin-context-menu": "^0.5.0",
|
||||
"slugify": "^1.6.6",
|
||||
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log#v1",
|
||||
"uuid": "^9.0.0"
|
||||
},
|
||||
@@ -7312,6 +7312,14 @@
|
||||
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
|
||||
}
|
||||
},
|
||||
"node_modules/slugify": {
|
||||
"version": "1.6.6",
|
||||
"resolved": "https://registry.npmjs.org/slugify/-/slugify-1.6.6.tgz",
|
||||
"integrity": "sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==",
|
||||
"engines": {
|
||||
"node": ">=8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
@@ -7766,14 +7774,6 @@
|
||||
"postcss": "^8.2.14"
|
||||
}
|
||||
},
|
||||
"node_modules/tauri-plugin-context-menu": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/tauri-plugin-context-menu/-/tauri-plugin-context-menu-0.5.0.tgz",
|
||||
"integrity": "sha512-CkAjSyxLx26hTXabG5Unbv+GWeH0XYNQB3zTqRxHpp257mWX8I4oASp8YF5T3zxFQEK++ZHqMZHpLrQ3usShRQ==",
|
||||
"dependencies": {
|
||||
"@tauri-apps/api": "^1.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/tauri-plugin-log-api": {
|
||||
"version": "0.0.0",
|
||||
"resolved": "git+ssh://git@github.com/tauri-apps/tauri-plugin-log.git#e5266f6719039c32b8f51ae86c9b726c2c9f3e42",
|
||||
|
||||
@@ -56,7 +56,7 @@
|
||||
"react-helmet-async": "^1.3.0",
|
||||
"react-router-dom": "^6.8.1",
|
||||
"react-use": "^17.4.0",
|
||||
"tauri-plugin-context-menu": "^0.5.0",
|
||||
"slugify": "^1.6.6",
|
||||
"tauri-plugin-log-api": "github:tauri-apps/tauri-plugin-log#v1",
|
||||
"uuid": "^9.0.0"
|
||||
},
|
||||
|
||||
165
src-tauri/Cargo.lock
generated
165
src-tauri/Cargo.lock
generated
@@ -171,12 +171,6 @@ dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bit_field"
|
||||
version = "0.10.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
@@ -717,30 +711,6 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-deque"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce6fd6f855243022dcecf8702fef0c297d4338e226845fe067f6341ad9fa0cef"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"crossbeam-epoch",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-epoch"
|
||||
version = "0.9.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae211234986c545741a7dc064309f67ee1e5ad243d0e48335adc0484d960bcc7"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"cfg-if",
|
||||
"crossbeam-utils",
|
||||
"memoffset",
|
||||
"scopeguard",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.8"
|
||||
@@ -760,12 +730,6 @@ dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crunchy"
|
||||
version = "0.2.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7"
|
||||
|
||||
[[package]]
|
||||
name = "crypto-common"
|
||||
version = "0.1.6"
|
||||
@@ -1062,22 +1026,6 @@ version = "2.5.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0206175f82b8d6bf6652ff7d71a1e27fd2e4efde587fd368662814d6ec1d9ce0"
|
||||
|
||||
[[package]]
|
||||
name = "exr"
|
||||
version = "1.71.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "832a761f35ab3e6664babfbdc6cef35a4860e816ec3916dcfd0882954e98a8a8"
|
||||
dependencies = [
|
||||
"bit_field",
|
||||
"flume",
|
||||
"half",
|
||||
"lebe",
|
||||
"miniz_oxide",
|
||||
"rayon-core",
|
||||
"smallvec",
|
||||
"zune-inflate",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fast-float"
|
||||
version = "0.2.0"
|
||||
@@ -1465,16 +1413,6 @@ dependencies = [
|
||||
"wasi 0.11.0+wasi-snapshot-preview1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "80792593675e051cf94a4b111980da2ba60d4a83e43e0048c5693baab3977045"
|
||||
dependencies = [
|
||||
"color_quant",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gimli"
|
||||
version = "0.28.0"
|
||||
@@ -1660,15 +1598,6 @@ dependencies = [
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "half"
|
||||
version = "2.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "02b4af3693f1b705df946e9fe5631932443781d0aabb423b62fcd4d73f6d2fd0"
|
||||
dependencies = [
|
||||
"crunchy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.12.3"
|
||||
@@ -2056,14 +1985,8 @@ dependencies = [
|
||||
"bytemuck",
|
||||
"byteorder",
|
||||
"color_quant",
|
||||
"exr",
|
||||
"gif",
|
||||
"jpeg-decoder",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"png",
|
||||
"qoi",
|
||||
"tiff",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2196,15 +2119,6 @@ version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130"
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bc0000e42512c92e31c2252315bda326620a4e034105e900c98ec492fa077b3e"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.65"
|
||||
@@ -2260,12 +2174,6 @@ dependencies = [
|
||||
"spin 0.5.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lebe"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.150"
|
||||
@@ -3229,15 +3137,6 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "qoi"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001"
|
||||
dependencies = [
|
||||
"bytemuck",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quick-xml"
|
||||
version = "0.31.0"
|
||||
@@ -3343,26 +3242,6 @@ version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9"
|
||||
|
||||
[[package]]
|
||||
name = "rayon"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c27db03db7734835b3f53954b534c91069375ce6ccaa2e065441e07d9b6cdb1"
|
||||
dependencies = [
|
||||
"either",
|
||||
"rayon-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rayon-core"
|
||||
version = "1.12.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ce3fb6ad83f861aac485e76e1985cd109d9a3713802152be56c3b1f0e0658ed"
|
||||
dependencies = [
|
||||
"crossbeam-deque",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_syscall"
|
||||
version = "0.1.57"
|
||||
@@ -4579,23 +4458,6 @@ dependencies = [
|
||||
"tauri-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-context-menu"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b93737f332761822f2d1ee6f7dbe4c1f94c4d03020a349bc1f8070d75b6409e8"
|
||||
dependencies = [
|
||||
"cocoa 0.24.1",
|
||||
"dispatch",
|
||||
"image",
|
||||
"lazy_static",
|
||||
"libc",
|
||||
"objc",
|
||||
"serde",
|
||||
"tauri",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tauri-plugin-log"
|
||||
version = "0.0.0"
|
||||
@@ -4773,17 +4635,6 @@ dependencies = [
|
||||
"once_cell",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tiff"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6d172b0f4d3fba17ba89811858b9d3d97f928aece846475bbda076ca46736211"
|
||||
dependencies = [
|
||||
"flate2",
|
||||
"jpeg-decoder",
|
||||
"weezl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "time"
|
||||
version = "0.3.30"
|
||||
@@ -5430,12 +5281,6 @@ dependencies = [
|
||||
"windows-metadata",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "weezl"
|
||||
version = "0.1.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9193164d4de03a926d909d3bc7c30543cecb35400c02114792c2cae20d5e2dbb"
|
||||
|
||||
[[package]]
|
||||
name = "whoami"
|
||||
version = "1.4.1"
|
||||
@@ -5887,7 +5732,6 @@ dependencies = [
|
||||
"sqlx",
|
||||
"tauri",
|
||||
"tauri-build",
|
||||
"tauri-plugin-context-menu",
|
||||
"tauri-plugin-log",
|
||||
"tauri-plugin-window-state",
|
||||
"tokio",
|
||||
@@ -5998,12 +5842,3 @@ dependencies = [
|
||||
"crc32fast",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zune-inflate"
|
||||
version = "0.2.54"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02"
|
||||
dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
@@ -47,7 +47,6 @@ tauri-plugin-log = { git = "https://github.com/tauri-apps/plugins-workspace", br
|
||||
tokio = { version = "1.25.0", features = ["sync"] }
|
||||
uuid = "1.3.0"
|
||||
log = "0.4.20"
|
||||
tauri-plugin-context-menu = "0.5.0"
|
||||
datetime = "0.5.2"
|
||||
|
||||
[features]
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.security.app-sandbox</key>
|
||||
<true/>
|
||||
|
||||
<key>com.apple.security.files.user-selected.read-write</key>
|
||||
<true/>
|
||||
|
||||
<key>com.apple.security.network.client</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
@@ -1,139 +1,124 @@
|
||||
function S(e, t) {
|
||||
return (
|
||||
console.log('IMPORTING Environment', e._id, e.name, JSON.stringify(e, null, 2)),
|
||||
{
|
||||
id: e._id,
|
||||
createdAt: new Date(e.created ?? Date.now()).toISOString().replace('Z', ''),
|
||||
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace('Z', ''),
|
||||
workspaceId: t,
|
||||
model: 'environment',
|
||||
name: e.name,
|
||||
variables: Object.entries(e.data).map(([n, a]) => ({
|
||||
enabled: !0,
|
||||
name: n,
|
||||
value: `${a}`,
|
||||
})),
|
||||
}
|
||||
);
|
||||
return console.log("IMPORTING Environment", e._id, e.name, JSON.stringify(e, null, 2)), {
|
||||
id: e._id,
|
||||
createdAt: new Date(e.created ?? Date.now()).toISOString().replace("Z", ""),
|
||||
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace("Z", ""),
|
||||
workspaceId: t,
|
||||
model: "environment",
|
||||
name: e.name,
|
||||
variables: Object.entries(e.data).map(([n, a]) => ({
|
||||
enabled: !0,
|
||||
name: n,
|
||||
value: `${a}`
|
||||
}))
|
||||
};
|
||||
}
|
||||
function I(e) {
|
||||
return m(e) && e._type === 'workspace';
|
||||
return m(e) && e._type === "workspace";
|
||||
}
|
||||
function y(e) {
|
||||
return m(e) && e._type === 'request_group';
|
||||
return m(e) && e._type === "request_group";
|
||||
}
|
||||
function g(e) {
|
||||
return m(e) && e._type === 'request';
|
||||
return m(e) && e._type === "request";
|
||||
}
|
||||
function f(e) {
|
||||
return m(e) && e._type === 'environment';
|
||||
return m(e) && e._type === "environment";
|
||||
}
|
||||
function m(e) {
|
||||
return Object.prototype.toString.call(e) === '[object Object]';
|
||||
return Object.prototype.toString.call(e) === "[object Object]";
|
||||
}
|
||||
function w(e) {
|
||||
return Object.prototype.toString.call(e) === '[object String]';
|
||||
return Object.prototype.toString.call(e) === "[object String]";
|
||||
}
|
||||
function O(e) {
|
||||
return Object.entries(e).map(([t, n]) => ({
|
||||
enabled: !0,
|
||||
name: t,
|
||||
value: `${n}`,
|
||||
value: `${n}`
|
||||
}));
|
||||
}
|
||||
function l(e) {
|
||||
return w(e) ? e.replaceAll(/{{\s*(_\.)?([^}]+)\s*}}/g, '${[$2]}') : e;
|
||||
return w(e) ? e.replaceAll(/{{\s*(_\.)?([^}]+)\s*}}/g, "${[$2]}") : e;
|
||||
}
|
||||
function h(e, t, n = 0) {
|
||||
var c, o;
|
||||
console.log('IMPORTING REQUEST', e._id, e.name, JSON.stringify(e, null, 2));
|
||||
let a = null,
|
||||
r = null;
|
||||
((c = e.body) == null ? void 0 : c.mimeType) === 'application/graphql'
|
||||
? ((a = 'graphql'), (r = l(e.body.text)))
|
||||
: ((o = e.body) == null ? void 0 : o.mimeType) === 'application/json' &&
|
||||
((a = 'application/json'), (r = l(e.body.text)));
|
||||
let i = null,
|
||||
u = {};
|
||||
return (
|
||||
e.authentication.type === 'bearer'
|
||||
? ((i = 'bearer'),
|
||||
(u = {
|
||||
token: l(e.authentication.token),
|
||||
}))
|
||||
: e.authentication.type === 'basic' &&
|
||||
((i = 'basic'),
|
||||
(u = {
|
||||
username: l(e.authentication.username),
|
||||
password: l(e.authentication.password),
|
||||
})),
|
||||
{
|
||||
id: e._id,
|
||||
createdAt: new Date(e.created ?? Date.now()).toISOString().replace('Z', ''),
|
||||
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace('Z', ''),
|
||||
workspaceId: t,
|
||||
folderId: e.parentId === t ? null : e.parentId,
|
||||
model: 'http_request',
|
||||
sortPriority: n,
|
||||
name: e.name,
|
||||
url: l(e.url),
|
||||
body: r,
|
||||
bodyType: a,
|
||||
authentication: u,
|
||||
authenticationType: i,
|
||||
method: e.method,
|
||||
headers: (e.headers ?? [])
|
||||
.map(({ name: d, value: p, disabled: s }) => ({
|
||||
enabled: !s,
|
||||
name: d,
|
||||
value: p,
|
||||
}))
|
||||
.filter(({ name: d, value: p }) => d !== '' || p !== ''),
|
||||
}
|
||||
);
|
||||
console.log("IMPORTING REQUEST", e._id, e.name, JSON.stringify(e, null, 2));
|
||||
let a = null, r = null;
|
||||
((c = e.body) == null ? void 0 : c.mimeType) === "application/graphql" ? (a = "graphql", r = l(e.body.text)) : ((o = e.body) == null ? void 0 : o.mimeType) === "application/json" && (a = "application/json", r = l(e.body.text));
|
||||
let i = null, u = {};
|
||||
return e.authentication.type === "bearer" ? (i = "bearer", u = {
|
||||
token: l(e.authentication.token)
|
||||
}) : e.authentication.type === "basic" && (i = "basic", u = {
|
||||
username: l(e.authentication.username),
|
||||
password: l(e.authentication.password)
|
||||
}), {
|
||||
id: e._id,
|
||||
createdAt: new Date(e.created ?? Date.now()).toISOString().replace("Z", ""),
|
||||
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace("Z", ""),
|
||||
workspaceId: t,
|
||||
folderId: e.parentId === t ? null : e.parentId,
|
||||
model: "http_request",
|
||||
sortPriority: n,
|
||||
name: e.name,
|
||||
url: l(e.url),
|
||||
body: r,
|
||||
bodyType: a,
|
||||
authentication: u,
|
||||
authenticationType: i,
|
||||
method: e.method,
|
||||
headers: (e.headers ?? []).map(({ name: d, value: p, disabled: s }) => ({
|
||||
enabled: !s,
|
||||
name: d,
|
||||
value: p
|
||||
})).filter(({ name: d, value: p }) => d !== "" || p !== "")
|
||||
};
|
||||
}
|
||||
function _(e, t) {
|
||||
return (
|
||||
console.log('IMPORTING FOLDER', e._id, e.name, JSON.stringify(e, null, 2)),
|
||||
{
|
||||
id: e._id,
|
||||
createdAt: new Date(e.created ?? Date.now()).toISOString().replace('Z', ''),
|
||||
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace('Z', ''),
|
||||
folderId: e.parentId === t ? null : e.parentId,
|
||||
workspaceId: t,
|
||||
model: 'folder',
|
||||
name: e.name,
|
||||
}
|
||||
);
|
||||
return console.log("IMPORTING FOLDER", e._id, e.name, JSON.stringify(e, null, 2)), {
|
||||
id: e._id,
|
||||
createdAt: new Date(e.created ?? Date.now()).toISOString().replace("Z", ""),
|
||||
updatedAt: new Date(e.updated ?? Date.now()).toISOString().replace("Z", ""),
|
||||
folderId: e.parentId === t ? null : e.parentId,
|
||||
workspaceId: t,
|
||||
model: "folder",
|
||||
name: e.name
|
||||
};
|
||||
}
|
||||
function b(e) {
|
||||
console.log('RUNNING INSOMNIA');
|
||||
console.log("RUNNING INSOMNIA");
|
||||
let t;
|
||||
try {
|
||||
t = JSON.parse(e);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (!m(t) || !Array.isArray(t.resources)) return;
|
||||
if (!m(t) || !Array.isArray(t.resources))
|
||||
return;
|
||||
const n = {
|
||||
workspaces: [],
|
||||
requests: [],
|
||||
environments: [],
|
||||
folders: [],
|
||||
},
|
||||
a = t.resources.filter(I);
|
||||
workspaces: [],
|
||||
requests: [],
|
||||
environments: [],
|
||||
folders: []
|
||||
}, a = t.resources.filter(I);
|
||||
for (const r of a) {
|
||||
const i = t.resources.find((o) => f(o) && o.parentId === r._id);
|
||||
const i = t.resources.find(
|
||||
(o) => f(o) && o.parentId === r._id
|
||||
);
|
||||
n.workspaces.push({
|
||||
id: r._id,
|
||||
createdAt: new Date(a.created ?? Date.now()).toISOString().replace('Z', ''),
|
||||
updatedAt: new Date(a.updated ?? Date.now()).toISOString().replace('Z', ''),
|
||||
model: 'workspace',
|
||||
createdAt: new Date(a.created ?? Date.now()).toISOString().replace("Z", ""),
|
||||
updatedAt: new Date(a.updated ?? Date.now()).toISOString().replace("Z", ""),
|
||||
model: "workspace",
|
||||
name: r.name,
|
||||
variables: i ? O(i.data) : [],
|
||||
variables: i ? O(i.data) : []
|
||||
});
|
||||
const u = t.resources.filter((o) => f(o) && o.parentId === (i == null ? void 0 : i._id));
|
||||
n.environments.push(...u.map((o) => S(o, r._id)));
|
||||
const u = t.resources.filter(
|
||||
(o) => f(o) && o.parentId === (i == null ? void 0 : i._id)
|
||||
);
|
||||
n.environments.push(
|
||||
...u.map((o) => S(o, r._id))
|
||||
);
|
||||
const c = (o) => {
|
||||
const d = t.resources.filter((s) => s.parentId === o);
|
||||
let p = 0;
|
||||
@@ -142,11 +127,8 @@ function b(e) {
|
||||
};
|
||||
c(r._id);
|
||||
}
|
||||
return (
|
||||
(n.requests = n.requests.filter(Boolean)),
|
||||
(n.environments = n.environments.filter(Boolean)),
|
||||
(n.workspaces = n.workspaces.filter(Boolean)),
|
||||
{ resources: n }
|
||||
);
|
||||
return n.requests = n.requests.filter(Boolean), n.environments = n.environments.filter(Boolean), n.workspaces = n.workspaces.filter(Boolean), { resources: n };
|
||||
}
|
||||
export { b as pluginHookImport };
|
||||
export {
|
||||
b as pluginHookImport
|
||||
};
|
||||
|
||||
@@ -1,130 +1,153 @@
|
||||
const f = 'https://schema.getpostman.com/json/collection/v2.1.0/collection.json',
|
||||
b = 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json',
|
||||
w = [b, f];
|
||||
function A(t) {
|
||||
const e = m(t);
|
||||
if (e == null) return;
|
||||
const r = s(e.info);
|
||||
if (!w.includes(r.schema) || !Array.isArray(e.item)) return;
|
||||
const b = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", g = "https://schema.getpostman.com/json/collection/v2.0.0/collection.json", T = [g, b];
|
||||
function S(e) {
|
||||
const t = h(e);
|
||||
if (t == null)
|
||||
return;
|
||||
const r = s(t.info);
|
||||
if (!T.includes(r.schema) || !Array.isArray(t.item))
|
||||
return;
|
||||
const a = {
|
||||
workspaces: [],
|
||||
environments: [],
|
||||
requests: [],
|
||||
folders: [],
|
||||
},
|
||||
c = {
|
||||
model: 'workspace',
|
||||
id: 'wrk_0',
|
||||
name: r.name || 'Postman Import',
|
||||
description: r.description || '',
|
||||
};
|
||||
a.workspaces.push(c);
|
||||
const p = (o, l = null) => {
|
||||
if (typeof o.name == 'string' && Array.isArray(o.item)) {
|
||||
const n = {
|
||||
model: 'folder',
|
||||
workspaceId: c.id,
|
||||
id: `fld_${a.folders.length}`,
|
||||
name: o.name,
|
||||
folderId: l,
|
||||
};
|
||||
a.folders.push(n);
|
||||
for (const i of o.item) p(i, n.id);
|
||||
} else if (typeof o.name == 'string' && 'request' in o) {
|
||||
const n = s(o.request),
|
||||
i = T(n.body),
|
||||
u = g(n.auth),
|
||||
y = {
|
||||
model: 'http_request',
|
||||
id: `req_${a.requests.length}`,
|
||||
workspaceId: c.id,
|
||||
folderId: l,
|
||||
name: o.name,
|
||||
method: n.method || 'GET',
|
||||
url: typeof n.url == 'string' ? n.url : s(n.url).raw,
|
||||
body: i.body,
|
||||
bodyType: i.bodyType,
|
||||
authentication: u.authentication,
|
||||
authenticationType: u.authenticationType,
|
||||
headers: [
|
||||
...i.headers,
|
||||
...u.headers,
|
||||
...h(n.header).map((d) => ({
|
||||
name: d.key,
|
||||
value: d.value,
|
||||
enabled: !d.disabled,
|
||||
})),
|
||||
],
|
||||
};
|
||||
a.requests.push(y);
|
||||
} else console.log('Unknown item', o, l);
|
||||
workspaces: [],
|
||||
environments: [],
|
||||
requests: [],
|
||||
folders: []
|
||||
}, l = {
|
||||
model: "workspace",
|
||||
id: "wrk_0",
|
||||
name: r.name || "Postman Import",
|
||||
description: r.description || ""
|
||||
};
|
||||
for (const o of e.item) p(o);
|
||||
return { resources: a };
|
||||
}
|
||||
function g(t) {
|
||||
const e = s(t);
|
||||
return 'basic' in e
|
||||
? {
|
||||
headers: [],
|
||||
authenticationType: 'basic',
|
||||
authentication: {
|
||||
username: e.basic.username || '',
|
||||
password: e.basic.password || '',
|
||||
},
|
||||
}
|
||||
: { headers: [], authenticationType: null, authentication: {} };
|
||||
}
|
||||
function T(t) {
|
||||
const e = s(t);
|
||||
return 'graphql' in e
|
||||
? {
|
||||
a.workspaces.push(l);
|
||||
const y = (n, c = null) => {
|
||||
if (typeof n.name == "string" && Array.isArray(n.item)) {
|
||||
const o = {
|
||||
model: "folder",
|
||||
workspaceId: l.id,
|
||||
id: `fld_${a.folders.length}`,
|
||||
name: n.name,
|
||||
folderId: c
|
||||
};
|
||||
a.folders.push(o);
|
||||
for (const i of n.item)
|
||||
y(i, o.id);
|
||||
} else if (typeof n.name == "string" && "request" in n) {
|
||||
const o = s(n.request), i = A(o.body), u = w(o.auth), f = {
|
||||
model: "http_request",
|
||||
id: `req_${a.requests.length}`,
|
||||
workspaceId: l.id,
|
||||
folderId: c,
|
||||
name: n.name,
|
||||
method: o.method || "GET",
|
||||
url: typeof o.url == "string" ? o.url : s(o.url).raw,
|
||||
body: i.body,
|
||||
bodyType: i.bodyType,
|
||||
authentication: u.authentication,
|
||||
authenticationType: u.authenticationType,
|
||||
headers: [
|
||||
{
|
||||
name: 'Content-Type',
|
||||
value: 'application/json',
|
||||
enabled: !0,
|
||||
},
|
||||
],
|
||||
bodyType: 'graphql',
|
||||
body: {
|
||||
text: JSON.stringify(
|
||||
{ query: e.graphql.query, variables: m(e.graphql.variables) },
|
||||
null,
|
||||
2,
|
||||
),
|
||||
},
|
||||
}
|
||||
: 'formdata' in e
|
||||
? {
|
||||
headers: [
|
||||
{
|
||||
name: 'Content-Type',
|
||||
value: 'application/x-www-form-urlencoded',
|
||||
enabled: !0,
|
||||
},
|
||||
],
|
||||
bodyType: 'application/x-www-form-urlencoded',
|
||||
body: {
|
||||
form: h(e.formdata).map((r) => ({
|
||||
enabled: !r.disabled,
|
||||
name: r.key ?? '',
|
||||
value: r.value ?? '',
|
||||
})),
|
||||
},
|
||||
}
|
||||
: { headers: [], bodyType: null, body: {} };
|
||||
...i.headers,
|
||||
...u.headers,
|
||||
...p(o.header).map((d) => ({
|
||||
name: d.key,
|
||||
value: d.value,
|
||||
enabled: !d.disabled
|
||||
}))
|
||||
]
|
||||
};
|
||||
a.requests.push(f);
|
||||
} else
|
||||
console.log("Unknown item", n, c);
|
||||
};
|
||||
for (const n of t.item)
|
||||
y(n);
|
||||
return { resources: m(a) };
|
||||
}
|
||||
function m(t) {
|
||||
function w(e) {
|
||||
const t = s(e);
|
||||
return "basic" in t ? {
|
||||
headers: [],
|
||||
authenticationType: "basic",
|
||||
authentication: {
|
||||
username: t.basic.username || "",
|
||||
password: t.basic.password || ""
|
||||
}
|
||||
} : { headers: [], authenticationType: null, authentication: {} };
|
||||
}
|
||||
function A(e) {
|
||||
const t = s(e);
|
||||
return "graphql" in t ? {
|
||||
headers: [
|
||||
{
|
||||
name: "Content-Type",
|
||||
value: "application/json",
|
||||
enabled: !0
|
||||
}
|
||||
],
|
||||
bodyType: "graphql",
|
||||
body: {
|
||||
text: JSON.stringify(
|
||||
{ query: t.graphql.query, variables: h(t.graphql.variables) },
|
||||
null,
|
||||
2
|
||||
)
|
||||
}
|
||||
} : "urlencoded" in t ? {
|
||||
headers: [
|
||||
{
|
||||
name: "Content-Type",
|
||||
value: "application/x-www-form-urlencoded",
|
||||
enabled: !0
|
||||
}
|
||||
],
|
||||
bodyType: "application/x-www-form-urlencoded",
|
||||
body: {
|
||||
form: p(t.urlencoded).map((r) => ({
|
||||
enabled: !r.disabled,
|
||||
name: r.key ?? "",
|
||||
value: r.value ?? ""
|
||||
}))
|
||||
}
|
||||
} : "formdata" in t ? {
|
||||
headers: [
|
||||
{
|
||||
name: "Content-Type",
|
||||
value: "multipart/form-data",
|
||||
enabled: !0
|
||||
}
|
||||
],
|
||||
bodyType: "multipart/form-data",
|
||||
body: {
|
||||
form: p(t.formdata).map(
|
||||
(r) => r.src != null ? {
|
||||
enabled: !r.disabled,
|
||||
name: r.key ?? "",
|
||||
file: r.src ?? ""
|
||||
} : {
|
||||
enabled: !r.disabled,
|
||||
name: r.key ?? "",
|
||||
value: r.value ?? ""
|
||||
}
|
||||
)
|
||||
}
|
||||
} : { headers: [], bodyType: null, body: {} };
|
||||
}
|
||||
function h(e) {
|
||||
try {
|
||||
return s(JSON.parse(t));
|
||||
} catch {}
|
||||
return s(JSON.parse(e));
|
||||
} catch {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function s(t) {
|
||||
return Object.prototype.toString.call(t) === '[object Object]' ? t : {};
|
||||
function s(e) {
|
||||
return Object.prototype.toString.call(e) === "[object Object]" ? e : {};
|
||||
}
|
||||
function h(t) {
|
||||
return Object.prototype.toString.call(t) === '[object Array]' ? t : [];
|
||||
function p(e) {
|
||||
return Object.prototype.toString.call(e) === "[object Array]" ? e : [];
|
||||
}
|
||||
export { A as pluginHookImport };
|
||||
function m(e) {
|
||||
return typeof e == "string" ? e.replace(/{{\s*(_\.)?([^}]+)\s*}}/g, "${[$2]}") : Array.isArray(e) && e != null ? e.map(m) : typeof e == "object" && e != null ? Object.fromEntries(
|
||||
Object.entries(e).map(([t, r]) => [t, m(r)])
|
||||
) : e;
|
||||
}
|
||||
export {
|
||||
S as pluginHookImport
|
||||
};
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -89,7 +89,7 @@ export function pluginHookImport(contents: string): { resources: ExportResources
|
||||
importItem(item);
|
||||
}
|
||||
|
||||
return { resources: exportResources };
|
||||
return { resources: convertTemplateSyntax(exportResources) };
|
||||
}
|
||||
|
||||
function importAuth(
|
||||
@@ -131,7 +131,7 @@ function importBody(rawBody: any): Pick<HttpRequest, 'body' | 'bodyType' | 'head
|
||||
),
|
||||
},
|
||||
};
|
||||
} else if ('formdata' in body) {
|
||||
} else if ('urlencoded' in body) {
|
||||
return {
|
||||
headers: [
|
||||
{
|
||||
@@ -142,13 +142,39 @@ function importBody(rawBody: any): Pick<HttpRequest, 'body' | 'bodyType' | 'head
|
||||
],
|
||||
bodyType: 'application/x-www-form-urlencoded',
|
||||
body: {
|
||||
form: toArray(body.formdata).map((f) => ({
|
||||
form: toArray(body.urlencoded).map((f) => ({
|
||||
enabled: !f.disabled,
|
||||
name: f.key ?? '',
|
||||
value: f.value ?? '',
|
||||
})),
|
||||
},
|
||||
};
|
||||
} else if ('formdata' in body) {
|
||||
return {
|
||||
headers: [
|
||||
{
|
||||
name: 'Content-Type',
|
||||
value: 'multipart/form-data',
|
||||
enabled: true,
|
||||
},
|
||||
],
|
||||
bodyType: 'multipart/form-data',
|
||||
body: {
|
||||
form: toArray(body.formdata).map((f) =>
|
||||
f.src != null
|
||||
? {
|
||||
enabled: !f.disabled,
|
||||
name: f.key ?? '',
|
||||
file: f.src ?? '',
|
||||
}
|
||||
: {
|
||||
enabled: !f.disabled,
|
||||
name: f.key ?? '',
|
||||
value: f.value ?? '',
|
||||
},
|
||||
),
|
||||
},
|
||||
};
|
||||
} else {
|
||||
// TODO: support other body types
|
||||
return { headers: [], bodyType: null, body: {} };
|
||||
@@ -171,3 +197,18 @@ function toArray(value: any): any[] {
|
||||
if (Object.prototype.toString.call(value) === '[object Array]') return value;
|
||||
else return [];
|
||||
}
|
||||
|
||||
/** Recursively render all nested object properties */
|
||||
function convertTemplateSyntax<T>(obj: T): T {
|
||||
if (typeof obj === 'string') {
|
||||
return obj.replace(/{{\s*(_\.)?([^}]+)\s*}}/g, '${[$2]}') as T;
|
||||
} else if (Array.isArray(obj) && obj != null) {
|
||||
return obj.map(convertTemplateSyntax) as T;
|
||||
} else if (typeof obj === 'object' && obj != null) {
|
||||
return Object.fromEntries(
|
||||
Object.entries(obj).map(([k, v]) => [k, convertTemplateSyntax(v)]),
|
||||
) as T;
|
||||
} else {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "ES2020",
|
||||
"target": "ESNext",
|
||||
"useDefineForClassFields": true,
|
||||
"module": "ESNext",
|
||||
"lib": [
|
||||
"ES2020"
|
||||
"ESNext"
|
||||
],
|
||||
"skipLibCheck": true,
|
||||
"moduleResolution": "bundler",
|
||||
|
||||
@@ -5,9 +5,13 @@ function u(r) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
if (t(e) && e.yaakSchema === 1) return { resources: e.resources };
|
||||
if (t(e) && e.yaakSchema === 1)
|
||||
return { resources: e.resources };
|
||||
}
|
||||
function t(r) {
|
||||
return Object.prototype.toString.call(r) === '[object Object]';
|
||||
return Object.prototype.toString.call(r) === "[object Object]";
|
||||
}
|
||||
export { t as isJSObject, u as pluginHookImport };
|
||||
export {
|
||||
t as isJSObject,
|
||||
u as pluginHookImport
|
||||
};
|
||||
|
||||
@@ -13,7 +13,7 @@ use std::fs::{create_dir_all, File};
|
||||
use std::process::exit;
|
||||
|
||||
use fern::colors::ColoredLevelConfig;
|
||||
use log::{debug, error, info};
|
||||
use log::{debug, info, warn};
|
||||
use rand::random;
|
||||
use serde::Serialize;
|
||||
use sqlx::{Pool, Sqlite, SqlitePool};
|
||||
@@ -657,7 +657,6 @@ fn main() {
|
||||
.build(),
|
||||
)
|
||||
.plugin(tauri_plugin_window_state::Builder::default().build())
|
||||
.plugin(tauri_plugin_context_menu::init())
|
||||
.setup(|app| {
|
||||
let dir = match is_dev() {
|
||||
true => current_dir().unwrap(),
|
||||
@@ -666,6 +665,8 @@ fn main() {
|
||||
|
||||
create_dir_all(dir.clone()).expect("Problem creating App directory!");
|
||||
let p = dir.join("db.sqlite");
|
||||
File::options().write(true).create(true).open(&p).expect("Problem creating database file!");
|
||||
|
||||
let p_string = p.to_string_lossy().replace(' ', "%20");
|
||||
let url = format!("sqlite://{}?mode=rwc", p_string);
|
||||
println!("Connecting to database at {}", url);
|
||||
@@ -747,7 +748,7 @@ fn main() {
|
||||
debug!("Updater downloaded");
|
||||
}
|
||||
tauri::UpdaterEvent::Error(e) => {
|
||||
error!("Updater error: {:?}", e);
|
||||
warn!("Updater received error: {:?}", e);
|
||||
}
|
||||
_ => {}
|
||||
},
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
},
|
||||
"package": {
|
||||
"productName": "Yaak",
|
||||
"version": "2023.3.0"
|
||||
"version": "2023.4.0-beta.3"
|
||||
},
|
||||
"tauri": {
|
||||
"windows": [],
|
||||
@@ -56,7 +56,7 @@
|
||||
"icons/release/icon.icns",
|
||||
"icons/release/icon.ico"
|
||||
],
|
||||
"identifier": "co.schier.yaak",
|
||||
"identifier": "app.yaak.desktop",
|
||||
"longDescription": "The best cross-platform visual API client",
|
||||
"resources": [
|
||||
"migrations/*",
|
||||
|
||||
@@ -5,7 +5,6 @@ import type { XYCoord } from 'react-dnd';
|
||||
import { useDrag, useDrop } from 'react-dnd';
|
||||
import { useKey, useKeyPressEvent } from 'react-use';
|
||||
|
||||
import { showMenu } from 'tauri-plugin-context-menu';
|
||||
import { useActiveEnvironmentId } from '../hooks/useActiveEnvironmentId';
|
||||
import { useActiveRequestId } from '../hooks/useActiveRequestId';
|
||||
import { useActiveWorkspace } from '../hooks/useActiveWorkspace';
|
||||
@@ -14,7 +13,6 @@ import { useCreateFolder } from '../hooks/useCreateFolder';
|
||||
import { useCreateRequest } from '../hooks/useCreateRequest';
|
||||
import { useDeleteAnyRequest } from '../hooks/useDeleteAnyRequest';
|
||||
import { useDeleteFolder } from '../hooks/useDeleteFolder';
|
||||
import { useDeleteRequest } from '../hooks/useDeleteRequest';
|
||||
import { useFolders } from '../hooks/useFolders';
|
||||
import { useKeyValue } from '../hooks/useKeyValue';
|
||||
import { useLatestResponse } from '../hooks/useLatestResponse';
|
||||
@@ -22,7 +20,6 @@ import { useListenToTauriEvent } from '../hooks/useListenToTauriEvent';
|
||||
import { usePrompt } from '../hooks/usePrompt';
|
||||
import { useRequests } from '../hooks/useRequests';
|
||||
import { useSendManyRequests } from '../hooks/useSendFolder';
|
||||
import { useSendRequest } from '../hooks/useSendRequest';
|
||||
import { useSidebarHidden } from '../hooks/useSidebarHidden';
|
||||
import { useUpdateAnyFolder } from '../hooks/useUpdateAnyFolder';
|
||||
import { useUpdateAnyRequest } from '../hooks/useUpdateAnyRequest';
|
||||
@@ -512,9 +509,7 @@ const SidebarItem = forwardRef(function SidebarItem(
|
||||
const createRequest = useCreateRequest();
|
||||
const createFolder = useCreateFolder();
|
||||
const deleteFolder = useDeleteFolder(itemId);
|
||||
const sendRequest = useSendRequest(itemId);
|
||||
const sendManyRequests = useSendManyRequests();
|
||||
const deleteRequest = useDeleteRequest(itemId);
|
||||
const latestResponse = useLatestResponse(itemId);
|
||||
const updateRequest = useUpdateRequest(itemId);
|
||||
const updateAnyFolder = useUpdateAnyFolder();
|
||||
@@ -565,41 +560,6 @@ const SidebarItem = forwardRef(function SidebarItem(
|
||||
[handleSubmitNameEdit],
|
||||
);
|
||||
|
||||
const handleContextMenu = useCallback(
|
||||
(e: React.MouseEvent<HTMLButtonElement>) => {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
showMenu({
|
||||
pos: { x: e.clientX, y: e.clientY },
|
||||
items:
|
||||
itemModel === 'http_request'
|
||||
? [
|
||||
{
|
||||
label: 'Send Request',
|
||||
event: () => sendRequest.mutate(),
|
||||
},
|
||||
{
|
||||
label: 'Delete Request',
|
||||
event: () => deleteRequest.mutate(),
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
label: 'Send All',
|
||||
event: () => sendManyRequests.mutate(child.children.map((c) => c.item.id)),
|
||||
},
|
||||
{
|
||||
label: 'Delete Folder',
|
||||
event: () => deleteFolder.mutate(),
|
||||
},
|
||||
],
|
||||
})
|
||||
.then((r) => console.log(r))
|
||||
.catch((e) => console.log(e));
|
||||
},
|
||||
[itemModel, sendRequest, deleteRequest, sendManyRequests, child.children, deleteFolder],
|
||||
);
|
||||
|
||||
const handleSelect = useCallback(() => onSelect(itemId), [onSelect, itemId]);
|
||||
|
||||
return (
|
||||
@@ -669,7 +629,6 @@ const SidebarItem = forwardRef(function SidebarItem(
|
||||
disabled={editing}
|
||||
onClick={handleSelect}
|
||||
onDoubleClick={handleStartEditing}
|
||||
onContextMenu={handleContextMenu}
|
||||
data-active={isActive}
|
||||
data-selected={selected}
|
||||
className={classNames(
|
||||
|
||||
@@ -176,7 +176,7 @@ function HeaderSize({ className, ...props }: HeaderSizeProps) {
|
||||
<div
|
||||
className={classNames(
|
||||
className,
|
||||
'h-md pt-[1px] flex items-center w-full pr-3 pl-20 border-b',
|
||||
'h-md pt-[1px] flex items-center w-full pr-3 border-b',
|
||||
platform?.osType === 'Darwin' && 'pl-20',
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import classNames from 'classnames';
|
||||
import React, { memo } from 'react';
|
||||
import { useActiveRequest } from '../hooks/useActiveRequest';
|
||||
import { useActiveWorkspace } from '../hooks/useActiveWorkspace';
|
||||
import { Icon } from './core/Icon';
|
||||
import { IconButton } from './core/IconButton';
|
||||
import { HStack } from './core/Stacks';
|
||||
@@ -17,7 +16,6 @@ interface Props {
|
||||
|
||||
export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Props) {
|
||||
const activeRequest = useActiveRequest();
|
||||
const activeWorkspace = useActiveWorkspace();
|
||||
|
||||
return (
|
||||
<HStack
|
||||
@@ -29,13 +27,7 @@ export const WorkspaceHeader = memo(function WorkspaceHeader({ className }: Prop
|
||||
<HStack space={0.5} className="flex-1 pointer-events-none" alignItems="center">
|
||||
<SidebarActions />
|
||||
<HStack alignItems="center">
|
||||
<WorkspaceActionsDropdown
|
||||
leftSlot={
|
||||
<div className="w-4 h-4 leading-4 rounded text-[0.8em] bg-[#1B88DE] bg-opacity-80 text-white mr-1">
|
||||
{activeWorkspace?.name[0]?.toUpperCase()}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
<WorkspaceActionsDropdown />
|
||||
<Icon icon="chevronRight" className="text-gray-900 text-opacity-disabled" />
|
||||
<EnvironmentActionsDropdown className="w-auto pointer-events-auto" />
|
||||
</HStack>
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
import { useMutation } from '@tanstack/react-query';
|
||||
import { invoke } from '@tauri-apps/api';
|
||||
import type { SaveDialogOptions } from '@tauri-apps/api/dialog';
|
||||
import { save } from '@tauri-apps/api/dialog';
|
||||
import { useActiveWorkspaceId } from './useActiveWorkspaceId';
|
||||
import slugify from 'slugify';
|
||||
import { useActiveWorkspace } from './useActiveWorkspace';
|
||||
import { useAlert } from './useAlert';
|
||||
|
||||
const saveArgs: SaveDialogOptions = {
|
||||
title: 'Export Data',
|
||||
defaultPath: 'yaak-export.json',
|
||||
};
|
||||
|
||||
export function useExportData() {
|
||||
const workspaceId = useActiveWorkspaceId();
|
||||
const workspace = useActiveWorkspace();
|
||||
const alert = useAlert();
|
||||
|
||||
return useMutation({
|
||||
@@ -19,12 +14,18 @@ export function useExportData() {
|
||||
alert({ title: 'Export Failed', body: err });
|
||||
},
|
||||
mutationFn: async () => {
|
||||
const exportPath = await save(saveArgs);
|
||||
if (workspace == null) return;
|
||||
|
||||
const workspaceSlug = slugify(workspace.name, { lower: true });
|
||||
const exportPath = await save({
|
||||
title: 'Export Data',
|
||||
defaultPath: `yaak.${workspaceSlug}.json`,
|
||||
});
|
||||
if (exportPath == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
await invoke('export_data', { workspaceId, exportPath });
|
||||
await invoke('export_data', { workspaceId: workspace.id, exportPath });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user