-
Notifications
You must be signed in to change notification settings - Fork 20
/
KanbanBoard.jsx
124 lines (118 loc) · 3.29 KB
/
KanbanBoard.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
const ownerId = "devgovgigs.near";
const requiredLabels = props.requiredLabels ?? ["near-social"];
const excludedLabels = props.excludedLabels ?? ["nft"];
const columnLabels = props.columnLabels ?? [
"widget",
"integration",
"feature-request",
];
const labelsToIdSet = (labels) => {
const ids = labels.map((label) => {
return (
Near.view(ownerId, "get_posts_by_label", {
label,
}) ?? []
);
});
const idsFlat = ids.flat(1);
return new Set(idsFlat);
};
const requiredPostsSet = labelsToIdSet(requiredLabels);
const excludedPostsSet = labelsToIdSet(excludedLabels);
const postsPerLabel = columnLabels.map((cl) => {
let allIds = (
Near.view(ownerId, "get_posts_by_label", {
label: cl,
}) ?? []
).reverse();
if (requiredLabels.length > 0) {
return {
label: cl,
posts: allIds.filter(
(i) => requiredPostsSet.has(i) && !excludedPostsSet.has(i)
),
};
} else {
// No extra filtering is required.
return { label: cl, posts: allIds };
}
});
return (
<div>
<div class="row mb-2">
{props.boardId ? (
<div class="col">
<small class="text-muted">
<a
class="card-link"
href={`https://near.social/#/devgovgigs.near/widget/Ideas?selectedBoardId=${props.boardId}`}
role="button"
target="_blank"
title="Link to this board"
>
<div class="hstack gap-3">
<div class="bi bi-share"></div>
<div>Link to this board</div>
</div>
</a>
</small>
</div>
) : null}
{requiredLabels.length > 0 ? (
<div class="col">
<small class="text-muted">
Required labels:
{requiredLabels.map((label) => {
return (
<a
href={`https://near.social/#/devgovgigs.near/widget/Ideas?label=${label}`}
>
<span class="badge text-bg-primary me-1">{label}</span>
</a>
);
})}
</small>
</div>
) : null}
{excludedLabels.length > 0 ? (
<div class="col">
<small class="text-muted">
Excluded labels:
{excludedLabels.map((label) => {
return (
<a
href={`https://near.social/#/devgovgigs.near/widget/Ideas?label=${label}`}
>
<span class="badge text-bg-primary me-1">{label}</span>
</a>
);
})}
</small>
</div>
) : null}
</div>
<div class="row">
{postsPerLabel.map((col) => {
return (
<div class="col-4">
<div class="card">
<div class="card-body border-secondary">
<h6 class="card-title">
{col.label.toUpperCase()}({col.posts.length})
</h6>
{col.posts.map((postId) => {
return (
<Widget
src={`${ownerId}/widget/CompactPost`}
props={{ id: postId }}
/>
);
})}
</div>
</div>
</div>
);
})}
</div>
</div>
);