Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useContext } from 'react';
import React, { useState, useContext, useEffect } from 'react';
import { Controlled as CodeMirror } from 'react-codemirror2';
import jsonlint from 'jsonlint-webpack';
import 'codemirror/lib/codemirror.css';
Expand Down Expand Up @@ -32,6 +32,11 @@ export const DialogSettings = () => {
const { state, actions } = useContext(StoreContext);
const { botName, settings } = state;
const [value, setValue] = useState(JSON.stringify(settings, null, 2));

useEffect(() => {
Comment thread
VanyLaw marked this conversation as resolved.
setValue(JSON.stringify(settings, null, 2));
}, [settings]);

const updateFormData = (editor, data, newValue) => {
try {
setValue(newValue);
Expand Down
5 changes: 2 additions & 3 deletions Composer/packages/client/src/store/action/setting.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import axios from 'axios';
import { get, debounce } from 'lodash';
import { get } from 'lodash';

import { ActionCreator, DialogSetting } from '../types';
import settingsStorage from '../../utils/dialogSettingStorage';
import { SensitiveProperties } from '../../constants';

import { BASEURL, ActionTypes } from './../../constants/index';

const post = debounce(axios.post, 1000);
export const setSettings: ActionCreator = async ({ dispatch }, botName: string, settings: DialogSetting) => {
try {
// set value to store
Expand All @@ -23,7 +22,7 @@ export const setSettings: ActionCreator = async ({ dispatch }, botName: string,
settingsStorage.setField(botName, property, propertyValue ? propertyValue : '');
}
// set value to server
await post(`${BASEURL}/projects/opened/settings`, { settings });
await axios.post(`${BASEURL}/projects/opened/settings`, { settings });
} catch (err) {
dispatch({
type: ActionTypes.SET_ERROR,
Expand Down
11 changes: 8 additions & 3 deletions Composer/packages/server/src/models/bot/botProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export class BotProject {
public environment: IEnvironment;
public settingManager: ISettingManager;
public settings: DialogSetting | null = null;
public isLuisConfigUpdate = false;
Comment thread
VanyLaw marked this conversation as resolved.
Outdated
constructor(ref: LocationRef) {
this.ref = ref;
this.dir = Path.resolve(this.ref.path); // make sure we swtich to posix style after here
Expand Down Expand Up @@ -106,7 +107,7 @@ export class BotProject {
// create or update dialog settings
public updateEnvSettings = async (slot: string, config: DialogSetting) => {
await this.settingManager.set(slot, config);
await this.luPublisher.setLuisConfig(config.luis);
this.isLuisConfigUpdate = await this.luPublisher.setLuisConfig(config.luis);
};

// merge the status managed by luPublisher to the LuFile structure to keep a unified interface
Expand Down Expand Up @@ -295,8 +296,12 @@ export class BotProject {
public publishLuis = async (authoringKey: string) => {
await this.luPublisher.setAuthoringKey(authoringKey);
const referred = this.luIndexer.getLuFiles().filter(this.isReferred);
const unpublished = await this.luPublisher.getUnpublisedFiles(referred);

let unpublished;
if (this.isLuisConfigUpdate) {
unpublished = referred;
} else {
unpublished = await this.luPublisher.getUnpublisedFiles(referred);
}
const invalidLuFile = unpublished.filter(file => file.diagnostics.length !== 0);
if (invalidLuFile.length !== 0) {
const msg = this.generateErrorMessage(invalidLuFile);
Expand Down
5 changes: 4 additions & 1 deletion Composer/packages/server/src/models/bot/luPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ export class LuPublisher {

public getLuisConfig = () => this.config;

public setLuisConfig = async (config: ILuisConfig) => {
public setLuisConfig = async (config: ILuisConfig): Promise<boolean> => {
if (!isEqual(config, this.config)) {
this.config = config;
if (!(await this.storage.exists(this._getSettingPath(config)))) {
await this._deleteGenerated(this.generatedFolderPath);
}
return true;
} else {
return false;
}
};

Expand Down