Skip to content

Commit

Permalink
Add private/local global icons for parameter storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Terando committed Oct 31, 2024
1 parent 6938c8f commit 72f6c16
Show file tree
Hide file tree
Showing 17 changed files with 141 additions and 39 deletions.
4 changes: 2 additions & 2 deletions @apicize/cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion @apicize/lib-rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion @apicize/lib-typescript/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
4 changes: 2 additions & 2 deletions @apicize/toolkit/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ export const CertificateEditor = observer((props: {
<MenuItem value={WorkbookCertificateType.PEM}>PEM</MenuItem>
</Select>
</FormControl>
<PersistenceEditor onUpdatePersistence={workspace.setCertificatePersistence} persistence={certificate.persistence} />
<PersistenceEditor onUpdatePersistence={(e) => workspace.setCertificatePersistence(e)} persistence={certificate.persistence} />
</Stack>
</Grid2>
{
Expand Down
23 changes: 20 additions & 3 deletions @apicize/toolkit/src/controls/editors/persistence-editor.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -19,8 +21,23 @@ export function PersistenceEditor(props: {
fullWidth
>
<MenuItem value={Persistence.Workbook}>Workbook</MenuItem>
<MenuItem value={Persistence.Private}>Workbook (Private)</MenuItem>
<MenuItem value={Persistence.Global}>Local Global</MenuItem>
<MenuItem value={Persistence.Private}>
<Box display='flex' justifyItems='center'>
Workbook (Private)
<Box display='inline-flex' width='2em' paddingLeft='0.5em' justifyItems='center' justifyContent='left'>
<SdCardAlertIcon color="private" />
</Box>
</Box>
</MenuItem>
<MenuItem value={Persistence.Global}>

<Box display='flex' justifyItems='center'>
Local Global
<Box display='inline-flex' width='2em' paddingLeft='0.5em' justifyItems='center' justifyContent='left'>
<FolderSharedIcon color="global" />
</Box>
</Box>
</MenuItem>
</Select>
</FormControl>
)
Expand Down
2 changes: 1 addition & 1 deletion @apicize/toolkit/src/controls/editors/proxy-editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const ProxyEditor = observer((props: {
/>
</Grid2>
<Grid2>
<PersistenceEditor onUpdatePersistence={workspace.setProxyPersistence} persistence={proxy.persistence} />
<PersistenceEditor onUpdatePersistence={(e) => workspace.setProxyPersistence(e)} persistence={proxy.persistence} />
</Grid2>
<Grid2>
<TextField
Expand Down
93 changes: 78 additions & 15 deletions @apicize/toolkit/src/controls/navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import ContentCopyOutlinedIcon from '@mui/icons-material/ContentCopyOutlined';
import AirlineStopsIcon from '@mui/icons-material/AirlineStops';
import SecurityIcon from '@mui/icons-material/Security';
import SettingsIcon from '@mui/icons-material/Settings';
import SdCardAlertIcon from '@mui/icons-material/SdCardAlert';
import FolderSharedIcon from '@mui/icons-material/FolderShared';
import DeleteIcon from '@mui/icons-material/DeleteOutlined'
import LanguageIcon from '@mui/icons-material/Language'
import { SimpleTreeView } from '@mui/x-tree-view/SimpleTreeView'
Expand All @@ -22,21 +24,32 @@ import { Box, IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Stack, use
import AddIcon from '@mui/icons-material/Add'
import React, { ReactNode, SyntheticEvent, useState } from 'react'
import { DndContext, DragEndEvent, useDraggable, useDroppable, useSensors, useSensor, PointerSensor, DragCancelEvent, DragMoveEvent } from '@dnd-kit/core'
import { GetTitle } from '@apicize/lib-typescript';
import { GetTitle, Persistence } from '@apicize/lib-typescript';
import { CSS, useCombinedRefs } from '@dnd-kit/utilities';
import { EditableItem } from "../models/editable";
import { EditableEntityType } from "../models/workbook/editable-entity-type";
import { useFileOperations } from "../contexts/file-operations.context";
import { useWorkspace } from "../contexts/workspace.context";
import { ToastSeverity, useFeedback } from "../contexts/feedback.context";
import { EditableWorkbookRequest } from "../models/workbook/editable-workbook-request";
import { EditableWorkbookScenario } from "../models/workbook/editable-workbook-scenario";
import { EditableWorkbookAuthorization } from "../models/workbook/editable-workbook-authorization";
import { EditableWorkbookCertificate } from "../models/workbook/editable-workbook-certificate";
import { EditableWorkbookProxy } from "../models/workbook/editable-workbook-proxy";

interface MenuPosition {
id: string
mouseX: number
mouseY: number
}

enum StateIcon {
None,
Running,
Private,
Shared
}

export const Navigation = observer((props: { onSettings?: () => void }) => {

const theme = useTheme()
Expand Down Expand Up @@ -222,6 +235,19 @@ export const Navigation = observer((props: { onSettings?: () => void }) => {
} as DraggableData
})

const iconFromStateIcon = (state: StateIcon) => {
switch (state) {
case StateIcon.Running:
return <PlayArrowIcon color="success" />
case StateIcon.Private:
return <SdCardAlertIcon color="private" />
case StateIcon.Shared:
return <FolderSharedIcon color="global" />
default:
return null
}
}

const dragStyle = {
transform: CSS.Translate.toString(transform)
}
Expand All @@ -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
Expand Down Expand Up @@ -281,11 +338,15 @@ export const Navigation = observer((props: { onSettings?: () => void }) => {
}}
>
<FolderIcon className='nav-folder' color='folder' />
<Box className='nav-node-text'>
{GetTitle(props.item)}
</Box>
<Box display='inline-flex' width='2em' paddingLeft='0.3em' justifyItems='center' justifyContent='left'>
{isRunning ? <PlayArrowIcon color="success" /> : null}
<Box
className='nav-node-text'
justifyContent='left'
justifyItems='center'
display='flex'
> {GetTitle(props.item)}
<Box display='inline-flex' width='2em' paddingLeft='1em' justifyItems='center' justifyContent='left'>
{iconFromStateIcon(stateIcon)}
</Box>
</Box>
<IconButton
sx={{
Expand Down Expand Up @@ -349,15 +410,17 @@ export const Navigation = observer((props: { onSettings?: () => void }) => {
}
<Box
className='nav-node-text'
sx={{ display: 'flex', alignItems: 'center' }}
justifyContent='left'
justifyItems='center'
display='flex'
>
{
props.item.invalid ? (<WarningAmberIcon color='warning' sx={{ marginRight: '0.25em' }} />) : null
}
{GetTitle(props.item)}
</Box>
<Box display='inline-flex' width='2em' paddingLeft='0.3em' justifyItems='center' justifyContent='left'>
{isRunning ? <PlayArrowIcon color="success" /> : null}
<Box display='inline-flex' width='2em' paddingLeft='1em' justifyItems='center' justifyContent='left'>
{iconFromStateIcon(stateIcon)}
</Box>
</Box>
<IconButton
sx={{
Expand Down
2 changes: 1 addition & 1 deletion @apicize/toolkit/src/controls/run-toolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const RunToolbar = observer((props: { sx?: SxProps }) => {
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)
}
Expand Down
8 changes: 7 additions & 1 deletion @apicize/toolkit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ declare module '@mui/material/styles' {
authorization?: PaletteOptions['primary']
certificate?: PaletteOptions['primary']
proxy?: PaletteOptions['primary']
private?: PaletteOptions['primary']
global?: PaletteOptions['primary']
}
}

Expand All @@ -53,6 +55,8 @@ declare module '@mui/material/IconButton' {
authorization: true
certificate: true
proxy: true
private: true
global: true
}
}

Expand All @@ -63,6 +67,8 @@ declare module '@mui/material/SvgIcon' {
scenario: true
authorization: true
certificate: true
proxy: true
proxy: true,
private: true
global: true
}
}
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "app",
"version": "0.8.3",
"version": "0.8.4",
"type": "module",
"scripts": {
"dev": "vite",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions app/src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions app/src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion app/src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions app/src/controls/configurable-theme.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 72f6c16

Please sign in to comment.