diff --git a/bin/cli-users b/bin/cli-users index 89f53a67d..89bf667a7 100755 --- a/bin/cli-users +++ b/bin/cli-users @@ -8,10 +8,13 @@ const program = require('./commander'); const inquirer = require('inquirer'); const UsersService = require('../services/users'); const UserModel = require('../models/user'); +const CommentModel = require('../models/comment'); +const ActionModel = require('../models/action'); const USER_ROLES = require('../models/enum/user_roles'); const mongoose = require('../services/mongoose'); const util = require('./util'); const Table = require('cli-table'); +const databaseVerifications = require('./verifications/database'); const validateRequired = (msg = 'Field is required', len = 1) => (input) => { if (input && input.length >= len) { @@ -122,26 +125,48 @@ async function createUser(options) { } catch (err) { console.error(err); - util.shutdown(); + util.shutdown(1); } } /** * Deletes a user. */ -function deleteUser(userID) { - UserModel - .findOneAndRemove({ - id: userID - }) - .then(() => { - console.log('Deleted user'); - util.shutdown(); - }) - .catch((err) => { - console.error(err); - util.shutdown(); - }); +async function deleteUser(userID) { + + try { + + // Find the user we're removing. + const user = await UserModel.findOne({id: userID}); + if (!user) { + throw new Error(`user with id ${userID} not found`); + } + + // Remove all the user's actions. + await ActionModel + .where({user_id: user.id}) + .setOptions({multi: true}) + .remove(); + + // Remove all the user's comments. + await CommentModel + .where({author_id: user.id}) + .setOptions({multi: true}) + .remove(); + + // Update the counts that might have changed. + for (const verification of databaseVerifications) { + await verification({fix: true, limit: Infinity, batch: 1000}); + } + + // Remove the user. + await user.remove(); + + util.shutdown(); + } catch (err) { + console.error(err); + util.shutdown(1); + } } /** diff --git a/client/coral-embed-stream/src/tabs/stream/components/Stream.css b/client/coral-embed-stream/src/tabs/stream/components/Stream.css index 23f620157..ac014e75d 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/Stream.css +++ b/client/coral-embed-stream/src/tabs/stream/components/Stream.css @@ -2,9 +2,22 @@ margin-top: 6px; } -.viewAllButton { +.viewAllButtonContainer { position: absolute; - right: 0px; + width: 100%; + display: flex; + justify-content: center; + margin-top: -11px; + z-index: 10; +} + +.viewAllButton { + composes: buttonReset from "coral-framework/styles/reset.css"; + + background-color: #4D8FCC; + color: white; + padding: 4px 8px; + border-radius: 2px; } .tabPanel { @@ -26,4 +39,4 @@ margin-top: 28px; padding-bottom: 50px; min-height: 600px; -} \ No newline at end of file +} diff --git a/client/coral-embed-stream/src/tabs/stream/components/Stream.js b/client/coral-embed-stream/src/tabs/stream/components/Stream.js index 07774f348..b5f45b8e5 100644 --- a/client/coral-embed-stream/src/tabs/stream/components/Stream.js +++ b/client/coral-embed-stream/src/tabs/stream/components/Stream.js @@ -13,7 +13,7 @@ import t, {timeago} from 'coral-framework/services/i18n'; import CommentBox from 'talk-plugin-commentbox/CommentBox'; import QuestionBox from '../../../components/QuestionBox'; import {isCommentActive} from 'coral-framework/utils'; -import {Button, Tab, TabCount, TabPane} from 'coral-ui'; +import {Tab, TabCount, TabPane} from 'coral-ui'; import cn from 'classnames'; import {getTopLevelParent, attachCommentToParent} from '../../../graphql/utils'; @@ -58,6 +58,7 @@ class Stream extends React.Component { loadNewReplies, auth: {user}, emit, + viewAllComments, } = this.props; // even though the permalinked comment is the highlighted one, we're displaying its parent + replies @@ -76,6 +77,14 @@ class Stream extends React.Component { return (