-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1415 from memphisdev/test_event_ui
test event + build
- Loading branch information
Showing
18 changed files
with
535 additions
and
703 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
318 changes: 117 additions & 201 deletions
318
ui_src/src/domain/functions/components/functionBox/index.js
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
ui_src/src/domain/functions/components/testFunctionModal/components/testMockEvent/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
// Copyright 2022-2023 The Memphis.dev Authors | ||
// Licensed under the Memphis Business Source License 1.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// Changed License: [Apache License, Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0), as published by the Apache Foundation. | ||
// | ||
// https://github.com/memphisdev/memphis/blob/master/LICENSE | ||
// | ||
// Additional Use Grant: You may make use of the Licensed Work (i) only as part of your own product or service, provided it is not a message broker or a message queue product or service; and (ii) provided that you do not use, provide, distribute, or make available the Licensed Work as a Service. | ||
// A "Service" is a commercial offering, product, hosted, or managed service, that allows third parties (other than your own employees and contractors acting on your behalf) to access and/or use the Licensed Work or a substantial set of the features or functionality of the Licensed Work to third parties as a software-as-a-service, platform-as-a-service, infrastructure-as-a-service or other similar services that compete with Licensor products or services. | ||
|
||
import './style.scss'; | ||
|
||
import { useState, useEffect } from 'react'; | ||
import { ReactComponent as TestEventModalIcon } from '../../../../../../assets/images/testEventModalcon.svg'; | ||
import Button from '../../../../../../components/button'; | ||
import Editor from '@monaco-editor/react'; | ||
import TestResult from '../testResult'; | ||
import { httpRequest } from '../../../../../../services/http'; | ||
import { ApiEndpoints } from '../../../../../../const/apiEndpoints'; | ||
|
||
const TestMockEvent = ({ functionDetails, open }) => { | ||
const [testMock, setTestMock] = useState(`{ | ||
"type": "record", | ||
"namespace": "com.example", | ||
"name": "test-schema", | ||
"fields": [ | ||
{ "name": "Master message", "type": "string", "default": "NONE" }, | ||
{ "name": "age", "type": "int", "default": "-1" }, | ||
{ "name": "phone", "type": "string", "default": "NONE" }, | ||
{ "name": "country", "type": "string", "default": "NONE" } | ||
] | ||
}`); | ||
const [testResultData, setTestResult] = useState(null); | ||
const [isLoading, setIsLoading] = useState(false); | ||
useEffect(() => { | ||
setTestResult(null); | ||
}, [open]); | ||
|
||
const testEvent = async () => { | ||
setIsLoading(true); | ||
const body = { | ||
function_name: functionDetails?.function_name, | ||
function_version: functionDetails?.installed_version, | ||
scm_type: functionDetails?.scm, | ||
branch: functionDetails?.branch, | ||
repo: functionDetails?.repo, | ||
owner: functionDetails?.owner, | ||
test_event: { | ||
headers: {}, | ||
content: testMock | ||
} | ||
}; | ||
try { | ||
const res = await httpRequest('POST', ApiEndpoints.TEST_FUNCTION, body); | ||
setTestResult(res); | ||
} catch (e) { | ||
} finally { | ||
setIsLoading(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="test-modal"> | ||
<div className="titleIcon"> | ||
<TestEventModalIcon /> | ||
</div> | ||
<div className="header"> | ||
<div className="title-container"> | ||
<p className="title">Generate test event</p> | ||
</div> | ||
<Button | ||
width="120px" | ||
height="40px" | ||
placeholder={'Test'} | ||
colorType="white" | ||
radiusType="circle" | ||
backgroundColorType={'purple'} | ||
border={'gray'} | ||
fontSize="12px" | ||
fontWeight="bold" | ||
onClick={() => { | ||
setTestResult(null); | ||
testEvent(); | ||
}} | ||
isLoading={isLoading} | ||
/> | ||
</div> | ||
<div className="test-area"> | ||
<div className="text-area-wrapper"> | ||
<label className="title">Event data</label> | ||
<div className="text-area"> | ||
<Editor | ||
options={{ | ||
minimap: { enabled: false }, | ||
scrollbar: { verticalScrollbarSize: 0, horizontalScrollbarSize: 0 }, | ||
scrollBeyondLastLine: false, | ||
roundedSelection: false, | ||
formatOnPaste: true, | ||
formatOnType: true, | ||
readOnly: false, | ||
fontSize: '12px', | ||
fontFamily: 'Inter', | ||
lineNumbers: 'off', | ||
automaticLayout: true | ||
}} | ||
language={'json'} | ||
height="calc(100%)" | ||
defaultValue={testMock} | ||
value={testMock} | ||
key={'tested'} | ||
onChange={(value) => setTestMock(value)} | ||
/> | ||
</div> | ||
</div> | ||
<TestResult testResultData={testResultData} loading={isLoading} /> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default TestMockEvent; |
69 changes: 69 additions & 0 deletions
69
ui_src/src/domain/functions/components/testFunctionModal/components/testMockEvent/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
.test-modal { | ||
padding: 30px 20px 0px 20px; | ||
height: 100%; | ||
|
||
.result-wrapper { | ||
width: 100%; | ||
} | ||
.titleIcon { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
width: 48px; | ||
height: 48px; | ||
background-color: #f0eeff; | ||
border-radius: 100%; | ||
} | ||
.header { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-between; | ||
.title-container { | ||
.title { | ||
color: #101828; | ||
font-family: 'Inter'; | ||
font-size: 18px; | ||
font-style: normal; | ||
font-weight: 600; | ||
line-height: 28px; | ||
margin-bottom: 0; | ||
} | ||
.sub-title { | ||
color: #475467; | ||
font-family: 'Inter'; | ||
font-size: 14px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: 20px; | ||
} | ||
} | ||
} | ||
|
||
.test-area { | ||
margin-top: 20px; | ||
height: calc(100% - 120px); | ||
overflow-y: auto; | ||
display: grid; | ||
grid-template-columns: 49% 49%; | ||
gap: 10px; | ||
position: relative; | ||
.text-area-wrapper { | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 10px; | ||
.title { | ||
font-size: 14px; | ||
font-family: 'InterSemiBold'; | ||
} | ||
.text-area { | ||
border-radius: 8px; | ||
border: 1px solid #e2e2e2; | ||
height: calc(100% - 30px); | ||
padding: 3px; | ||
overflow-y: auto; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.