 
 
 (react/defc ConfigExporter
-  {:component-will-mount
-   (fn [{:keys [state props]}]
-     (when-not (:workspace-id props)
-       (endpoints/call-ajax-orch
-        {:endpoint endpoints/list-workspaces
-         :on-done (fn [{:keys [success? get-parsed-response status-text]}]
-                    (if success?
-                      (let [ws-list (get-parsed-response)]
-                        (swap! state assoc :workspaces-list ws-list :selected-workspace (first ws-list)))
-                      (swap! state assoc :error status-text)))})))
-   :render
-   (fn [{:keys [props state locals refs]}]
+  {:render
+   (fn [{:keys [props state refs]}]
      (let [{:keys [workspace-id entity perform-copy]} props
-           {:keys [workspaces-list]} @state]
+           {:keys [selected-workspace]} @state]
        [:div {:style {:border style/standard-line
                       :backgroundColor (:background-light style/colors)
                       :borderRadius 8 :padding "1em" :marginTop "1em"}}

                     {:label "Root Entity Type" :key :rootEntityType :type "identity-select" :options common/root-entity-types})]))
        (common/clear-both)
        (when-not workspace-id
          (let [sorted-ws-list (sort-by (comp (partial mapv string/lower-case)
                                              (juxt :namespace :name)
                                              :workspace)
                                        workspaces-list)]
            [:div {:style {:marginBottom "1em"}}
             [:div {:style {:fontSize "120%" :margin "1em 0"}}
              "Destination Workspace:"]
             (if-not workspaces-list
               [comps/Spinner {:text "Loading workspaces..."}]
               (style/create-select
                {:defaultValue ""
                 :ref (common/create-element-ref-handler
                       {:store locals
                        :element-key :workspace-select
                        :did-mount
                        #(.on (.select2 (js/$ %)) "select2:select"
                              (fn [event]
                                (swap! state assoc :selected-workspace
                                       (nth sorted-ws-list (js/parseInt (.-value (.-target event)))))))
                        :will-unmount
                        #(.off (js/$ %))})
                 :style {:width 500}}
                (map (fn [ws] (clojure.string/join "/" (replace (:workspace ws) [:namespace :name])))
                     sorted-ws-list)))]))
        (style/create-validation-error-message (:validation-error @state))
        [comps/ErrorViewer {:error (:server-error @state)}]
        [buttons/Button {:text (if workspace-id "Import" "Export")
                         :disabled? (not (or workspace-id workspaces-list))
                         :onClick #(perform-copy (:selected-workspace @state) refs)}]]))})

(defn- create-import-form [state props entity config? perform-copy]
  (let [{:keys [workspace-id on-delete]} props

   [broadfcui.components.buttons :as buttons]
   [broadfcui.components.sticky :refer [Sticky]]
   [broadfcui.components.modals :as modals]
   [broadfcui.components.workspace-selector :refer [WorkspaceSelector]]
   [broadfcui.endpoints :as endpoints]
   [broadfcui.nav :as nav]
   [broadfcui.page.method-repo.create-method :as create]
