Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
Add activity review
Browse files Browse the repository at this point in the history
  • Loading branch information
kikakkz committed Dec 7, 2023
1 parent 3acf790 commit a36756e
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
16 changes: 16 additions & 0 deletions review/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,22 @@ impl MutationRoot {
async fn request_subscribe(&self) -> Vec<u8> {
bcs::to_bytes(&Operation::RequestSubscribe {}).unwrap()
}

async fn approve_activity(&self, activity_id: u64, reason: Option<String>) -> Vec<u8> {
bcs::to_bytes(&Operation::ApproveActivity {
activity_id,
reason,
})
.unwrap()
}

async fn reject_activity(&self, activity_id: u64, reason: String) -> Vec<u8> {
bcs::to_bytes(&Operation::RejectActivity {
activity_id,
reason,
})
.unwrap()
}
}

/// An error that can occur while querying the service.
Expand Down
12 changes: 7 additions & 5 deletions webui/src/components/ActivityPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,17 @@ const columns = computed(() => [
name: 'ReviewState',
label: 'Review State',
field: (row: Activity) => {
const approvers = approvedThreshold.value > reviewerNumber.value ? approvedThreshold.value : reviewerNumber.value
if ((activityApplications.value.get(row.id)?.approved || 0) > approvers) {
const approvers = approvedThreshold.value > reviewerNumber.value ? reviewerNumber.value : approvedThreshold.value
const approved = activityApplications.value.get(row.id)?.approved
if (approved !== undefined && approved >= approvers) {
return 'Approved'
}
const rejecters = rejectedThreshold.value > reviewerNumber.value ? rejectedThreshold.value : reviewerNumber.value
if ((activityApplications.value.get(row.id)?.rejected || 0) > rejecters) {
const rejecters = rejectedThreshold.value > reviewerNumber.value ? reviewerNumber.value : rejectedThreshold.value
const rejected = activityApplications.value.get(row.id)?.rejected
if (rejected !== undefined && rejected >= rejecters) {
return 'Rejected'
}
return `Reviewing (${activityApplications.value.get(row.id)?.approved || 0} approved, ${approvers} needed)`
return `Reviewing (${approved !== undefined ? approved : 0} approved, ${approvers} needed)`
}
}
])
Expand Down
6 changes: 3 additions & 3 deletions webui/src/components/ReviewActivity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<div :style='{marginTop: "24px"}'>
<q-input v-model='reason' type='textarea' :label='$t("MSG_REVIEW_REASON")' :disable='reviewed' />
</div>
<div :style='{marginTop: "24px"}' class='row'>
<div :style='{margin: "24px 0"}' class='row'>
<q-btn :label='$t("MSG_APPROVE")' :style='{marginRight:"16px",color: _review?.approved ? "blue" : ""}' @click='onApproveClick' :disable='reviewed' />
<q-btn :label='$t("MSG_REJECT")' :style='{color: _review && !_review?.approved ? "red" : ""}' @click='onRejectClick' :disable='reviewed' />
</div>
Expand Down Expand Up @@ -81,7 +81,7 @@ const onApproveClick = async () => {
console.log(error)
})
await mutate({
activityId,
activityId: parseInt(activityId.value.toString()),
reason: reason.value,
endpoint: 'review',
chainId: targetChain.value
Expand Down Expand Up @@ -111,7 +111,7 @@ const onRejectClick = async () => {
console.log(error)
})
await mutate({
activityId,
activityId: parseInt(activityId.value.toString()),
reason: reason.value,
endpoint: 'review',
chainId: targetChain.value
Expand Down
7 changes: 5 additions & 2 deletions webui/src/pages/ActivitiesPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,11 @@ const activityApplications = computed(() => review.activityApplications)
const activity = useActivityStore()
const activities = computed(() => activity._activities().filter((el) => {
return (activityApplications.value.get(el.id)?.approved || 0) >= approvedThreshold.value ||
(activityApplications.value.get(el.id)?.approved || 0) >= reviewerNumber.value
const approved = activityApplications.value.get(el.id)?.approved
if (!approved) {
return false
}
return approved >= approvedThreshold.value || approved >= reviewerNumber.value
}))
</script>

0 comments on commit a36756e

Please sign in to comment.