1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-30 14:00:07 +02:00

Cleanup merge

This commit is contained in:
Chen-I Lim 2020-10-14 12:39:34 -07:00
parent b202277772
commit 83c040511d
4 changed files with 113 additions and 116 deletions

View File

@ -5,16 +5,14 @@ import { BlockIcons } from "../blockIcons"
import { IPropertyOption } from "../board"
import { BoardTree } from "../boardTree"
import { CardFilter } from "../cardFilter"
import { Constants } from "../constants"
import ViewMenu from "../components/viewMenu"
import { Constants } from "../constants"
import { Menu as OldMenu } from "../menu"
import { Mutator } from "../mutator"
import { IBlock } from "../octoTypes"
import { OctoUtils } from "../octoUtils"
import { Utils } from "../utils"
import { BoardCard } from "./boardCard"
import { Board } from "../board"
import { BoardView } from "../boardView"
import { BoardColumn } from "./boardColumn"
import Button from "./button"
import { Editable } from "./editable"
@ -106,7 +104,7 @@ class BoardComponent extends React.Component<Props, State> {
onClose={() => this.setState({ viewMenu: false })}
mutator={mutator}
boardTree={boardTree}
pageController={pageController}
showView={showView}
/>}
<div className="imageDropdown"></div>
</div>

View File

@ -1,44 +1,44 @@
// Copyright (c) 2020-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React from 'react';
import ReactDOM from 'react-dom';
import PropTypes from 'prop-types';
import React from 'react'
import ReactDOM from 'react-dom'
import PropTypes from 'prop-types'
type Props = {
children: React.ReactNode
children: React.ReactNode
}
export default class RootPortal extends React.PureComponent<Props> {
el: HTMLDivElement
el: HTMLDivElement
static propTypes = {
children: PropTypes.node,
}
static propTypes = {
children: PropTypes.node,
}
constructor(props: Props) {
super(props);
this.el = document.createElement('div');
}
constructor(props: Props) {
super(props)
this.el = document.createElement('div')
}
componentDidMount() {
const rootPortal = document.getElementById('root-portal');
if (rootPortal) {
rootPortal.appendChild(this.el);
}
}
componentDidMount() {
const rootPortal = document.getElementById('root-portal')
if (rootPortal) {
rootPortal.appendChild(this.el)
}
}
componentWillUnmount() {
const rootPortal = document.getElementById('root-portal');
if (rootPortal) {
rootPortal.removeChild(this.el);
}
}
componentWillUnmount() {
const rootPortal = document.getElementById('root-portal')
if (rootPortal) {
rootPortal.removeChild(this.el)
}
}
render() {
return ReactDOM.createPortal(
this.props.children,
this.el,
);
}
render() {
return ReactDOM.createPortal(
this.props.children,
this.el,
)
}
}

View File

@ -27,7 +27,7 @@ type Props = {
type State = {
isHoverOnCover: boolean
isSearching: boolean
viewMenu: boolean
viewMenu: boolean
}
class TableComponent extends React.Component<Props, State> {
@ -38,7 +38,7 @@ class TableComponent extends React.Component<Props, State> {
constructor(props: Props) {
super(props)
this.state = { isHoverOnCover: false, isSearching: !!this.props.boardTree?.getSearchText(), viewMenu: false}
this.state = { isHoverOnCover: false, isSearching: !!this.props.boardTree?.getSearchText(), viewMenu: false }
}
componentDidUpdate(prevPros: Props, prevState: State) {
@ -90,21 +90,21 @@ class TableComponent extends React.Component<Props, State> {
<div className="octo-table">
<div className="octo-controls">
<Editable style={{ color: "#000000", fontWeight: 600 }} text={activeView.title} placeholderText="Untitled View" onChanged={(text) => { mutator.changeTitle(activeView, text) }} />
<div
className="octo-button"
style={{ color: "#000000", fontWeight: 600 }}
onClick={() => this.setState({viewMenu: true})}
>
{this.state.viewMenu &&
<ViewMenu
board={board}
onClose={() => this.setState({viewMenu:false})}
mutator={mutator}
boardTree={boardTree}
pageController={pageController}
/>}
<div className="imageDropdown"></div>
</div>
<div
className="octo-button"
style={{ color: "#000000", fontWeight: 600 }}
onClick={() => this.setState({ viewMenu: true })}
>
{this.state.viewMenu &&
<ViewMenu
board={board}
onClose={() => this.setState({ viewMenu: false })}
mutator={mutator}
boardTree={boardTree}
showView={showView}
/>}
<div className="imageDropdown"></div>
</div>
<div className="octo-spacer"></div>
<div className="octo-button" onClick={(e) => { this.propertiesClicked(e) }}>Properties</div>
<div className={hasFilter ? "octo-button active" : "octo-button"} onClick={(e) => { this.filterClicked(e) }}>Filter</div>

View File

@ -1,85 +1,84 @@
import React from "react"
import { Mutator } from "../mutator"
import Menu from "../widgets/menu"
import { Board } from "../board"
import { BoardTree } from "../boardTree"
import { IPageController } from "../octoTypes"
import { Utils } from "../utils"
import { BoardView } from "../boardView"
import { Mutator } from "../mutator"
import { Utils } from "../utils"
import Menu from "../widgets/menu"
type Props = {
mutator: Mutator,
boardTree?: BoardTree
pageController: IPageController,
board: Board,
onClose: () => void,
board: Board,
showView: (id: string) => void
onClose: () => void,
}
export default class ViewMenu extends React.Component<Props> {
handleDeleteView = async (id: string) => {
const {board, boardTree, mutator, pageController} = this.props;
Utils.log(`deleteView`)
const view = boardTree.activeView
const nextView = boardTree.views.find(o => o !== view)
await mutator.deleteBlock(view, "delete view")
pageController.showView(nextView.id)
}
handleDeleteView = async (id: string) => {
const { board, boardTree, mutator, showView } = this.props
Utils.log(`deleteView`)
const view = boardTree.activeView
const nextView = boardTree.views.find(o => o !== view)
await mutator.deleteBlock(view, "delete view")
showView(nextView.id)
}
handleViewClick = (id: string) => {
const {boardTree, pageController} = this.props;
Utils.log(`view ` + id)
const view = boardTree.views.find(o => o.id === id)
pageController.showView(view.id)
}
handleViewClick = (id: string) => {
const { boardTree, showView } = this.props
Utils.log(`view ` + id)
const view = boardTree.views.find(o => o.id === id)
showView(view.id)
}
handleAddViewBoard = async (id: string) => {
const {board, boardTree, mutator, pageController} = this.props;
Utils.log(`addview-board`)
const view = new BoardView()
view.title = "Board View"
view.viewType = "board"
view.parentId = board.id
handleAddViewBoard = async (id: string) => {
const { board, boardTree, mutator, showView } = this.props
Utils.log(`addview-board`)
const view = new BoardView()
view.title = "Board View"
view.viewType = "board"
view.parentId = board.id
const oldViewId = boardTree.activeView.id
const oldViewId = boardTree.activeView.id
await mutator.insertBlock(
view,
"add view",
async () => { pageController.showView(view.id) },
async () => { pageController.showView(oldViewId) })
}
await mutator.insertBlock(
view,
"add view",
async () => { showView(view.id) },
async () => { showView(oldViewId) })
}
handleAddViewTable = async (id: string) => {
const {board, boardTree, mutator, pageController} = this.props;
handleAddViewTable = async (id: string) => {
const { board, boardTree, mutator, showView } = this.props
Utils.log(`addview-table`)
const view = new BoardView()
view.title = "Table View"
view.viewType = "table"
view.parentId = board.id
view.visiblePropertyIds = board.cardProperties.map(o => o.id)
Utils.log(`addview-table`)
const view = new BoardView()
view.title = "Table View"
view.viewType = "table"
view.parentId = board.id
view.visiblePropertyIds = board.cardProperties.map(o => o.id)
const oldViewId = boardTree.activeView.id
const oldViewId = boardTree.activeView.id
await mutator.insertBlock(
view,
"add view",
async () => { pageController.showView(view.id) },
async () => { pageController.showView(oldViewId) })
}
await mutator.insertBlock(
view,
"add view",
async () => { showView(view.id) },
async () => { showView(oldViewId) })
}
render() {
const {board, onClose, boardTree, mutator, pageController} = this.props;
return (
<Menu onClose={onClose}>
{boardTree.views.map((view) => (<Menu.Text key={view.id} id={view.id} name={view.title} onClick={this.handleViewClick}/>))}
<Menu.Separator/>
{boardTree.views.length > 1 && <Menu.Text id="__deleteView" name="Delete View" onClick={this.handleDeleteView} />}
<Menu.SubMenu id="__addView" name="Add View">
<Menu.Text id='board' name='Board' onClick={this.handleAddViewBoard}/>
<Menu.Text id='table' name='Table' onClick={this.handleAddViewTable}/>
</Menu.SubMenu>
</Menu>
);
}
render() {
const { onClose, boardTree } = this.props
return (
<Menu onClose={onClose}>
{boardTree.views.map((view) => (<Menu.Text key={view.id} id={view.id} name={view.title} onClick={this.handleViewClick} />))}
<Menu.Separator />
{boardTree.views.length > 1 && <Menu.Text id="__deleteView" name="Delete View" onClick={this.handleDeleteView} />}
<Menu.SubMenu id="__addView" name="Add View">
<Menu.Text id='board' name='Board' onClick={this.handleAddViewBoard} />
<Menu.Text id='table' name='Table' onClick={this.handleAddViewTable} />
</Menu.SubMenu>
</Menu>
)
}
}