Code view in Configure tab of SUSI.AI Bot Wizard

The purpose of configure tab in SUSI.AI bot wizard is to provide the bot creator various options on how the bot will interact with different websites. It currently provides an option of enabling or disabling the chatbot on different websites.
The configure tab has two parts. One is the code view which allows the users to write websites on which they want to enable/disable the chatbot and a table below it which lists those websites.

The default code in code view is passed in a state in the Configure.js file. The following code demonstrates that:

this.state = {
  code: this.props.code,

Fetching data from code view:

After writing the websites on which the user wants the chatbot to be enabled/disabled and pressing on the ‘Save’ button, a functiongenerateConfigData is called.
This function takes the code in code view and stores in inside of a variable. Then it splits the code and makes two arrays:

  • enabledSites: This array contains all the websites that are written in  enabled field.
  • disabledSites: This array contains all the websites that are written in disabled field.

This process can be easily understood from the following code snippet:

let newCode = this.state.code;
let websiteData = newCode
let enabledSites = websiteData[0].split(',');
let disabledSites = websiteData[1].split(',');

This data is stored inside an object.

Displaying the data:

The data fetched from the code view now has to be displayed in form of a table. This data is looks like this:

let configData = [
   id: '1',
   name: '',
   last: 'Jan 12, 2018 20:08 hrs',
   status: 1,
   id: '2',
   name: '',
   last: 'Feb 19, 2018 13:00 hrs',
   status: 1,
   id: '3',
   name: '',
   last: 'Mar 14, 2018 10:15 hrs',
   Status: 2,

Status is 1 if the website is in enabled column and 2 if the website is in disabled column.
To display this data on the screen, we simply map through the data and display the rows of the table. The following code demonstrates it:

{, index) => {
 if ( {
   return (
    <TableRow key={index}>
      <TableRowColumn style={{ fontSize: '16px' }}>
      <TableRowColumn style={{ fontSize: '16px' }}>
         <MenuItem value={1} primaryText="Enable" />
         <MenuItem value={2} primaryText="Disable" />