Skip to content

Commit

Permalink
Merge pull request #39 from district0x/main
Browse files Browse the repository at this point in the history
Prod -> QA
  • Loading branch information
ginesdt committed Jan 30, 2024
2 parents 2d4c98c + a11883a commit 7f263e5
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,4 @@ jobs:
file: docker-builds/${{ matrix.image }}/Dockerfile
build-args: BUILD_ENV=${{ inputs.env }}
push: true
tags: ${{ secrets.ECR_REGISTRY }}/streamtide-${{ matrix.image }}:latest-${{ inputs.env }}
tags: ${{ secrets.ECR_REGISTRY }}/streamtide-${{ inputs.env }}-${{ matrix.image }}:latest
1 change: 1 addition & 0 deletions resources/scss/_vars-day.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ $disabled: #eaeaea;
$bgNotification: $purple;
$textNotification: $white;
$bgActiveRound: #86ff86;
$bgDisabled: lightgray;
1 change: 1 addition & 0 deletions resources/scss/_vars-night.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ $disabled: #353535;
$bgNotification: $lightLilac;
$textNotification: $black;
$bgActiveRound: green;
$bgDisabled: darkgray;
4 changes: 2 additions & 2 deletions resources/scss/components/popUpGrant.scss
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
line-height: 53px;
&:disabled {
pointer-events: none;
background-color: lightgray;
background-color: $bgDisabled;
}
}
&.add {
Expand Down Expand Up @@ -217,7 +217,7 @@
color: $purple;
overflow: hidden;
&:disabled {
background-color: lightgray;
background-color: $bgDisabled;
}
}

Expand Down
48 changes: 39 additions & 9 deletions resources/scss/layouts/admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,25 @@
h3 {
font-size: 20px;;
}
.reviewButtons {
.control-header {
display: flex;
margin-bottom: 10px;
align-items: end;
justify-content: space-between;
.btBasic {
&:disabled {
pointer-events: none;
background-color: lightgray;
margin-bottom: 10px;
.showRejected {
.input-group {
display: none;
}
}
.reviewButtons {
display: flex;
justify-content: space-between;

.btBasic {
&:disabled {
pointer-events: none;
background-color: $bgDisabled;
}
}
}
}
Expand All @@ -43,6 +54,20 @@
background: $bgCard;
padding: 19.86px 15px 18.58px;
max-height: 500px;
&.rejected {
background-color: $bgDisabled;
}
.rejected-annotation {
position: absolute;
bottom: 5px;
right: 5px;
font-size: smaller;
background: #a478f9;
border-radius: 92px;
padding: 1px 4px;
color: white;
font-weight: bold;
}
.data {
width: 100%;
display: flex;
Expand Down Expand Up @@ -103,6 +128,11 @@
opacity: 0.3;
pointer-events: none;
}
.input-group {
.help-block {
display: none;
}
}
}
&.remove {
transition: all 0.75s ease-in-out;
Expand Down Expand Up @@ -383,7 +413,7 @@
height: 56px;
&:disabled {
pointer-events: none;
background-color: lightgray;
background-color: $bgDisabled;
}
}
}
Expand Down Expand Up @@ -696,7 +726,7 @@

.btBasic:disabled {
pointer-events: none;
background-color: lightgray;
background-color: $bgDisabled;
}
}
}
Expand All @@ -716,7 +746,7 @@
.btBasic {
&:disabled {
pointer-events: none;
background-color: lightgray;
background-color: $bgDisabled;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/scss/layouts/profileEdit.scss
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@
letter-spacing: 1.87px;
&:disabled {
pointer-events: none;
background-color: lightgray;
background-color: $bgDisabled;
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions resources/scss/layouts/round.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

&:disabled {
pointer-events: none;
background-color: lightgray;
background-color: $bgDisabled;
}
}
}
Expand Down Expand Up @@ -85,7 +85,7 @@

&:disabled {
pointer-events: none;
background-color: lightgray;
background-color: $bgDisabled;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion resources/scss/layouts/send-support.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
margin-bottom: 23.09px;
&:disabled {
pointer-events: none;
background-color: lightgray;
background-color: $bgDisabled;
}
}
margin-bottom: 50px;
Expand Down
6 changes: 4 additions & 2 deletions src/streamtide/ui/admin/grant_approval_feed/events.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,12 @@
(re-frame/reg-event-fx
::review-grant-success
(fn [{:keys [db]} [_ args]]
(let [{:keys [:user/addresses :grant/status]} args]
(let [{:keys [:user/addresses :grant/status :on-success]} args]
(when on-success
(on-success))
{:db (-> db
(dissoc :reviewing-grants?)
(update :reviewed-grant? merge (reduce (fn [col address] (conj col {address status})) {} addresses)))
(update :reviewed-grant merge (reduce (fn [col address] (conj col {address status})) {} addresses)))
:dispatch [::notification-events/show (str "Grants successfully " (if (= :grant.status/approved status) "approved" "rejected") )]})))

(re-frame/reg-event-fx
Expand Down
62 changes: 43 additions & 19 deletions src/streamtide/ui/admin/grant_approval_feed/page.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"Page to approve the requested grants.
It shows a list of grants pending to be approved, such that an admin can approve or reject them"
(:require
[district.graphql-utils :as gql-utils]
[district.ui.component.form.input :refer [checkbox-input]]
[district.ui.component.page :refer [page]]
[district.ui.graphql.events :as graphql-events]
Expand All @@ -18,13 +19,23 @@
[streamtide.ui.utils :as ui-utils]))

(defn content-approval-entry [{:keys [:user/address :user/photo :user/name :user/socials]}
{:keys [:grant/request-date]}
form-data]
{:keys [:grant/request-date :grant/status]}
form-data show-rejected?]
(let [reviewing? @(subscribe [::gaf-subs/reviewing?])
decision? @(subscribe [::gaf-subs/decision? address])
nav (partial nav-anchor {:route :route.profile/index :params {:address address}})]
decision @(subscribe [::gaf-subs/decision address])
nav (partial nav-anchor {:route :route.profile/index :params {:address address}})
rejected? (or (= :grant.status/rejected decision)
(= :grant.status/rejected (gql-utils/gql-name->kw status)))]
[:div.contentApproval
(when decision? {:class "remove"})
{:class (cond
(or
(= :grant.status/approved decision)
(and (not show-rejected?)
decision))
"remove"
(and show-rejected? rejected?)
"rejected"
:else nil)}
[:div.cel.data
[nav [user-photo {:src photo :class "lb"}]]
[nav [:h3 name]]]
Expand All @@ -35,15 +46,16 @@
[:div.cel.buttons
[checkbox-input (merge {:form-data form-data
:id address}
(when reviewing? {:disabled true}))]]]))
(when reviewing? {:disabled true}))]]
(when rejected? [:div.rejected-annotation "Rejected"])]))

(def page-size 6)

(defn build-grants-query [{:keys [:statuses]} after]
(let []
[:search-grants
(cond-> {:first page-size
:statuses [:grant.status/requested]
:statuses statuses
:order-by :grants.order-by/request-date
:order-dir :desc}
after (assoc :after after))
Expand All @@ -58,7 +70,7 @@
[:user/socials [:social/network
:social/url]]]]]]]]))

(defn grants-entries [query-params grants-search form-data]
(defn grants-entries [query-params grants-search form-data show-rejected?]
(let [all-grants (->> @grants-search
(mapcat (fn [r] (-> r :search-grants :items))))
loading? (:graphql/loading? (last @grants-search))
Expand All @@ -81,33 +93,45 @@
(when-not (:graphql/loading? (first @grants-search))
(doall
(for [{:keys [:grant/user] :as grant} all-grants]
^{:key (:user/address user)} [content-approval-entry user grant form-data])))])))
^{:key (:user/address user)} [content-approval-entry user grant form-data show-rejected?])))])))


(defmethod page :route.admin/grant-approval-feed []
(let [query-params {:statuses [:grant.status/requested]}
grants-search (subscribe [::gql/query {:queries [(build-grants-query query-params nil)]}
{:id query-params}])
tx-id (str "add-patrons-" (random-uuid))
form-data (r/atom {})]
(let [tx-id (str "add-patrons-" (random-uuid))
form-data (r/atom {})
show-rejected-form-data (r/atom {})]
(fn []
(let [reviewing? @(subscribe [::gaf-subs/reviewing?])
(let [show-rejected? (:show-rejected @show-rejected-form-data)
query-params {:statuses (cond-> [:grant.status/requested]
show-rejected? (conj :grant.status/rejected))}
grants-search (subscribe [::gql/query {:queries [(build-grants-query query-params nil)]}
{:id query-params}])
reviewing? @(subscribe [::gaf-subs/reviewing?])
selected-addresses (filter (fn [[_ selected]] selected) @form-data)
review-button-props (fn [status]
(merge
{:on-click #(dispatch [::gaf-events/review-grant
{:send-tx/id tx-id
:user/addresses (keys selected-addresses)
:grant/status status}])}
:grant/status status
:on-success (fn []
(reset! form-data {}))}])}
(when (or reviewing? (empty? selected-addresses)) {:disabled true})))]
[admin-layout
[:div.reviewButtons
[:div.control-header
[:div.showRejected
[:label.checkField.simple
[checkbox-input {:id :show-rejected
:form-data show-rejected-form-data}]
[:span.checkmark {:class (when show-rejected? "checked")}]
[:span.text "Show rejected"]]]
[:div.reviewButtons
[:button.btBasic.btBasic-light.btApprove
(review-button-props :grant.status/approved)
"APPROVE selected"]
[:button.btBasic.btBasic-light.btDeny
(review-button-props :grant.status/rejected)
"DENY selected"]]
"DENY selected"]]]
[:div.headerApprovalFeed.d-none.d-lg-flex
[:div.cel.cel-data
[:span.titleCel.col-user "User Profile"]]
Expand All @@ -117,4 +141,4 @@
[:span.titleCel.col-date "Request Date"]]
[:div.cel.cel-buttons
[:span.titleCel.col-buttons "Select"]]]
[grants-entries query-params grants-search form-data]]))))
[grants-entries query-params grants-search form-data show-rejected?]]))))
4 changes: 2 additions & 2 deletions src/streamtide/ui/admin/grant_approval_feed/subs.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
(get db :reviewing-grants?)))

(re-frame/reg-sub
::decision?
::decision
(fn [db [_ address]]
(get-in db [:reviewed-grant? address])))
(get-in db [:reviewed-grant address])))

0 comments on commit 7f263e5

Please sign in to comment.