Update message body component to use activeStep prop
This commit is contained in:
parent
77603e2c04
commit
213a7dbc79
@ -84,7 +84,7 @@ const CurrentMessage = observer((props: any) => {
|
|||||||
whiteSpace: 'break-spaces'
|
whiteSpace: 'break-spaces'
|
||||||
},
|
},
|
||||||
}}>
|
}}>
|
||||||
<MessageBody messageType="bot" temp={true} >
|
<MessageBody messageType="bot" activeStep={true} >
|
||||||
{renderBlocks.length>0?toMarkdown(renderBlocks[0]):''}
|
{renderBlocks.length>0?toMarkdown(renderBlocks[0]):''}
|
||||||
</MessageBody>
|
</MessageBody>
|
||||||
<MessageBlink />
|
<MessageBlink />
|
||||||
|
@ -8,7 +8,7 @@ interface IProps {
|
|||||||
messageType: string,
|
messageType: string,
|
||||||
children: string,
|
children: string,
|
||||||
messageDone?: boolean,
|
messageDone?: boolean,
|
||||||
temp?: boolean
|
activeStep?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -24,14 +24,14 @@ const useStyles = createStyles((theme, options:any) => ({
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const MessageBody = observer((props: IProps) => {
|
const MessageBody = observer((props: IProps) => {
|
||||||
const { children, messageType, temp=false ,messageDone} = props;
|
const { children, messageType, activeStep=false ,messageDone} = props;
|
||||||
const { chat } = useMst();
|
const { chat } = useMst();
|
||||||
const {classes} = useStyles({
|
const {classes} = useStyles({
|
||||||
chatPanelWidth:chat.chatPanelWidth
|
chatPanelWidth:chat.chatPanelWidth
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
messageType === 'bot'
|
messageType === 'bot'
|
||||||
? <MessageMarkdown className={classes.bodyWidth} temp={temp} messageDone={messageDone}>
|
? <MessageMarkdown className={classes.bodyWidth} activeStep={activeStep} messageDone={messageDone}>
|
||||||
{children}
|
{children}
|
||||||
</MessageMarkdown>
|
</MessageMarkdown>
|
||||||
: <Container
|
: <Container
|
||||||
|
@ -12,13 +12,13 @@ import { keyframes,css } from "@emotion/react";
|
|||||||
interface StepProps {
|
interface StepProps {
|
||||||
language: string;
|
language: string;
|
||||||
children: string;
|
children: string;
|
||||||
done: boolean;
|
status: string;
|
||||||
index: number|undefined;
|
index: number|undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Step = observer((props:StepProps) => {
|
const Step = observer((props:StepProps) => {
|
||||||
const { chat } = useMst();
|
const { chat } = useMst();
|
||||||
const {language,children,done,index} = props;
|
const {language,children,status,index} = props;
|
||||||
const [opened, { toggle }] = useDisclosure(false);
|
const [opened, { toggle }] = useDisclosure(false);
|
||||||
|
|
||||||
// extract first line with # as button label
|
// extract first line with # as button label
|
||||||
@ -85,7 +85,7 @@ const Step = observer((props:StepProps) => {
|
|||||||
>
|
>
|
||||||
<Accordion.Item value={'step'+index} mah='200'>
|
<Accordion.Item value={'step'+index} mah='200'>
|
||||||
<Accordion.Control icon={
|
<Accordion.Control icon={
|
||||||
done
|
status === "done"
|
||||||
?<IconCheck size="1.125rem"/>
|
?<IconCheck size="1.125rem"/>
|
||||||
:<Loader size="xs" color="#ED6A45" speed={1} />
|
:<Loader size="xs" color="#ED6A45" speed={1} />
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ interface MessageMarkdownProps extends React.ComponentProps<typeof ReactMarkdown
|
|||||||
children: string,
|
children: string,
|
||||||
className: string,
|
className: string,
|
||||||
messageDone?: boolean,
|
messageDone?: boolean,
|
||||||
temp?: boolean
|
activeStep?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
type Step = {
|
type Step = {
|
||||||
@ -54,7 +54,7 @@ function parseMetaData(string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MessageMarkdown = observer((props: MessageMarkdownProps) => {
|
const MessageMarkdown = observer((props: MessageMarkdownProps) => {
|
||||||
const { children,temp=false,messageDone } = props;
|
const { children,activeStep=false,messageDone } = props;
|
||||||
const { chat } = useMst();
|
const { chat } = useMst();
|
||||||
const [steps, setSteps] = useState<Step[]>([]);
|
const [steps, setSteps] = useState<Step[]>([]);
|
||||||
const tree = fromMarkdown(children);
|
const tree = fromMarkdown(children);
|
||||||
@ -177,7 +177,7 @@ Generate a professionally written and formatted release note in markdown with th
|
|||||||
return <ReactMarkdown
|
return <ReactMarkdown
|
||||||
{...props}
|
{...props}
|
||||||
remarkPlugins={[()=> (tree) =>{
|
remarkPlugins={[()=> (tree) =>{
|
||||||
let stepCount = 1;
|
let stepCount = 0;
|
||||||
let chatmarkCount = 0;
|
let chatmarkCount = 0;
|
||||||
let previousNode:any = null;
|
let previousNode:any = null;
|
||||||
visit(tree, function (node) {
|
visit(tree, function (node) {
|
||||||
@ -227,8 +227,8 @@ Generate a professionally written and formatted release note in markdown with th
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lanugage === 'step' || lanugage === 'Step') {
|
if (lanugage === 'step' || lanugage === 'Step') {
|
||||||
let done = Number(index) < codes.length? true : lastNode.type !== 'code';
|
const status = activeStep && Number(index) === codes.length - 1 && lastNode.type === 'code' ? "running" : "done";
|
||||||
return <Step language={lanugage} done={temp?done:true} index={index}>{value}</Step>;
|
return <Step language={lanugage} status={status} index={index}>{value}</Step>;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lanugage === 'chatmark' || lanugage === 'ChatMark') {
|
if (lanugage === 'chatmark' || lanugage === 'ChatMark') {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user