<commit_before>(ns swarmpit.component.service.create-image-other
  (:require [material.icon :as icon]
            [material.component :as comp]
            [swarmpit.component.state :as state]
            [swarmpit.component.handler :as handler]
            [swarmpit.storage :as storage]
            [swarmpit.url :refer [dispatch!]]
            [swarmpit.routes :as routes]
            [clojure.string :as string]
            [rum.core :as rum]))

(def cursor [:page :service :wizard :image :other])

(def headers [{:name  "Name"
               :width "100%"}])

(defn- render-item
  [item]
  (let [value (val item)]
    value))

(defn- filter-items
  [items predicate]
  (filter #(string/includes? (:name %) predicate) items))

(defn- repository-handler
  [registry]
  (handler/get
    (routes/path-for-backend :repositories {:registry registry})
    {:on-call    (state/update-value [:searching] true cursor)
     :on-success (fn [response]
                   (state/update-value [:searching] false cursor)
                   (state/update-value [:data] response cursor))
     :on-error   (fn [_]
                   (state/update-value [:searching] false cursor))}))

(defn- form-registry [registry registries]
  (comp/form-comp
    "REGISTRY"
    (comp/select-field
      {:value    registry
       :onChange (fn [_ _ v]
                   (state/update-value [:data] [] cursor)
                   (state/update-value [:registry] v cursor)
                   (repository-handler registry))}
      (->> registries
           (map #(comp/menu-item
                   {:key         %
                    :value       %
                    :primaryText %}))))))

(defn- form-repository [repository]<commit_msg>fix other registries repository handler<commit_after>(ns swarmpit.component.service.create-image-other
  (:require [material.icon :as icon]
            [material.component :as comp]
            [swarmpit.component.state :as state]
            [swarmpit.component.handler :as handler]
            [swarmpit.storage :as storage]
            [swarmpit.url :refer [dispatch!]]
            [swarmpit.routes :as routes]
            [clojure.string :as string]
            [rum.core :as rum]))

(def cursor [:page :service :wizard :image :other])

(def headers [{:name  "Name"
               :width "100%"}])

(defn- render-item
  [item]
  (let [value (val item)]
    value))

(defn- filter-items
  [items predicate]
  (filter #(string/includes? (:name %) predicate) items))

(defn- repository-handler
  [registry]
  (handler/get
    (routes/path-for-backend :repositories {:registry registry})
    {:on-call    (state/update-value [:searching] true cursor)
     :on-success (fn [response]
                   (state/update-value [:searching] false cursor)
                   (state/update-value [:data] response cursor))
     :on-error   (fn [_]
                   (state/update-value [:searching] false cursor))}))

(defn- form-registry [registry registries]
  (comp/form-comp
    "REGISTRY"
    (comp/select-field
      {:value    registry
       :onChange (fn [_ _ v]
                   (state/update-value [:data] [] cursor)
                   (state/update-value [:registry] v cursor)
                   (repository-handler v))}
      (->> registries
           (map #(comp/menu-item
                   {:key         %
                    :value       %
                    :primaryText %}))))))

(defn- form-repository [repository]
{'fraction_non_alphanumeric': 0.13658820110433015, 'fraction_numerical': 0.0017436791630340018, 'mean_word_length': 1.9956483899042645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2273833', 'n_tokens_mistral': 1074, 'n_tokens_neox': 1016, 'n_words': 243}