Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class App extends Component {
constructor(props){
super(props);
this.state={
haveCorrectConfBoard: true,
haveConnectList: true,
haveConf: false,
headerIndex: null,
Expand All @@ -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)
}
}
})
}
})
}

Expand All @@ -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})
Expand All @@ -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,
Expand All @@ -90,6 +107,9 @@ class App extends Component {
})
})
})
.catch((err) => {
this.setState({ haveCorrectConfBoard:false})
})
}

getRows = (rows) => {
Expand Down Expand Up @@ -185,7 +205,9 @@ class App extends Component {

render() {
const { localItemList,
haveCorrectConfBoard,
mondayColumns,
haveConnectList,
haveConf,
configuration,
mondayJsonIndex,
Expand All @@ -202,6 +224,18 @@ class App extends Component {
<Jumbotron className="jumbotron-background">
<h1 className="display-3">Update Monday Board</h1>
{
!haveCorrectConfBoard ?
<div>
<p className="lead">No Configuration Board</p>
<p className="lead">Check out your board setting.</p>
</div>
:
!haveConnectList ?
<div>
<p className="lead">No configuration file for the target board</p>
<p className="lead">Check out configuration board.</p>
</div>
:
haveConf ?
<p className="lead">Click Update Button</p>
:
Expand All @@ -211,6 +245,9 @@ class App extends Component {
</Jumbotron>
</div>
{
!haveConnectList || !haveCorrectConfBoard ?
null
:
haveConf ?
<Update
configuration={configuration}
Expand Down