Compare commits

..

17 Commits

Author SHA1 Message Date
Gregory Schier
0290aba982 Bump beta.3 2023-11-19 20:46:55 -08:00
Gregory Schier
0bafc4e4f5 Postman variables + urlencoded forms 2023-11-19 20:29:24 -08:00
Gregory Schier
9a36f94279 Add back Windows/Linux builds 2023-11-19 18:22:13 -08:00
Gregory Schier
1d8e66179e Remove Tauri context menu plugin 2023-11-19 18:21:10 -08:00
Gregory Schier
fda6d16d8e Fix header padding windows/linux 2023-11-19 18:14:49 -08:00
Gregory Schier
c4737916df Some tweaks 2023-11-19 18:13:32 -08:00
Gregory Schier
919465cdbb Beta 2 2023-11-19 17:41:58 -08:00
Gregory Schier
de3730fa4f Network entitlement 2023-11-19 17:41:46 -08:00
Gregory Schier
aff26fdd46 Try sandboxing again 2023-11-19 17:06:31 -08:00
Gregory Schier
3c0edf06af Remove sandboxing 2023-11-17 09:33:16 -08:00
Gregory Schier
cb8939db88 touch 2023-11-17 08:00:04 -08:00
Gregory Schier
bf4b3213c4 Out of beta 2023-11-17 07:53:26 -08:00
Gregory Schier
633d7c52c4 Tweak 2023-11-17 07:52:03 -08:00
Gregory Schier
0401cb92aa Format GraphQL variables 2023-11-17 07:51:03 -08:00
Gregory Schier
bff6c668a0 Drag into folder (Closes #8) 2023-11-17 07:36:01 -08:00
Gregory Schier
ee87e65763 Mostly move some stuff around 2023-11-16 18:53:34 -08:00
Gregory Schier
f165a0b827 Better update logic 2023-11-14 14:28:06 -08:00
32 changed files with 446 additions and 6369 deletions

View File

@@ -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 }}

View File

@@ -1,3 +1,4 @@
node_modules/
dist/
out/
.prettierrc.cjs

View File

@@ -0,0 +1,20 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Build Desktop" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="npm run tauri build -- --target universal-apple-darwin" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
<option name="INDEPENDENT_SCRIPT_WORKING_DIRECTORY" value="true" />
<option name="SCRIPT_WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="INDEPENDENT_INTERPRETER_PATH" value="true" />
<option name="INTERPRETER_PATH" value="/bin/zsh" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="EXECUTE_IN_TERMINAL" value="true" />
<option name="EXECUTE_SCRIPT_FILE" value="false" />
<envs>
<env name="TAURI_KEY_PASSWORD" value="fishhook-upstream-wash-assured" />
<env name="TAURI_PRIVATE_KEY" value="dW50cnVzdGVkIGNvbW1lbnQ6IHJzaWduIGVuY3J5cHRlZCBzZWNyZXQga2V5ClJXUlRZMEl5OGxWaytTa3dIa2xXVUltQzRGUXIzd2lYQ2NpV0ZhQURSbWJWZ1NrK0tnY0FBQkFBQUFBQUFBQUFBQUlBQUFBQUV2M1VKdVRyVHpHSzhQdGc2ZVFtOVNsMU5tNEVSN280cFNrbXhncW9tdjNXaFJZUTJqUzQ5Q01zWTJWRVhaY1pGNHNjR1NFR3JmcWFRN09NdWdGMXpZVXhzejR4V3lDV1JpZHlnbW5LNS9vMFFtRlZjbUl4YjZSNzhlMmk3ait5SExYcG5QZUkxOFE9Cg==" />
</envs>
<method v="2" />
</configuration>
</component>

12
.run/Dev Desktop.run.xml Normal file
View File

@@ -0,0 +1,12 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Dev Desktop" type="js.build_tools.npm">
<package-json value="$PROJECT_DIR$/package.json" />
<command value="run" />
<scripts>
<script value="start" />
</scripts>
<node-interpreter value="project" />
<envs />
<method v="2" />
</configuration>
</component>

18
package-lock.json generated
View File

@@ -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",

View File

@@ -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"
},

235
src-tauri/Cargo.lock generated
View File

@@ -123,17 +123,6 @@ dependencies = [
"critical-section",
]
[[package]]
name = "atty"
version = "0.2.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
dependencies = [
"hermit-abi 0.1.19",
"libc",
"winapi",
]
[[package]]
name = "autocfg"
version = "1.1.0"
@@ -182,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"
@@ -535,30 +518,6 @@ dependencies = [
"windows-targets 0.48.5",
]
[[package]]
name = "clap"
version = "3.2.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123"
dependencies = [
"atty",
"bitflags 1.3.2",
"clap_lex",
"indexmap 1.9.3",
"strsim",
"termcolor",
"textwrap",
]
[[package]]
name = "clap_lex"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
dependencies = [
"os_str_bytes",
]
[[package]]
name = "cobs"
version = "0.2.3"
@@ -752,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"
@@ -795,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"
@@ -1097,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"
@@ -1500,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"
@@ -1695,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"
@@ -1756,15 +1650,6 @@ dependencies = [
"unicode-segmentation",
]
[[package]]
name = "hermit-abi"
version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
dependencies = [
"libc",
]
[[package]]
name = "hermit-abi"
version = "0.3.3"
@@ -2100,14 +1985,8 @@ dependencies = [
"bytemuck",
"byteorder",
"color_quant",
"exr",
"gif",
"jpeg-decoder",
"num-rational",
"num-traits",
"png",
"qoi",
"tiff",
]
[[package]]
@@ -2162,7 +2041,7 @@ version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b"
dependencies = [
"hermit-abi 0.3.3",
"hermit-abi",
"rustix",
"windows-sys 0.48.0",
]
@@ -2240,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"
@@ -2304,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"
@@ -2705,7 +2569,7 @@ version = "1.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43"
dependencies = [
"hermit-abi 0.3.3",
"hermit-abi",
"libc",
]
@@ -2883,12 +2747,6 @@ dependencies = [
"winapi",
]
[[package]]
name = "os_str_bytes"
version = "6.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2355d85b9a3786f481747ced0e0ff2ba35213a1f9bd406ed906554d7af805a1"
[[package]]
name = "overload"
version = "0.1.1"
@@ -3279,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"
@@ -3393,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"
@@ -4523,7 +4352,6 @@ dependencies = [
"anyhow",
"base64 0.21.5",
"bytes",
"clap",
"cocoa 0.24.1",
"dirs-next",
"embed_plist",
@@ -4630,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"
@@ -4782,21 +4593,6 @@ dependencies = [
"utf-8",
]
[[package]]
name = "termcolor"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6093bad37da69aab9d123a8091e4be0aa4a03e4d601ec641c327398315f62b64"
dependencies = [
"winapi-util",
]
[[package]]
name = "textwrap"
version = "0.16.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d"
[[package]]
name = "thin-slice"
version = "0.1.1"
@@ -4839,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"
@@ -5496,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"
@@ -5953,7 +5732,6 @@ dependencies = [
"sqlx",
"tauri",
"tauri-build",
"tauri-plugin-context-menu",
"tauri-plugin-log",
"tauri-plugin-window-state",
"tokio",
@@ -6064,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",
]

View File

@@ -30,7 +30,6 @@ serde = { version = "1.0", features = ["derive"] }
serde_json = { version = "1.0", features = ["raw_value"] }
sqlx = { version = "0.7.2", features = ["sqlite", "runtime-tokio-rustls", "json", "chrono", "time"] }
tauri = { version = "1.3", features = [
"cli",
"config-toml",
"devtools",
"fs-read-file",
@@ -48,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]

View File

@@ -2,7 +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.cs.allow-unsigned-executable-memory</key>
<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>

View File

@@ -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
};

View File

@@ -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

View File

@@ -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;
}
}

View File

@@ -1,10 +1,10 @@
{
"compilerOptions": {
"target": "ES2020",
"target": "ESNext",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": [
"ES2020"
"ESNext"
],
"skipLibCheck": true,
"moduleResolution": "bundler",

View File

@@ -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
};

View File

@@ -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);
}
_ => {}
},

View File

@@ -4,6 +4,8 @@ use log::info;
use tauri::{AppHandle, updater, Window, Wry};
use tauri::api::dialog;
use crate::is_dev;
// Check for updates every 3 hours
const MAX_UPDATE_CHECK_SECONDS: u64 = 60 * 60 * 3;
@@ -28,6 +30,10 @@ impl YaakUpdater {
app_handle: &AppHandle<Wry>,
mode: UpdateMode,
) -> Result<(), updater::Error> {
if is_dev() {
info!("Skipping update check because we are in dev mode");
return Ok(());
}
self.last_update_check = SystemTime::now();
let update_mode = get_update_mode_str(mode);
info!("Checking for updates mode={}", update_mode);
@@ -38,13 +44,40 @@ impl YaakUpdater {
.await
{
Ok(update) => {
if dialog::blocking::ask(
let h = app_handle.clone();
dialog::ask(
None::<&Window>,
"Update available",
format!("{} is available. Would you like to download and install it now?", update.latest_version()),
) {
_ = update.download_and_install().await;
}
"Update Available",
format!(
"{} is available. Would you like to download and install it now?",
update.latest_version()
),
|confirmed| {
if !confirmed {
return;
}
tauri::async_runtime::spawn(async move {
match update.download_and_install().await {
Ok(_) => {
if dialog::blocking::ask(
None::<&Window>,
"Update Installed",
format!("Would you like to restart the app?",),
) {
h.restart();
}
}
Err(e) => {
dialog::message(
None::<&Window>,
"Update Failed",
format!("The update failed to install: {}", e),
);
}
}
});
},
);
Ok(())
}
Err(updater::Error::UpToDate) => Ok(()),

View File

@@ -8,26 +8,10 @@
},
"package": {
"productName": "Yaak",
"version": "2023.3.0-beta.2"
"version": "2023.4.0-beta.3"
},
"tauri": {
"windows": [],
"cli": {
"description": "Yaak CLI",
"longDescription": "This is the Yaak CLI, yo",
"beforeHelp": "u can use it to build, develop and manage your Yaak application.",
"afterHelp": "Have fun!",
"args": [],
"subcommands": {
"import": {
"args": [{
"name": "file",
"short": "f",
"takesValue": true
}]
}
}
},
"allowlist": {
"all": false,
"os": {
@@ -72,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/*",

View File

@@ -14,12 +14,13 @@ import { responsesQueryKey } from '../hooks/useResponses';
import { useSyncWindowTitle } from '../hooks/useSyncWindowTitle';
import { workspacesQueryKey } from '../hooks/useWorkspaces';
import { trackPage } from '../lib/analytics';
import { DEFAULT_FONT_SIZE } from '../lib/constants';
import { NAMESPACE_NO_SYNC } from '../lib/keyValueStore';
import type { HttpRequest, HttpResponse, Model, Workspace } from '../lib/models';
import { modelsEq } from '../lib/models';
import { setPathname } from '../lib/persistPathname';
const DEFAULT_FONT_SIZE = 16;
export function GlobalHooks() {
// Include here so they always update, even
// if no component references them

View File

@@ -2,6 +2,7 @@ import { updateSchema } from 'cm6-graphql';
import type { EditorView } from 'codemirror';
import { useCallback, useEffect, useMemo, useRef } from 'react';
import { useIntrospectGraphQL } from '../hooks/useIntrospectGraphQL';
import { tryFormatJson } from '../lib/formatters';
import type { HttpRequest } from '../lib/models';
import { Button } from './core/Button';
import type { EditorProps } from './core/Editor';
@@ -89,10 +90,10 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
onClick={() => {
dialog.show({
title: 'Introspection Failed',
size: 'sm',
size: 'dynamic',
id: 'introspection-failed',
render: () => (
<div className="whitespace-pre-wrap">
<>
<FormattedError>{error ?? 'unknown'}</FormattedError>
<div className="w-full mt-3">
<Button
@@ -107,7 +108,7 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
Try Again
</Button>
</div>
</div>
</>
),
});
}}
@@ -121,6 +122,7 @@ export function GraphQLEditor({ defaultValue, onChange, baseRequest, ...extraEdi
<Separator variant="primary" />
<p className="pt-1 text-gray-500 text-sm">Variables</p>
<Editor
format={tryFormatJson}
contentType="application/json"
defaultValue={JSON.stringify(variables, null, 2)}
heightMode="auto"

View File

@@ -32,7 +32,7 @@ export function Overlay({
return (
<Portal name={portalName}>
{open && (
<FocusTrap>
<FocusTrap>
<motion.div
className={classNames('fixed inset-0', zIndexes[zIndex])}
initial={{ opacity: 0 }}

View File

@@ -255,7 +255,7 @@ export const RequestPane = memo(function RequestPane({ style, fullHeight, classN
defaultValue={`${activeRequest?.body?.text ?? ''}`}
contentType="application/json"
onChange={handleBodyTextChange}
format={(v) => tryFormatJson(v)}
format={tryFormatJson}
/>
) : activeRequest.bodyType === BODY_TYPE_XML ? (
<Editor

View File

@@ -20,7 +20,7 @@ const drag = { gridArea: 'drag' };
const DEFAULT = 0.5;
const MIN_WIDTH_PX = 10;
const MIN_HEIGHT_PX = 30;
const STACK_VERTICAL_WIDTH = 650;
const STACK_VERTICAL_WIDTH = 600;
export const RequestResponse = memo(function RequestResponse({ style }: Props) {
const containerRef = useRef<HTMLDivElement>(null);

View File

@@ -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';
@@ -78,6 +75,11 @@ export function Sidebar({ className }: Props) {
namespace: NAMESPACE_NO_SYNC,
});
const isCollapsed = useCallback(
(id: string) => collapsed.value?.[id] ?? false,
[collapsed.value],
);
const { tree, treeParentMap, selectableRequests } = useMemo<{
tree: TreeNode | null;
treeParentMap: Record<string, TreeNode>;
@@ -258,13 +260,21 @@ export function Sidebar({ className }: Props) {
const handleMove = useCallback<DraggableSidebarItemProps['onMove']>(
(id, side) => {
const hoveredTree = treeParentMap[id] ?? null;
let hoveredTree = treeParentMap[id] ?? null;
const dragIndex = hoveredTree?.children.findIndex((n) => n.item.id === id) ?? -99;
const hoveredIndex = dragIndex + (side === 'above' ? 0 : 1);
const hoveredItem = hoveredTree?.children[dragIndex]?.item ?? null;
let hoveredIndex = dragIndex + (side === 'above' ? 0 : 1);
if (hoveredItem?.model === 'folder' && side === 'below' && !isCollapsed(hoveredItem.id)) {
// Move into folder if it's open and we're moving below it
hoveredTree = hoveredTree?.children.find((n) => n.item.id === id) ?? null;
hoveredIndex = 0;
}
setHoveredTree(hoveredTree);
setHoveredIndex(hoveredIndex);
},
[treeParentMap],
[isCollapsed, treeParentMap],
);
const handleDragStart = useCallback<DraggableSidebarItemProps['onDragStart']>((id: string) => {
@@ -340,11 +350,8 @@ export function Sidebar({ className }: Props) {
],
);
if (tree == null) {
return null;
}
if (collapsed.value == null) {
// Not ready to render yet
if (tree == null || collapsed.value == null) {
return null;
}
@@ -364,7 +371,7 @@ export function Sidebar({ className }: Props) {
treeParentMap={treeParentMap}
selectedId={selectedId}
selectedTree={selectedTree}
collapsed={collapsed.value}
isCollapsed={isCollapsed}
tree={tree}
focused={hasFocus}
draggingId={draggingId}
@@ -392,7 +399,7 @@ interface SidebarItemsProps {
handleEnd: (id: string) => void;
handleDragStart: (id: string) => void;
onSelect: (requestId: string) => void;
collapsed: Record<string, boolean>;
isCollapsed: (id: string) => boolean;
}
function SidebarItems({
@@ -403,7 +410,7 @@ function SidebarItems({
draggingId,
onSelect,
treeParentMap,
collapsed,
isCollapsed,
hoveredTree,
hoveredIndex,
handleEnd,
@@ -438,16 +445,16 @@ function SidebarItems({
onSelect={onSelect}
onDragStart={handleDragStart}
useProminentStyles={focused}
collapsed={collapsed}
isCollapsed={isCollapsed}
child={child}
>
{child.item.model === 'folder' &&
!collapsed[child.item.id] &&
!isCollapsed(child.item.id) &&
draggingId !== child.item.id && (
<SidebarItems
treeParentMap={treeParentMap}
tree={child}
collapsed={collapsed}
isCollapsed={isCollapsed}
draggingId={draggingId}
hoveredTree={hoveredTree}
hoveredIndex={hoveredIndex}
@@ -478,12 +485,10 @@ type SidebarItemProps = {
itemModel: string;
useProminentStyles?: boolean;
selected?: boolean;
onSelect: (id: string) => void;
draggable?: boolean;
children?: ReactNode;
collapsed: Record<string, boolean>;
child: TreeNode;
};
} & Pick<SidebarItemsProps, 'isCollapsed' | 'onSelect'>;
const SidebarItem = forwardRef(function SidebarItem(
{
@@ -496,7 +501,7 @@ const SidebarItem = forwardRef(function SidebarItem(
useProminentStyles,
selected,
onSelect,
collapsed,
isCollapsed,
child,
}: SidebarItemProps,
ref: ForwardedRef<HTMLLIElement>,
@@ -504,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();
@@ -557,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 (
@@ -661,7 +629,6 @@ const SidebarItem = forwardRef(function SidebarItem(
disabled={editing}
onClick={handleSelect}
onDoubleClick={handleStartEditing}
onContextMenu={handleContextMenu}
data-active={isActive}
data-selected={selected}
className={classNames(
@@ -679,7 +646,7 @@ const SidebarItem = forwardRef(function SidebarItem(
icon="chevronRight"
className={classNames(
'-ml-0.5 mr-2 transition-transform',
!collapsed[itemId] && 'transform rotate-90',
!isCollapsed(itemId) && 'transform rotate-90',
)}
/>
)}

View File

@@ -8,11 +8,10 @@ import type {
} from 'react';
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useWindowSize } from 'react-use';
import { useListenToTauriEvent } from '../hooks/useListenToTauriEvent';
import { useOsInfo } from '../hooks/useOsInfo';
import { useSidebarHidden } from '../hooks/useSidebarHidden';
import { useSidebarWidth } from '../hooks/useSidebarWidth';
import { useListenToTauriEvent } from '../hooks/useListenToTauriEvent';
import { WINDOW_FLOATING_SIDEBAR_WIDTH } from '../lib/constants';
import { Button } from './core/Button';
import { HStack } from './core/Stacks';
import { Overlay } from './Overlay';
@@ -27,6 +26,8 @@ const head = { gridArea: 'head' };
const body = { gridArea: 'body' };
const drag = { gridArea: 'drag' };
const WINDOW_FLOATING_SIDEBAR_WIDTH = 600;
export default function Workspace() {
const { setWidth, width, resetWidth } = useSidebarWidth();
const { hide, show, hidden, toggle } = useSidebarHidden();
@@ -66,9 +67,9 @@ export default function Workspace() {
e.preventDefault(); // Prevent text selection and things
const newWidth = startWidth + (e.clientX - mouseStartX);
if (newWidth < 100) {
hide();
hide();
resetWidth();
} else {
} else {
show();
setWidth(newWidth);
}
@@ -121,9 +122,9 @@ export default function Workspace() {
)}
>
{floating ? (
<Overlay open={!hidden} portalName="sidebar" onClose={hide} zIndex={10}>
<Overlay open={!hidden} portalName="sidebar" onClose={hide}>
<motion.div
initial={{ opacity: 0, x: -10 }}
initial={{ opacity: 0, x: -20 }}
animate={{ opacity: 1, x: 0 }}
className={classNames(
'absolute top-0 left-0 bottom-0 bg-gray-100 border-r border-highlight w-[14rem]',
@@ -175,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}

View File

@@ -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>

View File

@@ -72,7 +72,7 @@ export function Dialog({
<span />
)}
{description && <p id={descriptionId}>{description}</p>}
<div className="h-full w-full">{children}</div>
<div className="h-full w-full grid grid-cols-[minmax(0,1fr)]">{children}</div>
{/*Put close at the end so that it's the last thing to be tabbed to*/}
{!hideX && (
<IconButton

View File

@@ -5,11 +5,12 @@ interface Props {
}
export function FormattedError({ children }: Props) {
console.log('ERROR', children);
return (
<pre
className={classNames(
'text-sm select-auto cursor-text bg-gray-100 p-3 rounded',
'whitespace-normal border border-red-500 border-dashed',
'w-full text-sm select-auto cursor-text bg-gray-100 p-3 rounded',
'whitespace-pre border border-red-500 border-dashed overflow-x-auto',
)}
>
{children}

View File

@@ -180,8 +180,8 @@ export const PairEditor = memo(function PairEditor({
forceUpdateKey={forceUpdateKey}
nameAutocomplete={nameAutocomplete}
valueAutocomplete={valueAutocomplete}
namePlaceholder={isLast ? namePlaceholder : ''}
valuePlaceholder={isLast ? valuePlaceholder : ''}
namePlaceholder={namePlaceholder}
valuePlaceholder={valuePlaceholder}
nameValidate={nameValidate}
valueValidate={valueValidate}
onChange={handleChange}

View File

@@ -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 });
},
});
}

View File

@@ -44,8 +44,9 @@ export function useIntrospectGraphQL(baseRequest: HttpRequest) {
}
if (response.status < 200 || response.status >= 300) {
const text = await getResponseBodyText(response);
return Promise.reject(
new Error(`Request failed with status ${response.status}.\n\n${response.body}`),
new Error(`Request failed with status ${response.status}.\n\n${text}`),
);
}

View File

@@ -1,2 +0,0 @@
export const DEFAULT_FONT_SIZE = 16;
export const WINDOW_FLOATING_SIDEBAR_WIDTH = 600;