mirror of
https://github.com/wassname/talk.git
synced 2026-09-11 12:51:33 +08:00
[next] Implement configuration panes (#2173)
* feat: moderation config * feat: configure banned and suspect words * chore: upgrade react and test libs to the newest version <3 * chore: upgrade typescript + some refactor * feat: general, organization and advanced configuration panes * fix: translation * feat: speedup fetching markdown editor * feat: localize markdown editor * chore: refactor container names * chore: rename infobox to communityGuidelines * feat: closing comment streams duration config * test: add feature tests for configurations * fix: mock only console.error * chore: upgrade node * chore: require node >= 10 * fix: better validation and default values * feat: Make DurationField a general purpose component and reuse for Edit Comment Timeframe * test: add unit test for duration field * fix: patch for bug when built in production * chore: bump npm version to latest * fix: adapted Dockerfile to new version of node * refactor: harmonized seconds/milliseconds to seconds * fix: resolve bug from merge conflict
This commit is contained in:
@@ -1,5 +1,3 @@
|
||||
import { isNull, omitBy } from "lodash";
|
||||
|
||||
import TenantContext from "talk-server/graph/tenant/context";
|
||||
import { GQLUpdateSettingsInput } from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import { Tenant } from "talk-server/models/tenant";
|
||||
@@ -12,7 +10,7 @@ export const Settings = ({
|
||||
tenant,
|
||||
}: TenantContext) => ({
|
||||
update: (input: GQLUpdateSettingsInput): Promise<Tenant | null> =>
|
||||
update(mongo, redis, tenantCache, tenant, omitBy(input.settings, isNull)),
|
||||
update(mongo, redis, tenantCache, tenant, input.settings),
|
||||
regenerateSSOKey: (): Promise<Tenant | null> =>
|
||||
regenerateSSOKey(mongo, redis, tenantCache, tenant),
|
||||
});
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { GraphQLResolveInfo } from "graphql";
|
||||
|
||||
import { getRequestedFields } from "talk-server/graph/tenant/resolvers/util";
|
||||
import {
|
||||
GQLComment,
|
||||
@@ -9,6 +10,7 @@ import * as comment from "talk-server/models/comment";
|
||||
import { getLatestRevision } from "talk-server/models/comment";
|
||||
import { createConnection } from "talk-server/models/helpers/connection";
|
||||
|
||||
import { getCommentEditableUntilDate } from "talk-server/services/comments";
|
||||
import TenantContext from "../context";
|
||||
import { getURLWithCommentID } from "./util";
|
||||
|
||||
@@ -49,9 +51,7 @@ export const Comment: GQLCommentTypeResolver<comment.Comment> = {
|
||||
edited: revisions.length > 1,
|
||||
// The date that the comment is editable until is the tenant's edit window
|
||||
// length added to the comment created date.
|
||||
editableUntil: new Date(
|
||||
createdAt.valueOf() + ctx.tenant.editCommentWindowLength
|
||||
),
|
||||
editableUntil: getCommentEditableUntilDate(ctx.tenant, createdAt),
|
||||
}),
|
||||
author: (c, input, ctx) => ctx.loaders.Users.user.load(c.authorID),
|
||||
statusHistory: ({ id }, input, ctx) =>
|
||||
|
||||
@@ -1,27 +1,14 @@
|
||||
import { DateTime } from "luxon";
|
||||
|
||||
import { GQLStoryTypeResolver } from "talk-server/graph/tenant/schema/__generated__/types";
|
||||
import { decodeActionCounts } from "talk-server/models/action/comment";
|
||||
import * as story from "talk-server/models/story";
|
||||
import { getStoryClosedAt } from "talk-server/services/stories";
|
||||
|
||||
import { storyModerationInputResolver } from "./ModerationQueues";
|
||||
|
||||
export const Story: GQLStoryTypeResolver<story.Story> = {
|
||||
comments: (s, input, ctx) => ctx.loaders.Comments.forStory(s.id, input),
|
||||
isClosed: () => false,
|
||||
closedAt: (s, input, ctx) => {
|
||||
if (s.closedAt) {
|
||||
return s.closedAt;
|
||||
}
|
||||
|
||||
if (ctx.tenant.autoCloseStream && ctx.tenant.closedTimeout) {
|
||||
return DateTime.fromJSDate(s.createdAt)
|
||||
.plus(ctx.tenant.closedTimeout)
|
||||
.toJSDate();
|
||||
}
|
||||
|
||||
return null;
|
||||
},
|
||||
closedAt: (s, input, ctx) => getStoryClosedAt(ctx.tenant, s),
|
||||
commentActionCounts: s => decodeActionCounts(s.commentCounts.action),
|
||||
commentCounts: s => s.commentCounts.status,
|
||||
moderationQueues: storyModerationInputResolver,
|
||||
|
||||
@@ -870,15 +870,14 @@ type Settings {
|
||||
requireEmailConfirmation: Boolean!
|
||||
|
||||
"""
|
||||
infoBoxEnable will enable the Info Box content visible above the question
|
||||
box.
|
||||
communityGuidelinesEnable will show the guidelines above the question box.
|
||||
"""
|
||||
infoBoxEnable: Boolean!
|
||||
communityGuidelinesEnable: Boolean!
|
||||
|
||||
"""
|
||||
infoBoxContent is the content of the Info Box.
|
||||
communityGuidelines is the content of the guidelines.
|
||||
"""
|
||||
infoBoxContent: String
|
||||
communityGuidelines: String
|
||||
|
||||
"""
|
||||
questionBoxEnable will enable the Question Box's content to be visible above
|
||||
@@ -913,8 +912,8 @@ type Settings {
|
||||
customCssUrl: String
|
||||
|
||||
"""
|
||||
closedTimeout is the amount of seconds from the created_at timestamp that a
|
||||
given story will be considered closed.
|
||||
closedTimeout is the amount of time (in seconds) from the createdAt timestamp
|
||||
that a given story will be considered closed.
|
||||
"""
|
||||
closedTimeout: Int!
|
||||
|
||||
@@ -936,8 +935,8 @@ type Settings {
|
||||
disableCommentingMessage: String
|
||||
|
||||
"""
|
||||
editCommentWindowLength is the length of time (in milliseconds) after a
|
||||
comment is posted that it can still be edited by the author.
|
||||
editCommentWindowLength is the length of time (in seconds) after a comment is
|
||||
posted that it can still be edited by the author.
|
||||
"""
|
||||
editCommentWindowLength: Int!
|
||||
|
||||
@@ -2123,15 +2122,15 @@ input SettingsInput {
|
||||
requireEmailConfirmation: Boolean
|
||||
|
||||
"""
|
||||
infoBoxEnable will enable the Info Box content visible above the question
|
||||
communityGuidelinesEnable will enable the Info Box content visible above the question
|
||||
box.
|
||||
"""
|
||||
infoBoxEnable: Boolean
|
||||
communityGuidelinesEnable: Boolean
|
||||
|
||||
"""
|
||||
infoBoxContent is the content of the Info Box.
|
||||
communityGuidelines is the content of the Info Box.
|
||||
"""
|
||||
infoBoxContent: String
|
||||
communityGuidelines: String
|
||||
|
||||
"""
|
||||
questionBoxEnable will enable the Question Box's content to be visible above
|
||||
@@ -2166,7 +2165,7 @@ input SettingsInput {
|
||||
customCssUrl: String
|
||||
|
||||
"""
|
||||
closedTimeout is the amount of seconds from the created_at timestamp that a
|
||||
closedTimeout is the amount of seconds from the createdAt timestamp that a
|
||||
given story will be considered closed.
|
||||
"""
|
||||
closedTimeout: Int
|
||||
@@ -2189,8 +2188,8 @@ input SettingsInput {
|
||||
disableCommentingMessage: String
|
||||
|
||||
"""
|
||||
editCommentWindowLength is the length of time (in milliseconds) after a
|
||||
comment is posted that it can still be edited by the author.
|
||||
editCommentWindowLength is the length of time (in seconds) after a comment is
|
||||
posted that it can still be edited by the author.
|
||||
"""
|
||||
editCommentWindowLength: Int
|
||||
|
||||
|
||||
Reference in New Issue
Block a user