Skip to content

Commit

Permalink
Merge pull request #276 from psarando/CORE-1955-app-ver-reorder
Browse files Browse the repository at this point in the history
CORE-1955 Add endpoint for reordering app versions
  • Loading branch information
psarando authored Oct 18, 2024
2 parents b107b3f + eaa07b2 commit db85fd1
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
[org.cyverse/metadata-client "3.1.2"]
[org.cyverse/common-cli "2.8.2"]
[org.cyverse/common-cfg "2.8.3"]
[org.cyverse/common-swagger-api "3.4.6"]
[org.cyverse/common-swagger-api "3.4.7"]
[org.cyverse/cyverse-groups-client "0.1.9"]
[org.cyverse/permissions-client "2.8.4"]
[org.cyverse/service-logging "2.8.4"]
Expand Down
6 changes: 6 additions & 0 deletions src/apps/persistence/app_metadata.clj
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,12 @@
(remove-nil-vals))]
(sql/update app_versions (set-fields version-info) (where {:id version-id})))))

(defn set-app-versions-order
[app-id versions]
(transaction
(doseq [[index id] (map-indexed (fn [i v] [i (:version_id v)]) (rseq versions))]
(sql/update app_versions (set-fields {:version_order index}) (where {:app_id app-id :id id})))))

(defn- get-app-publication-status-code-id
[status-code]
(-> (select* :app_publication_request_status_codes)
Expand Down
1 change: 1 addition & 0 deletions src/apps/protocols.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
(deleteAppVersion [_ system-id app-id app-version-id])
(relabelApp [_ system-id app])
(updateApp [_ system-id app])
(setAppVersionsOrder [_ system-id app-id versions])
(copyApp [_ system-id app-id])
(copyAppVersion [_ system-id app-id version-id])
(getAppDetails [_ system-id app-id admin?])
Expand Down
8 changes: 8 additions & 0 deletions src/apps/routes/apps/versions.clj
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
(assoc app :id app-id)
false)))

(PUT "/" []
:query [params SecuredQueryParamsRequired]
:body [{:keys [versions]} schema/AppVersionOrderRequest]
:return schema/App
:summary schema/AppVersionOrderSummary
:description schema/AppVersionOrderDocs
(ok (apps/set-app-versions-order current-user system-id app-id versions)))

(context "/:version-id" []
:path-params [version-id :- schema/AppVersionIdParam]

Expand Down
4 changes: 4 additions & 0 deletions src/apps/service/apps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@
[user system-id app]
(.updateApp (get-apps-client user) system-id app))

(defn set-app-versions-order
[user system-id app-id versions]
(.setAppVersionsOrder (get-apps-client user) system-id app-id versions))

(defn copy-app
[user system-id app-id]
(.copyApp (get-apps-client user) system-id app-id))
Expand Down
4 changes: 4 additions & 0 deletions src/apps/service/apps/agave.clj
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@
(validate-system-id system-id)
(reject-app-integration-request))

(setAppVersionsOrder [_ system-id app-id versions]
(validate-system-id system-id)
(reject-app-integration-request))

(copyApp [_ system-id app-id]
(validate-system-id system-id)
(reject-app-integration-request))
Expand Down
3 changes: 3 additions & 0 deletions src/apps/service/apps/combined.clj
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@
(updateApp [_ system-id app]
(.updateApp (util/get-apps-client clients system-id) system-id app))

(setAppVersionsOrder [_ system-id app-id versions]
(.setAppVersionsOrder (util/get-apps-client clients system-id) system-id app-id versions))

(copyApp [_ system-id app-id]
(.copyApp (util/get-apps-client clients system-id) system-id app-id))

Expand Down
4 changes: 4 additions & 0 deletions src/apps/service/apps/de.clj
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@
(validate-system-id system-id)
(edit/update-app user (update app :id uuidify)))

(setAppVersionsOrder [_ system-id app-id versions]
(validate-system-id system-id)
(edit/set-app-versions-order user (uuidify app-id) versions))

(copyApp [_ system-id app-id]
(validate-system-id system-id)
(edit/copy-app user (uuidify app-id)))
Expand Down
6 changes: 6 additions & 0 deletions src/apps/service/apps/de/edit.clj
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,12 @@
(update-app-groups task-id groups)
(get-app-ui user app-id version-id))))

(defn set-app-versions-order
[user app-id versions]
(verify-app-editable user (persistence/get-app app-id))
(persistence/set-app-versions-order app-id versions)
(get-app-ui user app-id))

(defn get-user-subcategory
[username index]
(-> (get-workspace username)
Expand Down

0 comments on commit db85fd1

Please sign in to comment.