Skip to content

Commit

Permalink
schema + settings
Browse files Browse the repository at this point in the history
- domain -> domain-name
- move fields inline instead of separate entities with refs
- auto look up label from attribute name
  • Loading branch information
mhuebert committed Dec 21, 2023
1 parent 94fbbd1 commit e0ba2bf
Show file tree
Hide file tree
Showing 29 changed files with 594 additions and 436 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -17,6 +17,7 @@
"@lezer/markdown": "^1.0.0",
"@nextjournal/lang-clojure": "1.0.0",
"@nextjournal/lezer-clojure": "1.0.0",
"@radix-ui/react-accordion": "^1.1.2",
"@radix-ui/react-alert-dialog": "^1.0.5",
"@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
Expand Down
32 changes: 27 additions & 5 deletions src/sb/app.cljc
Expand Up @@ -2,22 +2,44 @@
(:require [sb.app.account.ui]
[sb.app.asset.ui]
[sb.app.board.ui]
[sb.app.board.admin-ui]
[sb.app.chat.ui]
[sb.app.collection.ui]
[sb.app.content.ui]
[sb.app.discussion.ui]
[sb.app.domain.ui]
[sb.app.domain-name.ui :as domain.ui]
[sb.app.entity.ui]
[sb.app.field.admin-ui]
[sb.app.field.ui]
[sb.app.field.admin-ui :as field.admin-ui]
[sb.app.field.ui :as field.ui]
[sb.app.form.ui :as form.ui]
[sb.app.member.ui]
[sb.app.notification.ui]
[sb.app.org.ui]
[sb.app.project.ui]
[sb.app.social-feed.ui]
[sb.app.vote.ui]
[org.sparkboard.slack.schema]
[sb.transit :as t]))
[sb.transit :as t]
[inside-out.forms :as io]
[sb.i18n :refer [tr]]))

#?(:cljs
(def client-endpoints (t/read (shadow.resource/inline "public/js/sparkboard.views.transit.json"))))
(def client-endpoints (t/read (shadow.resource/inline "public/js/sparkboard.views.transit.json"))))

(def global-field-meta
{:account/email {:view field.ui/text-field
:props {:type "email"
:placeholder (tr :tr/email)}
:validators [form.ui/email-validator]}
:account/password {:view field.ui/text-field
:props {:type "password"
:placeholder (tr :tr/password)}
:validators [(io/min-length 8)]}
:entity/title {:validators [(io/min-length 3)]}
:board/project-fields {:view field.admin-ui/fields-editor}
:board/member-fields {:view field.admin-ui/fields-editor}
:field/label {:view field.ui/text-field}
:field/hint {:view field.ui/text-field}
:entity/domain-name {:view domain.ui/domain-field
:validators (domain.ui/validators)}
:image/avatar {:view field.ui/image-field}})
71 changes: 71 additions & 0 deletions src/sb/app/board/admin_ui.cljc
@@ -0,0 +1,71 @@
(ns sb.app.board.admin-ui
(:require [sb.app.views.ui :as ui]
[sb.app.board.data :as data]
[sb.app.views.header :as header]
[sb.app.form.ui :as form.ui]
[sb.app.entity.ui :as entity.ui :refer [use-persisted]]
[sb.app.field.ui :as field.ui]
[sb.app.domain-name.ui :as domain.ui]
[sb.app.field.admin-ui :as field.admin-ui]
[sb.app.views.radix :as radix]
[sb.i18n :refer [tr]]))

(ui/defview settings
{:route "/b/:board-id/settings"}
[{:as params :keys [board-id]}]
(let [board (data/settings params)]
[:<>
(header/entity board)
[radix/accordion {:class "max-w-[600px] mx-auto my-6 flex-v gap-6"
:multiple true}

[:div.field-label (tr :tr/basic-settings)]
[:div.flex-v.gap-4
(use-persisted board :entity/title)
(use-persisted board :entity/description)
(use-persisted board :entity/domain-name)
(use-persisted board :image/avatar {:label (tr :tr/image.logo)})]


[:div.field-label (tr :tr/projects-and-members)]
[:div.flex-v.gap-4
(field.admin-ui/fields-editor board :board/member-fields)
(field.admin-ui/fields-editor board :board/project-fields)]


[:div.field-label (tr :tr/registration)]
[:div.flex-v.gap-4
(use-persisted board :board/registration-open?)
(use-persisted board :board/registration-url-override)
(use-persisted board :board/registration-page-message)
(use-persisted board :board/invite-email-text)]]



;; TODO
;; - :board/project-sharing-buttons
;; - :board/member-tags

;; Registration
;; - :board/registration-invitation-email-text
;; - :board/registration-newsletter-field?
;; - :board/registration-open?
;; - :board/registration-message
;; - :board/registration-url-override
;; - :board/registration-codes

;; Theming
;; - border radius
;; - headline font
;; - accent color

;; Sponsors
;; - logo area with tiered sizes/visibility

;; Sticky Notes
;; - schema: a new entity type (not a special kind of project)
;; - modify migration based on ^new schema
;; - color is picked per sticky note
;; - sticky notes can include images/videos

]))
176 changes: 85 additions & 91 deletions src/sb/app/board/data.cljc
Expand Up @@ -10,97 +10,91 @@
[sb.validate :as validate]))

(sch/register!
{:board/show-project-numbers? {s- :boolean
:doc "Show 'project numbers' for this board"}
:board/max-members-per-project {:doc "Set a maximum number of members a project may have"
s- :int}
:board/project-sharing-buttons {:doc "Which social sharing buttons to display on project detail pages",
s- [:map-of :social/sharing-button :boolean]}
:board/is-template? {:doc "Board is only used as a template for creating other boards",
s- :boolean},
:board/labels {:unsure "How can this be handled w.r.t. locale?"
s- [:map-of [:enum
:label/member.one
:label/member.many
:label/project.one
:label/project.many] :string]},
:board/instructions {:doc "Secondary instructions for a board, displayed above projects"
s- :prose/as-map},
:board/max-projects-per-member {:doc "Set a maximum number of projects a member may join"
s- :int}
:board/sticky-color {:doc "Border color for sticky projects"
s- :html/color}
:board/member-tags (sch/ref :many :tag/as-map)
:board/project-fields (merge (sch/ref :many :field/as-map)
sch/component)
:board/member-fields (merge (sch/ref :many :field/as-map)
sch/component)
:board/registration-invitation-email-text {:doc "Body of email sent when inviting a user to a board."
s- :string},
:board/registration-newsletter-field? {:doc "During registration, request permission to send the user an email newsletter"
s- :boolean},
:board/registration-open? {:doc "Allows new registrations via the registration page. Does not affect invitations.",
s- :boolean},
:board/registration-message {:doc "Content displayed on registration screen (before user chooses provider / enters email)"
s- :prose/as-map},
:board/registration-url-override {:doc "URL to redirect user for registration (replaces the Sparkboard registration page, admins are expected to invite users)",
s- :http/url},
:board/registration-codes {s- [:map-of :string [:map {:closed true} [:registration-code/active? :boolean]]]}
:board/new-projects-require-approval? {s- :boolean}
:board/custom-css {:doc "Custom CSS for this board"
s- :string}
:board/custom-js {:doc "Custom JS for this board"
s- :string}
:board/as-map {s- [:map {:closed true}
:entity/id
:entity/title
:entity/created-at
:entity/public?
:entity/kind
:entity/parent

:board/registration-open?

(? :image/avatar)
(? :image/logo-large)
(? :image/footer)
(? :image/background)
(? :image/sub-header)

(? :entity/website)
(? :entity/meta-description)
(? :entity/description)
(? :entity/domain)
(? :entity/locale-default)
(? :entity/locale-dicts)
(? :entity/locale-suggestions)
(? :entity/social-feed)
(? :entity/deleted-at)
(? :entity/created-by)

(? :board/custom-css)
(? :board/custom-js)
(? :board/instructions)
(? :board/is-template?)
(? :board/labels)
(? :board/max-members-per-project)
(? :board/max-projects-per-member)
(? :board/member-fields)
(? :board/member-tags)
(? :board/new-projects-require-approval?)
(? :board/project-fields)
(? :board/project-sharing-buttons)
(? :board/registration-codes)
(? :board/registration-invitation-email-text)
(? :board/registration-message)
(? :board/registration-newsletter-field?)
(? :board/registration-url-override)
(? :board/show-project-numbers?)
(? :board/slack.team)
(? :board/sticky-color)

(? :member-vote/open?)
(? :webhook/subscriptions)]}})
{:board/project-numbers? {s- :boolean
:hint "Assign numbers to this board's projects."}
:board/max-members-per-project {s- :int}
:board/project-sharing-buttons {:hint "Social sharing buttons to be displayed on project detail pages"
s- [:map-of :social/sharing-button :boolean]}
:board/is-template? {:doc "Board is only used as a template for creating other boards"
s- :boolean},
:board/labels {:unsure "How can this be handled w.r.t. locale?"
s- [:map-of [:enum
:label/member.one
:label/member.many
:label/project.one
:label/project.many] :string]},
:board/home-page-message {:hint "Additional instructions for a board, displayed when a member has signed in."
s- :prose/as-map},
:board/max-projects-per-member {s- :int}
:board/sticky-color {:doc "Deprecate - sticky notes can pick their own colors"
s- :html/color}
:board/member-tags {s- [:sequential :tag/as-map]}
:board/project-fields {s- [:sequential :field/as-map]}
:board/member-fields {s- [:sequential :field/as-map]}
:board/invite-email-text {:hint "Text of email sent when inviting a user to a board."
s- :string},
:board/registration-newsletter-field? {:hint "During registration, request permission to send the user an email newsletter"
s- :boolean},
:board/registration-open? {:hint "Allows new registrations via the registration page. Does not affect invitations."
s- :boolean},
:board/registration-page-message {:hint "Content displayed on registration screen (before user chooses provider / enters email)"
s- :prose/as-map},
:board/registration-url-override {:hint "URL to redirect user for registration (replaces the Sparkboard registration page, admins are expected to invite users)",
s- :http/url},
:board/registration-codes {s- [:map-of :string [:map {:closed true} [:registration-code/active? :boolean]]]}
:board/new-projects-require-approval? {s- :boolean}
:board/custom-css {s- :string}
:board/custom-js {s- :string}
:board/as-map {s- [:map {:closed true}
:entity/id
:entity/title
:entity/created-at
:entity/public?
:entity/kind
:entity/parent

:board/registration-open?

(? :image/avatar)
(? :image/logo-large)
(? :image/footer)
(? :image/background)
(? :image/sub-header)

(? :entity/website)
(? :entity/meta-description)
(? :entity/description)
(? :entity/domain-name)
(? :entity/locale-default)
(? :entity/locale-dicts)
(? :entity/locale-suggestions)
(? :entity/social-feed)
(? :entity/deleted-at)
(? :entity/created-by)

(? :board/custom-css)
(? :board/custom-js)
(? :board/home-page-message)
(? :board/is-template?)
(? :board/labels)
(? :board/max-members-per-project)
(? :board/max-projects-per-member)
(? :board/member-fields)
(? :board/member-tags)
(? :board/new-projects-require-approval?)
(? :board/project-fields)
(? :board/project-sharing-buttons)
(? :board/registration-codes)
(? :board/invite-email-text)
(? :board/registration-page-message)
(? :board/registration-newsletter-field?)
(? :board/registration-url-override)
(? :board/project-numbers?)
(? :board/slack.team)
(? :board/sticky-color)

(? :member-vote/open?)
(? :webhook/subscriptions)]}})

(q/defx board:register!

Expand Down

0 comments on commit e0ba2bf

Please sign in to comment.