feat: Choose random color on collection creation (#3912)
Choose a random color from a shared color palette between backend and frontend during collection creation.
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import TestServer from "fetch-test-server";
|
||||
import { colorPalette } from "@shared/utils/collections";
|
||||
import { Document, CollectionUser, CollectionGroup } from "@server/models";
|
||||
import webService from "@server/services/web";
|
||||
import {
|
||||
@@ -1054,6 +1055,7 @@ describe("#collections.create", () => {
|
||||
expect(body.data.name).toBe("Test");
|
||||
expect(body.data.sort.field).toBe("index");
|
||||
expect(body.data.sort.direction).toBe("asc");
|
||||
expect(colorPalette.includes(body.data.color)).toBeTruthy();
|
||||
expect(body.policies.length).toBe(1);
|
||||
expect(body.policies[0].abilities.read).toBeTruthy();
|
||||
});
|
||||
|
||||
@@ -2,6 +2,8 @@ import fractionalIndex from "fractional-index";
|
||||
import invariant from "invariant";
|
||||
import Router from "koa-router";
|
||||
import { Sequelize, Op, WhereOptions } from "sequelize";
|
||||
import { randomElement } from "@shared/random";
|
||||
import { colorPalette } from "@shared/utils/collections";
|
||||
import collectionExporter from "@server/commands/collectionExporter";
|
||||
import teamUpdater from "@server/commands/teamUpdater";
|
||||
import { sequelize } from "@server/database/sequelize";
|
||||
@@ -50,7 +52,7 @@ const router = new Router();
|
||||
router.post("collections.create", auth(), async (ctx) => {
|
||||
const {
|
||||
name,
|
||||
color,
|
||||
color = randomElement(colorPalette),
|
||||
description,
|
||||
permission,
|
||||
sharing,
|
||||
|
||||
Reference in New Issue
Block a user