@messenger-box/platform-browser 0.0.1-alpha.42 → 0.0.1-alpha.420
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +540 -27
- package/jest.config.js +23 -7
- package/lib/components/InboxMessage/InboxDetails/index.d.ts +2 -0
- package/lib/components/InboxMessage/InboxDetails/style.d.ts +1 -0
- package/lib/components/InboxMessage/InboxSidebar/index.d.ts +11 -0
- package/lib/components/InboxMessage/InboxSidebar/styles.d.ts +1 -0
- package/lib/components/InboxMessage/Messages/index.d.ts +2 -0
- package/lib/components/InboxMessage/Messages/styles.d.ts +80 -0
- package/lib/components/InboxMessage/MessagesList/index.d.ts +2 -0
- package/lib/components/InboxMessage/Popover/index.d.ts +2 -0
- package/lib/components/InboxMessage/Popover/style.d.ts +27 -0
- package/lib/components/InboxMessage/UserModalContent/index.d.ts +2 -0
- package/lib/components/InboxMessage/UserModalContent/style.d.ts +1 -0
- package/lib/components/InboxMessage/index.d.ts +2 -0
- package/lib/components/InboxMessage/mock.d.ts +19 -0
- package/lib/components/InboxMessage/style.d.ts +1 -0
- package/lib/components/channel_view/DirectChannelView.d.ts +3 -0
- package/lib/components/channel_view/PublicChannelView.d.ts +3 -0
- package/lib/components/dashboard/menu_header.d.ts +5 -0
- package/lib/components/dashboard/modals/direct_modal.d.ts +9 -0
- package/lib/components/dashboard/modals.d.ts +8 -0
- package/lib/components/messenger/index.d.ts +6 -1
- package/lib/components/messenger/messagesList/index.d.ts +6 -4
- package/lib/components/messenger/messagesList/style.d.ts +1 -221
- package/lib/components/messenger/more_action/index.d.ts +11 -0
- package/lib/components/messenger/more_action/style.d.ts +1 -0
- package/lib/components/overlay_trigger.d.ts +3 -3
- package/lib/components/post/channel_intro_message/channel_intro_message.d.ts +2 -1
- package/lib/components/post/channel_layout/channel_identifier_router/channel_identifier_router.d.ts +2 -1
- package/lib/components/post/channel_view/channel_view.d.ts +2 -1
- package/lib/components/post/create_post/create_post.d.ts +2 -1
- package/lib/components/post/failed_post_options/failed_post_options.d.ts +2 -1
- package/lib/components/post/index.d.ts +5 -1
- package/lib/components/post/markdown/markdown.d.ts +2 -1
- package/lib/components/post/post/post.d.ts +2 -1
- package/lib/components/post/post_aria_label_div.d.ts +3 -2
- package/lib/components/post/post_body/post_body.d.ts +2 -1
- package/lib/components/post/post_header/post_header.d.ts +2 -1
- package/lib/components/post/post_header/post_header_custom_status.d.ts +2 -1
- package/lib/components/post/post_header/style.d.ts +1 -40
- package/lib/components/post/post_info/post_info.d.ts +2 -1
- package/lib/components/post/post_list/index.d.ts +2 -1
- package/lib/components/post/post_list/post_list.d.ts +2 -1
- package/lib/components/post/post_list_row/post_list_row.d.ts +2 -1
- package/lib/components/post/post_list_virtualized/latest_post_reader.d.ts +2 -1
- package/lib/components/post/post_list_virtualized/post_list_virtualized.d.ts +2 -1
- package/lib/components/post/post_markdown/post_markdown.d.ts +2 -1
- package/lib/components/post/post_message_view/post_message_view.d.ts +2 -1
- package/lib/components/post/post_pre_header/post_pre_header.d.ts +3 -2
- package/lib/components/post/post_profile_picture/post_profile_picture.d.ts +2 -1
- package/lib/components/post/post_view.d.ts +2 -1
- package/lib/components/post/profile_picture/profile_picture.d.ts +2 -1
- package/lib/components/post/show_more/show_more.d.ts +2 -1
- package/lib/components/post/style.d.ts +1 -93
- package/lib/components/post/threading/channel_threads/thread_footer/thread_footer.d.ts +2 -1
- package/lib/components/post/threading/common/button/button.d.ts +3 -3
- package/lib/components/post/threading/common/follow_button/follow_button.d.ts +2 -2
- package/lib/components/post/tutorial/tutorial_tip/tutorial_tip.d.ts +3 -3
- package/lib/components/post/user_profile/user_profile.d.ts +1 -1
- package/lib/components/status_icon.d.ts +2 -1
- package/lib/components/status_icon_new.d.ts +2 -2
- package/lib/compute.d.ts +8 -2
- package/lib/containers/Inbox.d.ts +3 -0
- package/lib/containers/Messenger.d.ts +5 -1
- package/lib/index.js +3864 -581
- package/lib/index.js.map +1 -1
- package/lib/packages/types/emojis.d.ts +5 -5
- package/lib/packages/types/files.d.ts +5 -5
- package/lib/packages/types/posts.d.ts +13 -13
- package/lib/packages/types/reactions.d.ts +1 -1
- package/lib/packages/types/utilities.d.ts +13 -13
- package/lib/style.d.ts +1 -37
- package/lib/utils/index.d.ts +2 -0
- package/lib/widgets/badges/badge.d.ts +3 -3
- package/lib/widgets/badges/bot_badge.d.ts +1 -1
- package/lib/widgets/badges/guest_badge.d.ts +1 -1
- package/lib/widgets/badges/style.d.ts +1 -23
- package/lib/widgets/icons/emoji_icon.d.ts +1 -1
- package/lib/widgets/icons/flag_icon_filled.d.ts +1 -1
- package/lib/widgets/icons/mattermost_logo.d.ts +1 -1
- package/lib/widgets/icons/status_away_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_away_icon.d.ts +1 -1
- package/lib/widgets/icons/status_dnd_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_dnd_icon.d.ts +1 -1
- package/lib/widgets/icons/status_offline_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_offline_icon.d.ts +1 -1
- package/lib/widgets/icons/status_online_avatar_icon.d.ts +1 -1
- package/lib/widgets/icons/status_online_icon.d.ts +1 -1
- package/lib/widgets/overlay_trigger.d.ts +3 -3
- package/lib/widgets/shared_user_indicator.d.ts +1 -1
- package/lib/widgets/simple_tooltip/simple_tooltip.d.ts +3 -3
- package/lib/widgets/users/avatar/avatar.d.ts +4 -4
- package/lib/widgets/users/avatar/style.d.ts +1 -75
- package/lib/widgets/users/avatars/avatars.d.ts +2 -2
- package/package.json +61 -67
- package/src/components/InboxMessage/InboxDetails/index.tsx +23 -0
- package/src/components/InboxMessage/InboxDetails/style.ts +27 -0
- package/src/components/InboxMessage/InboxSidebar/index.tsx +86 -0
- package/src/components/InboxMessage/InboxSidebar/styles.ts +57 -0
- package/src/components/InboxMessage/Messages/index.tsx +159 -0
- package/src/components/InboxMessage/Messages/styles.ts +85 -0
- package/src/components/InboxMessage/MessagesList/index.tsx +93 -0
- package/src/components/InboxMessage/Popover/index.tsx +57 -0
- package/src/components/InboxMessage/Popover/style.ts +27 -0
- package/src/components/InboxMessage/UserModalContent/index.tsx +60 -0
- package/src/components/InboxMessage/UserModalContent/style.ts +98 -0
- package/src/components/InboxMessage/index.tsx +286 -0
- package/src/components/InboxMessage/mock.ts +53 -0
- package/src/components/InboxMessage/style.ts +189 -0
- package/src/components/channel_view/DirectChannelView.tsx +25 -0
- package/src/components/channel_view/PublicChannelView.tsx +24 -0
- package/src/components/dashboard/menu_header.tsx +49 -0
- package/src/components/dashboard/modals/direct_modal.tsx +46 -0
- package/src/components/dashboard/modals.tsx +93 -0
- package/src/components/messenger/avatar/index.tsx +2 -4
- package/src/components/messenger/avatar/style.ts +3 -3
- package/src/components/messenger/index.tsx +258 -94
- package/src/components/messenger/messagesList/index.tsx +673 -249
- package/src/components/messenger/messagesList/messageBox.tsx +2 -1
- package/src/components/messenger/messagesList/style.ts +240 -14
- package/src/components/messenger/more_action/index.tsx +68 -0
- package/src/components/messenger/more_action/style.ts +45 -0
- package/src/components/messenger/postMessage/postMessage.tsx +2 -3
- package/src/components/messenger/postMessage/style.ts +3 -3
- package/src/components/messenger/sidebarThreadList/index.tsx +11 -10
- package/src/components/messenger/style.ts +16 -16
- package/src/components/messenger/threadSidebar/index.tsx +5 -5
- package/src/components/messenger/threadSidebar/style.ts +7 -7
- package/src/components/messenger/types/message.ts +1 -0
- package/src/components/post/channel_intro_message/channel_intro_message.tsx +0 -1
- package/src/components/post/index.tsx +102 -25
- package/src/components/post/post/post.tsx +8 -1
- package/src/components/post/post_header/post_header_custom_status.tsx +1 -2
- package/src/components/post/post_header/style.ts +3 -6
- package/src/components/post/style.ts +22 -8
- package/src/components/post/tutorial/tutorial_tip/tutorial_tip.tsx +1 -0
- package/src/components/post/user_profile/user_profile.tsx +1 -0
- package/src/compute.tsx +58 -37
- package/src/containers/Dashboard.tsx +488 -1
- package/src/containers/Inbox.tsx +13 -0
- package/src/containers/Loading.tsx +1 -1
- package/src/containers/Messenger.tsx +9 -4
- package/src/module.ts +10 -7
- package/src/style.ts +382 -19
- package/src/utils/index.ts +22 -0
- package/src/widgets/badges/badge.tsx +1 -2
- package/src/widgets/badges/style.ts +3 -3
- package/src/widgets/icons/accordion_toggle_icon.tsx +1 -1
- package/src/widgets/icons/add_reaction_icon.tsx +1 -1
- package/src/widgets/icons/admin_eye_icon.tsx +1 -1
- package/src/widgets/icons/alert_icon.tsx +1 -1
- package/src/widgets/icons/archive_icon.tsx +1 -1
- package/src/widgets/icons/arrow_right_icon.tsx +1 -1
- package/src/widgets/icons/at_icon.tsx +1 -1
- package/src/widgets/icons/attachment_icon.tsx +1 -1
- package/src/widgets/icons/back_icon.tsx +1 -1
- package/src/widgets/icons/bot_icon.tsx +1 -1
- package/src/widgets/icons/camera_icon.tsx +1 -1
- package/src/widgets/icons/checkbox_checked_icon.tsx +1 -1
- package/src/widgets/icons/checkbox_partial_icon.tsx +1 -1
- package/src/widgets/icons/close_circle_icon.tsx +1 -1
- package/src/widgets/icons/close_circle_solid_icon.tsx +1 -1
- package/src/widgets/icons/close_icon.tsx +1 -1
- package/src/widgets/icons/dots_horizontal.tsx +1 -1
- package/src/widgets/icons/download_icon.tsx +1 -1
- package/src/widgets/icons/draft_icon.tsx +1 -1
- package/src/widgets/icons/ellipsis_h_icon.tsx +1 -1
- package/src/widgets/icons/email_icon.tsx +1 -1
- package/src/widgets/icons/fa_add_icon.tsx +1 -1
- package/src/widgets/icons/fa_back_icon.tsx +1 -1
- package/src/widgets/icons/fa_dropdown_icon.tsx +1 -1
- package/src/widgets/icons/fa_edit_icon.tsx +1 -1
- package/src/widgets/icons/fa_logout_icon.tsx +1 -1
- package/src/widgets/icons/fa_next_icon.tsx +1 -1
- package/src/widgets/icons/fa_previous_icon.tsx +1 -1
- package/src/widgets/icons/fa_reload_icon.tsx +1 -1
- package/src/widgets/icons/fa_remove_icon.tsx +1 -1
- package/src/widgets/icons/fa_search_icon.tsx +1 -1
- package/src/widgets/icons/fa_select_icon.tsx +1 -1
- package/src/widgets/icons/fa_success_icon.tsx +1 -1
- package/src/widgets/icons/fa_warning_icon.tsx +1 -1
- package/src/widgets/icons/flag_icon.tsx +1 -1
- package/src/widgets/icons/gfycat_icon.tsx +1 -1
- package/src/widgets/icons/gif_reactions_icon.tsx +1 -1
- package/src/widgets/icons/gif_search_clear_icon.tsx +1 -1
- package/src/widgets/icons/gif_search_icon.tsx +1 -1
- package/src/widgets/icons/gif_trending_icon.tsx +1 -1
- package/src/widgets/icons/globe_icon.tsx +1 -1
- package/src/widgets/icons/icons.stories.js +1 -1
- package/src/widgets/icons/info_icon.tsx +1 -1
- package/src/widgets/icons/info_small_icon.tsx +1 -1
- package/src/widgets/icons/invite_icon.tsx +1 -1
- package/src/widgets/icons/invite_members_icon.tsx +1 -1
- package/src/widgets/icons/link_icon.tsx +1 -1
- package/src/widgets/icons/lock_icon.tsx +1 -1
- package/src/widgets/icons/mail_icon.tsx +1 -1
- package/src/widgets/icons/mail_plus_icon.tsx +1 -1
- package/src/widgets/icons/member_icon.tsx +1 -1
- package/src/widgets/icons/mentions_icon.tsx +1 -1
- package/src/widgets/icons/menu_icon.tsx +1 -1
- package/src/widgets/icons/message_icon.tsx +1 -1
- package/src/widgets/icons/pin_icon.tsx +1 -1
- package/src/widgets/icons/plugin_channel_header_icon.tsx +1 -1
- package/src/widgets/icons/plugin_icon.tsx +1 -1
- package/src/widgets/icons/reply_icon.tsx +1 -1
- package/src/widgets/icons/scroll_to_bottom_icon.tsx +1 -1
- package/src/widgets/icons/search_icon.tsx +1 -1
- package/src/widgets/icons/shield_outline_icon.tsx +1 -1
- package/src/widgets/icons/unarchive_icon.tsx +1 -1
- package/src/widgets/icons/unread_below_icon.tsx +1 -1
- package/src/widgets/icons/user_guide_icon.tsx +1 -1
- package/src/widgets/shared_user_indicator.tsx +1 -0
- package/src/widgets/simple_tooltip/simple_tooltip.tsx +1 -0
- package/src/widgets/users/avatar/avatar.tsx +1 -2
- package/src/widgets/users/avatar/style.ts +3 -3
- package/src/widgets/users/avatars/avatars.tsx +1 -0
- package/tsconfig.json +2 -1
- package/webpack.config.js +1 -1
- package/lib/components/messenger/mock.d.ts +0 -50
- package/lib/components/messenger/postMessage/postMessage.d.ts +0 -1
- package/lib/components/messenger/postMessage/style.d.ts +0 -22
- package/lib/components/messenger/sidebarThreadList/index.d.ts +0 -7
- package/lib/components/messenger/threadSidebar/index.d.ts +0 -1
- package/lib/components/messenger/threadSidebar/style.d.ts +0 -62
- package/lib/components/messenger/types/message.d.ts +0 -14
- package/src/api.ts +0 -35
- package/src/components/Counter.tsx +0 -52
- package/src/containers/Clock.tsx +0 -0
- package/src/containers/Counter.tsx +0 -42
- package/src/containers/PersonList.tsx +0 -20
- package/src/containers/ServerCounter.tsx +0 -140
- package/src/graphql/index.ts +0 -3
- package/src/graphql/mutations/addCount.graphql +0 -5
- package/src/graphql/mutations/addPerson.graphql +0 -6
- package/src/graphql/mutations/index.ts +0 -2
- package/src/graphql/queries/count.graphql +0 -5
- package/src/graphql/queries/index.ts +0 -3
- package/src/graphql/queries/person.graphql +0 -22
- package/src/graphql/queries/persons.graphql +0 -6
- package/src/graphql/subscriptions/count.graphql +0 -5
- package/src/graphql/subscriptions/index.ts +0 -1
- package/src/redux/__mocks__/api.ts +0 -4
- package/src/redux/actions/__tests__/sampleActions.test.ts +0 -159
- package/src/redux/actions/index.ts +0 -1
- package/src/redux/actions/sampleActions.ts +0 -91
- package/src/redux/index.ts +0 -2
- package/src/redux/reducers/Store.ts +0 -10
- package/src/redux/reducers/__tests__/sampleReducers.test.ts +0 -39
- package/src/redux/reducers/index.ts +0 -7
- package/src/redux/reducers/sampleReducers.ts +0 -71
- /package/src/components/post/channel_layout/{channel_controller.test.jsx → channel_controller.test.tsx} +0 -0
- /package/src/components/post/channel_layout/{channel_controller.jsx → channel_controller.tsx} +0 -0
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
export declare const styleSheet: {
|
|
2
|
-
ThreadSidebarStyles: () => {
|
|
3
|
-
'& .input_row_thread': {
|
|
4
|
-
width: string;
|
|
5
|
-
paddingLeft: string;
|
|
6
|
-
paddingRight: string;
|
|
7
|
-
marginLeft: string;
|
|
8
|
-
};
|
|
9
|
-
'& .close-icon': {
|
|
10
|
-
position: string;
|
|
11
|
-
left: string;
|
|
12
|
-
top: string;
|
|
13
|
-
float: string;
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
costumThreadStyles: () => {
|
|
17
|
-
'& .ant-comment-content-author-name > * ': {
|
|
18
|
-
color: string;
|
|
19
|
-
fontWeight: string;
|
|
20
|
-
fontSize: string;
|
|
21
|
-
};
|
|
22
|
-
'& span.ant-comment-content-author-time': {
|
|
23
|
-
color: string;
|
|
24
|
-
fontSize: string;
|
|
25
|
-
};
|
|
26
|
-
'& .btn-hover': {
|
|
27
|
-
display: string;
|
|
28
|
-
};
|
|
29
|
-
'& .hover_btns': {
|
|
30
|
-
borderRadius: string;
|
|
31
|
-
border: string;
|
|
32
|
-
display: string;
|
|
33
|
-
justifyContent: string;
|
|
34
|
-
padding: string;
|
|
35
|
-
position: string;
|
|
36
|
-
right: string;
|
|
37
|
-
top: string;
|
|
38
|
-
whiteSpace: string;
|
|
39
|
-
zIndex: string;
|
|
40
|
-
};
|
|
41
|
-
'& .hover_btns button': {
|
|
42
|
-
border: string;
|
|
43
|
-
display: string;
|
|
44
|
-
alignItems: string;
|
|
45
|
-
justifyContent: string;
|
|
46
|
-
margin: string;
|
|
47
|
-
width: string;
|
|
48
|
-
height: string;
|
|
49
|
-
background: string;
|
|
50
|
-
};
|
|
51
|
-
};
|
|
52
|
-
costumThreadHoverStyles: () => {
|
|
53
|
-
':hover .btn-hover': {
|
|
54
|
-
display: string;
|
|
55
|
-
};
|
|
56
|
-
'.btn-hover': {
|
|
57
|
-
display: string;
|
|
58
|
-
};
|
|
59
|
-
padding: string;
|
|
60
|
-
paddingRight: string;
|
|
61
|
-
};
|
|
62
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface IMessageList {
|
|
2
|
-
id: number;
|
|
3
|
-
loginUser: boolean;
|
|
4
|
-
message: string;
|
|
5
|
-
timeIsToday: boolean;
|
|
6
|
-
isReply: boolean;
|
|
7
|
-
thread?: IMessageReplyList[];
|
|
8
|
-
}
|
|
9
|
-
export interface IMessageReplyList {
|
|
10
|
-
threadId: number;
|
|
11
|
-
message: string;
|
|
12
|
-
time: string;
|
|
13
|
-
timeIsToday: boolean;
|
|
14
|
-
}
|
package/src/api.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
// Simulate a flaky API around otherwise an otherwise synchronous `f()`.
|
|
2
|
-
const flakify = <T>(f: () => T): Promise<T> =>
|
|
3
|
-
new Promise((resolve, reject) =>
|
|
4
|
-
// We'll always take 200 * (1d10 + 1) ms to respond
|
|
5
|
-
window.setTimeout(() => {
|
|
6
|
-
try {
|
|
7
|
-
// And ~20% of the time we'll fail
|
|
8
|
-
if (Math.random() < 0.2) {
|
|
9
|
-
throw new Error('Failed arbitrarily');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
resolve(f());
|
|
13
|
-
} catch (e) {
|
|
14
|
-
return reject(e);
|
|
15
|
-
}
|
|
16
|
-
}, 200 + Math.random() * 2000),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
export type Api = {
|
|
20
|
-
save(x: { value: number }): Promise<null>;
|
|
21
|
-
load(): Promise<{ value: number }>;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export const api: Api = {
|
|
25
|
-
save: (counter) =>
|
|
26
|
-
flakify(() => {
|
|
27
|
-
localStorage.setItem('__counterValue', counter.value.toString());
|
|
28
|
-
return null;
|
|
29
|
-
}),
|
|
30
|
-
load: () =>
|
|
31
|
-
flakify(() => {
|
|
32
|
-
const value = parseInt(localStorage.getItem('__counterValue'), 10);
|
|
33
|
-
return { value };
|
|
34
|
-
}),
|
|
35
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
export interface ICounterProps {
|
|
4
|
-
label: string;
|
|
5
|
-
counter: { value: number };
|
|
6
|
-
isSaving: boolean;
|
|
7
|
-
isLoading: boolean;
|
|
8
|
-
error: string;
|
|
9
|
-
increment: (n: number) => void;
|
|
10
|
-
save: (n: number) => void;
|
|
11
|
-
load: () => void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export interface ICounterState {
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export class CounterComponent extends React.Component<ICounterProps, ICounterState> {
|
|
18
|
-
|
|
19
|
-
private _onClickIncrement = (e: React.SyntheticEvent<HTMLButtonElement>) => {
|
|
20
|
-
e.preventDefault();
|
|
21
|
-
this.props.increment(1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
private _onClickSave = (e: React.SyntheticEvent<HTMLButtonElement>) => {
|
|
25
|
-
e.preventDefault();
|
|
26
|
-
if (!this.props.isSaving) {
|
|
27
|
-
this.props.save(this.props.counter.value);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
private _onClickLoad = (e: React.SyntheticEvent<HTMLButtonElement>) => {
|
|
32
|
-
e.preventDefault();
|
|
33
|
-
if (!this.props.isLoading) {
|
|
34
|
-
this.props.load();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
public render(): JSX.Element {
|
|
39
|
-
const { counter, label, isSaving, isLoading, error } = this.props;
|
|
40
|
-
return (
|
|
41
|
-
<form>
|
|
42
|
-
<legend>{label}</legend>
|
|
43
|
-
<pre>{JSON.stringify({ counter, isSaving, isLoading }, null, 2)}</pre>
|
|
44
|
-
<button onClick={this._onClickIncrement}>click me!</button>
|
|
45
|
-
<button disabled={isSaving} onClick={this._onClickSave}>{isSaving ? 'saving...' : 'save'}</button>
|
|
46
|
-
<button disabled={isLoading} onClick={this._onClickLoad}>{isLoading ? 'loading...' : 'load'}</button>
|
|
47
|
-
{error ? <div className="error">{error}</div> : null}
|
|
48
|
-
</form>);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
package/src/containers/Clock.tsx
DELETED
|
File without changes
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
incrementCounter,
|
|
3
|
-
loadCount,
|
|
4
|
-
saveCount,
|
|
5
|
-
Action,
|
|
6
|
-
Store,
|
|
7
|
-
} from '../redux';
|
|
8
|
-
import { connect } from 'react-redux';
|
|
9
|
-
import * as redux from 'redux';
|
|
10
|
-
import { CounterComponent, ICounterProps } from '../components';
|
|
11
|
-
|
|
12
|
-
export type CounterOwnProps = {
|
|
13
|
-
label: string;
|
|
14
|
-
store?: Store.Sample;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
const mapStateToProps = (state: Store.Sample) => ({
|
|
18
|
-
counter: state['@messenger-box/counter'],
|
|
19
|
-
isSaving: state['@messenger-box/isSaving'],
|
|
20
|
-
isLoading: state['@messenger-box/isLoading'],
|
|
21
|
-
error: state['@messenger-box/error'],
|
|
22
|
-
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const mapDispatchToProps = (dispatch: Function) => ({
|
|
26
|
-
increment: (n: number) =>
|
|
27
|
-
dispatch(incrementCounter(n)),
|
|
28
|
-
load: () =>
|
|
29
|
-
dispatch(loadCount(null)),
|
|
30
|
-
save: (value: number) =>
|
|
31
|
-
dispatch(saveCount({ value })),
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// const stateProps = mapStateToProps;
|
|
35
|
-
// const dispatchProps = returntypeof(mapDispatchToProps);
|
|
36
|
-
// type StateProps = typeof stateProps;
|
|
37
|
-
// type DispatchProps = typeof dispatchProps;
|
|
38
|
-
|
|
39
|
-
// https://github.com/DefinitelyTyped/DefinitelyTyped/issues/8787
|
|
40
|
-
export const Counter =
|
|
41
|
-
connect<any, any, any>(mapStateToProps, mapDispatchToProps)(CounterComponent);
|
|
42
|
-
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { graphql } from '@apollo/react-hoc';
|
|
3
|
-
import compose from 'lodash/flowRight';
|
|
4
|
-
import { PERSONS_QUERY } from '../graphql';
|
|
5
|
-
|
|
6
|
-
export interface IPersonListProps {
|
|
7
|
-
persons;
|
|
8
|
-
}
|
|
9
|
-
const PersonListComponent: React.SFC<IPersonListProps> = ({ persons }) => (
|
|
10
|
-
<div>
|
|
11
|
-
<h2>Persons:</h2>
|
|
12
|
-
{persons && persons.map((person, i) => <div key={i}>{person.name}</div>)}
|
|
13
|
-
</div>
|
|
14
|
-
);
|
|
15
|
-
|
|
16
|
-
export const PersonList: React.ComponentClass<{}> =
|
|
17
|
-
compose(
|
|
18
|
-
graphql<{}, any, {}, {}>(PERSONS_QUERY),
|
|
19
|
-
// flattenProp('data'),
|
|
20
|
-
)(PersonListComponent);
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import update from 'immutability-helper';
|
|
3
|
-
import { graphql } from '@apollo/react-hoc';
|
|
4
|
-
import compose from 'lodash/flowRight';
|
|
5
|
-
import { CounterComponent, ICounterProps } from '../components';
|
|
6
|
-
import { COUNT_SUBSCRIPTION, COUNT_QUERY, ADD_COUNT_MUTATION,} from '../graphql';
|
|
7
|
-
import { logger } from '@cdm-logger/client';
|
|
8
|
-
type SubscriptionProps = {
|
|
9
|
-
subscribeToMore: Function;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
// class WithSubscriptionCounter extends React.Component<SubscriptionProps & ICounterProps, {}> {
|
|
13
|
-
|
|
14
|
-
// public subscription;
|
|
15
|
-
|
|
16
|
-
// constructor(props) {
|
|
17
|
-
// super(props);
|
|
18
|
-
// }
|
|
19
|
-
|
|
20
|
-
// public componentWillReceiveProps(nextProps) {
|
|
21
|
-
// if (!nextProps.loading) {
|
|
22
|
-
// if (this.subscription) {
|
|
23
|
-
// this.subscription();
|
|
24
|
-
// this.subscription = null;
|
|
25
|
-
// }
|
|
26
|
-
|
|
27
|
-
// // Subscribe or re-subscribe
|
|
28
|
-
// if (!this.subscription) {
|
|
29
|
-
// this.subscribeToCount();
|
|
30
|
-
// }
|
|
31
|
-
// }
|
|
32
|
-
// }
|
|
33
|
-
|
|
34
|
-
// public componentWillUnmount() {
|
|
35
|
-
// if (this.subscription) {
|
|
36
|
-
// this.subscription();
|
|
37
|
-
// }
|
|
38
|
-
// }
|
|
39
|
-
|
|
40
|
-
// private subscribeToCount() {
|
|
41
|
-
// const { subscribeToMore } = this.props;
|
|
42
|
-
// this.subscription = subscribeToMore({
|
|
43
|
-
// document: onCountUpdated,
|
|
44
|
-
// variables: {},
|
|
45
|
-
// updateQuery: (prev, { subscriptionData: { data: { countUpdated: { amount } } } }) => {
|
|
46
|
-
// return update(prev, {
|
|
47
|
-
// count: {
|
|
48
|
-
// amount: {
|
|
49
|
-
// $set: amount,
|
|
50
|
-
// },
|
|
51
|
-
// },
|
|
52
|
-
// });
|
|
53
|
-
// },
|
|
54
|
-
// });
|
|
55
|
-
// }
|
|
56
|
-
|
|
57
|
-
// public render() {
|
|
58
|
-
// const { ICounerProps } = this.props;
|
|
59
|
-
// return <CounterComponent />;
|
|
60
|
-
// }
|
|
61
|
-
// }
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// save(amount) {
|
|
65
|
-
// return () => mutate({
|
|
66
|
-
// variables: { amount },
|
|
67
|
-
// updateQueries,
|
|
68
|
-
// });
|
|
69
|
-
// },
|
|
70
|
-
|
|
71
|
-
type countOptions = any & {
|
|
72
|
-
countData: any;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
const updateQueries = {
|
|
76
|
-
counter: (prev, { mutationResult }) => {
|
|
77
|
-
const newAmount = mutationResult.data.addCount.amount;
|
|
78
|
-
return update(prev, {
|
|
79
|
-
count: {
|
|
80
|
-
amount: {
|
|
81
|
-
$set: newAmount,
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
});
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
export const CounterWithApollo: React.ComponentClass = (compose(
|
|
89
|
-
graphql<{}, any, {}, {}>(ADD_COUNT_MUTATION, {
|
|
90
|
-
props: ({ ownProps, mutate }) => ({
|
|
91
|
-
save: (amount) => {
|
|
92
|
-
return () => mutate({
|
|
93
|
-
variables: { amount },
|
|
94
|
-
// optimisticResponse: {
|
|
95
|
-
// __typename: 'Mutation',
|
|
96
|
-
|
|
97
|
-
// },
|
|
98
|
-
});
|
|
99
|
-
},
|
|
100
|
-
}),
|
|
101
|
-
}),
|
|
102
|
-
graphql<{}, any, {}, {}>(ADD_COUNT_MUTATION, {
|
|
103
|
-
props: ({ ownProps, mutate }) => ({
|
|
104
|
-
increment: (amount) => {
|
|
105
|
-
return () => mutate({
|
|
106
|
-
variables: { amount },
|
|
107
|
-
// updateQueries,
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
}),
|
|
111
|
-
}),
|
|
112
|
-
)(graphql<ICounterProps, countOptions, {}, {}>(COUNT_QUERY, {
|
|
113
|
-
name: 'countData',
|
|
114
|
-
props: ({ countData }: any) => {
|
|
115
|
-
const newlog = logger.child({ childName: 'UIController' });
|
|
116
|
-
newlog.debug('count data : (%j)', countData);
|
|
117
|
-
return {
|
|
118
|
-
subscribeToCount: params => {
|
|
119
|
-
// logger.debug('count subscript data (%j)', params);
|
|
120
|
-
return countData.subscribeToMore({
|
|
121
|
-
document: COUNT_SUBSCRIPTION,
|
|
122
|
-
variables: {},
|
|
123
|
-
updateQuery: (prev: any, { subscriptionData }) => {
|
|
124
|
-
const payload = subscriptionData.data && subscriptionData.data.subscribeToWorkspace;
|
|
125
|
-
if (!payload) {
|
|
126
|
-
return prev;
|
|
127
|
-
}
|
|
128
|
-
return payload;
|
|
129
|
-
},
|
|
130
|
-
});
|
|
131
|
-
},
|
|
132
|
-
counter: countData.count && countData.count.amount,
|
|
133
|
-
isLoading: countData.loading,
|
|
134
|
-
isSaving: false,
|
|
135
|
-
load: () => countData.count.amount,
|
|
136
|
-
error: countData.error,
|
|
137
|
-
};
|
|
138
|
-
},
|
|
139
|
-
})(CounterComponent as any))
|
|
140
|
-
);
|
package/src/graphql/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const COUNT_SUBSCRIPTION = require('./count');
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import 'jest';
|
|
2
|
-
|
|
3
|
-
import { createStore } from 'redux';
|
|
4
|
-
import * as apiExports from '../../api';
|
|
5
|
-
import * as actions from '../sampleActions';
|
|
6
|
-
|
|
7
|
-
jest.mock('../../api');
|
|
8
|
-
|
|
9
|
-
const api: jest.Mocked<apiExports.Api> = apiExports.api as any;
|
|
10
|
-
|
|
11
|
-
describe('actions', () => {
|
|
12
|
-
const store = () => {
|
|
13
|
-
const reducer = jest.fn();
|
|
14
|
-
const { dispatch } = createStore(reducer);
|
|
15
|
-
reducer.mockReset(); // ignore @@redux/INIT
|
|
16
|
-
return { dispatch, reducer };
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
const eventually = (assertFn) =>
|
|
20
|
-
new Promise((resolve, reject) => {
|
|
21
|
-
setTimeout(() => {
|
|
22
|
-
try {
|
|
23
|
-
assertFn();
|
|
24
|
-
} catch (e) {
|
|
25
|
-
return reject(e);
|
|
26
|
-
}
|
|
27
|
-
resolve();
|
|
28
|
-
}, 1);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
const expectTypes = (reducer, types) => () =>
|
|
32
|
-
expect(reducer.mock.calls.map((x) => x[1].type)).toEqual(types);
|
|
33
|
-
|
|
34
|
-
describe('.saveCount', () => {
|
|
35
|
-
beforeEach(() => {
|
|
36
|
-
api.save.mockReturnValue(Promise.resolve(null));
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('sends an API request', () => {
|
|
40
|
-
actions.saveCount({ value: 14 })(jest.fn());
|
|
41
|
-
expect(api.save.mock.calls).toHaveLength(1);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
describe('when API request succeeds', () => {
|
|
45
|
-
it('dispatches @@messenger-box/SAVE_COUNT_SUCCESS', () => {
|
|
46
|
-
const { dispatch, reducer } = store();
|
|
47
|
-
actions.saveCount({ value: 14 })(dispatch);
|
|
48
|
-
return eventually(
|
|
49
|
-
expectTypes(reducer, [
|
|
50
|
-
'@@messenger-box/SAVE_COUNT_REQUEST',
|
|
51
|
-
'@@messenger-box/SAVE_COUNT_SUCCESS',
|
|
52
|
-
]),
|
|
53
|
-
);
|
|
54
|
-
});
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
describe('when API request fails', () => {
|
|
58
|
-
beforeEach(() => {
|
|
59
|
-
api.save.mockReturnValue(
|
|
60
|
-
Promise.reject(new Error('something terrible happened')),
|
|
61
|
-
);
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it('dispatches @@messenger-box/SAVE_COUNT_ERROR', () => {
|
|
65
|
-
const { dispatch, reducer } = store();
|
|
66
|
-
actions.saveCount({ value: 14 })(dispatch);
|
|
67
|
-
return eventually(
|
|
68
|
-
expectTypes(reducer, [
|
|
69
|
-
'@@messenger-box/SAVE_COUNT_REQUEST',
|
|
70
|
-
'@@messenger-box/SAVE_COUNT_ERROR',
|
|
71
|
-
]),
|
|
72
|
-
);
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('includes error message with @@messenger-box/SAVE_COUNT_ERROR', () => {
|
|
76
|
-
const { dispatch, reducer } = store();
|
|
77
|
-
actions.saveCount({ value: 14 })(dispatch);
|
|
78
|
-
return eventually(() => {
|
|
79
|
-
expect(reducer.mock.calls[1][1].error.message).toEqual(
|
|
80
|
-
'something terrible happened',
|
|
81
|
-
);
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('includes request with @@messenger-box/SAVE_COUNT_ERROR for convenience', () => {
|
|
86
|
-
const { dispatch, reducer } = store();
|
|
87
|
-
actions.saveCount({ value: 14 })(dispatch);
|
|
88
|
-
return eventually(() => {
|
|
89
|
-
expect(reducer.mock.calls[1][1].request).toEqual({
|
|
90
|
-
value: 14,
|
|
91
|
-
});
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
describe('.loadCount', () => {
|
|
98
|
-
beforeEach(() => {
|
|
99
|
-
api.load.mockReturnValue(Promise.resolve({ value: 14 }));
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
it('sends an API request', () => {
|
|
103
|
-
actions.loadCount(null)(jest.fn());
|
|
104
|
-
expect(api.load.mock.calls).toHaveLength(1);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
describe('when API request succeeds', () => {
|
|
108
|
-
it('dispatches @messenger-box/LOAD_COUNT_SUCCESS', () => {
|
|
109
|
-
const { dispatch, reducer } = store();
|
|
110
|
-
actions.loadCount(null)(dispatch);
|
|
111
|
-
return eventually(
|
|
112
|
-
expectTypes(reducer, [
|
|
113
|
-
'@@messenger-box/LOAD_COUNT_REQUEST',
|
|
114
|
-
'@@messenger-box/LOAD_COUNT_SUCCESS',
|
|
115
|
-
]),
|
|
116
|
-
);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('includes new value with LOAD_COUNT_SUCCESS', () => {
|
|
120
|
-
const { dispatch, reducer } = store();
|
|
121
|
-
actions.loadCount(null)(dispatch);
|
|
122
|
-
return eventually(() => {
|
|
123
|
-
expect(reducer.mock.calls[1][1].response).toEqual({
|
|
124
|
-
value: 14,
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
});
|
|
128
|
-
});
|
|
129
|
-
|
|
130
|
-
describe('when API request fails', () => {
|
|
131
|
-
beforeEach(() => {
|
|
132
|
-
api.load.mockReturnValue(
|
|
133
|
-
Promise.reject(new Error('something terrible happened')),
|
|
134
|
-
);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('dispatches @@messenger-box/LOAD_COUNT_ERROR', () => {
|
|
138
|
-
const { dispatch, reducer } = store();
|
|
139
|
-
actions.loadCount(null)(dispatch);
|
|
140
|
-
return eventually(
|
|
141
|
-
expectTypes(reducer, [
|
|
142
|
-
'@@messenger-box/LOAD_COUNT_REQUEST',
|
|
143
|
-
'@@messenger-box/LOAD_COUNT_ERROR',
|
|
144
|
-
]),
|
|
145
|
-
);
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('includes error message with @@messenger-box/LOAD_COUNT_ERROR', () => {
|
|
149
|
-
const { dispatch, reducer } = store();
|
|
150
|
-
actions.loadCount(null)(dispatch);
|
|
151
|
-
return eventually(() => {
|
|
152
|
-
expect(reducer.mock.calls[1][1].error.message).toEqual(
|
|
153
|
-
'something terrible happened',
|
|
154
|
-
);
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
});
|
|
159
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './sampleActions';
|