9-3-quick-fixes (#7586)

* collapse init

* fix markdown icons and nunjucks

* fix context menu

* fix lint
This commit is contained in:
Jack Kavanagh 2024-06-25 22:35:36 +02:00 committed by GitHub
parent 8320c4c626
commit 75dcdcc96e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 8 additions and 16 deletions

View File

@ -103,7 +103,6 @@ export interface CodeEditorProps {
// NOTE: for caching scroll and marks
uniquenessKey?: string;
updateFilter?: (filter: string) => void;
disableContextMenu?: boolean;
}
const normalizeMimeType = (mode?: string) => {
@ -172,7 +171,6 @@ export const CodeEditor = memo(forwardRef<CodeEditorHandle, CodeEditorProps>(({
style,
uniquenessKey,
updateFilter,
disableContextMenu,
}, ref) => {
const inputRef = useRef<HTMLInputElement>(null);
const textAreaRef = useRef<HTMLTextAreaElement>(null);
@ -575,7 +573,7 @@ export const CodeEditor = memo(forwardRef<CodeEditorHandle, CodeEditorProps>(({
data-editor-type="text"
data-testid="CodeEditor"
onContextMenu={event => {
if (readOnly || disableContextMenu) {
if (readOnly || !enableNunjucks) {
return;
}
event.preventDefault();

View File

@ -421,7 +421,6 @@ export const RequestScriptEditor: FC<Props> = ({
<CodeEditor
id={`script-editor-${uniquenessKey}`}
key={uniquenessKey}
disableContextMenu={true}
showPrettifyButton={true}
uniquenessKey={uniquenessKey}
defaultValue={defaultValue}

View File

@ -3,7 +3,6 @@ import { Tab, TabList, TabPanel, Tabs } from 'react-aria-components';
import { CodeEditor, CodeEditorHandle } from './codemirror/code-editor';
import { ErrorBoundary } from './error-boundary';
import { Icon } from './icon';
import { MarkdownPreview } from './markdown-preview';
interface Props {
@ -43,7 +42,6 @@ export const MarkdownEditor = forwardRef<CodeEditorHandle, Props>(({
id="write"
>
<div className='flex flex-1 items-center gap-2'>
<Icon icon="arrow-right-to-bracket" />
<span>Write</span>
</div>
</Tab>
@ -52,7 +50,6 @@ export const MarkdownEditor = forwardRef<CodeEditorHandle, Props>(({
id="preview"
>
<div className='flex flex-1 items-center gap-2'>
<Icon icon="arrow-right-from-bracket" />
<span>Preview</span>
</div>
</Tab>
@ -70,7 +67,6 @@ export const MarkdownEditor = forwardRef<CodeEditorHandle, Props>(({
dynamicHeight={!tall}
showPrettifyButton
noStyleActiveLine
enableNunjucks
mode={mode || 'text/x-markdown'}
placeholder={placeholder}
defaultValue={markdown}

View File

@ -1382,6 +1382,7 @@ export const toggleExpandAllRequestGroupsAction: ActionFunction = async ({ param
const data = await request.json() as {
toggle: 'collapse-all' | 'expand-all';
};
const isCollapsed = data.toggle === 'collapse-all';
const descendants = await database.withDescendants(workspace);
const requestGroups = descendants.filter(isRequestGroup);
@ -1389,11 +1390,10 @@ export const toggleExpandAllRequestGroupsAction: ActionFunction = async ({ param
await Promise.all(requestGroups.map(requestGroup => {
const requestGroupMeta = requestGroupMetas.find(meta => meta.parentId === requestGroup._id);
if (!requestGroupMeta) {
return;
if (requestGroupMeta) {
return models.requestGroupMeta.update(requestGroupMeta, { collapsed: isCollapsed });
}
return models.requestGroupMeta.update(requestGroupMeta, { collapsed: data.toggle === 'collapse-all' });
return models.requestGroupMeta.create({ parentId: requestGroup._id, collapsed: isCollapsed });
}));
return null;
};
@ -1414,11 +1414,10 @@ export const expandAllForRequest: ActionFunction = async ({ params, request }) =
await Promise.all(requestGroups.map(async requestGroup => {
const requestGroupMeta = await models.requestGroupMeta.getByParentId(requestGroup._id);
if (!requestGroupMeta) {
return;
if (requestGroupMeta) {
return models.requestGroupMeta.update(requestGroupMeta, { collapsed: false });
}
return models.requestGroupMeta.update(requestGroupMeta, { collapsed: false });
return models.requestGroupMeta.create({ parentId: requestGroup._id, collapsed: false });
}));
return { success: true };