You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by kl...@apache.org on 2022/09/30 02:09:49 UTC
[incubator-devlake] branch main updated: fix: add array checks to all chosen tags for jira boards (#3275)
This is an automated email from the ASF dual-hosted git repository.
klesh pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
The following commit(s) were added to refs/heads/main by this push:
new 22182f06 fix: add array checks to all chosen tags for jira boards (#3275)
22182f06 is described below
commit 22182f06d9d05c8c7c0b23b079d541470edcb53c
Author: Julien Chinapen <ju...@merico.dev>
AuthorDate: Thu Sep 29 22:09:44 2022 -0400
fix: add array checks to all chosen tags for jira boards (#3275)
* fix: add array check to all board tags memo
* fix: resolve react-hooks exhaustive-deps warning
* fix: revert dependency resolve
---
.../src/components/blueprints/BoardsSelector.jsx | 4 +-
config-ui/src/hooks/useJIRA.jsx | 2 +-
.../src/pages/blueprints/blueprint-detail.jsx | 3 +-
config-ui/src/pages/configure/settings/jira.jsx | 62 ++++++++++++++++------
4 files changed, 51 insertions(+), 20 deletions(-)
diff --git a/config-ui/src/components/blueprints/BoardsSelector.jsx b/config-ui/src/components/blueprints/BoardsSelector.jsx
index e64b7ceb..9c6d5b73 100644
--- a/config-ui/src/components/blueprints/BoardsSelector.jsx
+++ b/config-ui/src/components/blueprints/BoardsSelector.jsx
@@ -18,6 +18,8 @@
import React, { useEffect, useMemo } from 'react'
import { Intent, MenuItem } from '@blueprintjs/core'
import { MultiSelect, Select } from '@blueprintjs/select'
+import JiraBoard from '@/models/JiraBoard'
+
const BoardsSelector = (props) => {
const {
boards = [],
@@ -112,7 +114,7 @@ const BoardsSelector = (props) => {
...rT,
[configuredConnection.id]: [
...rT[configuredConnection.id],
- item
+ new JiraBoard(item)
]
}
: { ...rT }
diff --git a/config-ui/src/hooks/useJIRA.jsx b/config-ui/src/hooks/useJIRA.jsx
index d7f02dde..871b8de1 100644
--- a/config-ui/src/hooks/useJIRA.jsx
+++ b/config-ui/src/hooks/useJIRA.jsx
@@ -232,7 +232,7 @@ const useJIRA = (
data = [],
titleProperty,
idProperty,
- valueProperty,
+ valueProperty
) => {
return data.map((d, dIdx) => ({
id: d[idProperty],
diff --git a/config-ui/src/pages/blueprints/blueprint-detail.jsx b/config-ui/src/pages/blueprints/blueprint-detail.jsx
index 56586c6b..96756537 100644
--- a/config-ui/src/pages/blueprints/blueprint-detail.jsx
+++ b/config-ui/src/pages/blueprints/blueprint-detail.jsx
@@ -336,7 +336,8 @@ const BlueprintDetail = (props) => {
duration:
p.beganAt && p.finishedAt
? dayjs(p.beganAt).from(p.finishedAt, true)
- : p.beganAt && [TaskStatus.RUNNING, TaskStatus.CREATED].includes(p?.status)
+ : p.beganAt &&
+ [TaskStatus.RUNNING, TaskStatus.CREATED].includes(p?.status)
? dayjs(p.beganAt).toNow(true)
: ' - '
}))
diff --git a/config-ui/src/pages/configure/settings/jira.jsx b/config-ui/src/pages/configure/settings/jira.jsx
index 0346fcc8..90dacf79 100644
--- a/config-ui/src/pages/configure/settings/jira.jsx
+++ b/config-ui/src/pages/configure/settings/jira.jsx
@@ -155,9 +155,15 @@ export default function JiraSettings(props) {
const [incidentTags, setIncidentTags] = useState(savedIncidentTags)
const allChosenTagsInThisBoard = useMemo(
() => [
- ...requirementTags[configuredBoard?.id],
- ...bugTags[configuredBoard?.id],
- ...incidentTags[configuredBoard?.id]
+ ...(Array.isArray(requirementTags[configuredBoard?.id])
+ ? requirementTags[configuredBoard?.id]
+ : []),
+ ...(Array.isArray(bugTags[configuredBoard?.id])
+ ? bugTags[configuredBoard?.id]
+ : []),
+ ...(Array.isArray(incidentTags[configuredBoard?.id])
+ ? incidentTags[configuredBoard?.id]
+ : [])
],
[configuredBoard?.id, requirementTags, bugTags, incidentTags]
)
@@ -349,11 +355,15 @@ export default function JiraSettings(props) {
itemRenderer={(item, { handleClick, modifiers }) => (
<MenuItem
active={modifiers.active}
- disabled={allChosenTagsInThisBoard?.some(t => t.value === item.value)}
+ disabled={allChosenTagsInThisBoard?.some(
+ (t) => t.value === item.value
+ )}
key={item.value}
onClick={handleClick}
text={
- requirementTags[configuredBoard?.id]?.some(t => t.value === item.value) ? (
+ requirementTags[configuredBoard?.id]?.some(
+ (t) => t.value === item.value
+ ) ? (
<>
<img src={item.iconUrl} width={12} height={12} />{' '}
{item.title}{' '}
@@ -368,9 +378,9 @@ export default function JiraSettings(props) {
}
style={{
marginBottom: '2px',
- fontWeight: requirementTags[
- configuredBoard?.id
- ]?.some(t => t.value === item.value)
+ fontWeight: requirementTags[configuredBoard?.id]?.some(
+ (t) => t.value === item.value
+ )
? 700
: 'normal'
}}
@@ -397,7 +407,9 @@ export default function JiraSettings(props) {
onItemSelect={(item) => {
// setRequirementTags((rT) => !rT.includes(item) ? [...rT, item] : [...rT])
setRequirementTags((rT) =>
- !rT[configuredBoard?.id]?.some(t => t.value === item.value)
+ !rT[configuredBoard?.id]?.some(
+ (t) => t.value === item.value
+ )
? {
...rT,
[configuredBoard?.id]: [
@@ -478,11 +490,15 @@ export default function JiraSettings(props) {
itemRenderer={(item, { handleClick, modifiers }) => (
<MenuItem
active={modifiers.active}
- disabled={allChosenTagsInThisBoard?.some(t => t.value === item.value)}
+ disabled={allChosenTagsInThisBoard?.some(
+ (t) => t.value === item.value
+ )}
key={item.value}
onClick={handleClick}
text={
- bugTags[configuredBoard?.id]?.some(t => t.value === item.value) ? (
+ bugTags[configuredBoard?.id]?.some(
+ (t) => t.value === item.value
+ ) ? (
<>
<img src={item.iconUrl} width={12} height={12} />{' '}
{item.title}{' '}
@@ -497,7 +513,9 @@ export default function JiraSettings(props) {
}
style={{
marginBottom: '2px',
- fontWeight: bugTags[configuredBoard?.id]?.some(t => t.value === item.value)
+ fontWeight: bugTags[configuredBoard?.id]?.some(
+ (t) => t.value === item.value
+ )
? 700
: 'normal'
}}
@@ -524,7 +542,9 @@ export default function JiraSettings(props) {
onItemSelect={(item) => {
// setBugTags((bT) => !bT.includes(item) ? [...bT, item] : [...bT])
setBugTags((bT) =>
- !bT[configuredBoard?.id]?.some(t => t.value === item.value)
+ !bT[configuredBoard?.id]?.some(
+ (t) => t.value === item.value
+ )
? {
...bT,
[configuredBoard?.id]: [
@@ -611,11 +631,15 @@ export default function JiraSettings(props) {
itemRenderer={(item, { handleClick, modifiers }) => (
<MenuItem
active={modifiers.active}
- disabled={allChosenTagsInThisBoard?.some(t => t.value === item.value)}
+ disabled={allChosenTagsInThisBoard?.some(
+ (t) => t.value === item.value
+ )}
key={item.value}
onClick={handleClick}
text={
- incidentTags[configuredBoard?.id]?.some(t => t.value === item.value) ? (
+ incidentTags[configuredBoard?.id]?.some(
+ (t) => t.value === item.value
+ ) ? (
<>
<img src={item.iconUrl} width={12} height={12} />{' '}
{item.title}{' '}
@@ -630,7 +654,9 @@ export default function JiraSettings(props) {
}
style={{
marginBottom: '2px',
- fontWeight: incidentTags[configuredBoard?.id]?.some(t => t.value === item.value)
+ fontWeight: incidentTags[configuredBoard?.id]?.some(
+ (t) => t.value === item.value
+ )
? 700
: 'normal'
}}
@@ -657,7 +683,9 @@ export default function JiraSettings(props) {
onItemSelect={(item) => {
// setIncidentTags((iT) => !iT.includes(item) ? [...iT, item] : [...iT])
setIncidentTags((iT) =>
- !iT[configuredBoard?.id]?.some(t => t.value === item.value)
+ !iT[configuredBoard?.id]?.some(
+ (t) => t.value === item.value
+ )
? {
...iT,
[configuredBoard?.id]: [