nice hook
This commit is contained in:
parent
298f92ee7e
commit
bad91d5e84
|
|
@ -26,7 +26,15 @@ import { attachmentURL } from './attachmentsTab';
|
|||
import { fixTestPrompt } from '@web/components/prompts';
|
||||
import type { GitCommitInfo } from '@testIsomorphic/types';
|
||||
|
||||
export const GitCommitInfoContext = React.createContext<GitCommitInfo | undefined>(undefined);
|
||||
const GitCommitInfoContext = React.createContext<GitCommitInfo | undefined>(undefined);
|
||||
|
||||
export function GitCommitInfoProvider({ children, gitCommitInfo }: React.PropsWithChildren<{ gitCommitInfo: GitCommitInfo }>) {
|
||||
return <GitCommitInfoContext.Provider value={gitCommitInfo}>{children}</GitCommitInfoContext.Provider>;
|
||||
}
|
||||
|
||||
export function useGitCommitInfo() {
|
||||
return React.useContext(GitCommitInfoContext);
|
||||
}
|
||||
|
||||
const PromptButton: React.FC<{
|
||||
error: string;
|
||||
|
|
@ -47,7 +55,7 @@ const PromptButton: React.FC<{
|
|||
}
|
||||
}, [actions]);
|
||||
|
||||
const gitCommitInfo = React.useContext(GitCommitInfoContext);
|
||||
const gitCommitInfo = useGitCommitInfo();
|
||||
const prompt = React.useMemo(
|
||||
() => fixTestPrompt(
|
||||
error,
|
||||
|
|
|
|||
|
|
@ -37,8 +37,7 @@ import { TestListView } from './uiModeTestListView';
|
|||
import { TraceView } from './uiModeTraceView';
|
||||
import { SettingsView } from './settingsView';
|
||||
import { DefaultSettingsView } from './defaultSettingsView';
|
||||
import type { GitCommitInfo } from '@testIsomorphic/types';
|
||||
import { GitCommitInfoContext } from './errorsTab';
|
||||
import { GitCommitInfoProvider } from './errorsTab';
|
||||
|
||||
let xtermSize = { cols: 80, rows: 24 };
|
||||
const xtermDataSource: XtermDataSource = {
|
||||
|
|
@ -432,7 +431,7 @@ export const UIModeView: React.FC<{}> = ({
|
|||
<XtermWrapper source={xtermDataSource}></XtermWrapper>
|
||||
</div>
|
||||
<div className={clsx('vbox', isShowingOutput && 'hidden')}>
|
||||
<GitCommitInfoContext.Provider value={testModel?.config.metadata['git.commit.info']}>
|
||||
<GitCommitInfoProvider gitCommitInfo={testModel?.config.metadata['git.commit.info']}>
|
||||
<TraceView
|
||||
pathSeparator={queryParams.pathSeparator}
|
||||
item={selectedItem}
|
||||
|
|
@ -440,7 +439,7 @@ export const UIModeView: React.FC<{}> = ({
|
|||
revealSource={revealSource}
|
||||
onOpenExternally={location => testServerConnection?.openNoReply({ location: { file: location.file, line: location.line, column: location.column } })}
|
||||
/>
|
||||
</GitCommitInfoContext.Provider>
|
||||
</GitCommitInfoProvider>
|
||||
</div>
|
||||
</div>}
|
||||
sidebar={<div className='vbox ui-mode-sidebar'>
|
||||
|
|
|
|||
Loading…
Reference in a new issue