mirror of
https://github.com/Kingsrook/qqq-frontend-material-dashboard.git
synced 2025-07-18 13:20:43 +00:00
Add apiName & version to script editor; always prompt for commit message
This commit is contained in:
@ -48,7 +48,7 @@ interface AssociatedScriptDefinition
|
||||
testOutputFields: QFieldMetaData[];
|
||||
}
|
||||
|
||||
interface Props
|
||||
export interface ScriptTestFormProps
|
||||
{
|
||||
scriptId: number;
|
||||
scriptDefinition: AssociatedScriptDefinition;
|
||||
@ -56,15 +56,13 @@ interface Props
|
||||
fieldName: string;
|
||||
recordId: any;
|
||||
code: string;
|
||||
apiName: string;
|
||||
apiVersion: string;
|
||||
}
|
||||
|
||||
ScriptTestForm.defaultProps = {
|
||||
// foo: null,
|
||||
};
|
||||
|
||||
const qController = Client.getInstance();
|
||||
|
||||
function ScriptTestForm({scriptId, scriptDefinition, tableName, fieldName, recordId, code}: Props): JSX.Element
|
||||
function ScriptTestForm({scriptId, scriptDefinition, tableName, fieldName, recordId, code, apiName, apiVersion}: ScriptTestFormProps): JSX.Element
|
||||
{
|
||||
const [testInputValues, setTestInputValues] = useState({} as any);
|
||||
const [testOutputValues, setTestOutputValues] = useState({} as any);
|
||||
@ -72,11 +70,6 @@ function ScriptTestForm({scriptId, scriptDefinition, tableName, fieldName, recor
|
||||
const [testException, setTestException] = useState(null as string)
|
||||
const [firstRender, setFirstRender] = useState(true);
|
||||
|
||||
if(firstRender)
|
||||
{
|
||||
setFirstRender(false)
|
||||
}
|
||||
|
||||
if(firstRender)
|
||||
{
|
||||
scriptDefinition.testInputFields.forEach((field: QFieldMetaData) =>
|
||||
@ -85,6 +78,11 @@ function ScriptTestForm({scriptId, scriptDefinition, tableName, fieldName, recor
|
||||
});
|
||||
}
|
||||
|
||||
const buildFullExceptionMessage = (exception: any): string =>
|
||||
{
|
||||
return (exception.message + (exception.cause ? "\ncaused by: " + buildFullExceptionMessage(exception.cause) : ""));
|
||||
};
|
||||
|
||||
const testScript = () =>
|
||||
{
|
||||
const inputValues = new Map<string, any>();
|
||||
@ -116,6 +114,8 @@ function ScriptTestForm({scriptId, scriptDefinition, tableName, fieldName, recor
|
||||
{
|
||||
const formData = new FormData();
|
||||
formData.append("scriptId", scriptId);
|
||||
formData.append("apiName", apiName);
|
||||
formData.append("apiVersion", apiVersion);
|
||||
formData.append("code", code);
|
||||
|
||||
for(let fieldName of inputValues.keys())
|
||||
@ -142,8 +142,8 @@ function ScriptTestForm({scriptId, scriptDefinition, tableName, fieldName, recor
|
||||
setTestOutputValues(output.outputObject ?? {});
|
||||
if(output.exception)
|
||||
{
|
||||
setTestException(output.exception.message)
|
||||
console.log(`set test exception to ${output.exception.message}`);
|
||||
const exceptionMessage = buildFullExceptionMessage(output.exception);
|
||||
setTestException(exceptionMessage)
|
||||
}
|
||||
|
||||
if(output.scriptLogLines && output.scriptLogLines.length)
|
||||
|
Reference in New Issue
Block a user