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 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
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(() => {
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.bind(axios), 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
28 changes: 14 additions & 14 deletions Composer/packages/server/src/models/bot/luPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ import { LUFile, ILuisConfig, LuisStatus, FileUpdateType } from './interface';

const GENERATEDFOLDER = 'generated';
const LU_STATUS_FILE = 'luis.status.json';

const DEFAULT_STATUS = {
lastUpdateTime: 1,
lastPublishTime: 0, // means unpublished
};
export class LuPublisher {
public botDir: string;
public generatedFolderPath: string;
Expand All @@ -18,7 +21,6 @@ export class LuPublisher {
// key: filePath relative to bot dir
// value: lastUpdateTime && lastPublishTime
public status: { [key: string]: LuisStatus } = {};

constructor(path: string, storage: IFileStorage) {
this.botDir = path;
this.generatedFolderPath = Path.join(this.botDir, GENERATEDFOLDER);
Expand All @@ -36,15 +38,19 @@ export class LuPublisher {
// make sure all LU file have an initial value
files.forEach(f => {
if (!this.status[f]) {
this.status[f] = {
lastUpdateTime: 1,
lastPublishTime: 0, // means unpublished
};
this.status[f] = { ...DEFAULT_STATUS }; // use ... ensure don't referred to the same object
}
});
return this.status;
};

// reset status when config changed, because status don't represent the current config
public resetStatus = () => {
for (const key in this.status) {
this.status[key] = { ...DEFAULT_STATUS };
}
};

public saveStatus = async () => {
if (!(await this.storage.exists(this.generatedFolderPath))) {
await this.storage.mkDir(this.generatedFolderPath);
Expand Down Expand Up @@ -114,9 +120,8 @@ export class LuPublisher {
public setLuisConfig = async (config: ILuisConfig) => {
if (!isEqual(config, this.config)) {
this.config = config;
if (!(await this.storage.exists(this._getSettingPath(config)))) {
await this._deleteGenerated(this.generatedFolderPath);
}
await this._deleteGenerated(this.generatedFolderPath);
this.resetStatus();
}
};

Expand Down Expand Up @@ -156,11 +161,6 @@ export class LuPublisher {
});
};

private _getSettingPath = (config: ILuisConfig | null) => {
if (config === null) return '';
return Path.join(this.generatedFolderPath, `luis.settings.${config.environment}.${config.authoringRegion}.json`);
};

private _getConfig = (luFiles: LUFile[]) => {
const luConfig: any = { ...this.config };
luConfig.models = [];
Expand Down