[CORL-681] Configurable Staff Badges (#2620)

* feat: added configurable staff badge

* fix: removed ambigous styles
This commit is contained in:
Wyatt Johnson
2019-10-04 20:22:31 +00:00
committed by GitHub
parent e7ab0b27f9
commit 918ba10867
32 changed files with 428 additions and 44 deletions
+1
View File
@@ -94,6 +94,7 @@ export type Settings = GlobalModerationSettings &
| "wordList"
| "integrations"
| "reaction"
| "staff"
| "editCommentWindowLength"
| "customCSSURL"
| "communityGuidelines"
+10 -1
View File
@@ -1,7 +1,10 @@
import crypto from "crypto";
import { FluentBundle } from "fluent/compat";
import { GQLReactionConfiguration } from "coral-server/graph/tenant/schema/__generated__/types";
import {
GQLReactionConfiguration,
GQLStaffConfiguration,
} from "coral-server/graph/tenant/schema/__generated__/types";
import { translate } from "coral-server/services/i18n";
export const getDefaultReactionConfiguration = (
@@ -19,6 +22,12 @@ export const getDefaultReactionConfiguration = (
icon: "thumb_up",
});
export const getDefaultStaffConfiguration = (
bundle: FluentBundle
): GQLStaffConfiguration => ({
label: translate(bundle, "Staff", "staff-label"),
});
export function generateSSOKey() {
// Generate a new key. We generate a key of minimum length 32 up to 37 bytes,
// as 16 was the minimum length recommended.
+10 -2
View File
@@ -13,7 +13,11 @@ import { Settings } from "coral-server/models/settings";
import { I18n } from "coral-server/services/i18n";
import { tenants as collection } from "coral-server/services/mongodb/collections";
import { generateSSOKey, getDefaultReactionConfiguration } from "./helpers";
import {
generateSSOKey,
getDefaultReactionConfiguration,
getDefaultStaffConfiguration,
} from "./helpers";
/**
* TenantResource references a given resource that should be owned by a specific
@@ -64,6 +68,9 @@ export async function createTenant(
input: CreateTenantInput,
now = new Date()
) {
// Get the tenant's bundle.
const bundle = i18n.getBundle(input.locale);
const defaults: Sub<Tenant, CreateTenantInput> = {
// Create a new ID.
id: uuid.v4(),
@@ -168,7 +175,8 @@ export async function createTenant(
doNotStore: true,
},
},
reaction: getDefaultReactionConfiguration(i18n.getBundle(input.locale)),
reaction: getDefaultReactionConfiguration(bundle),
staff: getDefaultStaffConfiguration(bundle),
stories: {
scraping: {
enabled: true,