Cleanup model imports

This commit is contained in:
Chen-I Lim 2021-02-16 10:31:00 -08:00
parent a7f88c1103
commit 30e912c3f9
13 changed files with 57 additions and 62 deletions

View file

@ -2,9 +2,7 @@
// See LICENSE.txt for license information.
import {Utils} from '../utils'
import {IBlock} from '../blocks/block'
import {MutableBlock} from './block'
import {IBlock, MutableBlock} from './block'
type PropertyType = 'text' | 'number' | 'select' | 'multiSelect' | 'date' | 'person' | 'file' | 'checkbox' | 'url' | 'email' | 'phone' | 'createdTime' | 'createdBy' | 'updatedTime' | 'updatedBy'

View file

@ -1,10 +1,9 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {IBlock} from '../blocks/block'
import {FilterGroup} from '../filterGroup'
import {Utils} from '../utils'
import {MutableBlock} from './block'
import {IBlock, MutableBlock} from './block'
import {FilterGroup} from './filterGroup'
type IViewType = 'board' | 'table' // | 'calendar' | 'list' | 'gallery'
type ISortOption = { propertyId: '__title' | string, reversed: boolean }

View file

@ -1,9 +1,8 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Utils} from '../utils'
import {IBlock} from '../blocks/block'
import {MutableBlock} from './block'
import {IBlock, MutableBlock} from './block'
interface Card extends IBlock {
readonly icon: string

View file

@ -1,8 +1,6 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {IBlock} from '../blocks/block'
import {MutableBlock} from './block'
import {IBlock, MutableBlock} from './block'
type CommentBlock = IBlock

View file

@ -12,4 +12,3 @@ class MutableDividerBlock extends MutableContentBlock implements DividerBlock {
}
export {DividerBlock, MutableDividerBlock}

View file

@ -0,0 +1,27 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {Utils} from '../utils'
type FilterCondition = 'includes' | 'notIncludes' | 'isEmpty' | 'isNotEmpty'
class FilterClause {
propertyId: string
condition: FilterCondition
values: string[]
constructor(o: any = {}) {
this.propertyId = o.propertyId || ''
this.condition = o.condition || 'includes'
this.values = o.values?.slice() || []
}
isEqual(o: FilterClause): boolean {
return (
this.propertyId === o.propertyId &&
this.condition === o.condition &&
Utils.arraysEqual(this.values, o.values)
)
}
}
export {FilterClause, FilterCondition}

View file

@ -2,8 +2,8 @@
// See LICENSE.txt for license information.
import {IPropertyTemplate} from './blocks/board'
import {Card} from './blocks/card'
import {FilterClause} from './filterClause'
import {FilterGroup} from './filterGroup'
import {FilterClause} from './blocks/filterClause'
import {FilterGroup} from './blocks/filterGroup'
import {Utils} from './utils'
class CardFilter {

View file

@ -4,9 +4,10 @@ import React from 'react'
import {FormattedMessage, injectIntl, IntlShape} from 'react-intl'
import {IPropertyTemplate} from '../blocks/board'
import {FilterClause, FilterCondition} from '../filterClause'
import {FilterGroup} from '../filterGroup'
import {FilterClause, FilterCondition} from '../blocks/filterClause'
import {FilterGroup} from '../blocks/filterGroup'
import mutator from '../mutator'
import {OctoUtils} from '../octoUtils'
import {Utils} from '../utils'
import {BoardTree} from '../viewModel/boardTree'
import Button from '../widgets/buttons/button'
@ -91,7 +92,7 @@ class FilterComponent extends React.Component<Props> {
</Menu>
</MenuWrapper>
<MenuWrapper>
<Button>{FilterClause.filterConditionDisplayString(filter.condition, intl)}</Button>
<Button>{OctoUtils.filterConditionDisplayString(filter.condition, intl)}</Button>
<Menu>
<Menu.Text
id='includes'

View file

@ -1,42 +0,0 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {IntlShape} from 'react-intl'
import {Utils} from './utils'
type FilterCondition = 'includes' | 'notIncludes' | 'isEmpty' | 'isNotEmpty'
class FilterClause {
propertyId: string
condition: FilterCondition
values: string[]
static filterConditionDisplayString(filterCondition: FilterCondition, intl: IntlShape): string {
switch (filterCondition) {
case 'includes': return intl.formatMessage({id: 'Filter.includes', defaultMessage: 'includes'})
case 'notIncludes': return intl.formatMessage({id: 'Filter.not-includes', defaultMessage: 'doesn\'t include'})
case 'isEmpty': return intl.formatMessage({id: 'Filter.is-empty', defaultMessage: 'is empty'})
case 'isNotEmpty': return intl.formatMessage({id: 'Filter.is-not-empty', defaultMessage: 'is not empty'})
default: {
Utils.assertFailure()
return '(unknown)'
}
}
}
constructor(o: any = {}) {
this.propertyId = o.propertyId || ''
this.condition = o.condition || 'includes'
this.values = o.values?.slice() || []
}
isEqual(o: FilterClause): boolean {
return (
this.propertyId === o.propertyId &&
this.condition === o.condition &&
Utils.arraysEqual(this.values, o.values)
)
}
}
export {FilterClause, FilterCondition}

View file

@ -5,8 +5,8 @@ import {IBlock, MutableBlock} from './blocks/block'
import {Board, IPropertyOption, IPropertyTemplate, MutableBoard, PropertyType} from './blocks/board'
import {BoardView, ISortOption, MutableBoardView} from './blocks/boardView'
import {Card, MutableCard} from './blocks/card'
import {FilterGroup} from './blocks/filterGroup'
import {MutableImageBlock} from './blocks/imageBlock'
import {FilterGroup} from './filterGroup'
import octoClient from './octoClient'
import {OctoUtils} from './octoUtils'
import undoManager from './undomanager'

View file

@ -1,6 +1,8 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {IntlShape} from 'react-intl'
import {IBlock, MutableBlock} from './blocks/block'
import {IPropertyTemplate, MutableBoard} from './blocks/board'
import {MutableBoardView} from './blocks/boardView'
@ -9,6 +11,7 @@ import {MutableCommentBlock} from './blocks/commentBlock'
import {MutableDividerBlock} from './blocks/dividerBlock'
import {MutableImageBlock} from './blocks/imageBlock'
import {MutableTextBlock} from './blocks/textBlock'
import {FilterCondition} from './blocks/filterClause'
import {Utils} from './utils'
class OctoUtils {
@ -141,6 +144,19 @@ class OctoUtils {
const newSourceBlock = newBlocks.find((block) => block.id === newSourceBlockId)!
return [newBlocks, newSourceBlock, idMap]
}
static filterConditionDisplayString(filterCondition: FilterCondition, intl: IntlShape): string {
switch (filterCondition) {
case 'includes': return intl.formatMessage({id: 'Filter.includes', defaultMessage: 'includes'})
case 'notIncludes': return intl.formatMessage({id: 'Filter.not-includes', defaultMessage: 'doesn\'t include'})
case 'isEmpty': return intl.formatMessage({id: 'Filter.is-empty', defaultMessage: 'is empty'})
case 'isNotEmpty': return intl.formatMessage({id: 'Filter.is-not-empty', defaultMessage: 'is not empty'})
default: {
Utils.assertFailure()
return '(unknown)'
}
}
}
}
export {OctoUtils}

View file

@ -6,10 +6,10 @@ import {MutableBoardView} from '../blocks/boardView'
import {Card, MutableCard} from '../blocks/card'
import {MutableCommentBlock} from '../blocks/commentBlock'
import {DividerBlock, MutableDividerBlock} from '../blocks/dividerBlock'
import {FilterClause} from '../blocks/filterClause'
import {FilterGroup} from '../blocks/filterGroup'
import {ImageBlock, MutableImageBlock} from '../blocks/imageBlock'
import {MutableTextBlock, TextBlock} from '../blocks/textBlock'
import {FilterClause} from '../filterClause'
import {FilterGroup} from '../filterGroup'
class TestBlockFactory {
static createBoard(): MutableBoard {