Skip to content

Commit

Permalink
merge experiment into master
Browse files Browse the repository at this point in the history
  • Loading branch information
tima101 committed Jul 10, 2018
2 parents 48d9093 + 556b3d0 commit 1bf7350
Show file tree
Hide file tree
Showing 91 changed files with 2,128 additions and 3,184 deletions.
8 changes: 4 additions & 4 deletions admin/lib/withAuth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export default function withAuth(
let asUrl = '/login';
if (user) {
if (!user.defaultTeamSlug) {
redirectUrl = '/settings/create-team';
asUrl = '/settings/create-team';
redirectUrl = '/create-team';
asUrl = '/create-team';
} else {
redirectUrl = `/topics/detail?teamSlug=${user.defaultTeamSlug}&topicSlug=projects`;
asUrl = `/team/${user.defaultTeamSlug}/t/projects`;
redirectUrl = `/discussion?teamSlug=${user.defaultTeamSlug}`;
asUrl = `/team/${user.defaultTeamSlug}/d`;
}
}

Expand Down
9 changes: 5 additions & 4 deletions admin/lib/withStore.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import React from 'react';
import { Provider, inject } from 'mobx-react';

import { initStore, Store, getStore } from './store';
import { getInitialData, getUser } from './api/admin';
import { getInitialData } from './api/team-member';
import { getUser } from './api/public';

export default function withStore(BaseComponent) {
BaseComponent = inject('store')(BaseComponent);
Expand Down Expand Up @@ -33,22 +34,22 @@ export default function withStore(BaseComponent) {
Object.assign(props, (await BaseComponent.getInitialProps(ctx)) || {});
}

const { teamSlug, topicSlug, discussionSlug } = props;
const { teamSlug, discussionSlug } = props;
let initialData = {};

if (user) {
try {
initialData = await getInitialData({
request: ctx.req,
data: { teamSlug, topicSlug, discussionSlug },
data: { teamSlug, discussionSlug },
});
} catch (error) {
console.log(error);
}
}

Object.assign(props, {
initialState: { user, teamSlug, ...initialData },
initialState: { user, teamSlug, currentUrl: ctx.asPath, ...initialData },
});

return props;
Expand Down
7 changes: 0 additions & 7 deletions admin/server/models/Discussion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,6 @@ const mongoSchema = new mongoose.Schema({
required: true,
default: Date.now,
},
lastActivityDate: {
type: Date,
required: true,
default: Date.now,
},
});

mongoSchema.index({ name: 'text' });
Expand All @@ -51,7 +46,6 @@ interface IDiscussionDocument extends mongoose.Document {
memberIds: string[];
isPrivate: boolean;
createdAt: Date;
lastActivityDate: Date;
}

interface IDiscussionModel extends mongoose.Model<IDiscussionDocument> {
Expand Down Expand Up @@ -132,7 +126,6 @@ class DiscussionClass extends mongoose.Model {
const filter: any = { topicId, $or: [{ isPrivate: false }, { memberIds: userId }] };

const discussions: any[] = await this.find(filter)
.sort({ lastActivityDate: -1 })
.lean();

return { discussions };
Expand Down
11 changes: 0 additions & 11 deletions admin/server/models/Team.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as mongoose from 'mongoose';

import Topic from './Topic';

import generateSlug from '../utils/slugify';
import User from './User';

Expand Down Expand Up @@ -105,15 +103,6 @@ class TeamClass extends mongoose.Model {
defaultTeam,
});

await Topic.create({
createdUserId: userId,
teamId: team._id,
name: 'Projects',
slug: 'projects',
isProjects: true,
createdAt: new Date(),
});

return team;
}

Expand Down
201 changes: 0 additions & 201 deletions admin/server/models/Topic.ts

This file was deleted.

2 changes: 0 additions & 2 deletions admin/server/models/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ const mongoSchema = new mongoose.Schema({
default: '',
},

projectIds: [String],

isAdmin: {
type: Boolean,
default: false,
Expand Down
11 changes: 9 additions & 2 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
"build": "tsc --project tsconfig.json",
"start": "NODE_ENV=production node production-server/app.js",
"now": "now && now alias && now rm saas-api --safe --yes",
"lint": "tslint components pages lib server",
"lint": "tslint -p tsconfig.json",
"test": "jest --coverage",
"processes-8000": "ss -lptn 'sport = :8000'",
"processes-node": "ps -e|grep node"
"processes-node": "ps -e|grep node",
"kill-processes-at-port": "lsof -i tcp:8000 | awk 'NR!=1 {print $2}' | xargs kill"
},
"husky": {
"hooks": {
"pre-commit": "yarn lint && yarn build && cd ../app && yarn lint"
}
},
"jest": {
"coverageDirectory": "./.coverage"
Expand Down Expand Up @@ -55,6 +61,7 @@
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-jsx-a11y": "^6.0.3",
"eslint-plugin-react": "^7.8.2",
"husky": "^1.0.0-rc.13",
"jest": "^22.4.4",
"nodemon": "^1.17.4",
"ts-node": "^6.0.3",
Expand Down
2 changes: 1 addition & 1 deletion api/server/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import publicApi from './public';
import teamLeaderApi from './team-leader';
import teamMemberApi from './team-member';
import publicApi from './public';

export default function api(server) {
server.use('/api/v1/public', publicApi);
Expand Down
2 changes: 1 addition & 1 deletion api/server/api/public.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as express from 'express';

import Invitation from '../models/Invitation';
import logger from '../logs';
import Invitation from '../models/Invitation';

const router = express.Router();

Expand Down
Loading

0 comments on commit 1bf7350

Please sign in to comment.