Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 57 additions & 5 deletions studio/src/components/Chat/DevBotFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import '@/styles/components/DevBotFooter.scss';
import { DefaultButton, IconButton, Stack, TextField, makeStyles } from "@fluentui/react";
import { useTranslation } from 'react-i18next';
import React from "react";
import useConfig from '../../hooks/useConfig';


interface props {
Expand All @@ -20,7 +22,9 @@ const devbotfooterStyles = makeStyles(theme => ({
export const DevBotFooter = (props: props) => {
const fileInput = React.createRef<HTMLInputElement>();
const classStyles = devbotfooterStyles();
const { t, i18n} = useTranslation();
const [message, setMessage] = React.useState('');
const config = useConfig();

React.useEffect(() => {
if (props.inputText) {
Expand All @@ -35,17 +39,65 @@ export const DevBotFooter = (props: props) => {
}
}, [props.inputText]);

if (!config) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should have a default config always. We don't need such a long if block

return (
<Stack className='devbot-footer'>
<Stack.Item>
<Stack horizontal className='button-stack' tokens={{childrenGap: 20}}>
<Stack.Item>
<input ref={fileInput} accept=".pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .txt, .rtf, .odt" onChange={props.onFileChange} type='file' multiple hidden />
<DefaultButton onClick={() => { window.event?.stopImmediatePropagation(); fileInput?.current?.click(); }} className='primary-button'>{t('devFooter.uploadFiles')}</DefaultButton>
</Stack.Item>
<Stack.Item>
<DefaultButton onClick={() => props.pluginStoreToggle()} className='primary-button'>{t('devFooter.addPlugin')}</DefaultButton>
</Stack.Item>
</Stack>
</Stack.Item>
<Stack.Item>
<Stack className='input-field-stack'>
<Stack.Item>
<TextField
maxLength={200000}
value={message}
onKeyUp={(e) => {
if (props.disableSend) { return; }
if (e.key === 'Enter') {
props.sendMessageToWss(message);
setMessage('');
}
}
}
onChange={(e, value) => { setMessage(value || '') }}
type="text"
placeholder="Type your message here..."
multiline={true}
resizable={false}
onRenderSuffix={() => {
return (<IconButton
disabled={props.disableSend}
onClick={() => { if (props.disableSend) { return; } props.sendMessageToWss(message); setMessage('') }}
iconProps={{'iconName': 'Send'}} title="Emoji" ariaLabel="Emoji" />)
}}
/>
</Stack.Item>
</Stack>

</Stack.Item>
</Stack>
)
}

return (
<Stack className='devbot-footer'>
<Stack.Item>
<Stack horizontal className='button-stack' tokens={{childrenGap: 20}}>
{config.features["devFooter.uploadFiles"] && <Stack.Item>
<input ref={fileInput} accept=".pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .txt, .rtf, .odt" onChange={props.onFileChange} type='file' multiple hidden />
<DefaultButton onClick={() => { window.event?.stopImmediatePropagation(); fileInput?.current?.click(); }} className='primary-button'>{t('devFooter.uploadFiles')}</DefaultButton>
</Stack.Item>
}
<Stack.Item>
<input ref={fileInput} accept=".pdf, .doc, .docx, .xls, .xlsx, .ppt, .pptx, .txt, .rtf, .odt" onChange={props.onFileChange} type='file' multiple hidden />
<DefaultButton onClick={() => { window.event?.stopImmediatePropagation(); fileInput?.current?.click(); }} className='primary-button'>Upload Files</DefaultButton>
</Stack.Item>
<Stack.Item>
<DefaultButton onClick={() => props.pluginStoreToggle()} className='primary-button'>Add Plugin</DefaultButton>
<DefaultButton onClick={() => props.pluginStoreToggle()} className='primary-button'>{t('devFooter.addPlugin')}</DefaultButton>
</Stack.Item>
</Stack>
</Stack.Item>
Expand Down
6 changes: 5 additions & 1 deletion studio/src/components/Representations/RepView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import ReactMarkdown from 'react-markdown';
import gfm from 'remark-gfm';
import MermaidChart from "../Mermaid";
import '../../styles/markdownStyles.css';
import useConfig from "../../hooks/useConfig";

interface props {
representation: any;
token: string;
}
export const RepView = (props: props) => {

const config = useConfig();
const stackStyle: IStackStyles = {
root: {
paddingLeft: '10px',
Expand All @@ -39,6 +40,9 @@ export const RepView = (props: props) => {
};

const renderRepresentation = (representation: any) => {
if (!config){
return null;
}
if (representation?.name === 'code') {
return (<Editor options={{ readOnly: true }} defaultValue={representation?.text} height='calc(100vh - 44px)' defaultLanguage="markdown">
</Editor>)
Expand Down
14 changes: 14 additions & 0 deletions studio/src/hooks/useConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { useState, useEffect } from 'react';
import config from '../locales/config.json';

const useConfig = () => {
const [configData, setConfigData] = useState(null);

useEffect(() => {
setConfigData(config);
}, []);

return configData;
};

export default useConfig;
17 changes: 17 additions & 0 deletions studio/src/locales/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"features":{
"dslFileUpload": true,
"publishModal.publishButton": true,
"devFooter.uploadFiles": true,
"editorPage.devModeHeader": true,
"representation.nlr":true,
"representation.chart": true,
"representation.dsl": true,
"representation.code": false,
"error.errors": true,
"error.warnings": true,
"error.optimizations": true,
"error.botExperience": true

}
}
8 changes: 7 additions & 1 deletion studio/src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,11 @@
"publishModal.installationURL": "Get your project online",
"publishModal.installationSecret": "Secret Key",
"representations.editModeAlert": "Please submit or discard your changes before switching representations.",
"representations.title": "Representations"
"representations.title": "Representations",
"devFooter.addPlugin": "Add Plugins",
"devFooter.uploadFiles": "Upload Files",
"errors.errors": "Error",
"errors.warnings": "Warnings",
"errors.optimizations": "Optimize",
"errors.botExperience": "Bot Experience"
}
Loading