mirror of
https://github.com/penpot/penpot.git
synced 2026-04-25 11:18:36 +00:00
🐛 Fix show red bullet in workspace menu if mcp key is expired (#8727)
This commit is contained in:
parent
5a73003c7f
commit
5f722d9183
@ -48,7 +48,7 @@
|
||||
(def schema:props
|
||||
[:map {:title "ProfileProps"}
|
||||
[:plugins {:optional true} schema:plugin-registry]
|
||||
[:mcp-status {:optional true} ::sm/boolean]
|
||||
[:mcp-enabled {:optional true} ::sm/boolean]
|
||||
[:newsletter-updates {:optional true} ::sm/boolean]
|
||||
[:newsletter-news {:optional true} ::sm/boolean]
|
||||
[:onboarding-team-id {:optional true} ::sm/uuid]
|
||||
|
||||
@ -340,7 +340,10 @@
|
||||
(rx/of (ntf/hide)
|
||||
(dcmt/retrieve-comment-threads file-id)
|
||||
(dcmt/fetch-profiles)
|
||||
(df/fetch-fonts team-id)))
|
||||
(df/fetch-fonts team-id))
|
||||
|
||||
(when (contains? cf/flags :mcp)
|
||||
(rx/of (du/fetch-access-tokens))))
|
||||
|
||||
;; Once the essential data is fetched, lets proceed to
|
||||
;; fetch teh file bunldle
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.files.helpers :as cfh]
|
||||
[app.common.time :as ct]
|
||||
[app.common.uuid :as uuid]
|
||||
[app.config :as cf]
|
||||
[app.main.data.common :as dcm]
|
||||
@ -42,9 +43,13 @@
|
||||
[app.util.i18n :as i18n :refer [tr]]
|
||||
[app.util.keyboard :as kbd]
|
||||
[beicon.v2.core :as rx]
|
||||
[okulary.core :as l]
|
||||
[potok.v2.core :as ptk]
|
||||
[rumext.v2 :as mf]))
|
||||
|
||||
(def tokens-ref
|
||||
(l/derived :access-tokens st/state))
|
||||
|
||||
(mf/defc shortcuts*
|
||||
{::mf/private true}
|
||||
[{:keys [id]}]
|
||||
@ -978,10 +983,21 @@
|
||||
:class (stl/css :item-arrow)}]])
|
||||
|
||||
(when (contains? cf/flags :mcp)
|
||||
(let [mcp-enabled? (true? (-> profile :props :mcp-enabled))
|
||||
(let [tokens (mf/deref tokens-ref)
|
||||
expired? (some->> tokens
|
||||
(some #(when (= (:type %) "mcp") %))
|
||||
:expires-at
|
||||
(> (ct/now)))
|
||||
|
||||
mcp-enabled? (true? (-> profile :props :mcp-enabled))
|
||||
mcp-connection (-> workspace-local :mcp :connection)
|
||||
mcp-connected? (= mcp-connection "connected")
|
||||
mcp-error? (= mcp-connection "error")]
|
||||
mcp-error? (= mcp-connection "error")
|
||||
|
||||
active? (and mcp-enabled? mcp-connected?)
|
||||
failed? (or (and mcp-enabled? mcp-error?)
|
||||
(true? expired?))]
|
||||
|
||||
[:> dropdown-menu-item* {:class (stl/css :base-menu-item :menu-item)
|
||||
:on-click on-menu-click
|
||||
:on-key-down (fn [event]
|
||||
@ -993,8 +1009,8 @@
|
||||
[:span {:class (stl/css :item-name)}
|
||||
(tr "workspace.header.menu.option.mcp")]
|
||||
[:span {:class (stl/css-case :item-indicator true
|
||||
:active (and mcp-enabled? mcp-connected?)
|
||||
:failed (and mcp-enabled? mcp-error?))}]
|
||||
:active active?
|
||||
:failed failed?)}]
|
||||
[:> icon* {:icon-id i/arrow-right
|
||||
:class (stl/css :item-arrow)}]]))
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user