Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit 6581ab0

Browse files
committed
Merge branch 'alpha' of https://github.com/withspectrum/spectrum into 2.1.7
2 parents d0a19ac + 693b237 commit 6581ab0

40 files changed

+529
-182
lines changed

CONTRIBUTING.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Contributing
2+
3+
## Auto labelling
4+
5+
The PR template contains a section that looks something like this:
6+
7+
```
8+
<!--
9+
10+
Please check the checkboxes below for any labels you want assigned to the PR:
11+
12+
- [ ] WIP
13+
- [ ] Ready for review
14+
- [ ] Needs testing
15+
16+
-->
17+
```
18+
19+
If you check one of these boxes the corresponding label will automatically be applied to the PR by our bot. For example ticking "WIP" will assign the "WIP: Building" label:
20+
21+
22+
```
23+
- [x] WIP
24+
```

admin/src/components/formElements/style.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import styled, { css } from 'styled-components';
22
import { FlexRow, Transition } from '../globals';
3+
import Textarea from 'react-textarea-autosize';
34

45
export const StyledLabel = styled.label`
56
display: flex;
@@ -98,7 +99,7 @@ export const StyledInput = styled.input`
9899
}
99100
`;
100101

101-
export const StyledTextArea = styled.textarea`
102+
export const StyledTextArea = styled(Textarea)`
102103
flex: 1 0 auto;
103104
width: 100%;
104105
background: ${({ theme }) => theme.bg.default};

dangerfile.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@ import path from 'path';
33
import { warn, fail, message, markdown, schedule, danger } from 'danger';
44
import yarn from 'danger-plugin-yarn';
55
import jest from 'danger-plugin-jest';
6+
import flow from 'danger-plugin-flow';
67
import noTestShortcuts from 'danger-plugin-no-test-shortcuts';
8+
import noConsole from 'danger-plugin-no-console';
79

810
const APP_FOLDERS = [
911
'admin',
@@ -17,7 +19,7 @@ const APP_FOLDERS = [
1719
'src',
1820
'vulcan',
1921
];
20-
const CHECKBOXES = /^- \[x\] *(.*)?$/gim;
22+
const CHECKBOXES = /^\s*-\s*\[x\]\s*(.+?)$/gim;
2123
const possibleAutoLabels = {
2224
wip: 'WIP: Building',
2325
'needs testing': 'WIP: Needs Testing',
@@ -31,15 +33,18 @@ if (danger.github.pr.body.length < 10) {
3133

3234
// Add automatic labels to the PR
3335
schedule(async () => {
34-
const pr = danger.github.pr;
36+
const pr = danger.github.thisPR;
3537
const api = danger.github.api;
36-
const checkedBoxes = pr.body.match(CHECKBOXES);
38+
const checkedBoxes = danger.github.pr.body.match(CHECKBOXES);
3739
if (!checkedBoxes || checkedBoxes.length === 0) return;
3840

39-
const matches = checkedBoxes.map(result => result[1]);
41+
const matches = checkedBoxes
42+
.map(result => new RegExp(CHECKBOXES.source, 'mi').exec(result))
43+
.filter(Boolean)
44+
.map(res => res[1]);
4045

41-
const matchingLabels = matches.filter(match =>
42-
Object.keys(possibleAutoLabels).includes(match.toLowerCase())
46+
const matchingLabels = matches.filter(
47+
match => Object.keys(possibleAutoLabels).indexOf(match.toLowerCase()) > -1
4348
);
4449

4550
if (!matchingLabels || matchingLabels.length === 0) return;
@@ -64,3 +69,14 @@ jest();
6469
noTestShortcuts({
6570
testFilePredicate: filePath => filePath.endsWith('.test.js'),
6671
});
72+
73+
74+
schedule(noConsole({ whitelist: ['error'] }));
75+
76+
schedule(
77+
flow({
78+
// Don't fail the build, only warn the submitter
79+
warn: true,
80+
blacklist: ['flow-typed/**/*.js', 'public/**/*.js'],
81+
})
82+
);
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// flow-typed signature: 45f3a6b6919397f3ea67b75c1a9601bf
2+
// flow-typed version: <<STUB>>/danger-plugin-flow_vx.x.x/flow_v0.66.0
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'danger-plugin-flow'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'danger-plugin-flow' {
17+
declare module.exports: any;
18+
}
19+
20+
/**
21+
* We include stubs for each file inside this npm package in case you need to
22+
* require those files directly. Feel free to delete any files that aren't
23+
* needed.
24+
*/
25+
declare module 'danger-plugin-flow/dist/index' {
26+
declare module.exports: any;
27+
}
28+
29+
declare module 'danger-plugin-flow/dist/index.test' {
30+
declare module.exports: any;
31+
}
32+
33+
// Filename aliases
34+
declare module 'danger-plugin-flow/dist/index.js' {
35+
declare module.exports: $Exports<'danger-plugin-flow/dist/index'>;
36+
}
37+
declare module 'danger-plugin-flow/dist/index.test.js' {
38+
declare module.exports: $Exports<'danger-plugin-flow/dist/index.test'>;
39+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// flow-typed signature: be735722bffb485a8cf54a7c7080821a
2+
// flow-typed version: <<STUB>>/danger-plugin-no-console_v1.x/flow_v0.66.0
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'danger-plugin-no-console'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'danger-plugin-no-console' {
17+
declare module.exports: any;
18+
}
19+
20+
/**
21+
* We include stubs for each file inside this npm package in case you need to
22+
* require those files directly. Feel free to delete any files that aren't
23+
* needed.
24+
*/
25+
declare module 'danger-plugin-no-console/dist/index' {
26+
declare module.exports: any;
27+
}
28+
29+
declare module 'danger-plugin-no-console/docs/script/inherited-summary' {
30+
declare module.exports: any;
31+
}
32+
33+
declare module 'danger-plugin-no-console/docs/script/inner-link' {
34+
declare module.exports: any;
35+
}
36+
37+
declare module 'danger-plugin-no-console/docs/script/manual' {
38+
declare module.exports: any;
39+
}
40+
41+
declare module 'danger-plugin-no-console/docs/script/patch-for-local' {
42+
declare module.exports: any;
43+
}
44+
45+
declare module 'danger-plugin-no-console/docs/script/prettify/prettify' {
46+
declare module.exports: any;
47+
}
48+
49+
declare module 'danger-plugin-no-console/docs/script/pretty-print' {
50+
declare module.exports: any;
51+
}
52+
53+
declare module 'danger-plugin-no-console/docs/script/search_index' {
54+
declare module.exports: any;
55+
}
56+
57+
declare module 'danger-plugin-no-console/docs/script/search' {
58+
declare module.exports: any;
59+
}
60+
61+
declare module 'danger-plugin-no-console/docs/script/test-summary' {
62+
declare module.exports: any;
63+
}
64+
65+
// Filename aliases
66+
declare module 'danger-plugin-no-console/dist/index.js' {
67+
declare module.exports: $Exports<'danger-plugin-no-console/dist/index'>;
68+
}
69+
declare module 'danger-plugin-no-console/docs/script/inherited-summary.js' {
70+
declare module.exports: $Exports<'danger-plugin-no-console/docs/script/inherited-summary'>;
71+
}
72+
declare module 'danger-plugin-no-console/docs/script/inner-link.js' {
73+
declare module.exports: $Exports<'danger-plugin-no-console/docs/script/inner-link'>;
74+
}
75+
declare module 'danger-plugin-no-console/docs/script/manual.js' {
76+
declare module.exports: $Exports<'danger-plugin-no-console/docs/script/manual'>;
77+
}
78+
declare module 'danger-plugin-no-console/docs/script/patch-for-local.js' {
79+
declare module.exports: $Exports<'danger-plugin-no-console/docs/script/patch-for-local'>;
80+
}
81+
declare module 'danger-plugin-no-console/docs/script/prettify/prettify.js' {
82+
declare module.exports: $Exports<'danger-plugin-no-console/docs/script/prettify/prettify'>;
83+
}
84+
declare module 'danger-plugin-no-console/docs/script/pretty-print.js' {
85+
declare module.exports: $Exports<'danger-plugin-no-console/docs/script/pretty-print'>;
86+
}
87+
declare module 'danger-plugin-no-console/docs/script/search_index.js' {
88+
declare module.exports: $Exports<'danger-plugin-no-console/docs/script/search_index'>;
89+
}
90+
declare module 'danger-plugin-no-console/docs/script/search.js' {
91+
declare module.exports: $Exports<'danger-plugin-no-console/docs/script/search'>;
92+
}
93+
declare module 'danger-plugin-no-console/docs/script/test-summary.js' {
94+
declare module.exports: $Exports<'danger-plugin-no-console/docs/script/test-summary'>;
95+
}
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// flow-typed signature: 592c0e5852cd969e5602279b98fb79c2
2+
// flow-typed version: <<STUB>>/rethinkdb-changefeed-reconnect_v0.3.2/flow_v0.66.0
3+
4+
/**
5+
* This is an autogenerated libdef stub for:
6+
*
7+
* 'rethinkdb-changefeed-reconnect'
8+
*
9+
* Fill this stub out by replacing all the `any` types.
10+
*
11+
* Once filled out, we encourage you to share your work with the
12+
* community by sending a pull request to:
13+
* https://github.com/flowtype/flow-typed
14+
*/
15+
16+
declare module 'rethinkdb-changefeed-reconnect' {
17+
declare module.exports: any;
18+
}
19+
20+
/**
21+
* We include stubs for each file inside this npm package in case you need to
22+
* require those files directly. Feel free to delete any files that aren't
23+
* needed.
24+
*/
25+
declare module 'rethinkdb-changefeed-reconnect/example/example.babel' {
26+
declare module.exports: any;
27+
}
28+
29+
declare module 'rethinkdb-changefeed-reconnect/example/example' {
30+
declare module.exports: any;
31+
}
32+
33+
declare module 'rethinkdb-changefeed-reconnect/example/index' {
34+
declare module.exports: any;
35+
}
36+
37+
declare module 'rethinkdb-changefeed-reconnect/lib/__tests__/index.test' {
38+
declare module.exports: any;
39+
}
40+
41+
declare module 'rethinkdb-changefeed-reconnect/lib/index' {
42+
declare module.exports: any;
43+
}
44+
45+
declare module 'rethinkdb-changefeed-reconnect/src/__tests__/index.test' {
46+
declare module.exports: any;
47+
}
48+
49+
declare module 'rethinkdb-changefeed-reconnect/src/index' {
50+
declare module.exports: any;
51+
}
52+
53+
// Filename aliases
54+
declare module 'rethinkdb-changefeed-reconnect/example/example.babel.js' {
55+
declare module.exports: $Exports<'rethinkdb-changefeed-reconnect/example/example.babel'>;
56+
}
57+
declare module 'rethinkdb-changefeed-reconnect/example/example.js' {
58+
declare module.exports: $Exports<'rethinkdb-changefeed-reconnect/example/example'>;
59+
}
60+
declare module 'rethinkdb-changefeed-reconnect/example/index.js' {
61+
declare module.exports: $Exports<'rethinkdb-changefeed-reconnect/example/index'>;
62+
}
63+
declare module 'rethinkdb-changefeed-reconnect/lib/__tests__/index.test.js' {
64+
declare module.exports: $Exports<'rethinkdb-changefeed-reconnect/lib/__tests__/index.test'>;
65+
}
66+
declare module 'rethinkdb-changefeed-reconnect/lib/index.js' {
67+
declare module.exports: $Exports<'rethinkdb-changefeed-reconnect/lib/index'>;
68+
}
69+
declare module 'rethinkdb-changefeed-reconnect/src/__tests__/index.test.js' {
70+
declare module.exports: $Exports<'rethinkdb-changefeed-reconnect/src/__tests__/index.test'>;
71+
}
72+
declare module 'rethinkdb-changefeed-reconnect/src/index.js' {
73+
declare module.exports: $Exports<'rethinkdb-changefeed-reconnect/src/index'>;
74+
}

iris/models/community.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
} from 'shared/bull/queues';
1010
import { removeMemberInChannel } from './usersChannels';
1111
import type { DBCommunity } from 'shared/types';
12+
import type { Timeframe } from './utils';
1213

1314
export const getCommunityById = (id: string): Promise<DBCommunity> => {
1415
return db
@@ -589,7 +590,7 @@ export const getThreadCount = (communityId: string) => {
589590

590591
export const getCommunityGrowth = async (
591592
table: string,
592-
range: string,
593+
range: Timeframe,
593594
field: string,
594595
communityId: string,
595596
filter?: mixed

iris/models/directMessageThread.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//@flow
22
const { db } = require('./db');
3-
import { NEW_DOCUMENTS, eachAsyncNewValue } from './utils';
3+
import { NEW_DOCUMENTS, createChangefeed } from './utils';
44

55
export type DBDirectMessageThread = {
66
createdAt: Date,
@@ -80,8 +80,8 @@ const hasChanged = (field: string) =>
8080
.ne(db.row('new_val')(field));
8181
const THREAD_LAST_ACTIVE_CHANGED = hasChanged('threadLastActive');
8282

83-
const listenToUpdatedDirectMessageThreads = (cb: Function): Function => {
84-
return db
83+
const getUpdatedDirectMessageThreadChangefeed = () =>
84+
db
8585
.table('directMessageThreads')
8686
.changes({
8787
includeInitial: false,
@@ -92,7 +92,14 @@ const listenToUpdatedDirectMessageThreads = (cb: Function): Function => {
9292
right: ['id', 'createdAt', 'threadId', 'lastActive', 'lastSeen'],
9393
})
9494
.zip()
95-
.run(eachAsyncNewValue(cb));
95+
.run();
96+
97+
const listenToUpdatedDirectMessageThreads = (cb: Function): Function => {
98+
return createChangefeed(
99+
getUpdatedDirectMessageThreadChangefeed,
100+
cb,
101+
'listenToUpdatedDirectMessageThreads'
102+
);
96103
};
97104

98105
// prettier-ignore

iris/models/message.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
processReputationEventQueue,
77
_adminProcessToxicMessageQueue,
88
} from 'shared/bull/queues';
9-
import { NEW_DOCUMENTS, eachAsyncNewValue } from './utils';
9+
import { NEW_DOCUMENTS, createChangefeed } from './utils';
1010
import { setThreadLastActive } from './thread';
1111

1212
export type MessageTypes = 'text' | 'media';
@@ -149,14 +149,17 @@ export const storeMessage = (
149149
});
150150
};
151151

152-
export const listenToNewMessages = (cb: Function): Function => {
153-
return db
152+
const getNewMessageChangefeed = () =>
153+
db
154154
.table('messages')
155155
.changes({
156156
includeInitial: false,
157157
})
158158
.filter(NEW_DOCUMENTS)('new_val')
159-
.run(eachAsyncNewValue(cb));
159+
.run();
160+
161+
export const listenToNewMessages = (cb: Function): Function => {
162+
return createChangefeed(getNewMessageChangefeed, cb, 'listenToNewMessages');
160163
};
161164

162165
export const getMessageCount = (threadId: string): Promise<number> => {

0 commit comments

Comments
 (0)