Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ const StyledWrapper = styled.div`
}
}

&.load-time {
background-color: ${(props) => rgba(props.theme.colors.text.green, 0.08)};
border: 1px solid ${(props) => rgba(props.theme.colors.text.green, 0.09)};

svg {
color: ${(props) => props.theme.colors.text.green};
}
}

&.share {
background-color: ${(props) => rgba(props.theme.textLink, 0.08)};
border: 1px solid ${(props) => rgba(props.theme.textLink, 0.09)};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
import React from 'react';
import { getTotalRequestCountInCollection } from 'utils/collections/';
import { IconFolder, IconWorld, IconApi, IconShare, IconBook, IconTag } from '@tabler/icons';
import { areItemsLoading, getItemsLoadStats, getCollectionVersion } from 'utils/collections/index';
import { useRef, useState } from 'react';
import { useSelector, useDispatch } from 'react-redux';
import { IconApi, IconBook, IconClock, IconFolder, IconShare, IconTag, IconWorld } from '@tabler/icons';
import ShareCollection from 'components/ShareCollection/index';
import GenerateDocumentation from 'components/Sidebar/Collections/Collection/GenerateDocumentation';
import ChangeCollectionVersion from 'components/Sidebar/Collections/Collection/ChangeCollectionVersion';
import GenerateDocumentation from 'components/Sidebar/Collections/Collection/GenerateDocumentation';
import ToolHint from 'components/ToolHint';
import { addTab } from 'providers/ReduxStore/slices/tabs';
import StyledWrapper from './StyledWrapper';
import React, { useRef, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { getTotalRequestCountInCollection } from 'utils/collections/';
import { areItemsLoading, getCollectionVersion, getItemsLoadStats } from 'utils/collections/index';
import Migration from '../Migration';
import StyledWrapper from './StyledWrapper';

// Sub-second timings still read as seconds so the phases stay directly comparable.
const formatSeconds = (ms) => (typeof ms === 'number' ? `${(ms / 1000).toFixed(2)}s` : '—');

const Info = ({ collection }) => {
const dispatch = useDispatch();
const totalRequestsInCollection = getTotalRequestCountInCollection(collection);
const loadStats = collection.loadStats;

const isCollectionLoading = areItemsLoading(collection);
const { loading: itemsLoadingCount, total: totalItems } = getItemsLoadStats(collection);
Expand Down Expand Up @@ -149,6 +152,27 @@ const Info = ({ collection }) => {
</div>
</div>

{loadStats ? (
<div className="flex items-start" data-testid="info-load-time-row">
<div className="icon-box load-time flex-shrink-0 p-3 rounded-lg">
<IconClock className="w-5 h-5" stroke={1.5} />
</div>
<div className="ml-4">
<div className="font-medium">Load time</div>
<div className="mt-1 text-muted" data-testid="info-load-time-value">
{formatSeconds(loadStats.mountMs ?? loadStats.scanMs)}
{loadStats.fileCount !== undefined ? ` · ${loadStats.fileCount} files parsed` : ''}
</div>
{loadStats.scanMs !== undefined ? (
<div className="mt-1 text-muted">
{`scan ${formatSeconds(loadStats.scanMs)} — walk ${formatSeconds(loadStats.walkMs)}, `}
{`parse ${formatSeconds(loadStats.parseMs)}, tree ${formatSeconds(loadStats.buildMs)}`}
</div>
) : null}
</div>
</div>
) : null}

<div className="flex items-start group cursor-pointer" onClick={handleToggleShowShareCollectionModal(true)}>
<div className="icon-box share flex-shrink-0 p-3 rounded-lg">
<IconShare className="w-5 h-5" stroke={1.5} />
Expand Down
10 changes: 9 additions & 1 deletion packages/bruno-app/src/components/FileEditor/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { useEffect } from 'react';
import get from 'lodash/get';
import { useTheme } from 'providers/Theme';
import { useDispatch, useSelector } from 'react-redux';
import CodeEditor from './CodeEditor/index';
import { saveFile } from 'providers/ReduxStore/slices/collections/actions';
import { saveFile, fetchItemRaw } from 'providers/ReduxStore/slices/collections/actions';
import { IconDeviceFloppy } from '@tabler/icons';
import { toggleCollectionFileMode, updateFileContent } from 'providers/ReduxStore/slices/collections';
import { usePersistedState } from 'hooks/usePersistedState';
Expand All @@ -13,6 +14,13 @@ const FileEditor = ({ item, collection }) => {
const preferences = useSelector((state) => state.app.preferences);
const [scroll, setScroll] = usePersistedState({ key: `file-mode-scroll-${item.uid}`, default: 0 });

// `raw` isn't carried by the mount tree — it's fetched here, for the one item File Mode is
// actually showing, rather than kept resident for every item in the collection.
useEffect(() => {
if (item.draft || item.raw != null) return;
dispatch(fetchItemRaw({ collectionUid: collection.uid, itemUid: item.uid, pathname: item.pathname }));
}, [dispatch, collection.uid, item.uid, item.pathname, item.draft, item.raw]);

const content = item.draft ? item.draft.raw : item.raw || '';

const onEdit = (value) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ const StyledWrapper = styled.div`
}
.command-k-results {
flex: 1;
overflow-y: auto;
max-height: 400px;
/* Virtuoso owns the scrolling now, and sizes itself from the result count, so this must not
introduce a second scroll container or an independent height cap. */
overflow: hidden;
scrollbar-width: thin;
padding: 6px 0;
scroll-behavior: smooth;
/* Webkit scrollbar styling */
&::-webkit-scrollbar {
width: 8px;
Expand All @@ -134,8 +134,12 @@ const StyledWrapper = styled.div`
.result-item {
display: flex;
align-items: center;
padding: 10px 12px;
margin: 2px 8px;
/* Fixed height, and no vertical margin for it to collapse against: the list is virtualised and
this must match RESULT_ROW_HEIGHT, which is passed to Virtuoso as fixedItemHeight. */
height: 52px;
box-sizing: border-box;
padding: 0 12px;
margin: 0 8px;
gap: 10px;
cursor: pointer;
border-radius: ${(props) => props.theme.border.radius.base};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ export const MATCH_TYPES = {
};

export const SEARCH_CONFIG = {
MAX_DEPTH: 20,
FOCUS_DELAY: 100,
SCROLL_BEHAVIOR: 'smooth',
SCROLL_BLOCK: 'nearest',
DEBOUNCE_DELAY: 300
DEBOUNCE_DELAY: 350
};

export const DOCUMENTATION_RESULT = {
Expand Down
Loading
Loading