From 1461d6ad6b6e67e4e1647c8b9331911891858c7c Mon Sep 17 00:00:00 2001 From: Frikky Date: Thu, 17 Aug 2023 02:13:38 +0200 Subject: [PATCH] Fixed another new workflow recommendation issue --- backend/go-app/go.mod | 2 +- frontend/src/components/EditWorkflow.jsx | 118 ++++++++++++++--------- frontend/src/components/WorkflowGrid.jsx | 95 ++++++++++-------- 3 files changed, 126 insertions(+), 89 deletions(-) diff --git a/backend/go-app/go.mod b/backend/go-app/go.mod index 5f0ffdff..e400b547 100755 --- a/backend/go-app/go.mod +++ b/backend/go-app/go.mod @@ -1,6 +1,6 @@ module shuffle-shared -//replace github.com/shuffle/shuffle-shared => ../../../../git/shuffle-shared +replace github.com/shuffle/shuffle-shared => ../../../../git/shuffle-shared go 1.19 diff --git a/frontend/src/components/EditWorkflow.jsx b/frontend/src/components/EditWorkflow.jsx index c862f22b..38ddbcf5 100644 --- a/frontend/src/components/EditWorkflow.jsx +++ b/frontend/src/components/EditWorkflow.jsx @@ -3,6 +3,7 @@ import theme from '../theme.jsx'; import { isMobile } from "react-device-detect" import { MuiChipsInput } from "mui-chips-input"; import UsecaseSearch from "../components/UsecaseSearch.jsx" +import WorkflowGrid from "../components/WorkflowGrid.jsx" import dayjs from 'dayjs'; import { @@ -62,12 +63,14 @@ const EditWorkflow = (props) => { const [submitLoading, setSubmitLoading] = React.useState(false); const [showMoreClicked, setShowMoreClicked] = React.useState(false); - const [innerWorkflow, setInnerWorkflow] = React.useState(workflow) + const [innerWorkflow, setInnerWorkflow] = React.useState(workflow) + const [newWorkflowTags, setNewWorkflowTags] = React.useState(workflow.tags !== undefined && workflow.tags !== null ? JSON.parse(JSON.stringify(workflow.tags)) : []) + const [description, setDescription] = React.useState(workflow.description !== undefined ? workflow.description : "") + const [selectedUsecases, setSelectedUsecases] = React.useState(workflow.usecase_ids !== undefined && workflow.usecase_ids !== null ? JSON.parse(JSON.stringify(workflow.usecase_ids)) : []); const [foundWorkflowId, setFoundWorkflowId] = React.useState("") const [name, setName] = React.useState(workflow.name !== undefined ? workflow.name : "") - const [description, setDescription] = React.useState(workflow.description !== undefined ? workflow.description : "") const [dueDate, setDueDate] = React.useState(workflow.due_date !== undefined && workflow.due_date !== null && workflow.due_date !== 0 ? dayjs(workflow.due_date*1000) : dayjs().subtract(1, 'day')) // Gets the generated workflow @@ -154,58 +157,59 @@ const EditWorkflow = (props) => { PaperProps={{ style: { color: "white", - minWidth: isMobile ? "90%" : 550, - maxWidth: isMobile ? "90%" : 550, + minWidth: isMobile ? "90%" : 650, + maxWidth: isMobile ? "90%" : 650, minHeight: 400, + paddingTop: 25, //minWidth: isMobile ? "90%" : newWorkflow === true ? 1000 : 550, //maxWidth: isMobile ? "90%" : newWorkflow === true ? 1000 : 550, }, }} > -
+
-
- - {newWorkflow ? "New" : "Editing"} workflow - - {newWorkflow === true ? null : -
- - - - - -
- } +
+ + {newWorkflow ? "New" : "Editing"} workflow + + {newWorkflow === true ? null : +
+ + + + +
- - Workflows can be built from scratch, or from templates. Usecases can help you discover next steps, and you can search for them directly. Learn more - - {showUpload === true ? -
- - - -
- : null} + } +
+ + Workflows can be built from scratch, or from templates. Usecases can help you discover next steps, and you can search for them directly. Learn more + + {showUpload === true ? +
+ + + +
+ : null}
{/*newWorkflow === true ?
@@ -220,8 +224,8 @@ const EditWorkflow = (props) => {
- -
+ +
{ setName(event.target.value) @@ -475,7 +479,8 @@ const EditWorkflow = (props) => {
- + + + + {newWorkflow === true && name.length > 5 ? +
+ +
+ : null} ) diff --git a/frontend/src/components/WorkflowGrid.jsx b/frontend/src/components/WorkflowGrid.jsx index e4542e06..fb19e806 100644 --- a/frontend/src/components/WorkflowGrid.jsx +++ b/frontend/src/components/WorkflowGrid.jsx @@ -25,12 +25,9 @@ import WorkflowPaperNew from "../components/WorkflowPaperNew.jsx" const searchClient = algoliasearch("JNSS5CFDZZ", "db08e40265e2941b9a7d8f644b6e5240") const AppGrid = props => { - const { maxRows, showName, showSuggestion, isMobile, globalUrl, parsedXs, alternativeView, } = props - - const isCloud = - window.location.host === "localhost:3002" || - window.location.host === "shuffler.io"; + const { maxRows, showName, showSuggestion, isMobile, globalUrl, parsedXs, alternativeView, onlyResults, inputsearch } = props + const isCloud = window.location.host === "localhost:3002" || window.location.host === "shuffler.io"; const rowHandler = maxRows === undefined || maxRows === null ? 50 : maxRows const xs = parsedXs === undefined || parsedXs === null ? isMobile ? 6 : 4 : parsedXs //const [apps, setApps] = React.useState([]); @@ -38,7 +35,9 @@ const AppGrid = props => { const [formMail, setFormMail] = React.useState(""); const [message, setMessage] = React.useState(""); const [formMessage, setFormMessage] = React.useState(""); - const [usecases, setUsecases] = React.useState([]); + const [usecases, setUsecases] = React.useState([]); + + const [localMessage, setLocalMessage] = React.useState(""); const buttonStyle = {borderRadius: 30, height: 50, width: 220, margin: isMobile ? "15px auto 15px auto" : 20, fontSize: 18,} @@ -153,10 +152,10 @@ const AppGrid = props => { return response.json(); }) .then((responseJson) => { - if (responseJson.success !== false) { - console.log("Usecases: ", responseJson) - //handleKeysetting(responseJson, workflows) - } + if (responseJson.success !== false) { + console.log("Usecases: ", responseJson) + //handleKeysetting(responseJson, workflows) + } }) .catch((error) => { //alert.error("ERROR: " + error.toString()); @@ -166,8 +165,10 @@ const AppGrid = props => { useEffect(() => { fetchUsecases() + }, []) + // value={currentRefinement} const SearchBox = ({currentRefinement, refine, isSearchStalled} ) => { useEffect(() => { @@ -182,16 +183,23 @@ const AppGrid = props => { } }, []) + if (localMessage !== inputsearch && inputsearch !== undefined && inputsearch !== null && inputsearch.length > 0) { + console.log("In refinement: ", inputsearch) + //setLocalMessage(inputsearch) + refine(inputsearch) + } else if (onlyResults === true) { + // Don't return anything unless refinement works + return null + } + return (
+ {onlyResults !== true ? @@ -210,8 +218,8 @@ const AppGrid = props => { }} limit={5} /> - {/*isSearchStalled ? 'My search is stalled' : ''*/} - + : null} + ) } @@ -228,29 +236,35 @@ const AppGrid = props => { var counted = 0 return ( - - {hits.map((data, index) => { - workflowDelay += 50 +
+ {onlyResults === true && hits.length > 0 ? + + Relevant Workflows + + : null} + + {hits.map((data, index) => { + workflowDelay += 50 - if (counted === 12/xs*rowHandler) { - return null - } + if (counted === 12/xs*rowHandler) { + return null + } - counted += 1 + counted += 1 - return ( - - + return ( + + {/**/} {alternativeView === true ? : } - - ) - })} - + ) + })} + +
) } @@ -331,11 +345,11 @@ const AppGrid = props => { fullWidth={true} placeholder="What apps do you want to see?" type="" - id="standard-required" + id="standard-required" margin="normal" variant="outlined" autoComplete="off" - onChange={e => setMessage(e.target.value)} + onChange={e => setMessage(e.target.value)} />
: null } - - - - Search by - - - Algolia logo - - + {onlyResults === true ? null : + + + Search by + + + Algolia logo + + + }
) }