Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new team moved to team select #29

Merged
merged 2 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
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
8 changes: 7 additions & 1 deletion src/components/TeamSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import { find } from 'lodash-es'
import Select from 'react-select'

import './teamSelect.sass'
import { TeamTag } from './TeamTag';
import { TeamTag } from './TeamTag'

type Props = {
allowAll: boolean
allowNew: boolean
teams: any[]
activeTeam: any
onChangeTeam: (id: any, name: string) => void
Expand All @@ -16,6 +17,7 @@ type Props = {
export default class TeamSelect extends React.Component<Props> {
static defaultProps = {
allowAll: false,
allowNew: false,
}

handleChangeTeam = (val: any) => {
Expand All @@ -26,6 +28,10 @@ export default class TeamSelect extends React.Component<Props> {
const options = this.props.allowAll
? [{ name: 'All teams', id: 'all' }, ...this.props.teams]
: this.props.teams

if (this.props.allowNew) {
options.push({ name: 'Add team', id: 'new' })
}
return options.map((team) => ({
value: team.name,
team,
Expand Down
20 changes: 19 additions & 1 deletion src/components/TeamTag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ const colors = ['#000', '#FFF']
const getContrastColor = (original: string) => bestContrast(`#${original}`, colors)

export const TeamIcon = ({ team, iconSize }: { team: any; iconSize?: number }) => {
if (team.id === 'new') {
return (
<span className="teamTag-img" style={{ fontSize: iconSize }}>

<div
className="teamIcon view-add"
>
<div className="teamIcon-initials">+</div>
</div>
</span>
)
}

if (team.id === 'all') {
return (
Expand All @@ -23,7 +35,13 @@ export const TeamIcon = ({ team, iconSize }: { team: any; iconSize?: number }) =
)
}
return team.icon ? (
<AppIcon iconSize={iconSize} context="teams" id={team.id} className="teamTag-img" name={team.initials} />
<AppIcon
iconSize={iconSize}
context="teams"
id={team.id}
className="teamTag-img"
name={team.initials}
/>
) : (
<span className="teamTag-img" style={{ fontSize: iconSize }}>
<div
Expand Down
6 changes: 6 additions & 0 deletions src/components/teamIcon.sass
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@
line-height: 1
background: no-repeat center
background-size: 76%

&.view-add
background-color: #236aea
background-color: var(--style-primary-action-background-color)
color: white
color: var(--style-primary-action-color)
16 changes: 13 additions & 3 deletions src/parts/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,15 @@ export class Sidebar extends React.Component<SidebarProps> {
handleChangeTeam = (team: string) => {
if (team === 'all') {
navigate(`/apps`)
} else if (team === 'new') {
navigate(`/team/new`)
} else {
navigate(`/apps/${team}`)
}

if (this.props.onChoice) {
this.props.onChoice()
}
}

render() {
Expand All @@ -46,6 +52,7 @@ export class Sidebar extends React.Component<SidebarProps> {
{teams && (
<TeamSelect
allowAll
allowNew
activeTeam={activeTeam || 'all'}
teams={teams}
onChangeTeam={this.handleChangeTeam}
Expand Down Expand Up @@ -86,9 +93,12 @@ export class Sidebar extends React.Component<SidebarProps> {
</Link>
</div>
<div className="sidebar-addTeam">
<Link onClick={this.props.onChoice} to="/me">My profile</Link>
<Link onClick={this.props.onChoice} to="/team/new">Create a new team</Link>
<Link to="/" onClick={window.logout}>Logout</Link>
<Link onClick={this.props.onChoice} to="/me">
My profile
</Link>
<Link to="/" onClick={window.logout}>
Logout
</Link>
</div>
</>
)}
Expand Down