Skip to content

Commit

Permalink
chore(studio): bring changes (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
allardy authored Jun 9, 2021
1 parent 14b9fff commit d46fe7b
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 20 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## [0.0.17](https://github.com/botpress/studio/compare/v0.0.16...v0.0.17) (2021-06-09)



## [0.0.13](https://github.com/botpress/studio/compare/v0.0.12...v0.0.13) (2021-06-03)

### Bug Fixes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@botpress/studio",
"version": "0.0.16",
"version": "0.0.18",
"description": "Create your virtual assistants",
"main": "index.js",
"bin": "./packages/studio-be/out/index.js",
Expand Down
4 changes: 2 additions & 2 deletions packages/studio-be/src/core/dialog/flow/flow-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,9 @@ export class ScopedFlowService {
if (!expectedSaves) {
if (await this.ghost.fileExists(FLOW_DIR, flowPath)) {
const flow = await this.parseFlow(flowPath)
this.invalidateFlow(flowPath, flow)
this.localInvalidateFlow(flowPath, flow)
} else {
this.invalidateFlow(flowPath, undefined)
this.localInvalidateFlow(flowPath, undefined)
}
} else {
if (!isFromFile) {
Expand Down
2 changes: 1 addition & 1 deletion packages/studio-be/src/core/security/router-security.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export const checkBotVisibility = (configProvider: ConfigProvider, checkTokenHea
const config = await configProvider.getBotConfig(req.params.botId)
if (config.disabled) {
// The user must be able to get the config to change the bot status
if (req.originalUrl.endsWith(`/api/v1/bots/${req.params.botId}`)) {
if (req.originalUrl.endsWith(`/api/v1/studio/${req.params.botId}/config`)) {
return next()
}

Expand Down
2 changes: 1 addition & 1 deletion packages/studio-be/src/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const debug = require('debug')

const available = {}

export const Debug = (mod: string, base = 'bp') => {
export const Debug = (mod: string, base = 'bp:studio') => {
const namespace = base + ':' + mod
available[namespace] = true
const instance = debug(base).extend(mod)
Expand Down
7 changes: 2 additions & 5 deletions packages/studio-be/src/sdk/botpress.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1108,11 +1108,8 @@ declare module 'botpress/sdk' {
displayOrder?: number
/** This callback url is called when the condition is deleted or pasted in the flow */
callback?: string
/** The editor will use the custom component to provide the requested parameters */
editor?: {
module: string
component: string
}
/** The editor will use the LiteEditor component to provide the requested parameters */
useLiteEditor?: boolean
evaluate: (event: IO.IncomingEvent, params: any) => number
}

Expand Down
17 changes: 17 additions & 0 deletions packages/studio-be/src/studio/internal-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import _ from 'lodash'
import { StudioServices } from 'studio/studio-router'
import { CustomStudioRouter } from 'studio/utils/custom-studio-router'

import { getDebugScopes, setDebugScopes } from '../debug'

export class InternalRouter extends CustomStudioRouter {
constructor(services: StudioServices) {
super('Internal', services)
Expand All @@ -22,6 +24,21 @@ export class InternalRouter extends CustomStudioRouter {
next()
})

router.get(
'/getDebugScopes',
this.asyncMiddleware(async (req, res) => {
res.send(getDebugScopes())
})
)

router.post(
'/setDebugScopes',
this.asyncMiddleware(async (req, res) => {
setDebugScopes(req.body.scopes)
res.sendStatus(200)
})
)

router.post(
'/updateTokenVersion',
this.asyncMiddleware(async (req, res) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Condition } from 'botpress/sdk'
import _ from 'lodash'
import React, { FC } from 'react'
import InjectedModuleView from '~/components/PluginInjectionSite/module'

import { IntentParams, LiteEditor } from '~/views/Nlu/intents/LiteEditor'

import InputParams from './InputParams'

Expand All @@ -15,16 +16,19 @@ interface Props {
}

const ConditionEditor: FC<Props> = props => {
const editor = props.condition && props.condition.editor
const { topicName, params, updateParams, contentLang, forceSave } = props
const useLiteEditor = props.condition.useLiteEditor

return (
<div style={{ maxHeight: 500 }}>
{editor ? (
<InjectedModuleView
moduleName={editor.module}
componentName={editor.component}
extraProps={{ ..._.pick(props, ['topicName', 'params', 'updateParams', 'contentLang', 'forceSave']) }}
/>
{useLiteEditor ? (
<LiteEditor
topicName={topicName}
params={params}
updateParams={updateParams}
contentLang={contentLang}
forceSave={forceSave}
></LiteEditor>
) : (
<InputParams {...props} updateParams={props.updateParams} />
)}
Expand Down
3 changes: 1 addition & 2 deletions packages/studio-ui/src/web/views/Nlu/intents/LiteEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import { IntentEditor } from './FullEditor'
import IntentDropdown from './IntentDropdown'
import NameModal from './NameModal'

interface IntentParams {
export interface IntentParams {
intentName: string
}

interface Props {
bp: any
contentLang: string
forceSave: boolean
topicName: string
Expand Down

0 comments on commit d46fe7b

Please sign in to comment.