Skip to content
This repository was archived by the owner on Jan 5, 2026. It is now read-only.

Commit 4e00746

Browse files
authored
Moved shared store code to app/shared. (#2060)
* Moved shared store code to app/shared. * Lint fix.
1 parent 3b1c824 commit 4e00746

359 files changed

Lines changed: 938 additions & 10401 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212

1313
## Fixed
1414
- [client] Hid services pane by default in PR [2059](https://github.com/microsoft/BotFramework-Emulator/pull/2059)
15+
- [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)
1516
- [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)
1617
- [client] Removed buble background on attachments [2067](https://github.com/microsoft/BotFramework-Emulator/pull/2067)
1718
- [client] Fixed an issue where the themes menu was empty on Windows & Linux in PR [2069](https://github.com/microsoft/BotFramework-Emulator/pull/2069)

packages/app/client/src/commands/botCommands.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
3131
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3232
//
33-
import { SharedConstants } from '@bfemulator/app-shared';
33+
import { bot, resources, SharedConstants } from '@bfemulator/app-shared';
3434
import {
3535
BotConfigWithPathImpl,
3636
CommandRegistry,
@@ -39,9 +39,6 @@ import {
3939
} from '@bfemulator/sdk-shared';
4040
import { combineReducers, createStore } from 'redux';
4141

42-
import * as BotActions from '../state/actions/botActions';
43-
import { bot } from '../state/reducers/bot';
44-
import { resources } from '../state/reducers/resources';
4542
import { ActiveBotHelper } from '../ui/helpers/activeBotHelper';
4643

4744
import { BotCommands } from './botCommands';

packages/app/client/src/commands/botCommands.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,23 +31,24 @@
3131
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3232
//
3333

34-
import { getBotDisplayName, SharedConstants } from '@bfemulator/app-shared';
35-
import { BotConfigWithPath, Command, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';
36-
import { IFileService } from 'botframework-config/lib/schema';
37-
import { newNotification } from '@bfemulator/app-shared';
38-
39-
import * as BotActions from '../state/actions/botActions';
40-
import * as FileActions from '../state/actions/fileActions';
4134
import {
35+
beginAdd,
4236
chatFilesUpdated,
4337
chatsDirectoryUpdated,
38+
getBotDisplayName,
39+
newNotification,
4440
transcriptDirectoryUpdated,
4541
transcriptsUpdated,
46-
} from '../state/actions/resourcesActions';
42+
setActive,
43+
setRoot,
44+
SharedConstants,
45+
} from '@bfemulator/app-shared';
46+
import { BotConfigWithPath, Command, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';
47+
import { IFileService } from 'botframework-config/lib/schema';
48+
4749
import { pathExistsInRecentBots } from '../state/helpers/botHelpers';
4850
import { store } from '../state/store';
4951
import { ActiveBotHelper } from '../ui/helpers/activeBotHelper';
50-
import { beginAdd } from '../state/actions/notificationActions';
5152

5253
const Commands = SharedConstants.Commands;
5354

@@ -113,8 +114,8 @@ export class BotCommands {
113114
// Sets a bot as active (called from server-side)
114115
@Command(Commands.Bot.SetActive)
115116
protected async setActiveBot(bot: BotConfigWithPath, botDirectory: string) {
116-
store.dispatch(BotActions.setActive(bot));
117-
store.dispatch(FileActions.setRoot(botDirectory));
117+
store.dispatch(setActive(bot));
118+
store.dispatch(setRoot(botDirectory));
118119
await Promise.all([
119120
this.commandService.remoteCall(Commands.Electron.UpdateFileMenu),
120121
this.commandService.remoteCall(Commands.Electron.SetTitleBar, getBotDisplayName(bot)),

packages/app/client/src/commands/emulatorCommands.spec.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,16 @@
3131
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3232
//
3333

34-
import { SharedConstants } from '@bfemulator/app-shared';
34+
import {
35+
beginAdd,
36+
close,
37+
closeDocument as closeChatDocument,
38+
openBotViaUrlAction,
39+
openTranscript,
40+
SharedConstants,
41+
} from '@bfemulator/app-shared';
3542
import { CommandRegistry, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';
3643

37-
import { beginAdd } from '../state/actions/notificationActions';
38-
import { close } from '../state/actions/editorActions';
39-
import { openTranscript, closeDocument } from '../state/actions/chatActions';
40-
import { openBotViaUrlAction } from '../state';
41-
4244
import { EmulatorCommands } from './emulatorCommands';
4345

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

161163
expect(mockStore.dispatch).toHaveBeenCalledWith(close(SharedConstants.EDITOR_KEY_PRIMARY, mockFilePath));
162-
expect(mockStore.dispatch).toHaveBeenCalledWith(closeDocument(mockFilePath));
164+
expect(mockStore.dispatch).toHaveBeenCalledWith(closeChatDocument(mockFilePath));
163165
expect(mockStore.dispatch).toHaveBeenCalledWith(openTranscript(mockFilename));
164166
});
165167
});

packages/app/client/src/commands/emulatorCommands.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,22 @@
3131
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3232
//
3333

34-
import { newNotification, SharedConstants } from '@bfemulator/app-shared';
34+
import {
35+
beginAdd,
36+
closeDocument as closeChatDocument,
37+
close as closeEditorDocument,
38+
newNotification,
39+
openBotViaUrlAction,
40+
openTranscript,
41+
SharedConstants,
42+
} from '@bfemulator/app-shared';
3543
import { ChannelService, CommandServiceImpl, CommandServiceInstance } from '@bfemulator/sdk-shared';
3644
import { IEndpointService } from 'botframework-config/lib/schema';
3745
import { Command } from '@bfemulator/sdk-shared';
3846
import { EmulatorMode } from '@bfemulator/sdk-shared';
3947

40-
import * as ChatActions from '../state/actions/chatActions';
41-
import * as EditorActions from '../state/actions/editorActions';
42-
import { beginAdd } from '../state/actions/notificationActions';
4348
import { getTabGroupForDocument } from '../state/helpers/editorHelpers';
4449
import { store } from '../state/store';
45-
import { openBotViaUrlAction } from '../state';
4650

4751
const {
4852
Emulator,
@@ -91,7 +95,7 @@ export class EmulatorCommands {
9195
const { ShowOpenDialog } = SharedConstants.Commands.Electron;
9296
const filename: string = await this.commandService.remoteCall(ShowOpenDialog, dialogOptions);
9397
if (filename) {
94-
store.dispatch(ChatActions.openTranscript(filename));
98+
store.dispatch(openTranscript(filename));
9599
this.commandService
96100
.remoteCall(TrackEvent, 'transcriptFile_open', {
97101
method: 'file_menu',
@@ -111,9 +115,9 @@ export class EmulatorCommands {
111115
protected reloadTranscript(filePath: string, filename: string) {
112116
const tabGroup = getTabGroupForDocument(filePath);
113117
if (tabGroup) {
114-
store.dispatch(EditorActions.close(getTabGroupForDocument(filePath), filePath));
115-
store.dispatch(ChatActions.closeDocument(filePath));
118+
store.dispatch(closeEditorDocument(getTabGroupForDocument(filePath), filePath));
119+
store.dispatch(closeChatDocument(filePath));
116120
}
117-
store.dispatch(ChatActions.openTranscript(filename));
121+
store.dispatch(openTranscript(filename));
118122
}
119123
}

packages/app/client/src/commands/fileCommands.spec.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
//
3333

3434
import { CommandServiceImpl, CommandRegistry, CommandServiceInstance } from '@bfemulator/sdk-shared';
35-
import { SharedConstants } from '@bfemulator/app-shared';
36-
37-
import { addFile, removeFile, clear } from '../state/actions/fileActions';
38-
import { addDocPendingChange } from '../state/actions/editorActions';
35+
import { addDocPendingChange, addFile, clear, removeFile, SharedConstants } from '@bfemulator/app-shared';
3936

4037
import { FileCommands } from './fileCommands';
4138

packages/app/client/src/commands/fileCommands.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,17 @@
3131
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3232
//
3333

34-
import { isChatFile, isTranscriptFile, SharedConstants } from '@bfemulator/app-shared';
34+
import {
35+
addDocPendingChange,
36+
addFile,
37+
clear,
38+
isChatFile,
39+
isTranscriptFile,
40+
removeFile,
41+
SharedConstants,
42+
} from '@bfemulator/app-shared';
3543
import { Command } from '@bfemulator/sdk-shared';
3644

37-
import * as EditorActions from '../state/actions/editorActions';
38-
import * as FileActions from '../state/actions/fileActions';
3945
import { store } from '../state/store';
4046

4147
const { File } = SharedConstants.Commands;
@@ -46,21 +52,21 @@ export class FileCommands {
4652
// Adds a file to the file store
4753
@Command(File.Add)
4854
protected addFileToStore(payload) {
49-
store.dispatch(FileActions.addFile(payload));
55+
store.dispatch(addFile(payload));
5056
}
5157

5258
// ---------------------------------------------------------------------------
5359
// Removes a file from the file store
5460
@Command(File.Remove)
5561
protected removeFileFromStore(path) {
56-
store.dispatch(FileActions.removeFile(path));
62+
store.dispatch(removeFile(path));
5763
}
5864

5965
// ---------------------------------------------------------------------------
6066
// Clears the file store
6167
@Command(File.Clear)
6268
protected clearFileStore() {
63-
store.dispatch(FileActions.clear());
69+
store.dispatch(clear());
6470
}
6571

6672
// ---------------------------------------------------------------------------
@@ -69,7 +75,7 @@ export class FileCommands {
6975
protected fileChangedOnDisk(filename: string) {
7076
// add the filename to pending updates and prompt the user once the document is focused again
7177
if (isChatFile(filename) || isTranscriptFile(filename)) {
72-
store.dispatch(EditorActions.addDocPendingChange(filename));
78+
store.dispatch(addDocPendingChange(filename));
7379
}
7480
}
7581
}

packages/app/client/src/commands/notificationCommands.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@
3232
//
3333

3434
import { CommandServiceImpl, CommandRegistry, CommandServiceInstance } from '@bfemulator/sdk-shared';
35-
import { SharedConstants } from '@bfemulator/app-shared';
36-
37-
import { beginAdd, beginRemove } from '../state/actions/notificationActions';
35+
import { beginAdd, beginRemove, SharedConstants } from '@bfemulator/app-shared';
3836

3937
import { NotificationCommands } from './notificationCommands';
4038

packages/app/client/src/commands/notificationCommands.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@
3131
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3232
//
3333

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

37-
import * as NotificationActions from '../state/actions/notificationActions';
3837
import { store } from '../state/store';
3938
import { getGlobal } from '../utils';
4039

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

53-
store.dispatch(NotificationActions.beginAdd(notification));
52+
store.dispatch(beginAdd(notification));
5453
}
5554

5655
// ---------------------------------------------------------------------------
5756
// Removes a notification from the store / notification manager
5857
@Command(Commands.Remove)
5958
protected removeNotificationFromStore(id: string) {
60-
store.dispatch(NotificationActions.beginRemove(id));
59+
store.dispatch(beginRemove(id));
6160
}
6261
}

packages/app/client/src/commands/settingsCommands.spec.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@
3232
//
3333

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

38-
import { clientAwareSettings } from '../state/reducers/clientAwareSettings';
3938
import { store } from '../state/store';
40-
import { clientAwareSettingsChanged } from '../state/actions/clientAwareSettingsActions';
4139

4240
import { SettingsCommands } from './settingsCommands';
4341

0 commit comments

Comments
 (0)