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
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 [snapshotId]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kebab case the param

(if redacted?
snapshotId
(let [method-id (merge entity {:snapshot-id snapshotId})]
(links/create-internal {:href (nav/get-link :method-loader method-id)} snapshotId))))))
"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,20 @@
[: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.
(if (:ws-config @state)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Destructure state and props

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also wrap this in a let and destructure the things you're using from submission

(links/create-internal
{:data-test-id (str "method-config-" (:methodConfigurationName submission) "-link")
:style {:fontWeight "bold"}
:href (nav/get-link :workspace-method-config
(:workspace-id props)
{:namespace (:methodConfigurationNamespace submission)
:name (:methodConfigurationName submission)})}
(:methodConfigurationName submission))
[:span {:style {:fontWeight 500}} (:methodConfigurationName submission)
(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 +257,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))})
25 changes: 22 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,23 @@
(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 [redacted? (:redacted? config)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use :keys to destructure multiple at once

methodRepoMethod (: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 +92,10 @@
(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
}]}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Move these up a line

:toolbar {:get-items (constantly toolbar-items)}}])


Expand Down