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
Show all changes
33 commits
Select commit Hold shift + click to select a range
1cf8239
per slot dialog settings with optional obfucate
hailiu2586 Oct 16, 2019
ea33bf1
switch to choice group instead of dropdown
hailiu2586 Oct 16, 2019
9e95a79
use createPortal to project show-keys toggle
hailiu2586 Oct 17, 2019
62fd08b
Merge branch 'master' into hailiu/settings-ui
hailiu2586 Oct 17, 2019
13067b8
fix integration test for breadcrumb
hailiu2586 Oct 17, 2019
1b55347
use formatMessage for textual content
hailiu2586 Oct 17, 2019
9df430b
change text content
hailiu2586 Oct 17, 2019
f305d61
hide settings by default
hailiu2586 Oct 18, 2019
2b03f41
fix typo
hailiu2586 Oct 18, 2019
a833af3
Merge branch 'master' into hailiu/settings-ui
hailiu2586 Oct 18, 2019
5f030e6
fix lint and test:coverage
hailiu2586 Oct 18, 2019
3ce4433
fix test:coerage
hailiu2586 Oct 18, 2019
de09379
fix build
hailiu2586 Oct 18, 2019
c060771
Merge branch 'master' into hailiu/settings-ui
hailiu2586 Oct 18, 2019
8ed0bd9
udpate copy text
hailiu2586 Oct 18, 2019
84dd0c4
Update Composer/packages/client/src/utils/objUtil.ts
hailiu2586 Oct 18, 2019
5b9ee8e
fix hosted routes
hailiu2586 Oct 18, 2019
7f55036
fix open bot emulator
hailiu2586 Oct 19, 2019
5559c59
refactor cross frame state data
hailiu2586 Oct 21, 2019
197ebe7
Merge branch 'master' into hailiu/settings-ui
hailiu2586 Oct 21, 2019
f4d7231
fix setDialogSettingsSlot
hailiu2586 Oct 21, 2019
55d2db0
fix args order'
hailiu2586 Oct 21, 2019
1840d7a
add save button to hosted settings edit UI
hailiu2586 Oct 21, 2019
9fc9500
clean up obfuscate
hailiu2586 Oct 21, 2019
49df0fb
remove code-mirror
hailiu2586 Oct 21, 2019
6538362
Merge branch 'master' into hailiu/settings-ui
a-b-r-o-w-n Oct 22, 2019
18c141e
convert to css-in-js
a-b-r-o-w-n Oct 22, 2019
2505026
Merge branch 'master' into hailiu/settings-ui
a-b-r-o-w-n Oct 22, 2019
e8c8892
add hosted to ShellData type
a-b-r-o-w-n Oct 22, 2019
ac699c5
fix lint issue
hailiu2586 Oct 22, 2019
d52d698
add emotion babel plugin for test
a-b-r-o-w-n Oct 23, 2019
d8b0942
require jsx pragma
a-b-r-o-w-n Oct 23, 2019
5bcc37e
Merge branch 'master' into hailiu/settings-ui
hailiu2586 Oct 23, 2019
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
1 change: 1 addition & 0 deletions Composer/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
],
'@babel/preset-react',
'@babel/preset-typescript',
'@emotion/babel-preset-css-prop',
],
plugins: ['@babel/plugin-proposal-class-properties', '@babel/plugin-transform-runtime'],
},
Expand Down
2 changes: 1 addition & 1 deletion Composer/cypress/integration/Breadcrumb.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ context('breadcrumb', () => {
it('can show action name in breadcrumb', () => {
cy.wait(100);
cy.get('[data-testid="ProjectTree"]').within(() => {
cy.getByText('Handle ConversationUpdate').click();
cy.getByText('Handle an Event: BeginDialog').click();
cy.wait(500);
});

Expand Down
1 change: 1 addition & 0 deletions Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"@babel/preset-env": "7.3.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@emotion/babel-preset-css-prop": "^10.0.17",
"@typescript-eslint/eslint-plugin": "2.4.0",
"@typescript-eslint/parser": "2.4.0",
"babel-jest": "24.0.0",
Expand Down
1 change: 1 addition & 0 deletions Composer/packages/client/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = {
},
],
'@babel/preset-react',
'@emotion/babel-preset-css-prop',
],
plugins: ['@babel/plugin-proposal-class-properties', '@babel/plugin-transform-runtime'],
},
Expand Down
2 changes: 2 additions & 0 deletions Composer/packages/client/src/ShellApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import * as lgUtil from './utils/lgUtil';
import { StoreContext } from './store';
import ApiClient from './messenger/ApiClient';
import { getDialogData, setDialogData, sanitizeDialogData } from './utils';
import { isAbsHosted } from './utils/envUtil';
import { OpenAlertModal, DialogStyle } from './components/Modal';
import { getFocusPath, navigateTo } from './utils/navigation';

Expand Down Expand Up @@ -171,6 +172,7 @@ export const ShellApi: React.FC = () => {
focusedEvent: selected,
focusedSteps: focused ? [focused] : selected ? [selected] : [],
focusedTab: promptTab,
hosted: !!isAbsHosted(),
};
}

Expand Down
3 changes: 1 addition & 2 deletions Composer/packages/client/src/TestController.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { bot, botButton, calloutLabel, calloutDescription, calloutContainer } fr
import { BotStatus, LuisConfig, Text } from './constants';
import { PublishLuisDialog } from './publishDialog';
import { OpenAlertModal, DialogStyle } from './components/Modal';
import { isAbsHosted } from './utils/envUtil';
import { getReferredFiles } from './utils/luUtil';

const openInEmulator = (url, authSettings: { MicrosoftAppId: string; MicrosoftAppPassword: string }) => {
Expand All @@ -37,8 +38,6 @@ const STATE = {
SUCCESS: 2,
};

const isAbsHosted = () => process.env.COMPOSER_AUTH_PROVIDER === 'abs-h';

export const TestController: React.FC = () => {
const { state, actions } = useContext(StoreContext);
const [modalOpen, setModalOpen] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/** @jsx jsx */
import { jsx } from '@emotion/core';
import React, { useEffect, useState, useContext } from 'react';
import { Spinner, SpinnerSize, Dialog, DialogType, DialogFooter, PrimaryButton } from 'office-ui-fabric-react';
import formatMessage from 'format-message';
Expand Down Expand Up @@ -60,9 +62,9 @@ export const RequireAuth: React.FC = props => {
}

return (
<>
<React.Fragment>
{sessionExpiredDialog}
{props.children}
</>
</React.Fragment>
);
};

This file was deleted.

125 changes: 125 additions & 0 deletions Composer/packages/client/src/pages/setting/dialog-settings/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/** @jsx jsx */
import { jsx } from '@emotion/core';
import { useState, useContext, useEffect } from 'react';
import { RichEditor } from 'code-editor';
import formatMessage from 'format-message';
import { DefaultButton, ChoiceGroup, Link, Toggle } from 'office-ui-fabric-react';

import { StoreContext } from '../../../store';
import { isAbsHosted } from '../../../utils/envUtil';
import { obfuscate } from '../../../utils/objUtil';

import { hostedSettings, hostedControls, hostedToggle, slotChoice, settingsEditor } from './style';

const hostControlLabels = {
showKeys: formatMessage('Show keys'),
productionSlot: formatMessage('In production'),
integrationSlot: formatMessage('In test'),
botSettings: formatMessage('Settings'),
botSettingDescription: formatMessage(
'Settings contains detailed information about your bot. For security reasons, they are hidden by default. To test your bot or publish to Azure, you may need to provide these settings.'
),
learnMore: formatMessage('Learn more.'),
};

export const DialogSettings = () => {
const { state, actions } = useContext(StoreContext);
const { botName, settings: origSettings, botEnvironment } = state;
const absHosted = isAbsHosted();
const { luis, MicrosoftAppPassword, MicrosoftAppId, ...settings } = origSettings;
const managedSettings = { luis, MicrosoftAppPassword, MicrosoftAppId };
const visibleSettings = absHosted ? settings : origSettings;
const [value, setValue] = useState(JSON.stringify(visibleSettings, null, 2));
const [editing, setEditing] = useState(false);
const [slot, setSlot] = useState(botEnvironment === 'editing' ? 'integration' : botEnvironment);
const [parseError, setParseError] = useState('');

useEffect(() => {
setValue(JSON.stringify(editing ? visibleSettings : obfuscate(visibleSettings), null, 2));
}, [origSettings, editing]);

const changeEditing = (_, on) => {
setEditing(on);
actions.setEditDialogSettings(on, absHosted ? slot : undefined);
};

const slots = [
{ key: 'production', text: hostControlLabels.productionSlot, checked: slot === 'production' },
{ key: 'integration', text: hostControlLabels.integrationSlot, checked: slot === 'integration' },
];

const changeSlot = (_, option) => {
setSlot(option.key);
actions.setDialogSettingsSlot(editing, option.key);
};

const hostedControl = () => (
<div css={hostedControls}>
<h1>{hostControlLabels.botSettings}</h1>
<p>
{hostControlLabels.botSettingDescription}
&nbsp;
<Link href="//aka.ms/absh/docs/settings" target="_blank">
{hostControlLabels.learnMore}
</Link>
</p>
{absHosted ? <ChoiceGroup options={slots} onChange={changeSlot} css={slotChoice} selectedKey={slot} /> : null}
</div>
);

const toggle = () => (
<div css={hostedToggle}>
<Toggle label={hostControlLabels.showKeys} inlineLabel onChange={changeEditing} defaultChecked={editing} />
{absHosted && (
<DefaultButton disabled={!editing} text={formatMessage('Save')} onClick={() => handleChange(value, true)} />
)}
</div>
);

const saveChangeResult = result => {
try {
const mergedResult = absHosted ? { ...managedSettings, ...result } : result;
actions.setSettings(botName, mergedResult, absHosted ? slot : undefined);
} catch (err) {
console.error(err.message);
}
};

const handleChange = (value, commit) => {
setValue(value);
try {
const result = JSON.parse(value);
if (commit || !absHosted) {
saveChangeResult(result);
}
} catch (err) {
setParseError('invalid json');
}
};

const handleMount = monaco => {
monaco.languages.json.jsonDefaults.setDiagnosticsOptions({
validate: true,
});
};

return botName ? (
<div css={hostedSettings}>
{hostedControl()}
{toggle()}
<div css={settingsEditor}>
<RichEditor
language="json"
onChange={x => handleChange(x, false)}
errorMsg={parseError}
editorWillMount={handleMount}
options={{ folding: true, readOnly: !editing }}
value={value}
helpURL="https://www.json.org"
/>
</div>
</div>
) : (
<div>{formatMessage('Data loading...')}</div>
);
};

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { css } from '@emotion/core';

export const hostedSettings = css`
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
padding: 1rem;
display: flex;
flex-direction: column;
box-sizing: border-box;
`;

export const hostedControls = css`
margin-bottom: 18px;

& > h1 {
margin-top: 0;
}
`;

export const hostedToggle = css`
display: flex;

& > * {
margin-right: 2rem;
}
`;

export const slotChoice = css`
max-width: 40ch;
`;

export const settingsEditor = css`
flex: 1;
max-height: 70%;
`;
20 changes: 12 additions & 8 deletions Composer/packages/client/src/pages/setting/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Link } from '@reach/router';

import { ToolBar } from '../../components/ToolBar';
import { navigateTo } from '../../utils';
import { isAbsHosted } from '../../utils/envUtil';

import Routes from './router';
import { Tree } from './../../components/Tree/index';
Expand All @@ -13,19 +14,22 @@ import { title, fileList, contentEditor, linkItem } from './styles';
import { MainContent } from './../../components/MainContent/index';
import { TestController } from './../../TestController';

const settingLabels = {
title: formatMessage('Configuration'),
publish: formatMessage('Publish'),
settings: formatMessage('Settings'),
};

const absHosted = isAbsHosted();

const links = [
{ key: '/setting/dialog-settings', name: formatMessage('Dialog settings') },
{ key: '/setting/dialog-settings', name: settingLabels.settings },
{ key: `/setting/${absHosted ? 'remote-publish' : 'deployment'}`, name: settingLabels.publish },
// { key: 'services', name: formatMessage('Services') },
// { key: 'composer-configuration', name: formatMessage('Composer configuration'), disabled: true },
// { key: 'publishing-staging', name: formatMessage('Publishing and staging'), disabled: true },
];

if (process.env.COMPOSER_AUTH_PROVIDER === 'abs-h' || process.env.MOCKHOSTED) {
links.push({ key: '/setting/remote-publish', name: formatMessage('Publish') });
} else {
links.push({ key: '/setting/deployment', name: formatMessage('Deployment') });
}

export const SettingPage = () => {
const [active, setActive] = useState();

Expand Down Expand Up @@ -63,7 +67,7 @@ export const SettingPage = () => {
<div css={fileList}>
<Tree variant="large">
<div>
<div css={title}>{formatMessage('Settings')}</div>
<div css={title}>{settingLabels.title}</div>
<Nav
groups={[{ links }]}
onRenderLink={onRenderLink}
Expand Down
Loading