Skip to content

Commit

Permalink
Feat replay permission (#486)
Browse files Browse the repository at this point in the history
* feat: replay appOwner permission

* feat: getAppInfo

* feat: add owner for ownerless application

* feat: replay permission control

* fix: optimize replay pollingInterval

* fix: add request pane nodeType

* fix: pane request id

* feat: replay create new app

* feat: owner config Modal

* feat: replay readOnly mode

* feat: appId request header

* fix: owner modal open condition

* feat: compare temporary ignore

* feat: update arex-common to 0.1.0

* feat: set readOnly mode depend on has owners

* feat: use params.appId instand of params.id

* feat: auto inject appId to headers

* feat: move viewRecord api from Storage to Report

* fix: viewRecord api url

* fix: viewRecord api url

* ci: build config

* ci: disabled sourceMap

* ci: remove preinstall script

* ci: build script

* ci: 0.2.0

* ci: 0.2.0

* ci: 0.2.1

* ci: 0.2.2

* fix: clearLocalStorage import

* chore: repo private

* chore: repo private

* feat: axios header appId

* feat: decl

* feat: viewRecord appId

* feat: report initial loading spin

* feat: replay JSONEditor value encrypted

* feat: replay noRecordCountTip

* fix: props deps encrypted JSONEditor

* chore: update version to 0.6.0

---------

Co-authored-by: onePone <[email protected]>
  • Loading branch information
1pone and Xremn authored Oct 16, 2023
1 parent de0ce11 commit cd8d374
Show file tree
Hide file tree
Showing 74 changed files with 1,178 additions and 736 deletions.
9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
{
"name": "arex",
"version": "0.5.0",
"private": true,
"version": "0.6.0",
"description": "",
"homepage": "https://github.com/arextest/arex",
"main": "index.js",
"scripts": {
"prepare": "husky install",
"dev": "pnpm --filter=arex do-dev",
"dev:lite": "pnpm --filter=arex-lite do-dev",
"build": "pnpm run build:core && pnpm run -r do-build",
"build:core": "pnpm --filter=@arextest/arex-core -r do-build-core",
"postinstall": "pnpm run build",
"build": "pnpm run -r do-build",
"server": "pnpm -r do-server",
"lint": "prettier --write \"packages/**/*.{ts,tsx}\" && eslint \"packages/**/*.{ts,tsx}\" --fix",
"test": "pnpm -r test",
"test:run": "pnpm -r test:run",
"pre-commit": "pnpm run lint && pnpm run test:run",
"pre-commit": "pnpm run lint",
"rm": "find ./ -type d \\( -name \"dist\" -o -name \"node_modules\" \\) -exec rm -rf {} +",
"publish:core": "pnpm publish packages/arex-core --access=public",
"publish:common": "pnpm publish packages/arex-common --access=public",
Expand Down
9 changes: 4 additions & 5 deletions packages/arex-common/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"name": "@arextest/arex-common",
"version": "0.0.20",
"version": "0.2.5",
"homepage": "https://github.com/arextest/arex",
"main": "dist/arex-common.umd.cjs",
"main": "dist/arex-common.js",
"module": "dist/arex-common.js",
"type": "module",
"scripts": {
"build:code": "vite build",
"build:decl": "tsc --project tsconfig.decl.json",
"do-build": "pnpm run build:code && pnpm run build:decl",
"do-build-core": "pnpm run build:code && pnpm run build:decl"
"do-build": "pnpm run build:code && pnpm run build:decl"
},
"types": "./dist/index.d.ts",
"files": [
"dist/*"
],
"dependencies": {
"@arextest/arex-core": "workspace:latest",
"@arextest/arex-core": "*",
"@ant-design/icons": "^5.2.6",
"ahooks": "^3.7.5",
"allotment": "^1.18.1",
Expand Down
23 changes: 21 additions & 2 deletions packages/arex-common/src/components/DiffPath/DiffPathViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ export interface DiffPathViewerProps extends DiffJsonViewProps {
height?: string;
defaultActiveFirst?: boolean;
onChange?: (record?: InfoItem, data?: CompareResultDetail) => void;
requestDiffMsg: (params: any, record?: InfoItem) => Promise<CompareResultDetail>;
requestDiffMsg: (
params: any,
record?: InfoItem,
) => Promise<{ data: CompareResultDetail; encrypted: boolean }>;
requestQueryLogEntity: (params: {
compareResultId: string;
logIndex: number;
Expand All @@ -63,7 +66,22 @@ const DiffPathViewer: FC<DiffPathViewerProps> = (props) => {
const { t } = useTranslation();
const { token } = theme.useToken();

const { data: diffMsg, loading: loadingDiffMsg } = useRequest(props.requestDiffMsg, {
const {
data: { data: diffMsg, encrypted } = {
data: {
id: '',
categoryName: '',
operationName: '',
diffResultCode: 0,
logInfos: null,
exceptionMsg: null,
baseMsg: '',
testMsg: '',
},
encrypted: true,
},
loading: loadingDiffMsg,
} = useRequest(props.requestDiffMsg, {
defaultParams: [{ id: props.data.id }],
onSuccess: (data) => {
props.onChange?.(props.data);
Expand Down Expand Up @@ -176,6 +194,7 @@ const DiffPathViewer: FC<DiffPathViewerProps> = (props) => {
<DiffJsonView
hiddenTooltip
readOnly={props.contextMenuDisabled}
encrypted={encrypted}
diffJson={{
left: diffMsg?.baseMsg || '',
right: diffMsg?.testMsg || '',
Expand Down
3 changes: 2 additions & 1 deletion packages/arex-common/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ export default defineConfig({
}),
],
build: {
sourcemap: true,
// sourcemap: true,
outDir: './dist',
emptyOutDir: true,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'ArexCommon',
fileName: 'arex-common',
formats: ['es'],
},
rollupOptions: {
external: [
Expand Down
9 changes: 4 additions & 5 deletions packages/arex-core/package.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
{
"name": "@arextest/arex-core",
"version": "0.1.0",
"version": "0.2.5",
"homepage": "https://github.com/arextest/arex",
"main": "dist/arex-core.umd.cjs",
"main": "dist/arex-core.js",
"module": "dist/arex-core.js",
"type": "module",
"scripts": {
"build:code": "vite build",
"build:decl": "tsc --project tsconfig.decl.json",
"do-build": "pnpm run build:code && pnpm run build:decl",
"do-build-core": "pnpm run build:code && pnpm run build:decl"
"do-build": "pnpm run build:code && pnpm run build:decl"
},
"types": "dist/index.d.ts",
"files": [
"dist/*"
],
"dependencies": {
"@arextest/vanilla-jsoneditor": "0.17.25",
"@dnd-kit/core": "^6.0.8",
"@dnd-kit/sortable": "^7.0.2",
"@dnd-kit/utilities": "^3.2.1",
"@ant-design/icons": "^5.2.6",
"@arextest/vanilla-jsoneditor": "0.17.23",
"@emotion/serialize": "^1.1.1",
"ahooks": "^3.7.5",
"allotment": "^1.18.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { JSONEditor, JSONEditorPropsOptional, ReadonlyValue } from '@arextest/vanilla-jsoneditor';
import {
JSONEditor,
JSONEditorPropsOptional,
ReadonlyPassword,
ReadonlyValue,
} from '@arextest/vanilla-jsoneditor';
import { css } from '@emotion/react';
import styled from '@emotion/styled';
import { theme } from 'antd';
import { parse, stringify } from 'lossless-json';
import React, { useEffect, useRef } from 'react';

Expand Down Expand Up @@ -33,18 +37,24 @@ const EditorWaterMark = styled.div<{
}
`;

export default function SvelteJSONEditor(props: SvelteJSONEditorProps) {
export interface JSONEditorProps extends SvelteJSONEditorProps {
encrypted?: boolean;
}

export default function SvelteJSONEditor(props: JSONEditorProps) {
const { encrypted } = props;
const refContainer = useRef<HTMLDivElement>(null);
const refEditor = useRef<any>(null);
const { token } = theme.useToken();

useEffect(() => {
refEditor.current = new JSONEditor({
target: refContainer.current!,
props: {
// @ts-ignore
// disable build-in render component
onRenderValue: (props) => [{ component: ReadonlyValue, props }],
onRenderValue: (props) => [
{ component: encrypted ? ReadonlyPassword : ReadonlyValue, props },
],
// parse bigInt
// @ts-ignore
parser: LosslessJSONParser,
Expand All @@ -58,7 +68,7 @@ export default function SvelteJSONEditor(props: SvelteJSONEditorProps) {
refEditor.current = null;
}
};
}, []);
}, [encrypted]);

// update props
useEffect(() => {
Expand Down
6 changes: 5 additions & 1 deletion packages/arex-core/src/components/DiffJsonView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useTranslation } from 'react-i18next';
import { useArexCoreConfig } from '../../hooks';
import DiffJsonTooltip from './DiffJsonTooltip';
import { genAllDiffByType, LogEntity } from './helper';
import VanillaJSONEditor from './VanillaJSONEditor';
import VanillaJSONEditor from './JSONEditor';

export enum TargetEditor {
'left' = 'left',
Expand All @@ -24,6 +24,7 @@ export type PathHandler = (params: {
}) => void;
export type DiffJsonViewProps = {
readOnly?: boolean;
encrypted?: boolean;
height?: string | number;
hiddenTooltip?: boolean;
diffJson?: { left: string; right: string };
Expand All @@ -39,6 +40,7 @@ export type DiffJsonViewProps = {
const { useToken } = theme;
const DiffJsonView: FC<DiffJsonViewProps> = ({
readOnly,
encrypted,
diffJson,
diffPath,
hiddenTooltip,
Expand Down Expand Up @@ -142,6 +144,7 @@ const DiffJsonView: FC<DiffJsonViewProps> = ({
>
<VanillaJSONEditor
readOnly={readOnly}
encrypted={encrypted}
height={height}
language={language}
remark={remark?.[0] || (t('benchmark') as string)}
Expand Down Expand Up @@ -183,6 +186,7 @@ const DiffJsonView: FC<DiffJsonViewProps> = ({
>
<VanillaJSONEditor
readOnly={readOnly}
encrypted={encrypted}
height={height}
language={language}
remark={remark?.[1] || (t('test') as string)}
Expand Down
3 changes: 2 additions & 1 deletion packages/arex-core/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ export default defineConfig({
}),
],
build: {
sourcemap: true,
// sourcemap: true,
outDir: './dist',
emptyOutDir: true,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'ArexCore',
fileName: 'arex-core',
formats: ['es'],
},
rollupOptions: {
external: ['react', 'react-dom', 'antd', '@emotion/react', '@emotion/styled'],
Expand Down
10 changes: 4 additions & 6 deletions packages/arex-request/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
{
"name": "@arextest/arex-request",
"version": "0.1.1",
"version": "0.2.2",
"type": "module",
"main": "dist/arex-request.umd.cjs",
"main": "dist/arex-request.js",
"module": "dist/arex-request.js",
"homepage": "https://github.com/arextest/arex-request",
"scripts": {
"preinstall": "pnpm -w run build:core",
"build:code": "tsc && vite build",
"do-build": "pnpm run build:code",
"do-build": "tsc && vite build",
"do-test": "vitest",
"coverage": "vitest run --coverage"
},
Expand All @@ -17,7 +15,7 @@
"dist/*"
],
"dependencies": {
"@arextest/arex-core": "workspace:latest",
"@arextest/arex-core": "*",
"@arextest/monaco-react": "^4.5.1",
"@ant-design/icons": "^5.2.6",
"allotment": "^1.18.1",
Expand Down
6 changes: 2 additions & 4 deletions packages/arex-request/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@ import react from '@vitejs/plugin-react-swc';
import path from 'path';
import Icons from 'unplugin-icons/vite';
import { defineConfig } from 'vite';
import dts from 'vite-plugin-dts';

export default defineConfig({
plugins: [
react({
jsxImportSource: '@emotion/react',
}),
dts({
insertTypesEntry: true,
}),
Icons({ compiler: 'jsx', jsx: 'react' }),
],
// test: {
Expand All @@ -25,11 +21,13 @@ export default defineConfig({

build: {
outDir: './dist',
// sourcemap: true,
emptyOutDir: true,
lib: {
entry: path.resolve(__dirname, 'src/index.ts'),
name: 'ArexRequest',
fileName: 'arex-request',
formats: ['es'],
},
rollupOptions: {
external: [
Expand Down
10 changes: 5 additions & 5 deletions packages/arex/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "arex",
"private": true,
"version": "0.5.0",
"version": "0.6.0",
"type": "module",
"scripts": {
"test": "vitest",
Expand All @@ -10,11 +10,11 @@
"do-build": "node --max_old_space_size=16384 ./node_modules/vite/bin/vite.js build"
},
"dependencies": {
"@ant-design/icons": "^5.2.6",
"@arextest/arex-common": "workspace:^",
"@arextest/arex-core": "workspace:^",
"@arextest/arex-request": "workspace:^",
"@arextest/arex-common": "*",
"@arextest/arex-core": "*",
"@arextest/arex-request": "*",
"@arextest/monaco-react": "^4.5.1",
"@ant-design/icons": "^5.2.6",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@formkit/auto-animate": "^0.7.0",
Expand Down
6 changes: 4 additions & 2 deletions packages/arex/src/components/EmptyPanePlaceholder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { useTranslation } from '@arextest/arex-core';
import { Button, Space, Typography } from 'antd';
import React, { FC, useMemo } from 'react';

import { PanesType } from '@/constant';
import { CollectionNodeType, PanesType } from '@/constant';
import { useNavPane } from '@/hooks';
import { useWorkspaces } from '@/store';
import { generateId } from '@/utils';
import { shortcuts } from '@/utils/keybindings';

Expand All @@ -12,11 +13,12 @@ const shortcutsTipList = ['general.keybindings.toggle', 'navigation.help'];
const EmptyPanePlaceholder: FC = () => {
const { t } = useTranslation(['components', 'shortcuts']);
const navPane = useNavPane();
const { activeWorkspaceId } = useWorkspaces();

const handlePaneAdd = () => {
navPane({
type: PanesType.REQUEST,
id: generateId(12),
id: `${activeWorkspaceId}-${CollectionNodeType.interface}-${generateId(12)}`,
icon: 'Get',
name: 'Untitled',
});
Expand Down
4 changes: 2 additions & 2 deletions packages/arex/src/components/KeyboardShortcut.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { App, Collapse, Drawer, Input, InputProps, List, Typography } from 'antd';
import React, { CompositionEventHandler, useEffect, useMemo, useRef, useState } from 'react';

import { MenusType, PanesType } from '@/constant';
import { CollectionNodeType, MenusType, PanesType } from '@/constant';
import { useNavPane } from '@/hooks';
import { useMenusPanes, useWorkspaces } from '@/store';
import { decodePaneKey } from '@/store/useMenusPanes';
Expand Down Expand Up @@ -238,7 +238,7 @@ const KeyboardShortcut = React.memo(() => {
case 'pane.new': {
navPane({
type: PanesType.REQUEST,
id: generateId(12),
id: `${activeWorkspaceId}-${CollectionNodeType.interface}-${generateId(12)}`,
icon: 'Get',
name: 'Untitled',
});
Expand Down
Loading

0 comments on commit cd8d374

Please sign in to comment.