Skip to content

Commit

Permalink
fix: make copy, move and paste work for one bot instead of cross bots (
Browse files Browse the repository at this point in the history
…#4938)

* remove the border from the project tree header when clicking it

* fix: Make copy move and paste work for just in bot

* fix unit test
  • Loading branch information
lei9444 authored Nov 23, 2020
1 parent d18422c commit 5406ec0
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export const ProjectTree: React.FC<Props> = ({
{
label: formatMessage('Settings'),
onClick: () => {
navigateTo(createBotSettingUrl(bot.projectId, link.skillId));
navigateTo(createBotSettingUrl(link.projectId, link.skillId));
},
},
]
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/src/recoilModel/atoms/appState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const onboardingState = atom<{
},
});

export const clipboardActionsState = atom<any[]>({
export const clipboardActionsState = atomFamily<any[], string>({
key: getFullyQualifiedKey('clipboardActions'),
default: [],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('Editor dispatcher', () => {
beforeEach(() => {
const useRecoilTestHook = () => {
const [visualEditorState, setVisualEditorState] = useRecoilState(visualEditorSelectionState);
const [clipboardState, setClipboardActionsState] = useRecoilState(clipboardActionsState);
const [clipboardState, setClipboardActionsState] = useRecoilState(clipboardActionsState('test'));
const currentDispatcher = useRecoilValue(dispatcherState);

return {
Expand All @@ -30,7 +30,7 @@ describe('Editor dispatcher', () => {
const { result } = renderRecoilHook(useRecoilTestHook, {
states: [
{ recoilState: visualEditorSelectionState, initialValue: [{ action1: 'initialVisualEditorValue' }] },
{ recoilState: clipboardActionsState, initialValue: [{ action1: 'initialClipboardVal' }] },
{ recoilState: clipboardActionsState('test'), initialValue: [{ action1: 'initialClipboardVal' }] },
],
dispatcher: {
recoilState: dispatcherState,
Expand All @@ -45,7 +45,7 @@ describe('Editor dispatcher', () => {

it('should set clipboard state correctly', () => {
act(() => {
dispatcher.setVisualEditorClipboard([{ action2: 'updatedVal' }]);
dispatcher.setVisualEditorClipboard([{ action2: 'updatedVal' }], 'test');
});
expect(renderedComponent.current.clipboardState).toEqual([{ action2: 'updatedVal' }]);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import { CallbackInterface, useRecoilCallback } from 'recoil';
import { clipboardActionsState, visualEditorSelectionState } from '../atoms/appState';

export const editorDispatcher = () => {
const setVisualEditorClipboard = useRecoilCallback(({ set }: CallbackInterface) => (clipboardActions: any[]) => {
set(clipboardActionsState, [...clipboardActions]);
});
const setVisualEditorClipboard = useRecoilCallback(
({ set }: CallbackInterface) => (clipboardActions: any[], projectId: string) => {
set(clipboardActionsState(projectId), [...clipboardActions]);
}
);

const setVisualEditorSelection = useRecoilCallback(({ set }: CallbackInterface) => (selection: string[]) => {
set(visualEditorSelectionState, [...selection]);
Expand Down
4 changes: 2 additions & 2 deletions Composer/packages/client/src/shell/useShell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function useShell(source: EventSource, projectId: string): Shell {
const isRootBot = rootBotProjectId === projectId;

const userSettings = useRecoilValue(userSettingsState);
const clipboardActions = useRecoilValue(clipboardActionsState);
const clipboardActions = useRecoilValue(clipboardActionsState(projectId));
const featureFlags = useRecoilValue(featureFlagsState);
const {
updateDialog,
Expand Down Expand Up @@ -221,7 +221,7 @@ export function useShell(source: EventSource, projectId: string): Shell {
onFocusEvent: focusEvent,
onFocusSteps: focusSteps,
onSelect: setVisualEditorSelection,
onCopy: setVisualEditorClipboard,
onCopy: (clipboardActions) => setVisualEditorClipboard(clipboardActions, projectId),
createDialog: (actionsSeed) => {
return new Promise((resolve) => {
createDialogBegin(
Expand Down

0 comments on commit 5406ec0

Please sign in to comment.