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

Drag and Drop functionality for Stacks #303

Merged
merged 21 commits into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9190bd4
Card.capture typings converted to optional UUID string representing S…
nelsonni Jan 24, 2021
25e77a1
NewCardDialog accepts Enter key press on filename field (#295)
nelsonni Jan 24, 2021
94bb7e9
Webpack rules/loader config updates for Webpack 5 (per #290)
nelsonni Jan 26, 2021
f188d0a
Fix exports format for resolving static asset imports in React Compon…
nelsonni Jan 26, 2021
782c22c
Split Cards and Stack Action Creactors from handlers to separate conc…
nelsonni Jan 26, 2021
2619dcb
Update immutable tests to demonstrate optional property removal from …
nelsonni Jan 26, 2021
17f1bd8
CardComponent drag and drop updated for Stack interactions
nelsonni Jan 26, 2021
7b41871
Removed circular reference implementation for updateStacks
nelsonni Jan 26, 2021
1512e81
Removed console logging statements
nelsonni Jan 26, 2021
5f3323a
StackComponent drag and drop implemented
nelsonni Jan 26, 2021
3a4e512
CanvasComponent drop updated for Stack interactions
nelsonni Jan 26, 2021
8a10c15
Indentation updated to conform to ESLint rules
nelsonni Jan 26, 2021
7094e02
Todo note about possible Readonly typings for rootReducer output
nelsonni Jan 26, 2021
629ba8b
Merge branch 'development' into feat/stack-drag-n-drop
nelsonni Jan 26, 2021
18b1fe5
Merge branch 'development' into feat/stack-drag-n-drop
nelsonni Jan 28, 2021
19eb7d5
Merge branch 'development' into feat/stack-drag-n-drop
nelsonni Jan 28, 2021
31b9ba5
Merge branch 'development' into feat/stack-drag-n-drop
nelsonni Jan 29, 2021
61787d0
Type import fixes for cards and stacks containers
nelsonni Jan 29, 2021
ccfa64c
Unused type imports after cards and stacks split from handlers container
nelsonni Jan 29, 2021
feba14f
Reject self-ref drop events for StackComponent
nelsonni Jan 30, 2021
e22e52a
Allow Card drag-n-drop between Stacks
nelsonni Jan 30, 2021
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
6 changes: 0 additions & 6 deletions __test__/CardComponent.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('CardComponent', () => {
metafile: '243',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 10,
top: 10
},
Expand All @@ -47,7 +46,6 @@ describe('CardComponent', () => {
metafile: '199',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 20,
top: 40
},
Expand All @@ -58,7 +56,6 @@ describe('CardComponent', () => {
metafile: '243',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 10,
top: 10
},
Expand All @@ -69,7 +66,6 @@ describe('CardComponent', () => {
metafile: '243',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 10,
top: 10
},
Expand All @@ -80,7 +76,6 @@ describe('CardComponent', () => {
metafile: '243',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 10,
top: 10
},
Expand All @@ -91,7 +86,6 @@ describe('CardComponent', () => {
metafile: '243',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 10,
top: 10
}
Expand Down
4 changes: 0 additions & 4 deletions __test__/DiffPickerDialog.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ describe('DiffPickerDialog', () => {
metafile: '243',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 10,
top: 10
},
Expand All @@ -49,7 +48,6 @@ describe('DiffPickerDialog', () => {
metafile: '459',
created: DateTime.fromISO('1997-12-27T10:10:10.288-08:00'),
modified: DateTime.fromISO('1998-01-01T20:20:20.144-08:00'),
captured: false,
left: 27,
top: 105
}
Expand Down Expand Up @@ -228,7 +226,6 @@ describe('DiffPickerButton', () => {
metafile: '243',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 10,
top: 10
},
Expand All @@ -239,7 +236,6 @@ describe('DiffPickerButton', () => {
metafile: '459',
created: DateTime.fromISO('1997-12-27T10:10:10.288-08:00'),
modified: DateTime.fromISO('1998-01-01T20:20:20.144-08:00'),
captured: false,
left: 27,
top: 105
}
Expand Down
1 change: 0 additions & 1 deletion __test__/Editor.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ describe('Editor', () => {
metafile: '199',
created: DateTime.fromISO('1997-12-27T10:10:10.288-08:00'),
modified: DateTime.fromISO('1998-01-01T20:20:20.144-08:00'),
captured: false,
left: 27,
top: 105
}
Expand Down
2 changes: 1 addition & 1 deletion __test__/__mocks__/fileMock.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = 'test-file-stub';
export default 'test-file-stub';
3 changes: 0 additions & 3 deletions __test__/__mocks__/reduxStoreMock.old.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export const initialState: initStateT = {
metafile: '243',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 10,
top: 10
},
Expand All @@ -61,7 +60,6 @@ export const initialState: initStateT = {
metafile: '459',
created: DateTime.fromISO('1997-12-27T10:10:10.288-08:00'),
modified: DateTime.fromISO('1998-01-01T20:20:20.144-08:00'),
captured: false,
left: 27,
top: 105
},
Expand All @@ -72,7 +70,6 @@ export const initialState: initStateT = {
metafile: '199',
created: DateTime.fromISO('2019-01-21T08:14:52.181-08:00'),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00'),
captured: false,
left: 20,
top: 40
}
Expand Down
3 changes: 0 additions & 3 deletions __test__/__snapshots__/cardReducer.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
exports[`cardReducer cardReducer appends a new card to state on action ADD_CARD 1`] = `
Object {
"40d14391c": Object {
"captured": false,
"created": "2019-11-19T19:22:47.572-08:00",
"id": "40d14391c",
"left": 0,
Expand All @@ -14,7 +13,6 @@ Object {
"type": "Editor",
},
"t829w0351": Object {
"captured": false,
"created": "2014-04-09T08:14:02.371-08:00",
"id": "t829w0351",
"left": 100,
Expand All @@ -30,7 +28,6 @@ Object {
exports[`cardReducer cardReducer updates state of matched card on action UPDATE_CARD 1`] = `
Object {
"40d14391c": Object {
"captured": false,
"created": "2019-11-19T19:22:47.572-08:00",
"id": "40d14391c",
"left": 178,
Expand Down
1 change: 0 additions & 1 deletion __test__/app.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ describe('App', () => {
metafile: '65914371',
created: DateTime.fromISO('2014-04-09T08:14:02.371-08:00'),
modified: DateTime.fromISO('2014-06-23T21:58:44.507-08:00'),
captured: false,
left: 100,
top: 50
};
Expand Down
1 change: 0 additions & 1 deletion __test__/canvasReducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe('canvasReducer', () => {
metafile: '29334943',
created: DateTime.fromISO('2014-04-09T08:14:02.371-08:00'),
modified: DateTime.fromISO('2014-06-23T21:58:44.507-08:00'),
captured: false,
left: 100, top: 50
}

Expand Down
2 changes: 0 additions & 2 deletions __test__/cardReducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ describe('cardReducer', () => {
metafile: '29334943',
created: DateTime.fromISO('2019-11-19T19:22:47.572-08:00', { setZone: true }),
modified: DateTime.fromISO('2019-11-19T19:22:47.572-08:00', { setZone: true }),
captured: false,
left: 0, top: 0
}
}
Expand All @@ -25,7 +24,6 @@ describe('cardReducer', () => {
metafile: '84354571',
created: DateTime.fromISO('2014-04-09T08:14:02.371-08:00', { setZone: true }),
modified: DateTime.fromISO('2014-06-23T21:58:44.507-08:00', { setZone: true }),
captured: false,
left: 100, top: 50
}

Expand Down
55 changes: 55 additions & 0 deletions __test__/cards.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { DateTime } from 'luxon';

import type { Card, Metafile } from '../src/types';
import * as cards from '../src/containers/cards';
import { HandlerRequiredMetafile } from '../src/containers/handlers';
import { ActionKeys } from '../src/store/actions';

const testMetafile: Metafile = {
id: '3',
name: 'bar.js',
path: 'foo/bar.js',
handler: 'Editor',
modified: DateTime.fromISO('2010-01-15T11:19:23.810-08:00')
};

const testCard: Card = {
id: 't829w0351',
name: 'card1',
type: 'Editor',
metafile: '84354571',
created: DateTime.fromISO('2014-04-09T08:14:02.371-08:00'),
modified: DateTime.fromISO('2014-06-23T21:58:44.507-08:00'),
left: 100, top: 50
};

describe('cards.addCard', () => {
it('addCard resolves ADD_CARD action for card with handler property', () => {
const action = cards.addCard(testMetafile as HandlerRequiredMetafile);
return expect(action).toEqual(
expect.objectContaining({
type: ActionKeys.ADD_CARD,
card: expect.objectContaining({
name: testMetafile.name,
metafile: testMetafile.id
})
})
)
});
});

describe('cards.updateCard', () => {
it('updateCard resolves UPDATE_CARD action for card updates with modified timestamp updated', () => {
const action = cards.updateCard({ ...testCard, metafile: testMetafile.id });
expect(action.card.modified && action.card.modified > testCard.modified).toBe(true);
return expect(action).toEqual(
expect.objectContaining({
type: ActionKeys.UPDATE_CARD,
card: expect.objectContaining({
id: testCard.id,
metafile: testMetafile.id
})
})
);
});
});
25 changes: 2 additions & 23 deletions __test__/handlers.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
import mock from 'mock-fs';
import { DateTime } from 'luxon';

import type { Card } from '../src/types';
import { importFiletypes, loadStack } from '../src/containers/handlers';
import * as handlers from '../src/containers/handlers';
import { ActionKeys } from '../src/store/actions';

const card: Card = {
id: 't829w0351',
name: 'card1',
type: 'Editor',
metafile: '84354571',
created: DateTime.fromISO('2014-04-09T08:14:02.371-08:00'),
modified: DateTime.fromISO('2014-06-23T21:58:44.507-08:00'),
captured: false,
left: 100, top: 50
}

beforeEach(() => {
mock({
'foo/config/filetypes.json': '[{"filetype": "PHP", "handler": "Editor", "extensions": ["php", "phpt"]}]',
Expand All @@ -28,17 +15,9 @@ afterEach(mock.restore);

describe('handlers.importFiletypes', () => {
it('importFiletypes returns Redux actions for adding filetypes', async () => {
const filetypes = await importFiletypes();
const filetypes = await handlers.importFiletypes();
mock.restore(); // required to prevent snapshot rewriting because of file watcher race conditions in Jest
expect(filetypes.length > 1).toBe(true);
expect(filetypes[0].type).toBe(ActionKeys.ADD_FILETYPE);
});
});

describe('handlers.loadStack', () => {
it('loadStack returns Redux action with new Stack and updates to child Cards', () => {
const actions = loadStack('testStack', [card], 'sample note');
expect(actions).toHaveLength(2);
expect(actions.map(a => a.type)).toStrictEqual([ActionKeys.ADD_STACK, ActionKeys.UPDATE_CARD]);
});
});
9 changes: 8 additions & 1 deletion __test__/immutables.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as utils from '../src/store/immutables';

type State = {
config: { id: string; display: boolean; enabled: boolean };
config: { id: string; display?: boolean; enabled: boolean };
colors: string[];
cats: { [id: string]: { id: string; age: number; color: string } };
}
Expand Down Expand Up @@ -33,6 +33,13 @@ describe('immutables.updateObject', () => {
expect(newState.config.id).toMatch(state.config.id);
expect(newState.config.enabled).toBe(true);
});

it('updateObject immutably allows removal of optional properties', () => {
const { display, ...newConfig } = state.config;
const newState = utils.updateObject(state, { config: newConfig });
expect(newState.config).not.toHaveProperty('display');
expect(newState.config).toMatchObject(newConfig);
});
});

describe('immutables.addItemInArray', () => {
Expand Down
2 changes: 0 additions & 2 deletions __test__/repos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ describe('repos.checkoutBranch', () => {
name: 'bar.js',
created: DateTime.fromISO('2010-01-15T11:19:23.810-08:00'),
modified: DateTime.fromISO('2010-01-15T11:19:23.810-08:00'),
captured: false,
left: 10,
top: 25,
type: 'Editor',
Expand Down Expand Up @@ -197,7 +196,6 @@ describe('repos.getRepository', () => {
name: 'bar.js',
created: DateTime.fromISO('2010-01-15T11:19:23.810-08:00'),
modified: DateTime.fromISO('2010-01-15T11:19:23.810-08:00'),
captured: false,
left: 10,
top: 25,
type: 'Editor',
Expand Down
Loading