Skip to content

Commit

Permalink
🐛🦟 1003 fixing minor frontend bugs (#1008)
Browse files Browse the repository at this point in the history
* 1003 fixing minor frontend bugs|

* 1003 fixing minor frontend bugs|
  • Loading branch information
xoscar committed Jul 28, 2022
1 parent 942d184 commit 6b3362c
Show file tree
Hide file tree
Showing 24 changed files with 66 additions and 32 deletions.
1 change: 1 addition & 0 deletions web/src/App.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ code {
display: flex;
flex-direction: column;
flex-grow: 1;
width: inherit;
}
2 changes: 1 addition & 1 deletion web/src/components/AdvancedEditor/hooks/useAutoComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const useAutoComplete = ({testId, runId}: IProps) => {
const uniqueList = uniqBy(attributeList, 'key');
const identifierText = state.doc.sliceString(nodeBefore.from, nodeBefore.to);
const isIdentifier = nodeBefore.name === Tokens.Identifier;
const list = isIdentifier ? uniqueList.filter(({key}) => key.startsWith(identifierText)) : uniqueList;
const list = isIdentifier ? uniqueList.filter(({key}) => key.toLowerCase().includes(identifierText.toLowerCase())) : uniqueList;

return {
from: isIdentifier ? nodeBefore.from : word.from,
Expand Down
4 changes: 3 additions & 1 deletion web/src/components/AssertionForm/AssertionForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ const AssertionForm: React.FC<TAssertionFormProps> = ({
/>

<div style={{marginBottom: 8}}>
<Typography.Text>Define the checks to run against each span selected</Typography.Text>
<Typography.Text>
Define the checks to run as some checks are against the collection ({spanIdList.length} spans)
</Typography.Text>
<TooltipQuestion
title={`
Add one of more checks to be run against the span(s) that match your filter.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line no-restricted-exports
export {default} from './Rpc';
export {default} from './Grpc';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Col, Form, Input, Row, Select} from 'antd';
import * as Step from 'components/CreateTestPlugins/Step.styled';
import {useCallback, useEffect, useState} from 'react';
import RpcService from 'services/Triggers/Rpc.service';
import GrpcService from 'services/Triggers/Grpc.service';
import {IRpcValues, TDraftTestForm} from 'types/Test.types';
import RequestDetailsAuthInput from '../../../Rest/steps/RequestDetails/RequestDetailsAuthInput/RequestDetailsAuthInput';
import RequestDetailsUrlInput from '../../../Rest/steps/RequestDetails/RequestDetailsUrlInput';
Expand All @@ -19,7 +19,7 @@ const RequestDetailsForm = ({form}: IProps) => {
const getMethodList = useCallback(async () => {
if (protoFile) {
const fileText = await protoFile.text();
const list = RpcService.getMethodList(fileText);
const list = GrpcService.getMethodList(fileText);

setMethodList(list);
} else {
Expand Down
4 changes: 2 additions & 2 deletions web/src/components/CreateTestPlugins/Plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {IPluginComponentMap} from 'types/Plugins.types';
import {SupportedPlugins} from 'constants/Plugins.constants';
import Postman from './Postman';
import Rest from './Rest';
import Rpc from './Rpc';
import Grpc from './Grpc';

export const PluginsComponentMap: Record<SupportedPlugins, IPluginComponentMap> = {
[SupportedPlugins.REST]: Rest,
[SupportedPlugins.Messaging]: {},
[SupportedPlugins.RPC]: Rpc,
[SupportedPlugins.GRPC]: Grpc,
[SupportedPlugins.Postman]: Postman,
[SupportedPlugins.OpenAPI]: {},
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Form} from 'antd';
import RequestDetailsFileInput from 'components/CreateTestPlugins/Rpc/steps/RequestDetails/RequestDetailsFileInput';
import RequestDetailsFileInput from 'components/CreateTestPlugins/Grpc/steps/RequestDetails/RequestDetailsFileInput';
import React from 'react';
import {IPostmanValues, TDraftTestForm} from '../../../../../../types/Test.types';
import {useUploadCollectionCallback} from '../hooks/useUploadCollectionCallback';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {Form} from 'antd';
import {IPostmanValues, TDraftTestForm} from 'types/Test.types';
import RequestDetailsFileInput from '../../../../Rpc/steps/RequestDetails/RequestDetailsFileInput';
import RequestDetailsFileInput from '../../../../Grpc/steps/RequestDetails/RequestDetailsFileInput';
import {useUploadEnvFileCallback} from '../hooks/useUploadEnvFileCallback';

interface IProps {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useCallback, useEffect} from 'react';
import RequestDetailsForm from 'components/CreateTestPlugins/Rpc/steps/RequestDetails/RequestDetailsForm';
import RequestDetailsForm from 'components/CreateTestPlugins/Grpc/steps/RequestDetails/RequestDetailsForm';
import {IRpcValues, TDraftTestForm, TGRPCRequest} from 'types/Test.types';
import * as S from '../../EditTestForm.styled';
import {IFormProps} from '../EditRequestDetails';
Expand Down
14 changes: 9 additions & 5 deletions web/src/components/RunTopPanel/RunTopPanel.styled.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,25 @@
import {ReflexContainer, ReflexElement} from 'react-reflex';
import styled from 'styled-components';

export const Container = styled.main`
export const Container = styled(ReflexContainer)`
display: flex;
height: 100%;
width: 100%;
&.vertical > .reflex-splitter {
border-color: transparent;
background: transparent;
}
`;

export const LeftPanel = styled.div`
export const LeftPanel = styled(ReflexElement)`
display: flex;
flex-basis: 50%;
flex-direction: column;
padding: 24px;
`;

export const RightPanel = styled.div`
export const RightPanel = styled(ReflexElement)`
background: ${({theme}) => theme.color.white};
box-shadow: 0 20px 24px rgba(153, 155, 168, 0.18);
flex-basis: 50%;
overflow-y: scroll;
`;
8 changes: 5 additions & 3 deletions web/src/components/RunTopPanel/RunTopPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {useState} from 'react';
import {ReflexSplitter} from 'react-reflex';

import Diagram from 'components/Diagram';
import {SupportedDiagrams} from 'components/Diagram/Diagram';
Expand All @@ -18,8 +19,8 @@ const RunTopPanel = ({run}: IProps) => {
const {onSearch, selectedSpan} = useSpan();

return (
<S.Container>
<S.LeftPanel>
<S.Container orientation="vertical">
<S.LeftPanel minSize={600}>
<DiagramSwitcher
onTypeChange={type => {
TraceAnalyticsService.onSwitchDiagramView(type);
Expand All @@ -30,7 +31,8 @@ const RunTopPanel = ({run}: IProps) => {
/>
<Diagram trace={run.trace!} runState={run.state} type={diagramType} />
</S.LeftPanel>
<S.RightPanel>
<ReflexSplitter />
<S.RightPanel minSize={500}>
<SpanDetail span={selectedSpan} />
</S.RightPanel>
</S.Container>
Expand Down
16 changes: 8 additions & 8 deletions web/src/constants/Plugins.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const pokeshopPostmanFile = new File([JSON.stringify(pokeshopPostmanData)], 'pok
export enum SupportedPlugins {
REST = 'REST',
Messaging = 'Messaging',
RPC = 'RPC',
GRPC = 'GRPC',
Postman = 'Postman',
OpenAPI = 'OpenAPI',
}
Expand All @@ -26,7 +26,7 @@ const Default: IPlugin = {
stepList: [
{
id: 'plugin-selection',
name: 'Select a plugin',
name: 'Select test type',
title: 'Choose the way of creating a test',
component: 'SelectPlugin',
isDefaultValid: true,
Expand Down Expand Up @@ -81,10 +81,10 @@ const Rest: IPlugin = {
],
};

const RPC: IPlugin = {
name: SupportedPlugins.RPC,
title: 'RPC Request',
description: 'Test and debug your RPC request',
const GRPC: IPlugin = {
name: SupportedPlugins.GRPC,
title: 'GRPC Request',
description: 'Test and debug your GRPC request',
isActive: true,
type: TriggerTypes.grpc,
demoList: [
Expand Down Expand Up @@ -193,13 +193,13 @@ const OpenAPI: IPlugin = {

export const Plugins: Record<SupportedPlugins, IPlugin> = {
[SupportedPlugins.REST]: Rest,
[SupportedPlugins.RPC]: RPC,
[SupportedPlugins.GRPC]: GRPC,
[SupportedPlugins.Postman]: Postman,
[SupportedPlugins.Messaging]: Messaging,
[SupportedPlugins.OpenAPI]: OpenAPI,
};

export const TriggerTypeToPlugin = {
[TriggerTypes.http]: Plugins.REST,
[TriggerTypes.grpc]: Plugins.RPC,
[TriggerTypes.grpc]: Plugins.GRPC,
} as const;
17 changes: 15 additions & 2 deletions web/src/pages/CreateTest/CreateTestContent.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {useEffect} from 'react';
import {useNavigate} from 'react-router-dom';
import CreateTestHeader from 'components/CreateTestHeader';
import CreateTestSteps from 'components/CreateTestSteps';
Expand All @@ -6,12 +7,24 @@ import * as S from './CreateTest.styled';

const CreateTestContent: React.FC = () => {
const navigate = useNavigate();
const {stepList, activeStep, pluginName, onGoTo, isLoading} = useCreateTest();
const {stepList, activeStep, pluginName, onGoTo, onReset, isLoading} = useCreateTest();

useEffect(() => {
return () => {
onReset();
};
}, []);

return (
<S.Wrapper>
<CreateTestHeader onBack={() => navigate('/')} />
<CreateTestSteps isLoading={isLoading} onGoTo={onGoTo} stepList={stepList} selectedKey={activeStep} pluginName={pluginName} />
<CreateTestSteps
isLoading={isLoading}
onGoTo={onGoTo}
stepList={stepList}
selectedKey={activeStep}
pluginName={pluginName}
/>
</S.Wrapper>
);
};
Expand Down
10 changes: 9 additions & 1 deletion web/src/providers/CreateTest/CreateTest.provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {createContext, useCallback, useContext, useMemo} from 'react';
import {useNavigate} from 'react-router-dom';
import {noop} from 'lodash';
import {IPlugin} from 'types/Plugins.types';
import {initialState, setDraftTest, setPlugin, setStepNumber} from 'redux/slices/CreateTest.slice';
import {initialState, setDraftTest, setPlugin, setStepNumber, reset} from 'redux/slices/CreateTest.slice';
import {useAppDispatch, useAppSelector} from 'redux/hooks';
import CreateTestSelectors from 'selectors/CreateTest.selectors';
import {useCreateTestMutation, useRunTestMutation} from 'redux/apis/TraceTest.api';
Expand All @@ -20,6 +20,7 @@ interface IContext extends ICreateTestState {
onUpdateDraftTest(draftTest: TDraftTest): void;
onUpdatePlugin(plugin: IPlugin): void;
onGoTo(stepId: string): void;
onReset(): void;
}

export const Context = createContext<IContext>({
Expand All @@ -33,6 +34,7 @@ export const Context = createContext<IContext>({
onUpdateDraftTest: noop,
onUpdatePlugin: noop,
onGoTo: noop,
onReset: noop,
});

interface IProps {
Expand Down Expand Up @@ -109,6 +111,10 @@ const CreateTestProvider = ({children}: IProps) => {
[dispatch]
);

const onReset = useCallback(() => {
dispatch(reset());
}, [dispatch]);

const value = useMemo<IContext>(
() => ({
stepList,
Expand All @@ -124,6 +130,7 @@ const CreateTestProvider = ({children}: IProps) => {
onCreateTest,
onUpdateDraftTest,
onUpdatePlugin,
onReset,
}),
[
stepList,
Expand All @@ -139,6 +146,7 @@ const CreateTestProvider = ({children}: IProps) => {
onCreateTest,
onUpdateDraftTest,
onUpdatePlugin,
onReset,
]
);

Expand Down
5 changes: 4 additions & 1 deletion web/src/redux/slices/CreateTest.slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ const createTestSlice = createSlice<ICreateTestState, TCreateTestSliceActions, '
name: 'createTest',
initialState,
reducers: {
reset() {
return initialState;
},
setPlugin(
state,
{
Expand Down Expand Up @@ -43,5 +46,5 @@ const createTestSlice = createSlice<ICreateTestState, TCreateTestSliceActions, '
},
});

export const {setPlugin, setStepNumber, setDraftTest} = createTestSlice.actions;
export const {setPlugin, setStepNumber, setDraftTest, reset} = createTestSlice.actions;
export default createTestSlice.reducer;
4 changes: 2 additions & 2 deletions web/src/services/Test.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {SupportedPlugins} from 'constants/Plugins.constants';
import {IPlugin} from 'types/Plugins.types';
import TestDefinitionService from './TestDefinition.service';
import Validator from '../utils/Validator';
import RpcService from './Triggers/Rpc.service';
import GrpcService from './Triggers/Grpc.service';
import HttpService from './Triggers/Http.service';
import PostmanService from './Triggers/Postman.service';

Expand All @@ -25,7 +25,7 @@ const basicDetailsValidation = ({name, description}: TDraftTest): boolean => {
};

const TriggerServiceMap = {
[SupportedPlugins.RPC]: RpcService,
[SupportedPlugins.GRPC]: GrpcService,
[SupportedPlugins.REST]: HttpService,
[SupportedPlugins.Messaging]: HttpService,
[SupportedPlugins.OpenAPI]: HttpService,
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions web/src/types/Test.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface ICreateTestState {
}

export type TCreateTestSliceActions = {
reset: CaseReducer<ICreateTestState>;
setPlugin: CaseReducer<ICreateTestState, PayloadAction<{plugin: IPlugin}>>;
setStepNumber: CaseReducer<ICreateTestState, PayloadAction<{stepNumber: number; completeStep?: boolean}>>;
setDraftTest: CaseReducer<ICreateTestState, PayloadAction<{draftTest: TDraftTest}>>;
Expand Down

0 comments on commit 6b3362c

Please sign in to comment.