Skip to content

Commit

Permalink
mod: select space automatically after select history (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
hetao92 authored Jan 19, 2023
1 parent a360c9f commit 0736e39
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/pages/Console/OutputBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import styles from './index.module.less';
interface IProps {
index: number;
result: HistoryResult;
onHistoryItem: (gql: string) => void;
onHistoryItem: (gql: string, space?: string) => void;
onExplorer?: (params: {
space: string;
vertexes: any[],
Expand Down Expand Up @@ -280,7 +280,7 @@ const OutputBox = (props: IProps) => {
].filter(Boolean);
return <div className={styles.outputBox}>
<div className={styles.outputHeader}>
<p className={cls(styles.gql, { [styles.errorInfo]: !resultSuccess })} onClick={() => onHistoryItem(gql)}>
<p className={cls(styles.gql, { [styles.errorInfo]: !resultSuccess })} onClick={() => onHistoryItem(gql, space)}>
<span className={styles.gqlValue}>{space ? `[${space}]>` : '$'} {gql}</span>
</p>
<div className={styles.outputOperations}>
Expand Down
10 changes: 8 additions & 2 deletions app/pages/Console/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ const Console = (props: IProps) => {
}
};

const updateGql = (value: string) => update({ currentGQL: value });
const updateGql = (value: string, space?: string) => {
update({ currentGQL: value, currentSpace: space || currentSpace });
window.scrollTo({
top: 0,
behavior: 'smooth'
});
};

const handleSaveQuery = (query: string) => {
if (query !== '') {
Expand Down Expand Up @@ -179,7 +185,7 @@ const Console = (props: IProps) => {
result={item}
templateRender={templateRender}
onExplorer={onExplorer ? handleExplorer : undefined}
onHistoryItem={gql => updateGql(gql)}
onHistoryItem={(gql, space) => updateGql(gql, space)}
onResultConfig={handleResultConfig}
/>
)) : <OutputBox
Expand Down

0 comments on commit 0736e39

Please sign in to comment.