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

Tracker: fix issue status colors in the kanban view #2231

Merged
merged 2 commits into from
Jul 8, 2022
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
217 changes: 0 additions & 217 deletions plugins/tracker-resources/src/components/issues/Board.svelte

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,10 @@
$: color =
fill ??
(value.color !== undefined ? getPlatformColor(value.color) : undefined) ??
(category !== undefined ? getPlatformColor(category.color) : undefined)
(category !== undefined ? getPlatformColor(category.color) : undefined) ??
'currentColor'
</script>

{#if icon !== undefined && color !== undefined}
{#if icon !== undefined}
<Icon {icon} fill={color} {size} />
{/if}
15 changes: 11 additions & 4 deletions plugins/tracker-resources/src/components/issues/KanbanView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
IconAdd,
showPanel,
showPopup,
getPlatformColor,
Loading,
tooltip
tooltip,
getPlatformColor
} from '@anticrm/ui'
import { focusStore, ListSelectionProvider, SelectDirection, selectionStore } from '@anticrm/view-resources'
import ActionContext from '@anticrm/view-resources/src/components/ActionContext.svelte'
Expand All @@ -40,7 +40,8 @@
getKanbanStatuses,
getPriorityStates,
issuesGroupBySorting,
issuesSortOrderMap
issuesSortOrderMap,
UNSET_COLOR
} from '../../utils'
import CreateIssue from '../CreateIssue.svelte'
import ProjectEditor from '../projects/ProjectEditor.svelte'
Expand Down Expand Up @@ -195,7 +196,13 @@
<div class="header flex-col">
<div class="flex-between label font-medium w-full h-full">
<div class="flex-row-center gap-2">
<Icon icon={state.icon} fill={getPlatformColor(state.color)} size={'small'} />
{#if state.icon}
<Icon
icon={state.icon}
fill={state.color === UNSET_COLOR ? 'currentColor' : getPlatformColor(state.color)}
size="small"
/>
{/if}
<span class="lines-limit-2 ml-2">{state.title}</span>
<span class="counter ml-2 text-md">{count}</span>
</div>
Expand Down
20 changes: 11 additions & 9 deletions plugins/tracker-resources/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import { defaultPriorities, defaultProjectStatuses, issuePriorities } from './ty

export * from './types'

export const UNSET_COLOR = -1

export interface NavigationItem {
id: string
label: IntlString
Expand Down Expand Up @@ -344,7 +346,7 @@ export async function getKanbanStatuses (
issues: Array<WithLookup<Issue>>
): Promise<TypeState[]> {
if (groupBy === IssuesGrouping.NoGrouping) {
return [{ _id: undefined, color: 0, title: await translate(tracker.string.NoGrouping, {}) }]
return [{ _id: undefined, color: UNSET_COLOR, title: await translate(tracker.string.NoGrouping, {}) }]
}
if (groupBy === IssuesGrouping.Priority) {
const states = issues.reduce<TypeState[]>((result, issue) => {
Expand All @@ -355,7 +357,7 @@ export async function getKanbanStatuses (
{
_id: priority,
title: issuePriorities[priority].label,
color: 0,
color: UNSET_COLOR,
icon: issuePriorities[priority].icon
}
]
Expand All @@ -371,14 +373,14 @@ export async function getKanbanStatuses (
return issues.reduce<TypeState[]>((result, issue) => {
const status = issue.$lookup?.status
if (status === undefined || result.find(({ _id }) => _id === status._id) !== undefined) return result
const icon = '$lookup' in status ? status.$lookup?.category?.icon : undefined
const category = '$lookup' in status ? status.$lookup?.category : undefined
return [
...result,
{
_id: status._id,
title: status.name,
color: status.color ?? 0,
icon
icon: category?.icon,
color: status.color ?? category?.color ?? UNSET_COLOR
}
]
}, [])
Expand All @@ -392,7 +394,7 @@ export async function getKanbanStatuses (
{
_id: issue.assignee,
title: issue.$lookup?.assignee?.name ?? noAssignee,
color: 0,
color: UNSET_COLOR,
icon: undefined
}
]
Expand All @@ -407,7 +409,7 @@ export async function getKanbanStatuses (
{
_id: issue.project,
title: issue.$lookup?.project?.label ?? noProject,
color: 0,
color: UNSET_COLOR,
icon: undefined
}
]
Expand All @@ -420,7 +422,7 @@ export function getIssueStatusStates (issueStatuses: Array<WithLookup<IssueStatu
return issueStatuses.map((status) => ({
_id: status._id,
title: status.name,
color: status.color ?? status.$lookup?.category?.color ?? 0,
color: status.color ?? status.$lookup?.category?.color ?? UNSET_COLOR,
icon: status.$lookup?.category?.icon ?? undefined
}))
}
Expand All @@ -430,7 +432,7 @@ export async function getPriorityStates (): Promise<TypeState[]> {
defaultPriorities.map(async (priority) => ({
_id: priority,
title: await translate(issuePriorities[priority].label, {}),
color: 0,
color: UNSET_COLOR,
icon: issuePriorities[priority].icon
}))
)
Expand Down