feat: feature/mvp-sprint-1 Fixed a commander bug where root level values where not rendering the value in popup window correctly and fixed some overflow scroll issues on commander suggestions box
This commit is contained in:
parent
ae8e066c4f
commit
804f356adc
@ -168,6 +168,11 @@ export const ThingtimeProvider = (props: any): JSX.Element => {
|
|||||||
(...args) => {
|
(...args) => {
|
||||||
const rawPath = args[0]
|
const rawPath = args[0]
|
||||||
const path = rawPath
|
const path = rawPath
|
||||||
|
|
||||||
|
if (!path) {
|
||||||
|
return thingtime
|
||||||
|
}
|
||||||
|
|
||||||
// do we need to sanitise?
|
// do we need to sanitise?
|
||||||
// const path = sanitise(rawPath)
|
// const path = sanitise(rawPath)
|
||||||
console.log("Getting thingtime at path", path)
|
console.log("Getting thingtime at path", path)
|
||||||
|
@ -269,22 +269,18 @@ export const Commander = (props) => {
|
|||||||
|
|
||||||
if (commandIsAction) {
|
if (commandIsAction) {
|
||||||
// nothing
|
// nothing
|
||||||
|
const prevVal = getThingtime(commandPath)
|
||||||
|
const parentPath = getParentPath(commandPath) || "thingtime"
|
||||||
try {
|
try {
|
||||||
// first try to execute literal javscript
|
// first try to execute literal javscript
|
||||||
const fn = `() => { return ${commandValue} }`
|
const fn = `() => { return ${commandValue} }`
|
||||||
const evalFn = eval(fn)
|
const evalFn = eval(fn)
|
||||||
const realVal = evalFn()
|
const realVal = evalFn()
|
||||||
const prevVal = getThingtime(commandPath)
|
|
||||||
const parentPath = getParentPath(commandPath)
|
|
||||||
// console.log("nik realVal", realVal)
|
// console.log("nik realVal", realVal)
|
||||||
// console.log("nik prevVal", prevVal)
|
// console.log("nik prevVal", prevVal)
|
||||||
// console.log("nik parentPath", parentPath)
|
// console.log("nik parentPath", parentPath)
|
||||||
// console.log("nik commandPath", commandPath)
|
// console.log("nik commandPath", commandPath)
|
||||||
setThingtime(commandPath, realVal)
|
setThingtime(commandPath, realVal)
|
||||||
if (!prevVal) {
|
|
||||||
setContextPath(parentPath)
|
|
||||||
setShowContext(true, "commandIsAction check")
|
|
||||||
}
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(
|
console.log(
|
||||||
"Caught error after trying to execute literal javascript",
|
"Caught error after trying to execute literal javascript",
|
||||||
@ -299,10 +295,6 @@ export const Commander = (props) => {
|
|||||||
const prevVal = getThingtime(commandPath)
|
const prevVal = getThingtime(commandPath)
|
||||||
const parentPath = getParentPath(commandPath)
|
const parentPath = getParentPath(commandPath)
|
||||||
setThingtime(commandPath, realVal)
|
setThingtime(commandPath, realVal)
|
||||||
if (!prevVal) {
|
|
||||||
setContextPath(parentPath)
|
|
||||||
setShowContext(true, "commandIsAction check")
|
|
||||||
}
|
|
||||||
} catch {
|
} catch {
|
||||||
// something very bad went wrong
|
// something very bad went wrong
|
||||||
console.log(
|
console.log(
|
||||||
@ -311,7 +303,13 @@ export const Commander = (props) => {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (commandContainsPath) {
|
if (!prevVal) {
|
||||||
|
setContextPath(commandPath)
|
||||||
|
setShowContext(true, "commandIsAction check")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if (commandContainsPath)
|
||||||
|
else {
|
||||||
// const prevValue = getThingtime(commandPath)
|
// const prevValue = getThingtime(commandPath)
|
||||||
|
|
||||||
// const newValue = setThingtime(commandPath, prevValue)
|
// const newValue = setThingtime(commandPath, prevValue)
|
||||||
@ -392,19 +390,29 @@ export const Commander = (props) => {
|
|||||||
left={0}
|
left={0}
|
||||||
alignItems={["flex-start", "center"]}
|
alignItems={["flex-start", "center"]}
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
overflowY="scroll"
|
|
||||||
maxWidth="100%"
|
maxWidth="100%"
|
||||||
height="auto"
|
height="auto"
|
||||||
maxHeight="90vh"
|
|
||||||
marginTop={2}
|
marginTop={2}
|
||||||
borderRadius="12px"
|
borderRadius="12px"
|
||||||
marginX={1}
|
marginX={1}
|
||||||
>
|
>
|
||||||
<Flex
|
<Flex
|
||||||
|
alignItems={["flex-start", "center"]}
|
||||||
flexDirection="column"
|
flexDirection="column"
|
||||||
|
overflowY="scroll"
|
||||||
|
width="auto"
|
||||||
|
maxWidth="100%"
|
||||||
|
maxHeight="90vh"
|
||||||
|
borderRadius="12px"
|
||||||
|
>
|
||||||
|
<Flex
|
||||||
|
flexDirection="column"
|
||||||
|
flexShrink={0}
|
||||||
display={showSuggestions ? "flex" : "none"}
|
display={showSuggestions ? "flex" : "none"}
|
||||||
|
overflowY="scroll"
|
||||||
width={["100%", "400px"]}
|
width={["100%", "400px"]}
|
||||||
maxWidth="100%"
|
maxWidth="100%"
|
||||||
|
maxHeight="300px"
|
||||||
marginBottom={3}
|
marginBottom={3}
|
||||||
background="grey"
|
background="grey"
|
||||||
borderRadius="12px"
|
borderRadius="12px"
|
||||||
@ -439,7 +447,8 @@ export const Commander = (props) => {
|
|||||||
pointerEvents="all"
|
pointerEvents="all"
|
||||||
paddingY={3}
|
paddingY={3}
|
||||||
>
|
>
|
||||||
<Thingtime thing={contextValue}></Thingtime>
|
<Thingtime path={contextPath} thing={contextValue}></Thingtime>
|
||||||
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
<Center
|
<Center
|
||||||
|
Loading…
Reference in New Issue
Block a user