398 Commits

Author SHA1 Message Date
91f47653bf Fix SiteForm properties 2019-04-03 17:50:27 +08:00
0b1cd203c3 Add sync actions to CRUDActions 2019-04-03 11:41:54 +08:00
71f7687ab9 Add Link (ContextLink) 2019-04-02 23:33:06 +08:00
d5cb6b92b6 Remove onUpdateTeam from TeamList 2019-04-02 19:35:39 +08:00
0f0ba81795 Add CRUDList.tsx 2019-04-02 17:24:04 +08:00
264f5aba60 Add T prefix for all type defs 2019-04-02 16:22:38 +08:00
db96b95522 Add SiteList.tsx 2019-04-02 15:32:40 +08:00
0630260628 Add space-within-parens rule 2019-04-02 15:09:47 +08:00
adfa7a069a Add common tslint.json configuration 2019-04-02 14:46:40 +08:00
b8ff27128b Make query optional 2019-04-02 14:38:11 +08:00
0a9648c392 Add packages/common/src/types.ts 2019-04-02 14:38:01 +08:00
2f17418753 Simplify CRUDReducer methods 2019-04-02 12:03:38 +08:00
580fb368e6 Simplify types for CRUDActions & CRUDReducer 2019-04-02 11:44:34 +08:00
8b6f90235e Use default action type and add status to async actions
Since TypeScript can infer types based on string types, it has became
easier to define a single constant of an action that returns a promise,
and then dispatch actions with different statuses: pending, resolved,
and/or rejected. This seems like more typing at first, but in the long
run it will become easier to write generic reducer methods, and the
names of reduced types will not have to be repeated every time.

For example, previously we had to write:

    type MyActionTypes =
      IAsyncAction<IUser, 'LOGIN_PENDING', 'LOGIN_RESOLVED', 'LOGIN_REJECTED'>
      | ...

And now we can write:

    type MyActionTypes =
      IAsyncAction<IUser, 'LOGIN'>
      | ...
2019-04-01 15:20:42 +08:00
61e7e8db4f Fix test in HTTPClientMock.test.ts 2019-04-01 14:24:47 +08:00
31bb2aa5ee Make CRUDActions method bound 2019-04-01 13:11:43 +08:00
500133e0c8 Export crud 2019-04-01 13:04:43 +08:00
fbfcb67c41 Throw error when URL param missing 2019-04-01 12:57:52 +08:00
73be64a900 Add packages/client/src/crud 2019-04-01 12:56:31 +08:00
eed79f35f2 Add start of test for crud 2019-03-28 19:35:09 +08:00
d6113b2fc4 Add CRUDActions 2019-03-28 00:16:14 +08:00
32b527d92f Add CRUDReducer 2019-03-27 19:10:35 +08:00
ed047be2e3 Add valueOrError.ts 2019-03-27 16:23:47 +08:00
58a0fb1772 Add /teams/new route 2019-03-26 20:37:15 +08:00
b38004a08a Add Modal.tsx 2019-03-26 20:33:00 +08:00
1e7ea06f3d Inline sourcemaps and source when compiling TS 2019-03-26 20:00:19 +08:00
289ea00de8 Add tests more tests to TeamConnector.test.tsx 2019-03-26 14:29:44 +08:00
9dd6994498 Make HTTPClientMock#wait() to wait for all requests 2019-03-26 14:12:55 +08:00
d3f294a57c Add packages/client/src/crumbs 2019-03-25 18:30:32 +08:00
9b5809a1d5 Add Breadcrumbs 2019-03-25 17:32:12 +08:00
fbeea5ad3e Use Route in TeamManager.tsx 2019-03-25 17:21:43 +08:00
e76f762d23 Fix TeamService deleting all team realtions by userId 2019-03-25 13:30:21 +08:00
c83fa2d6d4 packages/client: Style TeamManager, fix error on delete 2019-03-25 13:28:09 +08:00
3f96a128a0 packages/server: Return API errors as JSON 2019-03-25 13:27:36 +08:00
5c22f44930 Use === in without.ts 2019-03-25 13:20:03 +08:00
c1d7077061 packages/server: Return validation errors as JSON 2019-03-25 13:19:20 +08:00
e50dd99206 Add common/src/without.ts 2019-03-24 10:47:53 +08:00
d5c4be2ac1 Sort imports 2019-03-24 09:48:08 +08:00
3bcf9d646e Style team manager 2019-03-23 22:50:44 +08:00
77838e8e0c packages/comments-server: Migrate to mysql/mariadb
Currently mysql2 prints a warning every time a connection is
established. This should be fixed with soon:

https://github.com/typeorm/typeorm/pull/3753
2019-03-23 21:21:50 +08:00
93b048bc10 Add correlationId to SqlLogger 2019-03-23 21:16:20 +08:00
cc360afbbe Use Route params in TeamConnector.tsx (untested)
TODO: Fix SQLite3 complaining

https://github.com/typeorm/typeorm/issues/307
2019-03-23 17:14:22 +08:00
dca5374911 Use $typeorm in buildfile 2019-03-23 17:14:08 +08:00
3595a71cec Make TestUtils.tsx type safe
After spending almost two days in finding the issue, I ran across a few
TypeScript issues on their GitHub page:

- Loss of type inference converting to named parameters object
  https://github.com/Microsoft/TypeScript/issues/29791

- Parameter of a callback without a specified type next to it breaks code.
  https://github.com/Microsoft/TypeScript/issues/29799

- Convert to named parameters
  https://github.com/Microsoft/TypeScript/pull/30089

It became clear that TypeScript is unable to infer method return
arguments if a generic type is used more than once in generic parameter
object. Instead it returns {}.

For example, the following would fail on line 28:

    type Convert<A, B> = (value: A) => B

    interface IParams<C, D> {
      value: C
      convert: Convert<C, D>
      doConvert: (value: C, convert: this['convert']) => D
    }

    function doSomething<E, F>(value: E, convert: Convert<E, F>) {
      return convert(value)
    }

    function build<G, H>(params: IParams<G, H>) {
      const {value, convert} = params
      return params.doConvert(value, convert)
    }

    const outerResult = build({
      value: {
        a: {
          value: 1,
        },
        b: 'string',
      },
      convert: value => value.a,
      doConvert: (value, convert) => {
        const innerResult = doSomething(value, convert)
        innerResult.value
        console.log('innerResult:', innerResult)
        return innerResult
      },
    })

    console.log('outerResult:', outerResult)

With the message:

    Property 'value' does not exist on type '{}'.

If we replace parameter object IParams with regular ordered function
parameters, the compilation succeeds.

RyanCavanough (TS project lead) from GitHub commented:

> We don't have a separate pass to say "Go dive into the function and
> check to see if all its return statements don't rely on its parameter
> type" - doing so would be expensive in light of the fact that extremely
> few real-world functions actually behave like that in practice.

Source: https://github.com/Microsoft/TypeScript/issues/29799#issuecomment-464154659

These modifications bring type safety to TestUtils.tsx, and therefore
client-side tests of React components, while keeping almost the same
ease of use as before.
2019-03-23 15:48:52 +08:00
0af4aa9554 Fix broken RegisterForm.test.tsx 2019-03-22 14:46:09 +08:00
637b51382a Fix broken LoginForm.test.tsx 2019-03-22 14:43:43 +08:00
8f8c3b6c9c Refactor action definitions to type less 2019-03-22 13:26:58 +08:00
f2e44f477c Add better type checking when connecting components 2019-03-20 16:57:41 +05:00
150a02b344 Add team to @rondo/comments-client 2019-03-20 16:38:20 +05:00
8ae82c5065 Add ability to specify custom JSX in TestUtils 2019-03-20 15:28:05 +05:00