mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 22:45:25 +00:00
* style: enhance button layout and input styles across multiple components for improved UI consistency * style: update RequestsNotLoaded component with new warning styles and enhance theme color definitions for status indicators * refactor: update theme usage across components for consistency - Changed color references from theme.brand to theme.primary.text in various StyledWrapper components. - Added hover effects to enhance UI interactivity in CollectionSettings and FolderSettings. - Removed unnecessary margin and padding adjustments in several components for cleaner layout. - Improved accessibility by ensuring aria attributes are correctly set in MenuDropdown. - Standardized styling for method indicators in RequestPane components. These changes aim to create a more cohesive look and feel across the application while adhering to the updated theme guidelines. * refactor: clean up method selector styling in NewRequest component * chore: temp playwright test fixes * refactor: update modal sizes across various components for consistency - Changed modal size from "sm" to "md" in RenameWorkspace, CreateApiSpec, CloneCollection, DeleteCollectionItem, and RenameCollection components. - Improved styling in HttpMethodSelector by adding padding for better layout. - Updated theme color references in multiple theme files to use a new palette structure for consistency and maintainability. * refactor: enhance styling and theme integration in TimelineItem components - Updated HttpMethodSelector to clarify padding calculation in comments. - Integrated theme colors for OAuth2 indicator and timestamp in TimelineItem for better visual consistency. - Adjusted Method component to use uppercase styling for method display. - Modified RelativeTime component to apply muted text color for improved readability. - Updated INFO color in dark and light themes for better contrast and accessibility. * refactor: remove duplicate import statements in theme files - Cleaned up import statements in vscode.js and light-pastel.js by removing redundant lines for improved code clarity and maintainability. * refactor: improve styling and theme integration in various components - Added accent color and cursor style for checkbox inputs in Modal's StyledWrapper. - Updated border-radius values in HttpMethodSelector and NewRequest StyledWrapper components to use theme variables for consistency. - Introduced a new textbox class in NewRequest StyledWrapper for better styling control. - Changed modal size from "sm" to "md" in CreateEnvironment for improved layout. --------- Co-authored-by: Bijin A B <bijin@usebruno.com>
161 lines
5.7 KiB
JavaScript
161 lines
5.7 KiB
JavaScript
import React, { useEffect, useState, useCallback, useMemo, useRef } from 'react';
|
|
import find from 'lodash/find';
|
|
import get from 'lodash/get';
|
|
import classnames from 'classnames';
|
|
import { useSelector, useDispatch } from 'react-redux';
|
|
import { updateRequestPaneTab } from 'providers/ReduxStore/slices/tabs';
|
|
import QueryEditor from 'components/RequestPane/QueryEditor';
|
|
import Auth from 'components/RequestPane/Auth';
|
|
import GraphQLVariables from 'components/RequestPane/GraphQLVariables';
|
|
import RequestHeaders from 'components/RequestPane/RequestHeaders';
|
|
import Vars from 'components/RequestPane/Vars';
|
|
import Assertions from 'components/RequestPane/Assertions';
|
|
import Script from 'components/RequestPane/Script';
|
|
import Tests from 'components/RequestPane/Tests';
|
|
import { useTheme } from 'providers/Theme';
|
|
import { updateRequestGraphqlQuery } from 'providers/ReduxStore/slices/collections';
|
|
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
|
|
import Documentation from 'components/Documentation/index';
|
|
import GraphQLSchemaActions from '../GraphQLSchemaActions/index';
|
|
import HeightBoundContainer from 'ui/HeightBoundContainer';
|
|
import Settings from 'components/RequestPane/Settings';
|
|
import ResponsiveTabs from 'ui/ResponsiveTabs';
|
|
|
|
const TAB_CONFIG = [
|
|
{ key: 'query', label: 'Query' },
|
|
{ key: 'variables', label: 'Variables' },
|
|
{ key: 'headers', label: 'Headers' },
|
|
{ key: 'auth', label: 'Auth' },
|
|
{ key: 'vars', label: 'Vars' },
|
|
{ key: 'script', label: 'Script' },
|
|
{ key: 'assert', label: 'Assert' },
|
|
{ key: 'tests', label: 'Tests' },
|
|
{ key: 'docs', label: 'Docs' },
|
|
{ key: 'settings', label: 'Settings' }
|
|
];
|
|
|
|
const GraphQLRequestPane = ({ item, collection, onSchemaLoad, toggleDocs, handleGqlClickReference }) => {
|
|
const dispatch = useDispatch();
|
|
const tabs = useSelector((state) => state.tabs.tabs);
|
|
const activeTabUid = useSelector((state) => state.tabs.activeTabUid);
|
|
const preferences = useSelector((state) => state.app.preferences);
|
|
|
|
const query = item.draft
|
|
? get(item, 'draft.request.body.graphql.query', '')
|
|
: get(item, 'request.body.graphql.query', '');
|
|
const variables = item.draft
|
|
? get(item, 'draft.request.body.graphql.variables', '')
|
|
: get(item, 'request.body.graphql.variables', '');
|
|
|
|
const { displayedTheme } = useTheme();
|
|
const [schema, setSchema] = useState(null);
|
|
const schemaActionsRef = useRef(null);
|
|
|
|
const focusedTab = find(tabs, (t) => t.uid === activeTabUid);
|
|
const requestPaneTab = focusedTab?.requestPaneTab;
|
|
|
|
useEffect(() => {
|
|
onSchemaLoad(schema);
|
|
}, [schema, onSchemaLoad]);
|
|
|
|
const onQueryChange = useCallback(
|
|
(value) => {
|
|
dispatch(
|
|
updateRequestGraphqlQuery({
|
|
query: value,
|
|
itemUid: item.uid,
|
|
collectionUid: collection.uid
|
|
})
|
|
);
|
|
},
|
|
[dispatch, item.uid, collection.uid]
|
|
);
|
|
|
|
const onRun = useCallback(
|
|
() => dispatch(sendRequest(item, collection.uid)),
|
|
[dispatch, item, collection.uid]
|
|
);
|
|
|
|
const onSave = useCallback(
|
|
() => dispatch(saveRequest(item.uid, collection.uid)),
|
|
[dispatch, item.uid, collection.uid]
|
|
);
|
|
|
|
const selectTab = useCallback(
|
|
(tabKey) => {
|
|
dispatch(updateRequestPaneTab({ uid: item.uid, requestPaneTab: tabKey }));
|
|
},
|
|
[dispatch, item.uid]
|
|
);
|
|
|
|
const allTabs = useMemo(() => TAB_CONFIG.map(({ key, label }) => ({ key, label })), []);
|
|
|
|
const tabPanel = useMemo(() => {
|
|
switch (requestPaneTab) {
|
|
case 'query':
|
|
return (
|
|
<QueryEditor
|
|
collection={collection}
|
|
theme={displayedTheme}
|
|
schema={schema}
|
|
onSave={onSave}
|
|
value={query}
|
|
onRun={onRun}
|
|
onEdit={onQueryChange}
|
|
onClickReference={handleGqlClickReference}
|
|
font={get(preferences, 'font.codeFont', 'default')}
|
|
fontSize={get(preferences, 'font.codeFontSize')}
|
|
/>
|
|
);
|
|
case 'variables':
|
|
return <GraphQLVariables item={item} variables={variables} collection={collection} />;
|
|
case 'headers':
|
|
return <RequestHeaders item={item} collection={collection} />;
|
|
case 'auth':
|
|
return <Auth item={item} collection={collection} />;
|
|
case 'vars':
|
|
return <Vars item={item} collection={collection} />;
|
|
case 'assert':
|
|
return <Assertions item={item} collection={collection} />;
|
|
case 'script':
|
|
return <Script item={item} collection={collection} />;
|
|
case 'tests':
|
|
return <Tests item={item} collection={collection} />;
|
|
case 'docs':
|
|
return <Documentation item={item} collection={collection} />;
|
|
case 'settings':
|
|
return <Settings item={item} collection={collection} />;
|
|
default:
|
|
return <div className="mt-4">404 | Not found</div>;
|
|
}
|
|
}, [requestPaneTab, item, collection, displayedTheme, schema, onSave, query, onRun, onQueryChange, handleGqlClickReference, preferences, variables]);
|
|
|
|
if (!activeTabUid || !focusedTab?.uid || !requestPaneTab) {
|
|
return <div className="pb-4 px-4">An error occurred!</div>;
|
|
}
|
|
|
|
const rightContent = (
|
|
<div ref={schemaActionsRef}>
|
|
<GraphQLSchemaActions item={item} collection={collection} onSchemaLoad={setSchema} toggleDocs={toggleDocs} />
|
|
</div>
|
|
);
|
|
|
|
return (
|
|
<div className="flex flex-col h-full relative">
|
|
<ResponsiveTabs
|
|
tabs={allTabs}
|
|
activeTab={requestPaneTab}
|
|
onTabSelect={selectTab}
|
|
rightContent={rightContent}
|
|
rightContentRef={schemaActionsRef}
|
|
/>
|
|
|
|
<section className={classnames('flex w-full flex-1 mt-4')}>
|
|
<HeightBoundContainer>{tabPanel}</HeightBoundContainer>
|
|
</section>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default GraphQLRequestPane;
|