From 72f6c164c1eaee23db315d42122f8d1f7ca9628c Mon Sep 17 00:00:00 2001 From: Jason Terando Date: Wed, 30 Oct 2024 21:39:16 -0500 Subject: [PATCH] Add private/local global icons for parameter storage --- @apicize/cli/Cargo.toml | 4 +- @apicize/lib-rust/Cargo.toml | 2 +- @apicize/lib-typescript/package.json | 2 +- @apicize/toolkit/package.json | 4 +- .../controls/editors/certificate-editor.tsx | 2 +- .../controls/editors/persistence-editor.tsx | 23 ++++- .../src/controls/editors/proxy-editor.tsx | 2 +- @apicize/toolkit/src/controls/navigation.tsx | 93 ++++++++++++++++--- @apicize/toolkit/src/controls/run-toolbar.tsx | 2 +- @apicize/toolkit/src/index.ts | 8 +- CHANGELOG.md | 4 + app/package.json | 4 +- app/src-tauri/Cargo.lock | 4 +- app/src-tauri/Cargo.toml | 4 +- app/src-tauri/tauri.conf.json | 2 +- app/src/controls/configurable-theme.tsx | 12 +++ yarn.lock | 8 +- 17 files changed, 141 insertions(+), 39 deletions(-) diff --git a/@apicize/cli/Cargo.toml b/@apicize/cli/Cargo.toml index aba3525..1fd4889 100644 --- a/@apicize/cli/Cargo.toml +++ b/@apicize/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "apicize-run" -version = "0.8.3" +version = "0.8.4" description = "Apicize CLI test runner" authors = ["Apicize"] license = "MIT" @@ -13,7 +13,7 @@ rust-version = "1.70" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -apicize-lib = { path = "../lib-rust", version = "^0.8.3" } +apicize-lib = { path = "../lib-rust", version = "^0.8.4" } clap = { version = "4.5.19", features = ["derive"] } colored = "2.1.0" num-format = { version = "0.4.4", features = ["with-system-locale"] } diff --git a/@apicize/lib-rust/Cargo.toml b/@apicize/lib-rust/Cargo.toml index 4bd4594..223bd8f 100644 --- a/@apicize/lib-rust/Cargo.toml +++ b/@apicize/lib-rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "apicize-lib" -version = "0.8.3" +version = "0.8.4" edition = "2021" rust-version = "1.70" description = "Library supporting Apicize request dispatch, testing and serialization" diff --git a/@apicize/lib-typescript/package.json b/@apicize/lib-typescript/package.json index ee9debc..409e088 100644 --- a/@apicize/lib-typescript/package.json +++ b/@apicize/lib-typescript/package.json @@ -1,7 +1,7 @@ { "name": "@apicize/lib-typescript", "private": true, - "version": "0.8.3", + "version": "0.8.4", "description": "TypeScript model definitions for Apicize", "scripts": { "build": "tsc", diff --git a/@apicize/toolkit/package.json b/@apicize/toolkit/package.json index f36e275..4d575cd 100644 --- a/@apicize/toolkit/package.json +++ b/@apicize/toolkit/package.json @@ -1,7 +1,7 @@ { "name": "@apicize/toolkit", "private": true, - "version": "0.8.3", + "version": "0.8.4", "description": "UI toolkit for Apicize applications", "keywords": [], "license": "MIT", @@ -41,7 +41,7 @@ "mobx-react-lite": "^4.0.7" }, "dependencies": { - "@apicize/lib-typescript": "^0.8.3", + "@apicize/lib-typescript": "^0.8.4", "@dnd-kit/core": "^6.1.0", "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", diff --git a/@apicize/toolkit/src/controls/editors/certificate-editor.tsx b/@apicize/toolkit/src/controls/editors/certificate-editor.tsx index 140d083..d4a0eb6 100644 --- a/@apicize/toolkit/src/controls/editors/certificate-editor.tsx +++ b/@apicize/toolkit/src/controls/editors/certificate-editor.tsx @@ -121,7 +121,7 @@ export const CertificateEditor = observer((props: { PEM - + workspace.setCertificatePersistence(e)} persistence={certificate.persistence} /> { diff --git a/@apicize/toolkit/src/controls/editors/persistence-editor.tsx b/@apicize/toolkit/src/controls/editors/persistence-editor.tsx index 17eb461..d4af23e 100644 --- a/@apicize/toolkit/src/controls/editors/persistence-editor.tsx +++ b/@apicize/toolkit/src/controls/editors/persistence-editor.tsx @@ -1,5 +1,7 @@ import { Persistence } from "@apicize/lib-typescript"; -import { FormControl, InputLabel, MenuItem, Select } from "@mui/material"; +import { Box, FormControl, InputLabel, MenuItem, Select } from "@mui/material"; +import SdCardAlertIcon from '@mui/icons-material/SdCardAlert'; +import FolderSharedIcon from '@mui/icons-material/FolderShared'; export function PersistenceEditor(props: { persistence: Persistence, @@ -19,8 +21,23 @@ export function PersistenceEditor(props: { fullWidth > Workbook - Workbook (Private) - Local Global + + + Workbook (Private) + + + + + + + + + Local Global + + + + + ) diff --git a/@apicize/toolkit/src/controls/editors/proxy-editor.tsx b/@apicize/toolkit/src/controls/editors/proxy-editor.tsx index e521d8b..22fc330 100644 --- a/@apicize/toolkit/src/controls/editors/proxy-editor.tsx +++ b/@apicize/toolkit/src/controls/editors/proxy-editor.tsx @@ -33,7 +33,7 @@ export const ProxyEditor = observer((props: { /> - + workspace.setProxyPersistence(e)} persistence={proxy.persistence} /> void }) => { const theme = useTheme() @@ -222,6 +235,19 @@ export const Navigation = observer((props: { onSettings?: () => void }) => { } as DraggableData }) + const iconFromStateIcon = (state: StateIcon) => { + switch (state) { + case StateIcon.Running: + return + case StateIcon.Private: + return + case StateIcon.Shared: + return + default: + return null + } + } + const dragStyle = { transform: CSS.Translate.toString(transform) } @@ -237,17 +263,48 @@ export const Navigation = observer((props: { onSettings?: () => void }) => { // Requests can be hierarchical let children: EditableItem[] | undefined - let isRunning: boolean + let stateIcon: StateIcon = StateIcon.None + if (props.item.entityType === EditableEntityType.Group) { const childIds = workspace.workspace.requests.childIds?.get(props.item.id) children = childIds?.map(id => workspace.workspace.requests.entities.get(id) )?.filter(e => e !== undefined) - isRunning = workspace.executingRequestIDs.indexOf(props.item.id) !== -1 + if (workspace.executingRequestIDs.indexOf(props.item.id) !== -1) { + stateIcon = StateIcon.Running + } } else if (props.item.entityType === EditableEntityType.Request) { - isRunning = workspace.executingRequestIDs.indexOf(props.item.id) !== -1 - } else { - isRunning = false + if (workspace.executingRequestIDs.indexOf(props.item.id) !== -1) { + stateIcon = StateIcon.Running + } + } else if (props.item.entityType === EditableEntityType.Scenario) { + const scenario = props.item as EditableWorkbookScenario + if (scenario.persistence === Persistence.Private) { + stateIcon = StateIcon.Private + } else if (scenario.persistence === Persistence.Global) { + stateIcon = StateIcon.Shared + } + } else if (props.item.entityType === EditableEntityType.Authorization) { + const auth = props.item as EditableWorkbookAuthorization + if (auth.persistence === Persistence.Private) { + stateIcon = StateIcon.Private + } else if (auth.persistence === Persistence.Global) { + stateIcon = StateIcon.Shared + } + } else if (props.item.entityType === EditableEntityType.Certificate) { + const cert = props.item as EditableWorkbookCertificate + if (cert.persistence === Persistence.Private) { + stateIcon = StateIcon.Private + } else if (cert.persistence === Persistence.Global) { + stateIcon = StateIcon.Shared + } + } else if (props.item.entityType === EditableEntityType.Proxy) { + const proxy = props.item as EditableWorkbookProxy + if (proxy.persistence === Persistence.Private) { + stateIcon = StateIcon.Private + } else if (proxy.persistence === Persistence.Global) { + stateIcon = StateIcon.Shared + } } return children @@ -281,11 +338,15 @@ export const Navigation = observer((props: { onSettings?: () => void }) => { }} > - - {GetTitle(props.item)} - - - {isRunning ? : null} + {GetTitle(props.item)} + + {iconFromStateIcon(stateIcon)} + void }) => { } { props.item.invalid ? () : null } {GetTitle(props.item)} - - - {isRunning ? : null} + + {iconFromStateIcon(stateIcon)} + { if (workspace.active?.id) { try { await workspace.cancelRequest(workspace.active?.id) - feedback.toast('Request cancelled', ToastSeverity.Success) + feedback.toast('Request cancelled', ToastSeverity.Info) } catch (e) { feedback.toast(`Unable to cancel request - ${e}`, ToastSeverity.Error) } diff --git a/@apicize/toolkit/src/index.ts b/@apicize/toolkit/src/index.ts index b7cbd8b..5b47c8e 100644 --- a/@apicize/toolkit/src/index.ts +++ b/@apicize/toolkit/src/index.ts @@ -42,6 +42,8 @@ declare module '@mui/material/styles' { authorization?: PaletteOptions['primary'] certificate?: PaletteOptions['primary'] proxy?: PaletteOptions['primary'] + private?: PaletteOptions['primary'] + global?: PaletteOptions['primary'] } } @@ -53,6 +55,8 @@ declare module '@mui/material/IconButton' { authorization: true certificate: true proxy: true + private: true + global: true } } @@ -63,6 +67,8 @@ declare module '@mui/material/SvgIcon' { scenario: true authorization: true certificate: true - proxy: true + proxy: true, + private: true + global: true } } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d60605..dd4a2ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +# 0.8.4 + +* Add private/local global icons for parameter storage + # 0.8.3 * Fix request cloning when body has data diff --git a/app/package.json b/app/package.json index 6874226..cdb926a 100644 --- a/app/package.json +++ b/app/package.json @@ -1,6 +1,6 @@ { "name": "app", - "version": "0.8.3", + "version": "0.8.4", "type": "module", "scripts": { "dev": "vite", @@ -10,7 +10,7 @@ "tauri": "tauri" }, "dependencies": { - "@apicize/toolkit": "^0.8.3", + "@apicize/toolkit": "^0.8.4", "@dnd-kit/core": "^6.1.0", "@mui/material": "^6.1.1", "@mui/system": "^6.1.1", diff --git a/app/src-tauri/Cargo.lock b/app/src-tauri/Cargo.lock index f068753..49c8a6a 100644 --- a/app/src-tauri/Cargo.lock +++ b/app/src-tauri/Cargo.lock @@ -104,7 +104,7 @@ checksum = "c042108f3ed77fd83760a5fd79b53be043192bb3b9dba91d8c574c0ada7850c8" [[package]] name = "apicize" -version = "0.8.2" +version = "0.8.3" dependencies = [ "apicize-lib", "env_logger", @@ -122,7 +122,7 @@ dependencies = [ [[package]] name = "apicize-lib" -version = "0.8.2" +version = "0.8.3" dependencies = [ "async-recursion", "async-trait", diff --git a/app/src-tauri/Cargo.toml b/app/src-tauri/Cargo.toml index c1af8a2..fc77300 100644 --- a/app/src-tauri/Cargo.toml +++ b/app/src-tauri/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "apicize" -version = "0.8.3" +version = "0.8.4" description = "Apicize HTTP call testing application" authors = ["Jason Terando"] license = "MIT" @@ -17,7 +17,7 @@ tauri-build = { version = "2.0.0", features = [] } [dependencies] serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } -apicize-lib = { version = "0.8.3", path = "../../@apicize/lib-rust" } +apicize-lib = { version = "0.8.4", path = "../../@apicize/lib-rust" } tauri = { version = "2.0.0", features = ["image-png"] } tokio-util = "0.7.11" tauri-plugin-fs = "2.0.0" diff --git a/app/src-tauri/tauri.conf.json b/app/src-tauri/tauri.conf.json index 9b0c5b8..61873ff 100644 --- a/app/src-tauri/tauri.conf.json +++ b/app/src-tauri/tauri.conf.json @@ -2,7 +2,7 @@ "$schema": "../../node_modules/@tauri-apps/cli/config.schema.json", "identifier": "apicize.app", "productName": "Apicize", - "version": "0.8.3", + "version": "0.8.4", "app": { "security": { "csp": null diff --git a/app/src/controls/configurable-theme.tsx b/app/src/controls/configurable-theme.tsx index 97d90f0..9fbbdd4 100644 --- a/app/src/controls/configurable-theme.tsx +++ b/app/src/controls/configurable-theme.tsx @@ -61,6 +61,18 @@ export const ConfigurableTheme = observer((props: { children?: ReactNode }) => { }, name: 'request' }), + private: palette.palette.augmentColor({ + color: { + main: '#c3195d' + }, + name: 'request' + }), + global: palette.palette.augmentColor({ + color: { + main: '#38598b' + }, + name: 'request' + }), }, typography: { fontSize: settings.fontSize, diff --git a/yarn.lock b/yarn.lock index f586ee7..28d2aa5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -15,7 +15,7 @@ __metadata: languageName: node linkType: hard -"@apicize/lib-typescript@npm:^0.8.3, @apicize/lib-typescript@workspace:@apicize/lib-typescript": +"@apicize/lib-typescript@npm:^0.8.4, @apicize/lib-typescript@workspace:@apicize/lib-typescript": version: 0.0.0-use.local resolution: "@apicize/lib-typescript@workspace:@apicize/lib-typescript" dependencies: @@ -23,11 +23,11 @@ __metadata: languageName: unknown linkType: soft -"@apicize/toolkit@npm:^0.8.3, @apicize/toolkit@workspace:@apicize/toolkit": +"@apicize/toolkit@npm:^0.8.4, @apicize/toolkit@workspace:@apicize/toolkit": version: 0.0.0-use.local resolution: "@apicize/toolkit@workspace:@apicize/toolkit" dependencies: - "@apicize/lib-typescript": "npm:^0.8.3" + "@apicize/lib-typescript": "npm:^0.8.4" "@dnd-kit/core": "npm:^6.1.0" "@emotion/react": "npm:^11.11.1" "@emotion/styled": "npm:^11.11.0" @@ -2655,7 +2655,7 @@ __metadata: version: 0.0.0-use.local resolution: "app@workspace:app" dependencies: - "@apicize/toolkit": "npm:^0.8.3" + "@apicize/toolkit": "npm:^0.8.4" "@dnd-kit/core": "npm:^6.1.0" "@mui/material": "npm:^6.1.1" "@mui/system": "npm:^6.1.1"