mirror of
https://github.com/mattermost/focalboard.git
synced 2024-11-24 08:22:29 +02:00
fix trello import
This commit is contained in:
parent
400c5a108c
commit
2e7427d2f3
@ -5,6 +5,7 @@ import minimist from 'minimist'
|
||||
import {exit} from 'process'
|
||||
import {ArchiveUtils} from '../util/archive'
|
||||
import {Block} from '../../webapp/src/blocks/block'
|
||||
import {Board} from '../../webapp/src/blocks/board'
|
||||
import {IPropertyOption, IPropertyTemplate, createBoard} from '../../webapp/src/blocks/board'
|
||||
import {createBoardView} from '../../webapp/src/blocks/boardView'
|
||||
import {createCard} from '../../webapp/src/blocks/card'
|
||||
@ -50,23 +51,23 @@ function main() {
|
||||
const input = JSON.parse(inputData) as Trello
|
||||
|
||||
// Convert
|
||||
const blocks = convert(input)
|
||||
const [boards, blocks] = convert(input)
|
||||
|
||||
// Save output
|
||||
// TODO: Stream output
|
||||
const outputData = ArchiveUtils.buildBlockArchive(blocks)
|
||||
const outputData = ArchiveUtils.buildBlockArchive(boards, blocks)
|
||||
fs.writeFileSync(outputFile, outputData)
|
||||
|
||||
console.log(`Exported to ${outputFile}`)
|
||||
}
|
||||
|
||||
function convert(input: Trello): Block[] {
|
||||
function convert(input: Trello): [Board[], Block[]] {
|
||||
const boards: Board[] = []
|
||||
const blocks: Block[] = []
|
||||
|
||||
// Board
|
||||
const board = createBoard()
|
||||
console.log(`Board: ${input.name}`)
|
||||
board.rootId = board.id
|
||||
board.title = input.name
|
||||
board.description = input.desc
|
||||
|
||||
@ -93,13 +94,13 @@ function convert(input: Trello): Block[] {
|
||||
options
|
||||
}
|
||||
board.cardProperties = [cardProperty]
|
||||
blocks.push(board)
|
||||
boards.push(board)
|
||||
|
||||
// Board view
|
||||
const view = createBoardView()
|
||||
view.title = 'Board View'
|
||||
view.fields.viewType = 'board'
|
||||
view.rootId = board.id
|
||||
view.boardId = board.id
|
||||
view.parentId = board.id
|
||||
blocks.push(view)
|
||||
|
||||
@ -109,7 +110,7 @@ function convert(input: Trello): Block[] {
|
||||
|
||||
const outCard = createCard()
|
||||
outCard.title = card.name
|
||||
outCard.rootId = board.id
|
||||
outCard.boardId = board.id
|
||||
outCard.parentId = board.id
|
||||
|
||||
// Map lists to Select property options
|
||||
@ -130,7 +131,7 @@ function convert(input: Trello): Block[] {
|
||||
// console.log(`\t${card.desc}`)
|
||||
const text = createTextBlock()
|
||||
text.title = card.desc
|
||||
text.rootId = board.id
|
||||
text.boardId = board.id
|
||||
text.parentId = outCard.id
|
||||
blocks.push(text)
|
||||
|
||||
@ -150,7 +151,7 @@ function convert(input: Trello): Block[] {
|
||||
} else {
|
||||
checkBlock.fields.value = false
|
||||
}
|
||||
checkBlock.rootId = outCard.rootId
|
||||
checkBlock.boardId = board.id
|
||||
checkBlock.parentId = outCard.id
|
||||
blocks.push(checkBlock)
|
||||
|
||||
@ -164,7 +165,7 @@ function convert(input: Trello): Block[] {
|
||||
console.log('')
|
||||
console.log(`Found ${input.cards.length} card(s).`)
|
||||
|
||||
return blocks
|
||||
return [boards, blocks]
|
||||
}
|
||||
|
||||
function showHelp() {
|
||||
|
Loading…
Reference in New Issue
Block a user