open wizard from shell - not working yet

This commit is contained in:
Jan Prochazka
2021-06-06 18:40:05 +02:00
parent 1e59407954
commit fd30c40c5f

View File

@@ -14,24 +14,37 @@
findReplace: true, findReplace: true,
}); });
// registerCommand({
// id: 'shell.openWizard',
// category: 'Shell',
// name: 'Open wizard',
// // testEnabled: () => getCurrentEditor()?.openWizardEnabled(),
// onClick: () => getCurrentEditor().openWizard(),
// });
const configRegex = /\s*\/\/\s*@ImportExportConfigurator\s*\n\s*\/\/\s*(\{[^\n]+\})\n/; const configRegex = /\s*\/\/\s*@ImportExportConfigurator\s*\n\s*\/\/\s*(\{[^\n]+\})\n/;
const requireRegex = /\s*(\/\/\s*@require\s+[^\n]+)\n/g; const requireRegex = /\s*(\/\/\s*@require\s+[^\n]+)\n/g;
const initRegex = /([^\n]+\/\/\s*@init)/g; const initRegex = /([^\n]+\/\/\s*@init)/g;
</script> </script>
<script lang="ts"> <script lang="ts">
import { getContext } from 'svelte'; import { getContext } from 'svelte';
import invalidateCommands from '../commands/invalidateCommands'; import invalidateCommands from '../commands/invalidateCommands';
import registerCommand from '../commands/registerCommand';
import { registerFileCommands } from '../commands/stdCommands'; import { registerFileCommands } from '../commands/stdCommands';
import VerticalSplitter from '../elements/VerticalSplitter.svelte'; import VerticalSplitter from '../elements/VerticalSplitter.svelte';
import ImportExportModal from '../modals/ImportExportModal.svelte';
import { showModal } from '../modals/modalTools';
import AceEditor from '../query/AceEditor.svelte'; import AceEditor from '../query/AceEditor.svelte';
import RunnerOutputPane from '../query/RunnerOutputPane.svelte'; import RunnerOutputPane from '../query/RunnerOutputPane.svelte';
import useEditorData from '../query/useEditorData'; import useEditorData from '../query/useEditorData';
import axiosInstance from '../utility/axiosInstance'; import axiosInstance from '../utility/axiosInstance';
import { changeTab } from '../utility/common'; import { changeTab } from '../utility/common';
import createActivator, { getActiveComponent } from '../utility/createActivator'; import createActivator, { getActiveComponent } from '../utility/createActivator';
import { showSnackbarError } from '../utility/snackbar';
import socket from '../utility/socket'; import socket from '../utility/socket';
import useEffect from '../utility/useEffect'; import useEffect from '../utility/useEffect';
import useTimerLabel from '../utility/useTimerLabel'; import useTimerLabel from '../utility/useTimerLabel';
@@ -118,6 +131,19 @@
return busy; return busy;
} }
// export function openWizardEnabled() {
// return ($editorValue || '').match(configRegex);
// }
export function openWizard() {
const jsonTextMatch = ($editorValue || '').match(configRegex);
if (jsonTextMatch) {
showModal(ImportExportModal, { initialValues: JSON.parse(jsonTextMatch[1]) });
} else {
showSnackbarError('No wizard info found');
}
}
export async function execute() { export async function execute() {
if (busy) return; if (busy) return;
executeNumber += 1; executeNumber += 1;
@@ -138,6 +164,10 @@
timerLabel.start(); timerLabel.start();
} }
export function canKill() {
return busy;
}
export function kill() { export function kill() {
axiosInstance.post('runners/cancel', { axiosInstance.post('runners/cancel', {
runid: runnerId, runid: runnerId,
@@ -151,6 +181,7 @@
return [ return [
{ command: 'shell.execute' }, { command: 'shell.execute' },
{ command: 'shell.kill' }, { command: 'shell.kill' },
{ command: 'shell.openWizard' },
{ divider: true }, { divider: true },
{ command: 'shell.toggleComment' }, { command: 'shell.toggleComment' },
{ divider: true }, { divider: true },
@@ -161,6 +192,7 @@
{ command: 'shell.replace' }, { command: 'shell.replace' },
]; ];
} }
</script> </script>
<VerticalSplitter> <VerticalSplitter>