Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usability: links to methods and configs [risk: low] #1444

Merged
merged 9 commits into from
Nov 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/cljs/main/broadfcui/components/entity_details.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
[broadfcui.common.links :as links]
[broadfcui.common.style :as style]
[broadfcui.config :as config]
[broadfcui.nav :as nav]
[broadfcui.utils :as utils]
))

Expand Down Expand Up @@ -78,7 +79,12 @@
"agora" (list
(make-field :namespace "Namespace")
(make-field :name "Name")
(make-field :snapshotId "Snapshot ID" :dropdown? true))
(make-field :snapshotId "Snapshot ID" :dropdown? true
:render (fn [snapshot-id]
(if redacted?
snapshot-id
(let [method-id (merge entity {:snapshot-id snapshot-id})]
(links/create-internal {:href (nav/get-link :method-loader method-id)} snapshot-id))))))
"dockstore" (list
(make-field :methodPath "Path"
:render (fn [path]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,24 @@
[:span {:style {:fontWeight 500}} (:methodConfigurationNamespace submission)]]
[:div {}
[:div {:style {:fontWeight 200 :display "inline-block" :width 90}} "Name:"]
[:span {:style {:fontWeight 500}} (:methodConfigurationName submission)]])
;; if we were able to retrieve the method config (see :load-details), then display
;; the config's name as a link. Else, display it as text with an informative tooltip.
(let [config-name (:methodConfigurationName submission)
config-namespace (:methodConfigurationNamespace submission)
ws-config (:ws-config @state)
workspace-id (:workspace-id props)]
(if ws-config
(links/create-internal
{:data-test-id (str "method-config-" config-name "-link")
:style {:fontWeight "bold"}
:href (nav/get-link :workspace-method-config
workspace-id
{:namespace config-namespace
:name config-name})}
config-name)
[:span {:style {:fontWeight 500}} config-name
(dropdown/render-info-box
{:text "This config was updated or deleted since this submission ran."})]))])
(if (get-in submission [:submissionEntity :entityType])
[:div {}
(style/create-section-header "Submission Entity")
Expand Down Expand Up @@ -244,5 +261,16 @@
:on-done (fn [{:keys [success? status-text get-parsed-response]}]
(swap! state assoc :server-response (if success?
{:submission (get-parsed-response)}
{:error-message status-text})))}))
{:error-message status-text}))
;; if we successfully retrieved the submission, make a call to see if the current
;; user has access to the method config on which this submission ran. The config
;; may have been updated/deleted, and therefore the user may not be able to see it.
(let [submission (get-parsed-response)
config-id {:namespace (:methodConfigurationNamespace submission)
:name (:methodConfigurationName submission)}]
(endpoints/call-ajax-orch
{:endpoint (endpoints/get-workspace-method-config (:workspace-id props) config-id)
:on-done (fn [{:keys [success? status-text get-parsed-response]}]
(when success?
(swap! state assoc :ws-config (get-parsed-response))))})))}))
:component-did-mount (fn [{:keys [this]}] (this :load-details))})
23 changes: 20 additions & 3 deletions src/cljs/main/broadfcui/page/workspace/workspace_common.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
[broadfcui.common.table.style :as table-style]
[broadfcui.common.table.utils :as table-utils]
[broadfcui.common.icons :as icons]
[broadfcui.nav :as nav]
[broadfcui.utils :as utils]
))

Expand Down Expand Up @@ -47,6 +48,22 @@
(defn config->id [config]
(select-keys config [:namespace :name]))

(defn- referenced-method-parts [config]
(replace (:methodRepoMethod config) [:sourceRepo :methodNamespace :methodName :methodPath :methodVersion]))

(defn- method-as-text [config]
(string/join "/" (referenced-method-parts config)))

(defn- method-as-maybe-link [config]
(let [{:keys [redacted? methodRepoMethod]} config
repo (:sourceRepo methodRepoMethod)
coldata (referenced-method-parts config)]
(if (or redacted? (not (= repo "agora")))
(apply style/render-entity coldata)
(let [method-id {:namespace (:methodNamespace methodRepoMethod)
:name (:methodName methodRepoMethod)
:snapshot-id (:methodVersion methodRepoMethod)}]
(links/create-internal {:href (nav/get-link :method-loader method-id)} (apply style/render-entity coldata))))))

(defn method-config-selector [{:keys [data-test-id configs render-name toolbar-items]}]
(assert configs "No configs given")
Expand Down Expand Up @@ -74,9 +91,9 @@
(if (= repo "dockstore") "Dockstore" "FireCloud"))
:render (fn [repo] [:span {:style {:fontWeight 200}} repo])}
{:header "Method" :initial-width 800
:column-data (comp (juxt :sourceRepo :methodNamespace :methodName :methodPath :methodVersion) :methodRepoMethod)
:as-text (partial clojure.string/join "/")
:render (partial apply style/render-entity)}]}
:sort-by :text
:as-text method-as-text
:render method-as-maybe-link}]}
:toolbar {:get-items (constantly toolbar-items)}}])


Expand Down