Show a manage links button for web scraper nodes - cheerio, puppeteer, playwright
This commit is contained in:
parent
e7edbc695c
commit
1b8813a8b9
|
|
@ -28,6 +28,8 @@ import ToolDialog from 'views/tools/ToolDialog'
|
||||||
import AssistantDialog from 'views/assistants/AssistantDialog'
|
import AssistantDialog from 'views/assistants/AssistantDialog'
|
||||||
import ExpandTextDialog from 'ui-component/dialog/ExpandTextDialog'
|
import ExpandTextDialog from 'ui-component/dialog/ExpandTextDialog'
|
||||||
import FormatPromptValuesDialog from 'ui-component/dialog/FormatPromptValuesDialog'
|
import FormatPromptValuesDialog from 'ui-component/dialog/FormatPromptValuesDialog'
|
||||||
|
import PromptLangsmithHubDialog from 'ui-component/dialog/PromptLangsmithHubDialog'
|
||||||
|
import ManageScrapedLinksDialog from 'ui-component/dialog/ManageScrapedLinksDialog'
|
||||||
import CredentialInputHandler from './CredentialInputHandler'
|
import CredentialInputHandler from './CredentialInputHandler'
|
||||||
|
|
||||||
// utils
|
// utils
|
||||||
|
|
@ -35,7 +37,6 @@ import { getInputVariables } from 'utils/genericHelper'
|
||||||
|
|
||||||
// const
|
// const
|
||||||
import { FLOWISE_CREDENTIAL_ID } from 'store/constant'
|
import { FLOWISE_CREDENTIAL_ID } from 'store/constant'
|
||||||
import PromptLangsmithHubDialog from '../../ui-component/dialog/PromptLangsmithHubDialog'
|
|
||||||
|
|
||||||
const EDITABLE_OPTIONS = ['selectedTool', 'selectedAssistant']
|
const EDITABLE_OPTIONS = ['selectedTool', 'selectedAssistant']
|
||||||
|
|
||||||
|
|
@ -62,22 +63,25 @@ const NodeInputHandler = ({ inputAnchor, inputParam, data, disabled = false, isA
|
||||||
const [showFormatPromptValuesDialog, setShowFormatPromptValuesDialog] = useState(false)
|
const [showFormatPromptValuesDialog, setShowFormatPromptValuesDialog] = useState(false)
|
||||||
const [formatPromptValuesDialogProps, setFormatPromptValuesDialogProps] = useState({})
|
const [formatPromptValuesDialogProps, setFormatPromptValuesDialogProps] = useState({})
|
||||||
const [showPromptHubDialog, setShowPromptHubDialog] = useState(false)
|
const [showPromptHubDialog, setShowPromptHubDialog] = useState(false)
|
||||||
|
const [showManageScrapedLinksDialog, setShowManageScrapedLinksDialog] = useState(false)
|
||||||
|
const [manageScrapedLinksDialogProps, setManageScrapedLinksDialogProps] = useState({})
|
||||||
|
|
||||||
const onExpandDialogClicked = (value, inputParam) => {
|
const onExpandDialogClicked = (value, inputParam) => {
|
||||||
const dialogProp = {
|
const dialogProps = {
|
||||||
value,
|
value,
|
||||||
inputParam,
|
inputParam,
|
||||||
disabled,
|
disabled,
|
||||||
confirmButtonName: 'Save',
|
confirmButtonName: 'Save',
|
||||||
cancelButtonName: 'Cancel'
|
cancelButtonName: 'Cancel'
|
||||||
}
|
}
|
||||||
setExpandDialogProps(dialogProp)
|
setExpandDialogProps(dialogProps)
|
||||||
setShowExpandDialog(true)
|
setShowExpandDialog(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onShowPromptHubButtonClicked = () => {
|
const onShowPromptHubButtonClicked = () => {
|
||||||
setShowPromptHubDialog(true)
|
setShowPromptHubDialog(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onShowPromptHubButtonSubmit = (templates) => {
|
const onShowPromptHubButtonSubmit = (templates) => {
|
||||||
setShowPromptHubDialog(false)
|
setShowPromptHubDialog(false)
|
||||||
for (const t of templates) {
|
for (const t of templates) {
|
||||||
|
|
@ -86,6 +90,23 @@ const NodeInputHandler = ({ inputAnchor, inputParam, data, disabled = false, isA
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const onManageLinksDialogClicked = (url, selectedLinks) => {
|
||||||
|
const dialogProps = {
|
||||||
|
url,
|
||||||
|
selectedLinks,
|
||||||
|
confirmButtonName: 'Save',
|
||||||
|
cancelButtonName: 'Cancel'
|
||||||
|
}
|
||||||
|
setManageScrapedLinksDialogProps(dialogProps)
|
||||||
|
setShowManageScrapedLinksDialog(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const onManageLinksDialogSave = (links) => {
|
||||||
|
setShowManageScrapedLinksDialog(false)
|
||||||
|
data.inputs.selectedLinks = links
|
||||||
|
}
|
||||||
|
|
||||||
const onEditJSONClicked = (value, inputParam) => {
|
const onEditJSONClicked = (value, inputParam) => {
|
||||||
// Preset values if the field is format prompt values
|
// Preset values if the field is format prompt values
|
||||||
let inputValue = value
|
let inputValue = value
|
||||||
|
|
@ -436,6 +457,37 @@ const NodeInputHandler = ({ inputAnchor, inputParam, data, disabled = false, isA
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
{(data.name === 'cheerioWebScraper' ||
|
||||||
|
data.name === 'puppeteerWebScraper' ||
|
||||||
|
data.name === 'playwrightWebScraper') &&
|
||||||
|
inputParam.name === 'url' && (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'row',
|
||||||
|
width: '100%'
|
||||||
|
}}
|
||||||
|
disabled={disabled}
|
||||||
|
sx={{ borderRadius: '12px', width: '100%', mt: 1 }}
|
||||||
|
variant='contained'
|
||||||
|
onClick={() =>
|
||||||
|
onManageLinksDialogClicked(
|
||||||
|
data.inputs[inputParam.name] ?? inputParam.default ?? '',
|
||||||
|
data.inputs.selectedLinks
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Manage Links
|
||||||
|
</Button>
|
||||||
|
<ManageScrapedLinksDialog
|
||||||
|
show={showManageScrapedLinksDialog}
|
||||||
|
dialogProps={manageScrapedLinksDialogProps}
|
||||||
|
onCancel={() => setShowManageScrapedLinksDialog(false)}
|
||||||
|
onSave={onManageLinksDialogSave}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</Box>
|
</Box>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue