feat: global state to know about pairs in the current workflow

This commit is contained in:
karishmas6
2024-10-19 18:25:16 +05:30
parent 869b809f2b
commit 3b52cb695a

View File

@@ -22,6 +22,16 @@ interface GlobalInfo {
setRecordingName: (recordingName: string) => void; setRecordingName: (recordingName: string) => void;
recordingUrl: string; recordingUrl: string;
setRecordingUrl: (recordingUrl: string) => void; setRecordingUrl: (recordingUrl: string) => void;
currentWorkflowActionsState: {
hasScrapeListAction: boolean;
hasScreenshotAction: boolean;
hasScrapeSchemaAction: boolean;
};
setCurrentWorkflowActionsState: (actionsState: {
hasScrapeListAction: boolean;
hasScreenshotAction: boolean;
hasScrapeSchemaAction: boolean;
}) => void;
}; };
class GlobalInfoStore implements Partial<GlobalInfo> { class GlobalInfoStore implements Partial<GlobalInfo> {
@@ -38,6 +48,11 @@ class GlobalInfoStore implements Partial<GlobalInfo> {
rerenderRuns = false; rerenderRuns = false;
recordingName = ''; recordingName = '';
recordingUrl = 'https://'; recordingUrl = 'https://';
currentWorkflowActionsState = {
hasScrapeListAction: false,
hasScreenshotAction: false,
hasScrapeSchemaAction: false,
};
}; };
const globalInfoStore = new GlobalInfoStore(); const globalInfoStore = new GlobalInfoStore();
@@ -55,6 +70,7 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => {
const [recordingId, setRecordingId] = useState<string | null>(globalInfoStore.recordingId); const [recordingId, setRecordingId] = useState<string | null>(globalInfoStore.recordingId);
const [recordingName, setRecordingName] = useState<string>(globalInfoStore.recordingName); const [recordingName, setRecordingName] = useState<string>(globalInfoStore.recordingName);
const [recordingUrl, setRecordingUrl] = useState<string>(globalInfoStore.recordingUrl); const [recordingUrl, setRecordingUrl] = useState<string>(globalInfoStore.recordingUrl);
const [currentWorkflowActionsState, setCurrentWorkflowActionsState] = useState(globalInfoStore.currentWorkflowActionsState);
const notify = (severity: 'error' | 'warning' | 'info' | 'success', message: string) => { const notify = (severity: 'error' | 'warning' | 'info' | 'success', message: string) => {
setNotification({ severity, message, isOpen: true }); setNotification({ severity, message, isOpen: true });
@@ -93,6 +109,8 @@ export const GlobalInfoProvider = ({ children }: { children: JSX.Element }) => {
setRecordingName, setRecordingName,
recordingUrl, recordingUrl,
setRecordingUrl, setRecordingUrl,
currentWorkflowActionsState,
setCurrentWorkflowActionsState,
}} }}
> >
{children} {children}