Implements option D of docs/Design/Multitenancy/Multitenancy.md, which that document now describes as shipped. An Organization may claim hostnames (Admin Panel / People / Organizations -> Edit), carry its own branding - product name, logos, help link, legal notice and theme colour - and have its own Organization admins, appointed from the row's "..." menu. The request's host picks the Organization; its branding replaces the instance branding for that request, and the client bundle that host serves points its DDP connection back at that host instead of at the one ROOT_URL. An Organization admin administers their own Organization and nothing else: its people, its Organizations row, its theme colour and its backups. They can never grant the site-wide Admin flag, never manage a site admin, and never see another Organization's people or archives. Per-tenant backup and restore is one new control in Admin Panel / Attachments / Backup - Scope. An Organization's archive holds its boards and everything on them plus the attachments those boards use, and no accounts, no instance settings and no org/team documents, because those are shared. A restore may only write to boards that Organization owns: the board ids are the intersection of what the archive claims with what the Organization really owns, every document is checked against that, and "replace all" replaces that Organization's documents rather than everyone's. Admin Panel / Settings / Visibility gains a Change color section above Logo: the site theme, rendered by the SAME shared picker as Board Settings and Member Settings - one template for all three, the way one shared table page serves every table. Its design is the new docs/Design/Page/Theme.md. The order of themes is WeKan's default theme, then the site theme (an Organization's own value on its own hosts), then a user's own override; a board's own colour still owns the board page. All of it is OFF unless the server is started with MULTITENANCY=true (plus MULTITENANCY_TRUST_PROXY_HOST=true when a trusted proxy sets X-Forwarded-Host), so an instance that has never heard of tenants answers exactly as before. One WeKan server per customer remains the supported topology for customers who must not share a process, and the design says plainly what this does NOT isolate. The decisions are three pure modules - models/lib/tenants.js, tenantAdmin.js and tenantBackup.js - so the same rules run on the client, on the server and in the tests. Four new suites pin the separation rather than the plumbing: forged Host headers, cross-tenant queries, privilege escalation and cross-tenant restores. Thanks to xet7 !
5.5 KiB
Design: Change color
One design, one implementation, for every place a theme colour is chosen: the swatches grouped by category, the "Default theme" row, the custom-colour wheels and the preview. One template renders all of them — the way Table is one table page for every table and Left Menu is one menu for every Admin Panel page.
A place that offers "Change color" does not write markup. It renders the shared template and says whose theme is being set:
+themeColorPicker(scope="board") //- Board Settings / Change Color
+themeColorPicker(scope="global") //- Member Settings / Change color
+themeColorPicker(scope="admin") //- Admin Panel / Settings / Visibility / Change color
scope is the only difference between them.
Related files
| File Path | File Type | Description |
|---|---|---|
client/components/main/themeColorPicker.jade |
.jade template |
The picker: the "Default theme" row, the category groups of swatches, the custom-colour wheels and the preview. |
client/components/main/themeColorPicker.js |
.js component |
Reads the current value for the scope, applies a click immediately, and writes it where that scope says. |
models/lib/themeCategories.js |
.js module, pure helpers |
The categories, their order, which allow a custom colour and how many. |
models/metadata/colors.js |
.js module |
BOARD_COLORS — the theme names themselves. |
client/components/main/globalThemeColor.js |
.js startup |
Applies the winning theme to <body> and the CSS variables — the layering below. |
client/components/sidebar/sidebar.jade |
.jade template |
Board Settings / Change Color — scope="board". |
client/components/users/userHeader.jade |
.jade template |
Member Settings / Change color — scope="global". |
client/components/settings/settingBody.jade |
.jade template |
Admin Panel / Settings / Visibility / Change color — scope="admin". |
server/models/users.js |
.js methods |
setGlobalThemeColor — the user's own override. |
server/methods/tenant.js |
.js methods |
getAdminThemeColor / setAdminThemeColor — the site theme, and which document it lands in. |
models/lib/tenantAdmin.js |
.js module, pure helpers |
themeTarget() — the instance's theme, or one Organization's. |
docs/Theme/Theme.md |
.md guide |
What the themes look like, and the custom-colour categories. |
The order of themes
Weakest first. Each layer replaces the one under it, and only where it is set:
| Layer | Set in | Stored in | |
|---|---|---|---|
| 1 | Default theme | — | nothing; WeKan's own stylesheet |
| 2 | Site theme | Admin Panel / Settings / Visibility / Change color | Settings.themeColor, or an Organization's orgThemeColor on its own hosts |
| 3 | User's own | Member Settings / Change color | user.profile.globalThemeColor |
A board's own colour is not one of these layers: it is what a board looks like. It owns the board page, so the site theme is not applied there — but a user's own override is, because they asked for it everywhere.
Layer 2 is one setting with two possible homes, and the server picks the home
(themeTarget() in models/lib/tenantAdmin.js):
- the site admin sets the instance's theme — the one every Organization that has not chosen its own inherits, which is why their pane says so under the title;
- an Organization's own admin sets that Organization's theme, which replaces the instance's on that Organization's hosts. It reaches nothing else.
The client never decides that. It calls getAdminThemeColor / setAdminThemeColor,
and the server answers for whoever is asking — see
Multitenancy (D.9) for how an Organization's
value gets published in the instance's place.
Places that use this design
| Place | Scope | Writes | Clearing it means |
|---|---|---|---|
| Board Settings / Change Color | board |
board.color + board.customThemeColors |
— (a board always has a colour, so there is no "Default theme" row) |
| Member Settings / Change color | global |
setGlobalThemeColor |
fall back to the site theme, and to per-board colours |
| Admin Panel / Settings / Visibility / Change color | admin |
setAdminThemeColor |
fall back to WeKan's default theme (or, for an Organization, to the instance's) |
What the picker guarantees
- No Save button anywhere. Clicking a swatch applies it immediately, and a
custom-colour wheel applies on
change(not on every intermediate value of a drag). The three places behave identically because it is the same code. - The same categories, in the same order, with the same labels
(
THEME_CATEGORY_ORDER), and the colour wheels appear only for the categories that take a custom colour — one for flat, two for clear (a gradient). - A "Default theme" row wherever there is something to fall back to, i.e. every
scope except
board. - The value is validated on the server. A theme name must be one of
BOARD_COLORSand a custom colour must be a hex colour; anything else is refused rather than stored and rendered as a class.
Adding another place that chooses a theme
- Render
+themeColorPicker(scope="…")— no markup of your own. - Add the scope to
SCOPESinthemeColorPicker.js, with one branch inreadCurrent()and one inapplySelection(). - Say where it sits in the order of themes, in the table above.
If a new place needs a different-looking picker, change this template so every place gets it. That is the point of the design.