From cff91ea93c94a4809ddcc4721082e5f5c36c89c9 Mon Sep 17 00:00:00 2001 From: hiroTochigi Date: Tue, 6 Oct 2020 15:28:54 -0500 Subject: [PATCH] production --- src/App.js | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/src/App.js b/src/App.js index 1f1b243..75c13c7 100644 --- a/src/App.js +++ b/src/App.js @@ -13,6 +13,7 @@ class App extends Component { constructor(props){ super(props); this.state={ + haveCorrectConfBoard: true, haveConnectList: true, haveConf: false, headerIndex: null, @@ -36,16 +37,24 @@ class App extends Component { } getConfigurationBoardId = (boardIds) => { + let result = [] return new Promise((resolve, reject) => { for(let i=0; boardIds.length > i; i++){ monday .api(`query { boards(ids:[${boardIds[i]}]) { name }}`) .then((res) => { if (res.data.boards[0].name === "Configuration"){ - resolve(boardIds[i]) + result.push(boardIds[i]) } - } - )} + if (i === boardIds.length - 1){ + if (result.length === 1){ + resolve(result[0]) + }else{ + reject(null) + } + } + }) + } }) } @@ -61,10 +70,11 @@ class App extends Component { } getContext = (res) => { + console.log(res) const context = res.data; const boardIds = context.boardIds || [context.boardId]; - this.getConfigurationBoardId(boardIds).then((confId) => { + console.log(confId) const confBoardId = confId const targetBoardId = boardIds[0] !== confBoardId ? boardIds[0] : boardIds[1] this.setState({boardId:targetBoardId}) @@ -76,7 +86,14 @@ class App extends Component { .then((res) => { const boardAllItems = res.data.boards[0].items; const confVarialbes = makeConfVariable(boardAllItems, boardName) - this.setState({connectList:confVarialbes.connect_list, + if (Object.keys(confVarialbes.connect_list).length === 0){ + this.setState({haveConnectList:false}) + return + } + this.setState({ + haveCorrectConfBoard:true, + haveConnectList:true, + connectList:confVarialbes.connect_list, headerIndex:0, connectIds:confVarialbes.ids, exclusiveLabels: confVarialbes.exclusiveLabelList, @@ -90,6 +107,9 @@ class App extends Component { }) }) }) + .catch((err) => { + this.setState({ haveCorrectConfBoard:false}) + }) } getRows = (rows) => { @@ -185,7 +205,9 @@ class App extends Component { render() { const { localItemList, + haveCorrectConfBoard, mondayColumns, + haveConnectList, haveConf, configuration, mondayJsonIndex, @@ -202,6 +224,18 @@ class App extends Component {

Update Monday Board

{ + !haveCorrectConfBoard ? +
+

No Configuration Board

+

Check out your board setting.

+
+ : + !haveConnectList ? +
+

No configuration file for the target board

+

Check out configuration board.

+
+ : haveConf ?

Click Update Button

: @@ -211,6 +245,9 @@ class App extends Component {
{ + !haveConnectList || !haveCorrectConfBoard ? + null + : haveConf ?