Skip to content

Commit

Permalink
feat: Bot Project Operations (microsoft#4316)
Browse files Browse the repository at this point in the history
  • Loading branch information
srinaath committed Oct 8, 2020
1 parent 5db6c0d commit 7ca4296
Show file tree
Hide file tree
Showing 84 changed files with 2,123 additions and 563 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('<CreationFlow/>', () => {
const createProjectMock = jest.fn();
const initRecoilState = ({ set }) => {
set(dispatcherState, {
createProject: createProjectMock,
createNewBot: createProjectMock,
fetchStorages: jest.fn(),
fetchTemplateProjects: jest.fn(),
onboardingAddCoachMarkRef: jest.fn(),
Expand Down Expand Up @@ -70,14 +70,14 @@ describe('<CreationFlow/>', () => {
act(() => {
fireEvent.click(node);
});
expect(createProjectMock).toHaveBeenCalledWith(
'EchoBot',
'EchoBot-1',
'',
expect.stringMatching(/(\/|\\)test-folder(\/|\\)Desktop/),
'',
'en-US',
undefined
);
expect(createProjectMock).toHaveBeenCalledWith({
appLocale: 'en-US',
description: '',
location: '/test-folder/Desktop',
name: 'EchoBot-1',
qnaKbUrls: undefined,
schemaUrl: '',
templateId: 'EchoBot',
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as React from 'react';
import { fireEvent } from '@bfc/test-utils';

import { PublishDialog } from '../../../src/components/TestController/publishDialog';
import { botNameState, settingsState, dispatcherState, currentProjectIdState } from '../../../src/recoilModel';
import { botDisplayNameState, settingsState, dispatcherState, currentProjectIdState } from '../../../src/recoilModel';
import { renderWithRecoil } from '../../testUtils';
jest.useFakeTimers();

Expand All @@ -31,7 +31,7 @@ describe('<PublishDialog />', () => {
setSettings: setSettingsMock,
});
set(currentProjectIdState, projectId);
set(botNameState(projectId), 'sampleBot0');
set(botDisplayNameState(projectId), 'sampleBot0');
set(settingsState(projectId), {
luis: luisConfig,
qna: qnaConfig,
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/__tests__/components/skill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ describe('<SkillForm />', () => {
manifestUrl: 'Validating',
})
);
expect(httpClient.get).toBeCalledWith(`/projects/${projectId}/skill/retrieve-skill-manifest`, {
expect(httpClient.get).toBeCalledWith(`/projects/${projectId}/skill/retrieveSkillManifest`, {
params: {
url: formData.manifestUrl,
},
Expand Down Expand Up @@ -261,7 +261,7 @@ describe('<SkillForm />', () => {
manifestUrl: 'Validating',
})
);
expect(httpClient.get).toBeCalledWith(`/projects/${projectId}/skill/retrieve-skill-manifest`, {
expect(httpClient.get).toBeCalledWith(`/projects/${projectId}/skill/retrieveSkillManifest`, {
params: {
url: formData.manifestUrl,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import React from 'react';
import { renderWithRecoil } from '../../testUtils';
import {
settingsState,
botNameState,
botDisplayNameState,
publishTypesState,
publishHistoryState,
currentProjectIdState,
Expand Down Expand Up @@ -53,7 +53,7 @@ const state = {

const initRecoilState = ({ set }) => {
set(currentProjectIdState, state.projectId);
set(botNameState(state.projectId), state.botName);
set(botDisplayNameState(state.projectId), state.botName);
set(publishTypesState(state.projectId), state.publishTypes);
set(publishHistoryState(state.projectId), state.publishHistory);
set(settingsState(state.projectId), state.settings);
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/Onboarding/Onboarding.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { useRecoilValue } from 'recoil';
import onboardingStorage from '../utils/onboardingStorage';
import { OpenConfirmModal } from '../components/Modal/ConfirmDialog';
import { useLocation } from '../utils/hooks';
import { dispatcherState, onboardingState, botProjectsSpaceState, validateDialogSelectorFamily } from '../recoilModel';
import { dispatcherState, onboardingState, botProjectIdsState, validateDialogSelectorFamily } from '../recoilModel';

import OnboardingContext from './OnboardingContext';
import TeachingBubbles from './TeachingBubbles/TeachingBubbles';
Expand All @@ -20,7 +20,7 @@ const getCurrentSet = (stepSets) => stepSets.findIndex(({ id }) => id === onboar

const Onboarding: React.FC = () => {
const didMount = useRef(false);
const botProjects = useRecoilValue(botProjectsSpaceState);
const botProjects = useRecoilValue(botProjectIdsState);
const rootBotProjectId = botProjects[0];
const dialogs = useRecoilValue(validateDialogSelectorFamily(rootBotProjectId));
const { onboardingSetComplete } = useRecoilValue(dispatcherState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export const validateManifestUrl = async ({
} else {
try {
setValidationState({ ...validationState, manifestUrl: ValidationState.Validating });
const { data } = await httpClient.get(`/projects/${projectId}/skill/retrieve-skill-manifest`, {
const { data } = await httpClient.get(`/projects/${projectId}/skill/retrieveSkillManifest`, {
params: {
url: manifestUrl,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,20 @@ type CreationFlowProps = RouteComponentProps<{}>;
const CreationFlow: React.FC<CreationFlowProps> = () => {
const {
fetchTemplates,
openProject,
createProject,
saveProjectAs,
fetchStorages,
fetchFolderItemsByPath,
setCreationFlowStatus,
createFolder,
updateCurrentPathForStorage,
updateFolder,
saveTemplateId,
fetchProjectById,
fetchRecentProjects,
openProject,
createNewBot,
saveProjectAs,
fetchProjectById,
} = useRecoilValue(dispatcherState);

const creationFlowStatus = useRecoilValue(creationFlowStatusState);
const projectId = useRecoilValue(currentProjectIdState);
const templateProjects = useRecoilValue(templateProjectsState);
Expand Down Expand Up @@ -102,15 +103,16 @@ const CreationFlow: React.FC<CreationFlowProps> = () => {
};

const handleCreateNew = async (formData, templateId: string, qnaKbUrls?: string[]) => {
createProject(
templateId || '',
formData.name,
formData.description,
formData.location,
formData.schemaUrl,
const newBotData = {
templateId: templateId || '',
name: formData.name,
description: formData.description,
location: formData.location,
schemaUrl: formData.schemaUrl,
appLocale,
qnaKbUrls
);
qnaKbUrls,
};
createNewBot(newBotData);
};

const handleSaveAs = (formData) => {
Expand Down
10 changes: 8 additions & 2 deletions Composer/packages/client/src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ import { useRecoilValue } from 'recoil';
import { SharedColors } from '@uifabric/fluent-theme';
import { FontWeights } from 'office-ui-fabric-react/lib/Styling';

import { dispatcherState, appUpdateState, botNameState, localeState, currentProjectIdState } from '../recoilModel';
import {
dispatcherState,
appUpdateState,
botDisplayNameState,
localeState,
currentProjectIdState,
} from '../recoilModel';
import composerIcon from '../images/composerIcon.svg';
import { AppUpdaterStatus } from '../constants';

Expand Down Expand Up @@ -75,7 +81,7 @@ const headerTextContainer = css`
export const Header = () => {
const { setAppUpdateShowing } = useRecoilValue(dispatcherState);
const projectId = useRecoilValue(currentProjectIdState);
const projectName = useRecoilValue(botNameState(projectId));
const projectName = useRecoilValue(botDisplayNameState(projectId));
const locale = useRecoilValue(localeState(projectId));
const appUpdate = useRecoilValue(appUpdateState);
const { showing, status } = appUpdate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
dispatcherState,
validateDialogSelectorFamily,
botStatusState,
botNameState,
botDisplayNameState,
luFilesState,
qnaFilesState,
settingsState,
Expand Down Expand Up @@ -62,7 +62,7 @@ export const TestController: React.FC<{ projectId: string }> = (props) => {

const dialogs = useRecoilValue(validateDialogSelectorFamily(projectId));
const botStatus = useRecoilValue(botStatusState(projectId));
const botName = useRecoilValue(botNameState(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
const luFiles = useRecoilValue(luFilesState(projectId));
const settings = useRecoilValue(settingsState(projectId));
const qnaFiles = useRecoilValue(qnaFilesState(projectId));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useRecoilValue } from 'recoil';
import { v4 as uuid } from 'uuid';

import { ContentProps } from '../constants';
import { botNameState } from '../../../../recoilModel';
import { botDisplayNameState } from '../../../../recoilModel';

const styles = {
row: css`
Expand Down Expand Up @@ -51,7 +51,7 @@ const InlineLabelField: React.FC<FieldProps> = (props) => {
};

export const Description: React.FC<ContentProps> = ({ errors, value, schema, onChange, projectId }) => {
const botName = useRecoilValue(botNameState(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
const { $schema, ...rest } = value;

const { hidden, properties } = useMemo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { useRecoilValue } from 'recoil';
import formatMessage from 'format-message';

import { ContentProps, VERSION_REGEX } from '../constants';
import { botNameState, skillManifestsState } from '../../../../recoilModel';
import { botDisplayNameState, skillManifestsState } from '../../../../recoilModel';

const styles = {
container: css`
Expand Down Expand Up @@ -42,7 +42,7 @@ export const getManifestId = (
};

export const SaveManifest: React.FC<ContentProps> = ({ errors, manifest, setSkillManifest, projectId }) => {
const botName = useRecoilValue(botNameState(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
const skillManifests = useRecoilValue(skillManifestsState(projectId));

const { id } = manifest;
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/pages/home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { navigate } from '@reach/router';
import { useRecoilValue } from 'recoil';

import { CreationFlowStatus } from '../../constants';
import { dispatcherState, botNameState } from '../../recoilModel';
import { dispatcherState, botDisplayNameState } from '../../recoilModel';
import {
recentProjectsState,
templateProjectsState,
Expand Down Expand Up @@ -63,7 +63,7 @@ const tutorials = [
const Home: React.FC<RouteComponentProps> = () => {
const templateProjects = useRecoilValue(templateProjectsState);
const projectId = useRecoilValue(currentProjectIdState);
const botName = useRecoilValue(botNameState(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
const recentProjects = useRecoilValue(recentProjectsState);
const templateId = useRecoilValue(templateIdState);
const { openProject, setCreationFlowStatus, onboardingAddCoachMarkRef, saveTemplateId } = useRecoilValue(
Expand Down
5 changes: 3 additions & 2 deletions Composer/packages/client/src/pages/knowledge-base/QnAPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { navigateTo } from '../../utils/navigation';
import { TestController } from '../../components/TestController/TestController';
import { INavTreeItem } from '../../components/NavTree';
import { Page } from '../../components/Page';
import { botNameState, dialogsState, qnaAllUpViewStatusState } from '../../recoilModel/atoms/botState';
import { botDisplayNameState, dialogsState, qnaAllUpViewStatusState } from '../../recoilModel/atoms/botState';
import { dispatcherState } from '../../recoilModel';
import { QnAAllUpViewStatus } from '../../recoilModel/types';

Expand All @@ -31,9 +31,10 @@ interface QnAPageProps extends RouteComponentProps<{}> {

const QnAPage: React.FC<QnAPageProps> = (props) => {
const { dialogId = '', projectId = '' } = props;

const actions = useRecoilValue(dispatcherState);
const dialogs = useRecoilValue(dialogsState(projectId));
const botName = useRecoilValue(botNameState(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
//To do: support other languages
const locale = 'en-us';
//const locale = useRecoilValue(localeState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
skillManifestsState,
dialogSchemasState,
qnaFilesState,
botProjectFileState,
} from '../../recoilModel';

import {
Expand All @@ -38,6 +39,7 @@ export default function useNotifications(projectId: string, filter?: string) {
const skillManifests = useRecoilValue(skillManifestsState(projectId));
const dialogSchemas = useRecoilValue(dialogSchemasState(projectId));
const qnaFiles = useRecoilValue(qnaFilesState(projectId));
const botProjectFile = useRecoilValue(botProjectFileState(projectId));

const botAssets = {
projectId,
Expand All @@ -48,6 +50,7 @@ export default function useNotifications(projectId: string, filter?: string) {
skillManifests,
setting,
dialogSchemas,
botProjectFile,
};

const memoized = useMemo(() => {
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/pages/publish/Publish.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { projectContainer } from '../design/styles';
import {
dispatcherState,
settingsState,
botNameState,
botDisplayNameState,
publishTypesState,
publishHistoryState,
} from '../../recoilModel';
Expand All @@ -36,7 +36,7 @@ const Publish: React.FC<RouteComponentProps<{ projectId: string; targetName?: st
const { projectId = '' } = props;
const [selectedTarget, setSelectedTarget] = useState<PublishTarget | undefined>();
const settings = useRecoilValue(settingsState(projectId));
const botName = useRecoilValue(botNameState(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
const publishTypes = useRecoilValue(publishTypesState(projectId));
const publishHistory = useRecoilValue(publishHistoryState(projectId));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const getProjectLink = (path: string, id?: string) => {
const SettingPage: React.FC<RouteComponentProps> = () => {
const projectId = useRecoilValue(currentProjectIdState);
const {
deleteBotProject,
deleteBot: deleteBotProject,
addLanguageDialogBegin,
addLanguageDialogCancel,
delLanguageDialogBegin,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,21 @@ import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown';
import cloneDeep from 'lodash/cloneDeep';
import { Label } from 'office-ui-fabric-react/lib/Label';

import { dispatcherState, userSettingsState, botNameState, localeState, settingsState } from '../../../recoilModel';
import {
dispatcherState,
userSettingsState,
botDisplayNameState,
localeState,
settingsState,
} from '../../../recoilModel';
import { languageListTemplates } from '../../../components/MultiLanguage';

import { settingsEditor, toolbar } from './style';
import { BotSettings } from './constants';

export const DialogSettings: React.FC<RouteComponentProps<{ projectId: string }>> = (props) => {
const { projectId = '' } = props;
const botName = useRecoilValue(botNameState(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
const locale = useRecoilValue(localeState(projectId));
const settings = useRecoilValue(settingsState(projectId));
const userSettings = useRecoilValue(userSettingsState);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
dispatcherState,
ejectRuntimeSelector,
boilerplateVersionState,
botNameState,
botDisplayNameState,
settingsState,
isEjectRuntimeExistState,
} from '../../../recoilModel';
Expand All @@ -30,7 +30,7 @@ import { breathingSpace, runtimeSettingsStyle, runtimeControls, runtimeToggle, c

export const RuntimeSettings: React.FC<RouteComponentProps<{ projectId: string }>> = (props) => {
const { projectId = '' } = props;
const botName = useRecoilValue(botNameState(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
const settings = useRecoilValue(settingsState(projectId));
const ejectedRuntimeExists = useRecoilValue(isEjectRuntimeExistState(projectId));

Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/pages/skills/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import formatMessage from 'format-message';
import { useRecoilValue } from 'recoil';
import { SkillSetting } from '@bfc/shared';

import { dispatcherState, settingsState, botNameState } from '../../recoilModel';
import { dispatcherState, settingsState, botDisplayNameState } from '../../recoilModel';
import { Toolbar, IToolbarItem } from '../../components/Toolbar';
import { TestController } from '../../components/TestController/TestController';
import { CreateSkillModal } from '../../components/CreateSkillModal';
Expand All @@ -22,7 +22,7 @@ const Skills: React.FC<RouteComponentProps<{ projectId: string }>> = (props) =>
const { projectId = '' } = props;
const [showAddSkillDialogModal, setShowAddSkillDialogModal] = useState(false);

const botName = useRecoilValue(botNameState(projectId));
const botName = useRecoilValue(botDisplayNameState(projectId));
const settings = useRecoilValue(settingsState(projectId));
const { addSkill, setSettings } = useRecoilValue(dispatcherState);

Expand Down
Loading

0 comments on commit 7ca4296

Please sign in to comment.