[CORL-158] Open/Close stream inside of configure tab (#2223)

* feat: Open or Close stream inside of configure tab

* feat: default disable/close commenting message

* fix: adjusted tests
This commit is contained in:
Kiwi
2019-03-19 18:30:44 +01:00
committed by GitHub
parent 5a7340ac3a
commit 41db413bea
34 changed files with 783 additions and 208 deletions
@@ -0,0 +1,23 @@
import { GQLCloseCommentingTypeResolver } from "talk-server/graph/tenant/schema/__generated__/types";
import * as settings from "talk-server/models/settings";
import { translate } from "talk-server/services/i18n";
export const CloseCommenting: GQLCloseCommentingTypeResolver<
settings.CloseCommenting
> = {
message: (closeCommenting, input, ctx) => {
if (closeCommenting.message) {
return closeCommenting.message;
}
// Get the translation bundle.
const bundle = ctx.i18n.getBundle(ctx.lang);
// Translate the default close message.
return translate(
bundle,
"Comments are closed on this story.",
"closeCommentingDefaultMessage"
);
},
};
@@ -0,0 +1,23 @@
import { GQLDisableCommentingTypeResolver } from "talk-server/graph/tenant/schema/__generated__/types";
import * as settings from "talk-server/models/settings";
import { translate } from "talk-server/services/i18n";
export const DisableCommenting: GQLDisableCommentingTypeResolver<
settings.DisableCommenting
> = {
message: (disableCommenting, input, ctx) => {
if (disableCommenting.message) {
return disableCommenting.message;
}
// Get the translation bundle.
const bundle = ctx.i18n.getBundle(ctx.lang);
// Translate the default close message.
return translate(
bundle,
"Comments are closed on this story.",
"disableCommentingDefaultMessage"
);
},
};
@@ -4,10 +4,12 @@ import { GQLResolver } from "talk-server/graph/tenant/schema/__generated__/types
import { AcceptCommentPayload } from "./AcceptCommentPayload";
import { AuthIntegrations } from "./AuthIntegrations";
import { CloseCommenting } from "./CloseCommenting";
import { Comment } from "./Comment";
import { CommentCounts } from "./CommentCounts";
import { CommentModerationAction } from "./CommentModerationAction";
import { CommentRevision } from "./CommentRevision";
import { DisableCommenting } from "./DisableCommenting";
import { FacebookAuthIntegration } from "./FacebookAuthIntegration";
import { GoogleAuthIntegration } from "./GoogleAuthIntegration";
import { ModerationQueue } from "./ModerationQueue";
@@ -24,11 +26,13 @@ import { User } from "./User";
const Resolvers: GQLResolver = {
AcceptCommentPayload,
AuthIntegrations,
CloseCommenting,
Comment,
CommentCounts,
CommentModerationAction,
CommentRevision,
Cursor,
DisableCommenting,
FacebookAuthIntegration,
GoogleAuthIntegration,
ModerationQueue,
@@ -780,7 +780,7 @@ type DisableCommenting {
message will be shown above the comment stream while
commenting is disabled site-wide.
"""
message: String
message: String!
}
################################################################################
@@ -912,7 +912,7 @@ type CloseCommenting {
message when provided will be the message that shows when the comment stream
is closed for commenting.
"""
message: String
message: String!
}
"""
+2
View File
@@ -0,0 +1,2 @@
closeCommentingDefaultMessage = Comments are closed on this story.
disableCommentingDefaultMessage = Comments are closed on this story.
+35 -3
View File
@@ -30,6 +30,10 @@ export type FacebookAuthIntegration = Omit<
"callbackURL" | "redirectURL"
>;
/**
* AuthIntegrations are the set of configurations for the variations of
* authentication solutions.
*/
export interface AuthIntegrations {
local: GQLLocalAuthIntegration;
sso: GQLSSOAuthIntegration;
@@ -38,6 +42,9 @@ export interface AuthIntegrations {
facebook: FacebookAuthIntegration;
}
/**
* Auth is the set of configured authentication integrations.
*/
export type Auth = Omit<GQLAuth, "integrations"> & {
/**
* integrations are the set of configurations for the variations of
@@ -46,11 +53,25 @@ export type Auth = Omit<GQLAuth, "integrations"> & {
integrations: AuthIntegrations;
};
/**
* CloseCommenting contains settings related to the automatic closing of commenting on
* Stories.
*/
export type CloseCommenting = Omit<GQLSettings["closeCommenting"], "message"> &
Partial<Pick<GQLSettings["closeCommenting"], "message">>;
/**
* DisableCommenting will disable commenting site-wide.
*/
export type DisableCommenting = Omit<
GQLSettings["disableCommenting"],
"message"
> &
Partial<Pick<GQLSettings["disableCommenting"], "message">>;
export type Settings = GlobalModerationSettings &
Pick<
GQLSettings,
| "closeCommenting"
| "disableCommenting"
| "charCount"
| "email"
| "karma"
@@ -62,7 +83,18 @@ export type Settings = GlobalModerationSettings &
| "communityGuidelines"
> & {
/**
* Set of configured authentication integrations.
* auth is the set of configured authentication integrations.
*/
auth: Auth;
/**
* closeCommenting contains settings related to the automatic closing of commenting on
* Stories.
*/
closeCommenting: CloseCommenting;
/**
* disableCommenting will disable commenting site-wide.
*/
disableCommenting: DisableCommenting;
};