1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-03-29 21:01:01 +02:00
focalboard/webapp/src/pages/dashboard/centerContent.tsx
Harshil Sharma d0ba389063
FTUE - Dashboard (#1177)
* Dashboard UI complete

* Updating UI changes

* Finishing touches

* Made navigation better

* Updated dashboard navigation

* Fixed spacing issue

* Fixed spacing issue

* Updating UI

* Fixed a CSS linter issue

* Update webapp/i18n/en.json

Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>

* Updated docs

Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>

* Update webapp/i18n/en.json

Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>

* Disabled image

* FIxed tests

* Review fixes

Co-authored-by: Asaad Mahmood <asaadmahmood@users.noreply.github.com>
Co-authored-by: Justine Geffen <justinegeffen@users.noreply.github.com>
Co-authored-by: Scott Bishel <scott.bishel@mattermost.com>
2021-09-14 10:42:18 -06:00

102 lines
4.2 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useEffect, useState} from 'react'
import {useHistory} from 'react-router-dom'
import {useIntl} from 'react-intl'
import SearchIllustration from '../../svg/search-illustration'
import {UserWorkspace} from '../../user'
import {useAppDispatch, useAppSelector} from '../../store/hooks'
import {getUserWorkspaceList, setUserWorkspaces} from '../../store/workspace'
import octoClient from '../../octoClient'
import SearchIcon from '../../widgets/icons/search'
const DashboardCenterContent = (): JSX.Element => {
const rawWorkspaces = useAppSelector<UserWorkspace[]>(getUserWorkspaceList) || []
const dispatch = useAppDispatch()
const history = useHistory()
const intl = useIntl()
const [searchFilter, setSearchFilter] = useState('')
const initializeUserWorkspaces = async () => {
const userWorkspaces = await octoClient.getUserWorkspaces()
dispatch(setUserWorkspaces(userWorkspaces))
}
useEffect(() => {
if (rawWorkspaces.length > 0) {
return
}
initializeUserWorkspaces()
})
const userWorkspaces = rawWorkspaces.
filter((workspace) => workspace.title.toLowerCase().includes(searchFilter) || workspace.boardCount.toString().includes(searchFilter)).
sort((a, b) => {
if ((a.boardCount === 0 && b.boardCount === 0) || (a.boardCount !== 0 && b.boardCount !== 0)) {
return a.title.localeCompare(b.title)
}
return b.boardCount - a.boardCount
})
return (
<div className='DashboardCenterContent'>
<div className='DashboardPage__header'>
<h1 className='h1'>{intl.formatMessage({id: 'DashboardPage.title', defaultMessage: 'Dashboard'})}</h1>
<div className='DashboardPage__search'>
<SearchIcon/>
<input
type='text'
placeholder={intl.formatMessage({id: 'ViewHeader.search', defaultMessage: 'Search'})}
onChange={(e) => {
setSearchFilter(e.target.value.trim().toLowerCase())
}}
/>
</div>
</div>
<div className='DashboardPage__content'>
{
userWorkspaces.length !== 0 &&
<div className='text-heading3'>{'All Channels'}</div>
}
<div className='DashboardPage__workspace-container'>
{
userWorkspaces.length === 0 &&
<div className='DashboardPage__emptyResult'>
<SearchIllustration/>
<h3>{intl.formatMessage({id: 'DashboardPage.CenterPanel.NoWorkspaces', defaultMessage: 'Sorry, we could not find any channels matching that term'})}</h3>
<p className='small'>{intl.formatMessage({id: 'DashboardPage.CenterPanel.NoWorkspacesDescription', defaultMessage: 'Please try searching for another term'})}</p>
</div>
}
{
userWorkspaces.map((workspace) => (
<div
key={workspace.id}
className='DashboardPage__workspace'
onClick={() => {
history.push(`/workspace/${workspace.id}`)
}}
>
<div className='text-heading2'>
{workspace.title}
</div>
<div className='small'>
{`${workspace.boardCount} board${workspace.boardCount > 1 ? 's' : ''}`}
</div>
</div>
))
}
</div>
</div>
</div>
)
}
export default DashboardCenterContent