@nocobase/plugin-theme-editor 1.5.0-beta.3 → 1.5.0-beta.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,15 +8,16 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "1.5.0-beta.3",
11
+ "@nocobase/client": "1.5.0-beta.30",
12
12
  "react": "18.2.0",
13
13
  "antd": "5.12.8",
14
14
  "lodash": "4.17.21",
15
- "@nocobase/server": "1.5.0-beta.3",
15
+ "@nocobase/server": "1.5.0-beta.30",
16
16
  "@ant-design/cssinjs": "1.21.1",
17
17
  "@ant-design/icons": "5.2.6",
18
- "@nocobase/utils": "1.5.0-beta.3",
18
+ "@nocobase/utils": "1.5.0-beta.30",
19
19
  "react-i18next": "11.18.6",
20
- "@nocobase/database": "1.5.0-beta.3",
20
+ "@nocobase/actions": "1.5.0-beta.30",
21
+ "@nocobase/database": "1.5.0-beta.30",
21
22
  "@emotion/css": "11.13.0"
22
23
  };
@@ -0,0 +1,10 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+ import { Context, Next } from '@nocobase/actions';
10
+ export declare function updateTheme(ctx: Context, next: Next): Promise<void>;
@@ -0,0 +1,54 @@
1
+ /**
2
+ * This file is part of the NocoBase (R) project.
3
+ * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
+ * Authors: NocoBase Team.
5
+ *
6
+ * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
+ * For more information, please refer to: https://www.nocobase.com/agreement.
8
+ */
9
+
10
+ var __defProp = Object.defineProperty;
11
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
12
+ var __getOwnPropNames = Object.getOwnPropertyNames;
13
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
14
+ var __export = (target, all) => {
15
+ for (var name in all)
16
+ __defProp(target, name, { get: all[name], enumerable: true });
17
+ };
18
+ var __copyProps = (to, from, except, desc) => {
19
+ if (from && typeof from === "object" || typeof from === "function") {
20
+ for (let key of __getOwnPropNames(from))
21
+ if (!__hasOwnProp.call(to, key) && key !== except)
22
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23
+ }
24
+ return to;
25
+ };
26
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
27
+ var update_user_theme_exports = {};
28
+ __export(update_user_theme_exports, {
29
+ updateTheme: () => updateTheme
30
+ });
31
+ module.exports = __toCommonJS(update_user_theme_exports);
32
+ async function updateTheme(ctx, next) {
33
+ const { themeId } = ctx.action.params.values || {};
34
+ const { currentUser } = ctx.state;
35
+ if (!currentUser) {
36
+ ctx.throw(401);
37
+ }
38
+ const userRepo = ctx.db.getRepository("users");
39
+ const user = await userRepo.findOne({ filter: { id: currentUser.id } });
40
+ await userRepo.update({
41
+ filterByTk: currentUser.id,
42
+ values: {
43
+ systemSettings: {
44
+ ...user.systemSettings,
45
+ themeId
46
+ }
47
+ }
48
+ });
49
+ await next();
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ updateTheme
54
+ });
@@ -39,7 +39,7 @@ const defaultTheme = {
39
39
  optional: true,
40
40
  isBuiltIn: true,
41
41
  uid: "default",
42
- default: true
42
+ default: process.env.__E2E__ ? true : false
43
43
  };
44
44
  const dark = {
45
45
  config: {
@@ -64,7 +64,7 @@ const compact = {
64
64
  optional: true,
65
65
  isBuiltIn: true,
66
66
  uid: "compact",
67
- default: false
67
+ default: process.env.__E2E__ ? false : true
68
68
  };
69
69
  const compactDark = {
70
70
  config: {
@@ -7,11 +7,9 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
 
10
- var __create = Object.create;
11
10
  var __defProp = Object.defineProperty;
12
11
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
12
  var __getOwnPropNames = Object.getOwnPropertyNames;
14
- var __getProtoOf = Object.getPrototypeOf;
15
13
  var __hasOwnProp = Object.prototype.hasOwnProperty;
16
14
  var __export = (target, all) => {
17
15
  for (var name in all)
@@ -25,14 +23,6 @@ var __copyProps = (to, from, except, desc) => {
25
23
  }
26
24
  return to;
27
25
  };
28
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
29
- // If the importer is in node compatibility mode or this is not an ESM
30
- // file that has been converted to a CommonJS file using a Babel-
31
- // compatible transform (i.e. "__esModule" has not been set), then set
32
- // "default" to the CommonJS "module.exports" for node compatibility.
33
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
34
- mod
35
- ));
36
26
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
37
27
  var plugin_exports = {};
38
28
  __export(plugin_exports, {
@@ -41,8 +31,8 @@ __export(plugin_exports, {
41
31
  });
42
32
  module.exports = __toCommonJS(plugin_exports);
43
33
  var import_server = require("@nocobase/server");
44
- var import_path = __toESM(require("path"));
45
34
  var import_builtinThemes = require("./builtinThemes");
35
+ var import_update_user_theme = require("./actions/update-user-theme");
46
36
  class PluginThemeEditorServer extends import_server.Plugin {
47
37
  theme;
48
38
  afterAdd() {
@@ -50,14 +40,8 @@ class PluginThemeEditorServer extends import_server.Plugin {
50
40
  async beforeLoad() {
51
41
  }
52
42
  async load() {
53
- await this.importCollections(import_path.default.resolve(__dirname, "./collections"));
54
- this.db.addMigrations({
55
- namespace: "theme-editor",
56
- directory: (0, import_path.resolve)(__dirname, "./migrations"),
57
- context: {
58
- plugin: this
59
- }
60
- });
43
+ this.app.resourceManager.registerActionHandler("users:updateTheme", import_update_user_theme.updateTheme);
44
+ this.app.acl.allow("users", "updateTheme", "loggedIn");
61
45
  this.app.acl.allow("themeConfig", "list", "public");
62
46
  this.app.acl.registerSnippet({
63
47
  name: `pm.${this.name}.themeConfig`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-theme-editor",
3
- "version": "1.5.0-beta.3",
3
+ "version": "1.5.0-beta.30",
4
4
  "main": "dist/server/index.js",
5
5
  "homepage": "https://docs.nocobase.com/handbook/theme-editor",
6
6
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/theme-editor",
@@ -32,7 +32,7 @@
32
32
  "@nocobase/test": "1.x",
33
33
  "@nocobase/utils": "1.x"
34
34
  },
35
- "gitHead": "81afcf4affdb652faf4636e6d9351828ce8906be",
35
+ "gitHead": "40c48b2ecf3e2315a76dcb729dbda825b6a1331c",
36
36
  "keywords": [
37
37
  "System management"
38
38
  ]