<commit_before>(ns org.broadinstitute.firecloud-ui.page.workspace.summary.summary-tab
  (:require
    [clojure.string :refer [trim capitalize blank?]]
    [dmohs.react :as react]
    [org.broadinstitute.firecloud-ui.common :as common]
    [org.broadinstitute.firecloud-ui.common.components :as comps]
    [org.broadinstitute.firecloud-ui.common.icons :as icons]
    [org.broadinstitute.firecloud-ui.common.style :as style]
    [org.broadinstitute.firecloud-ui.endpoints :as endpoints]
    [org.broadinstitute.firecloud-ui.page.workspace.summary.acl-editor :refer [AclEditor]]
    [org.broadinstitute.firecloud-ui.page.workspace.summary.attribute-editor :refer [AttributeViewer]]
    [org.broadinstitute.firecloud-ui.page.workspace.summary.workspace-cloner :refer [WorkspaceCloner]]
    [org.broadinstitute.firecloud-ui.utils :as utils]
    ))


(defn- render-tags [tags]
  (let [tagstyle {:marginRight 13 :borderRadius 2 :padding "5px 13px"
                  :backgroundColor (:tag-background style/colors)
                  :color (:tag-foreground style/colors)
                  :display "inline-block" :fontSize "94%"}]
    [:div {}
     (map (fn [tag] [:span {:style tagstyle} tag]) tags)]))


(defn- view-summary [state props ws status owner? this on-view-attributes]
  (let [locked? (get-in ws ["workspace" "isLocked"])]
    [:div {:style {:margin "45px 25px"}}
     (when (:deleting? @state)
       [comps/Blocker {:banner "Deleting..."}])
     (when (contains? @state :locking?)
       [comps/Blocker {:banner (if (:locking? @state) "Unlocking..." "Locking...")}])
     (when (:editing-acl? @state)
       [AclEditor {:workspace-id (:workspace-id props)
                   :dismiss-self #(swap! state dissoc :editing-acl?)
                   :update-owners #(swap! state update-in [:server-response :workspace] assoc "owners" %)}])
     (when (:cloning? @state)
       [WorkspaceCloner {:dismiss #(swap! state dissoc :cloning?)
                         :workspace-id (:workspace-id props)}])
     [:div {:style {:float "left" :width 290 :marginRight 40}}
      ;; TODO - make the width of the float-left dynamic
      [comps/StatusLabel {:text (capitalize (name status))
                          :icon (case status
                                  "Complete" [comps/CompleteIcon {:size 36}]
                                  "Running" [comps/RunningIcon {:size 36}]
                                  "Exception" [comps/ExceptionIcon {:size 36}])
                          :color (style/color-for-status status)}]
      [comps/SidebarButton {:style :light :margin :top :color :button-blue
                            :text "View attributes" :icon :document
                            :onClick on-view-attributes}]
      [comps/SidebarButton {:style :light :margin :top :color :button-blue
                            :text "Clone..." :icon :plus
                            :onClick #(swap! state assoc :cloning? true)}]
      (when owner?
        [comps/SidebarButton {:style :light :margin :top :color :button-blue
                              :text (if locked? "Unlock" "Lock") :icon :locked
                              :onClick #(react/call :lock-or-unlock this locked?)}])
      (when owner?
        [comps/SidebarButton {:style :light :margin :top :color :exception-red
                              :text "Delete" :icon :trash-can
                              :disabled? (if locked? "This workspace is locked")
                              :onClick #(when (js/confirm "Are you sure?")
                                         (swap! state assoc :deleting? true)
                                         (react/call :delete this))}])]
     [:div {:style {:marginLeft 330}}
      (style/create-section-header "Workspace Owner")
      (style/create-paragraph
        [:div {}
         (interpose ", " (map #(style/render-email %) (ws "owners")))
         (when owner?
           [:span {}
            " ("
            (style/create-link
              #(swap! state assoc :editing-acl? true)
              "Sharing...")
            ")"])])]
     (common/clear-both)]))

(react/defc Summary
  {:get-initial-state
   (fn []
     {:viewing-attributes? false})
   :render
   (fn [{:keys [state props this]}]
     (cond
       (nil? (:server-response @state))
       [comps/Spinner {:text "Loading workspace..."}]
       (get-in @state [:server-response :error-message])
       (style/create-server-error-message (get-in @state [:server-response :error-message]))
       :else
       (let [ws (get-in @state [:server-response :workspace])
             owner? (= "OWNER" (ws "accessLevel"))
             writer? (or (= "WRITER" (ws "accessLevel")) owner?)
             status (common/compute-status ws)]
         (if (:viewing-attributes? @state)
           (let [ws-response ((get-in @state [:server-response :workspace]) "workspace")]<commit_msg>Show google bucket name on the workspace summary page<commit_after>(ns org.broadinstitute.firecloud-ui.page.workspace.summary.summary-tab
  (:require
    [clojure.string :refer [trim capitalize blank?]]
    [dmohs.react :as react]
    [org.broadinstitute.firecloud-ui.common :as common]
    [org.broadinstitute.firecloud-ui.common.components :as comps]
    [org.broadinstitute.firecloud-ui.common.icons :as icons]
    [org.broadinstitute.firecloud-ui.common.style :as style]
    [org.broadinstitute.firecloud-ui.endpoints :as endpoints]
    [org.broadinstitute.firecloud-ui.page.workspace.summary.acl-editor :refer [AclEditor]]
    [org.broadinstitute.firecloud-ui.page.workspace.summary.attribute-editor :refer [AttributeViewer]]
    [org.broadinstitute.firecloud-ui.page.workspace.summary.workspace-cloner :refer [WorkspaceCloner]]
    [org.broadinstitute.firecloud-ui.utils :as utils]
    ))


(defn- render-tags [tags]
  (let [tagstyle {:marginRight 13 :borderRadius 2 :padding "5px 13px"
                  :backgroundColor (:tag-background style/colors)
                  :color (:tag-foreground style/colors)
                  :display "inline-block" :fontSize "94%"}]
    [:div {}
     (map (fn [tag] [:span {:style tagstyle} tag]) tags)]))


(defn- view-summary [state props ws status owner? this on-view-attributes]
  (let [locked? (get-in ws ["workspace" "isLocked"])]
    [:div {:style {:margin "45px 25px"}}
     (when (:deleting? @state)
       [comps/Blocker {:banner "Deleting..."}])
     (when (contains? @state :locking?)
       [comps/Blocker {:banner (if (:locking? @state) "Unlocking..." "Locking...")}])
     (when (:editing-acl? @state)
       [AclEditor {:workspace-id (:workspace-id props)
                   :dismiss-self #(swap! state dissoc :editing-acl?)
                   :update-owners #(swap! state update-in [:server-response :workspace] assoc "owners" %)}])
     (when (:cloning? @state)
       [WorkspaceCloner {:dismiss #(swap! state dissoc :cloning?)
                         :workspace-id (:workspace-id props)}])
     [:div {:style {:float "left" :width 290 :marginRight 40}}
      ;; TODO - make the width of the float-left dynamic
      [comps/StatusLabel {:text (capitalize (name status))
                          :icon (case status
                                  "Complete" [comps/CompleteIcon {:size 36}]
                                  "Running" [comps/RunningIcon {:size 36}]
                                  "Exception" [comps/ExceptionIcon {:size 36}])
                          :color (style/color-for-status status)}]
      [comps/SidebarButton {:style :light :margin :top :color :button-blue
                            :text "View attributes" :icon :document
                            :onClick on-view-attributes}]
      [comps/SidebarButton {:style :light :margin :top :color :button-blue
                            :text "Clone..." :icon :plus
                            :onClick #(swap! state assoc :cloning? true)}]
      (when owner?
        [comps/SidebarButton {:style :light :margin :top :color :button-blue
                              :text (if locked? "Unlock" "Lock") :icon :locked
                              :onClick #(react/call :lock-or-unlock this locked?)}])
      (when owner?
        [comps/SidebarButton {:style :light :margin :top :color :exception-red
                              :text "Delete" :icon :trash-can
                              :disabled? (if locked? "This workspace is locked")
                              :onClick #(when (js/confirm "Are you sure?")
                                         (swap! state assoc :deleting? true)
                                         (react/call :delete this))}])]
     [:div {:style {:marginLeft 330}}
      (style/create-section-header "Workspace Owner")
      (style/create-paragraph
        [:div {}
         (interpose ", " (map #(style/render-email %) (ws "owners")))
         (when owner?
           [:span {}
            " ("
            (style/create-link
              #(swap! state assoc :editing-acl? true)
              "Sharing...")
            ")"])])
      (when-let [bucketName (get-in ws ["workspace" "bucketName"])]
        [:div {}
         (style/create-section-header "Google Bucket")
         (style/create-paragraph [:div {} bucketName])])]
     (common/clear-both)]))

(react/defc Summary
  {:get-initial-state
   (fn []
     {:viewing-attributes? false})
   :render
   (fn [{:keys [state props this]}]
     (cond
       (nil? (:server-response @state))
       [comps/Spinner {:text "Loading workspace..."}]
       (get-in @state [:server-response :error-message])
       (style/create-server-error-message (get-in @state [:server-response :error-message]))
       :else
       (let [ws (get-in @state [:server-response :workspace])
             owner? (= "OWNER" (ws "accessLevel"))
             writer? (or (= "WRITER" (ws "accessLevel")) owner?)
             status (common/compute-status ws)]
         (if (:viewing-attributes? @state)
           (let [ws-response ((get-in @state [:server-response :workspace]) "workspace")]
{'fraction_non_alphanumeric': 0.14653007934116702, 'fraction_numerical': 0.005222456563221854, 'mean_word_length': 2.1226089683286298, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5530936', 'n_tokens_mistral': 3064, 'n_tokens_neox': 2897, 'n_words': 714}