Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved shared store code to app/shared. #2060

Merged
merged 3 commits into from
Jan 30, 2020
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Fixed
- [client] Hid services pane by default in PR [2059](https://github.com/microsoft/BotFramework-Emulator/pull/2059)
- [client/main] Moved duplicate redux store code (actions / reducers / helpers) to `app/shared` package in PR [2060](https://github.com/microsoft/BotFramework-Emulator/pull/2060)
- [client] Fixed an issue where trying to add a QnA KB manually after signing into Azure was causing the app to crash in PR [2066](https://github.com/microsoft/BotFramework-Emulator/pull/2066)
- [client] Removed buble background on attachments [2067](https://github.com/microsoft/BotFramework-Emulator/pull/2067)
- [client] Fixed an issue where the themes menu was empty on Windows & Linux in PR [2069](https://github.com/microsoft/BotFramework-Emulator/pull/2069)
Expand Down
5 changes: 1 addition & 4 deletions packages/app/client/src/commands/botCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import { SharedConstants } from '@bfemulator/app-shared';
import { bot, resources, SharedConstants } from '@bfemulator/app-shared';
import {
BotConfigWithPathImpl,
CommandRegistry,
Expand All @@ -39,9 +39,6 @@ import {
} from '@bfemulator/sdk-shared';
import { combineReducers, createStore } from 'redux';

import * as BotActions from '../state/actions/botActions';
import { bot } from '../state/reducers/bot';
import { resources } from '../state/reducers/resources';
import { ActiveBotHelper } from '../ui/helpers/activeBotHelper';

import { BotCommands } from './botCommands';
Expand Down
23 changes: 12 additions & 11 deletions packages/app/client/src/commands/botCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { getBotDisplayName, SharedConstants } from '@bfemulator/app-shared';
import { BotConfigWithPath, Command, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';
import { IFileService } from 'botframework-config/lib/schema';
import { newNotification } from '@bfemulator/app-shared';

import * as BotActions from '../state/actions/botActions';
import * as FileActions from '../state/actions/fileActions';
import {
beginAdd,
chatFilesUpdated,
chatsDirectoryUpdated,
getBotDisplayName,
newNotification,
transcriptDirectoryUpdated,
transcriptsUpdated,
} from '../state/actions/resourcesActions';
setActive,
setRoot,
SharedConstants,
} from '@bfemulator/app-shared';
import { BotConfigWithPath, Command, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';
import { IFileService } from 'botframework-config/lib/schema';

import { pathExistsInRecentBots } from '../state/helpers/botHelpers';
import { store } from '../state/store';
import { ActiveBotHelper } from '../ui/helpers/activeBotHelper';
import { beginAdd } from '../state/actions/notificationActions';

const Commands = SharedConstants.Commands;

Expand Down Expand Up @@ -113,8 +114,8 @@ export class BotCommands {
// Sets a bot as active (called from server-side)
@Command(Commands.Bot.SetActive)
protected async setActiveBot(bot: BotConfigWithPath, botDirectory: string) {
store.dispatch(BotActions.setActive(bot));
store.dispatch(FileActions.setRoot(botDirectory));
store.dispatch(setActive(bot));
store.dispatch(setRoot(botDirectory));
await Promise.all([
this.commandService.remoteCall(Commands.Electron.UpdateFileMenu),
this.commandService.remoteCall(Commands.Electron.SetTitleBar, getBotDisplayName(bot)),
Expand Down
16 changes: 9 additions & 7 deletions packages/app/client/src/commands/emulatorCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { SharedConstants } from '@bfemulator/app-shared';
import {
beginAdd,
close,
closeDocument as closeChatDocument,
openBotViaUrlAction,
openTranscript,
SharedConstants,
} from '@bfemulator/app-shared';
import { CommandRegistry, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';

import { beginAdd } from '../state/actions/notificationActions';
import { close } from '../state/actions/editorActions';
import { openTranscript, closeDocument } from '../state/actions/chatActions';
import { openBotViaUrlAction } from '../state';

import { EmulatorCommands } from './emulatorCommands';

let mockState = {};
Expand Down Expand Up @@ -159,7 +161,7 @@ describe('The emulator commands', () => {
handler(mockFilePath, mockFilename);

expect(mockStore.dispatch).toHaveBeenCalledWith(close(SharedConstants.EDITOR_KEY_PRIMARY, mockFilePath));
expect(mockStore.dispatch).toHaveBeenCalledWith(closeDocument(mockFilePath));
expect(mockStore.dispatch).toHaveBeenCalledWith(closeChatDocument(mockFilePath));
expect(mockStore.dispatch).toHaveBeenCalledWith(openTranscript(mockFilename));
});
});
22 changes: 13 additions & 9 deletions packages/app/client/src/commands/emulatorCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,22 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { newNotification, SharedConstants } from '@bfemulator/app-shared';
import {
beginAdd,
closeDocument as closeChatDocument,
close as closeEditorDocument,
newNotification,
openBotViaUrlAction,
openTranscript,
SharedConstants,
} from '@bfemulator/app-shared';
import { ChannelService, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';
import { IEndpointService } from 'botframework-config/lib/schema';
import { Command } from '@bfemulator/sdk-shared';
import { EmulatorMode } from '@bfemulator/sdk-shared';

import * as ChatActions from '../state/actions/chatActions';
import * as EditorActions from '../state/actions/editorActions';
import { beginAdd } from '../state/actions/notificationActions';
import { getTabGroupForDocument } from '../state/helpers/editorHelpers';
import { store } from '../state/store';
import { openBotViaUrlAction } from '../state';

const {
Emulator,
Expand Down Expand Up @@ -91,7 +95,7 @@ export class EmulatorCommands {
const { ShowOpenDialog } = SharedConstants.Commands.Electron;
const filename: string = await this.commandService.remoteCall(ShowOpenDialog, dialogOptions);
if (filename) {
store.dispatch(ChatActions.openTranscript(filename));
store.dispatch(openTranscript(filename));
this.commandService
.remoteCall(TrackEvent, 'transcriptFile_open', {
method: 'file_menu',
Expand All @@ -111,9 +115,9 @@ export class EmulatorCommands {
protected reloadTranscript(filePath: string, filename: string) {
const tabGroup = getTabGroupForDocument(filePath);
if (tabGroup) {
store.dispatch(EditorActions.close(getTabGroupForDocument(filePath), filePath));
store.dispatch(ChatActions.closeDocument(filePath));
store.dispatch(closeEditorDocument(getTabGroupForDocument(filePath), filePath));
store.dispatch(closeChatDocument(filePath));
}
store.dispatch(ChatActions.openTranscript(filename));
store.dispatch(openTranscript(filename));
}
}
5 changes: 1 addition & 4 deletions packages/app/client/src/commands/fileCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@
//

import { CommandServiceImpl, CommandRegistry, CommandServiceInstance } from '@bfemulator/sdk-shared';
import { SharedConstants } from '@bfemulator/app-shared';

import { addFile, removeFile, clear } from '../state/actions/fileActions';
import { addDocPendingChange } from '../state/actions/editorActions';
import { addDocPendingChange, addFile, clear, removeFile, SharedConstants } from '@bfemulator/app-shared';

import { FileCommands } from './fileCommands';

Expand Down
20 changes: 13 additions & 7 deletions packages/app/client/src/commands/fileCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,17 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { isChatFile, isTranscriptFile, SharedConstants } from '@bfemulator/app-shared';
import {
addDocPendingChange,
addFile,
clear,
isChatFile,
isTranscriptFile,
removeFile,
SharedConstants,
} from '@bfemulator/app-shared';
import { Command } from '@bfemulator/sdk-shared';

import * as EditorActions from '../state/actions/editorActions';
import * as FileActions from '../state/actions/fileActions';
import { store } from '../state/store';

const { File } = SharedConstants.Commands;
Expand All @@ -46,21 +52,21 @@ export class FileCommands {
// Adds a file to the file store
@Command(File.Add)
protected addFileToStore(payload) {
store.dispatch(FileActions.addFile(payload));
store.dispatch(addFile(payload));
}

// ---------------------------------------------------------------------------
// Removes a file from the file store
@Command(File.Remove)
protected removeFileFromStore(path) {
store.dispatch(FileActions.removeFile(path));
store.dispatch(removeFile(path));
}

// ---------------------------------------------------------------------------
// Clears the file store
@Command(File.Clear)
protected clearFileStore() {
store.dispatch(FileActions.clear());
store.dispatch(clear());
}

// ---------------------------------------------------------------------------
Expand All @@ -69,7 +75,7 @@ export class FileCommands {
protected fileChangedOnDisk(filename: string) {
// add the filename to pending updates and prompt the user once the document is focused again
if (isChatFile(filename) || isTranscriptFile(filename)) {
store.dispatch(EditorActions.addDocPendingChange(filename));
store.dispatch(addDocPendingChange(filename));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@
//

import { CommandServiceImpl, CommandRegistry, CommandServiceInstance } from '@bfemulator/sdk-shared';
import { SharedConstants } from '@bfemulator/app-shared';

import { beginAdd, beginRemove } from '../state/actions/notificationActions';
import { beginAdd, beginRemove, SharedConstants } from '@bfemulator/app-shared';

import { NotificationCommands } from './notificationCommands';

Expand Down
7 changes: 3 additions & 4 deletions packages/app/client/src/commands/notificationCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { Notification, SharedConstants } from '@bfemulator/app-shared';
import { beginAdd, beginRemove, Notification, SharedConstants } from '@bfemulator/app-shared';
import { Command } from '@bfemulator/sdk-shared';

import * as NotificationActions from '../state/actions/notificationActions';
import { store } from '../state/store';
import { getGlobal } from '../utils';

Expand All @@ -50,13 +49,13 @@ export class NotificationCommands {
notification = getGlobal(SharedConstants.NOTIFICATION_FROM_MAIN);
}

store.dispatch(NotificationActions.beginAdd(notification));
store.dispatch(beginAdd(notification));
}

// ---------------------------------------------------------------------------
// Removes a notification from the store / notification manager
@Command(Commands.Remove)
protected removeNotificationFromStore(id: string) {
store.dispatch(NotificationActions.beginRemove(id));
store.dispatch(beginRemove(id));
}
}
4 changes: 1 addition & 3 deletions packages/app/client/src/commands/settingsCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@
//

import { CommandRegistry, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';
import { SharedConstants } from '@bfemulator/app-shared';
import { clientAwareSettings, clientAwareSettingsChanged, SharedConstants } from '@bfemulator/app-shared';
import { combineReducers, createStore } from 'redux';

import { clientAwareSettings } from '../state/reducers/clientAwareSettings';
import { store } from '../state/store';
import { clientAwareSettingsChanged } from '../state/actions/clientAwareSettingsActions';

import { SettingsCommands } from './settingsCommands';

Expand Down
3 changes: 1 addition & 2 deletions packages/app/client/src/commands/settingsCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { ClientAwareSettings, SharedConstants } from '@bfemulator/app-shared';
import { clientAwareSettingsChanged, ClientAwareSettings, SharedConstants } from '@bfemulator/app-shared';
import { Command } from '@bfemulator/sdk-shared';

import { clientAwareSettingsChanged } from '../state/actions/clientAwareSettingsActions';
import { store } from '../state/store';

const { Settings } = SharedConstants.Commands;
Expand Down
14 changes: 10 additions & 4 deletions packages/app/client/src/commands/uiCommands.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,19 @@
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
import { SharedConstants } from '@bfemulator/app-shared';
import {
invalidateArmToken,
AzureAuthAction,
AzureAuthWorkflow,
EditorActions,
NavBarActions,
OpenEditorAction,
SelectNavBarAction,
SharedConstants,
} from '@bfemulator/app-shared';
import { CommandRegistry, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';

import { CONTENT_TYPE_APP_SETTINGS, DOCUMENT_ID_APP_SETTINGS } from '../constants';
import { AzureAuthAction, AzureAuthWorkflow, invalidateArmToken } from '../state/actions/azureAuthActions';
import { EditorActions, OpenEditorAction } from '../state/actions/editorActions';
import { NavBarActions, SelectNavBarAction } from '../state/actions/navBarActions';
import * as editorHelpers from '../state/helpers/editorHelpers';
import { store } from '../state/store';
import {
Expand Down
33 changes: 17 additions & 16 deletions packages/app/client/src/commands/uiCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,26 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { newNotification, SharedConstants } from '@bfemulator/app-shared';
import { Command, CommandServiceImpl, CommandServiceInstance, StartConversationParams } from '@bfemulator/sdk-shared';
import { ServiceTypes } from 'botframework-config/lib/schema';
import { ComponentClass } from 'react';

import * as Constants from '../constants';
import {
azureArmTokenDataChanged,
beginAdd,
beginAzureAuthWorkflow,
invalidateArmToken,
} from '../state/actions/azureAuthActions';
import * as EditorActions from '../state/actions/editorActions';
import * as NavBarActions from '../state/actions/navBarActions';
import { ProgressIndicatorPayload, updateProgressIndicator } from '../state/actions/progressIndicatorActions';
import { switchTheme } from '../state/actions/themeActions';
newNotification,
open as openDocument,
select as selectNavBar,
switchTheme,
updateProgressIndicator,
AzureAuthState,
ProgressIndicatorPayload,
SharedConstants,
} from '@bfemulator/app-shared';
import { Command, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';
import { ServiceTypes } from 'botframework-config/lib/schema';
import { ComponentClass } from 'react';

import * as Constants from '../constants';
import { showMarkdownPage, showWelcomePage } from '../state/helpers/editorHelpers';
import { AzureAuthState } from '../state/reducers/azureAuth';
import { store } from '../state/store';
import {
AzureLoginFailedDialogContainer,
Expand All @@ -64,8 +67,6 @@ import {
UpdateUnavailableDialogContainer,
DataCollectionDialogContainer,
} from '../ui/dialogs';
import { openBotViaUrlAction } from '../state/actions/botActions';
import { beginAdd } from '../state/actions/notificationActions';
import { OpenBotDialogProps } from '../ui/dialogs/openBotDialog/openBotDialog';

const { UI, Telemetry } = SharedConstants.Commands;
Expand Down Expand Up @@ -138,7 +139,7 @@ export class UiCommands {
// Switches navbar tab selection
@Command(UI.SwitchNavBarTab)
protected switchNavBar(tabName: string): void {
store.dispatch(NavBarActions.select(tabName));
store.dispatch(selectNavBar(tabName));
}

// ---------------------------------------------------------------------------
Expand All @@ -147,7 +148,7 @@ export class UiCommands {
protected showAppSettings(): void {
const { CONTENT_TYPE_APP_SETTINGS, DOCUMENT_ID_APP_SETTINGS } = Constants;
store.dispatch(
EditorActions.open({
openDocument({
contentType: CONTENT_TYPE_APP_SETTINGS,
documentId: DOCUMENT_ID_APP_SETTINGS,
isGlobal: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/app/client/src/platform/log/logService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

import { appendToLog } from '../../state/actions/chatActions';
import { appendToLog } from '@bfemulator/app-shared';

import { logService } from './logService';

Expand Down
Loading