       (component
        (html
         [:div
-         (let [project (:project project-data)]
-          (case modal
-            :basic (jira-connect-modal project owner)
-            :connect (jira-basic-modal project owner)
-            nil))
+         (case modal
+           :basic (jira-basic-modal project owner)
+           :connect (jira-connect-modal project owner)
+           nil)
          [:p "There are 2 options for setting up JIRA with CircleCI: Atlassian Connect or JIRA Basic Authentication. Choose one of the options below to continue."]
          (element
           :column-group

                             :on-click #(om/set-state! owner :modal :basic)}
                            "Add JIRA Credentials")]]))])))))

(defn jira-integration [project-data owner]
  (reify
    om/IInitState
    (init-state [_]
      {:modal nil})
    om/IRenderState
    (render-state [_ {:keys [modal]}]
      (let [project (:project project-data)
            inputs (inputs/get-inputs-from-app-state owner)
            jira-creds (-> project :jira)
            open-fn (fn [auth-type] #(om/set-state! owner :modal auth-type))
            close-fn (fn [] (om/set-state! owner :modal nil))
            track-event (fn [event-type]
                          ((om/get-shared owner :track-event)
                           {:event-type event-type
                            :properties {:component "jira-settings"
                                         :auth-type "basic"}}))]
        (html
         [:section
          [:article
           (card/titled
            {:title (str "JIRA integration for " (vcs-url/project-name (:vcs_url project)))}
            (om/build jira-empty-state project))]])))))

#_(defmulti jira-integration (fn [project-data _]
                             (if (or (config/enterprise?)
                                     (get-in project-data [:project :jira :username]))
                               :basic
                               :connect)))

#_(defmethod jira-integration :connect [project-data owner]
  (reify
    om/IInitState
    (init-state [_]
      {:show-modal? false})
    om/IRenderState
    (render-state [_ {:keys [show-modal?]}]
      (let [project (:project project-data)
            project-id (project-model/id project)
            jira-input-path (conj state/inputs-path :jira :circle_token)
            track-event (fn [event-type component]
                          ((om/get-shared owner :track-event)
                           {:event-type event-type
                            :properties {:component component
                                         :auth-type "connect"}}))]
        (html
         [:section
          [:article
           (card/titled
            {:title (str "JIRA integration for " (vcs-url/project-name (:vcs_url project)))
             :action (button/button {:on-click (fn [_]
                                                 (om/set-state! owner :show-modal? true)
                                                 (track-event :add-credentials-clicked "jira-integration"))
                                     :kind :primary
                                     :size :medium}
                                    "Configure Token")}
            (html
             [:div
              [:p
               "Install the CircleCI JIRA add-on from the Atlassian Marketplace and add the token here."]
              (when show-modal?
                (letfn [(close-fn [_]
                          (om/set-state! owner :show-modal? false)
                          (track-event :cancel-clicked))]
                  (jira-connect-modal {:project project
                                       :close-fn close-fn
                                       :track-fn track-event
                                       :jira-input-path jira-input-path}
                                      owner)))
              (when-let [credentials (:jira project)]
                (letfn [(linkify [url]
                          (html
                           [:a {:href url
                                :target "_blank"} url]))]
                  (om/build table/table
                            {:rows [credentials]
                             :key-fn :circle_token
                             :columns [{:header "JIRA URL"
                                        :cell-fn (comp linkify :base_url)}
                                       {:header "Token"
                                        :cell-fn :circle_token}
                                       {:header "Remove"
                                        :type #{:shrink :right}
                                        :cell-fn
                                        (fn [{:keys [base_url]}]
                                          (om/build remove-action-button
                                                    {:confirmation-question
                                                     (html
                                                      [:p "Are you sure you want to remove the integration for " (linkify base_url) "?"])
                                                     :remove-fn #(do
                                                                   (raise! owner [:edited-input {:path jira-input-path
                                                                                                 :value nil}])
                                                                   (raise! owner [:saved-project-settings {:project-id project-id
                                                                                                           :merge-paths [jira-input-path]}]))}))}]})))]))]])))))



#_(defmethod jira-integration :basic [project-data owner]
  (reify
    om/IInitState
    (init-state [_]
      {:show-modal? false})
    om/IRenderState
    (render-state [_ {:keys [show-modal?]}]
      (let [project (:project project-data)
            inputs (inputs/get-inputs-from-app-state owner)
            project-id (project-model/id project)
            jira-input-path (fn [& args] (apply conj state/inputs-path :jira args))
            track-event (fn [event-type component]
                          ((om/get-shared owner :track-event)
                           {:event-type event-type
                            :properties {:component component
                                         :auth-type "basic"}}))]
        (html
         [:section
          [:article
           (card/titled
            {:title (str "JIRA integration for " (vcs-url/project-name (:vcs_url project)))
             :action (button/button {:on-click (fn [_]
                                                 (om/set-state! owner :show-modal? true)
                                                 (track-event :add-credentials-clicked "jira-integration"))
                                     :kind :primary
                                     :size :medium}
                                    "Configure Credentials")}
            (html
             [:div
              [:p
               "Configure JIRA to create issues from CircleCI's build page."]
              (when show-modal?
                (letfn [(close-fn [_]
                          (om/set-state! owner :show-modal? false)
                          (track-event :cancel-clicked))]
                  (jira-basic-modal {:project project
                                     :close-fn close-fn
                                     :track-fn track-event
                                     :jira-input-path jira-input-path}
                                    owner)))
              (when-let [credentials (:jira project)]
                (letfn [(linkify [url]
                          (html
                           [:a {:href url
                                :target "_blank"} url]))]
                  (om/build table/table
                            {:rows [credentials]
                             :key-fn :username
                             :columns [{:header "JIRA base hostname"
                                        :cell-fn (comp linkify :base_url)}
                                       {:header "JIRA username"
                                        :cell-fn :username}
                                       {:header "Remove"
                                        :type #{:shrink :right}
                                        :cell-fn
                                        (fn [{:keys [base_url]}]
                                          (om/build remove-action-button
                                                    {:confirmation-question
                                                     (html
                                                      [:p "Are you sure you want to remove the integration for " (linkify base_url) "?"])
                                                     :remove-fn #(do
                                                                   (raise! owner [:edited-input {:path (jira-input-path)
                                                                                                 :value nil}])
                                                                   (raise! owner [:saved-project-settings {:project-id project-id
                                                                                                           :merge-paths [[:jira]]}]))}))}]})))]))]])))))

(defn aws-codedeploy-app-name [project-data owner]
  (reify

(defn jira-connect-modal
  [project owner]
  (let [inputs (inputs/get-inputs-from-app-state owner)
        token (get-in inputs [:jira :circle_token])
        track-event (fn [event-type]
                      ((om/get-shared owner :track-event)
                       {:event-type event-type
