2022-03-31 08:32:42 +00:00
|
|
|
//
|
2022-04-23 16:59:57 +00:00
|
|
|
// Copyright © 2022 Hardcore Engineering Inc.
|
2022-03-31 08:32:42 +00:00
|
|
|
//
|
|
|
|
// Licensed under the Eclipse Public License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License. You may
|
|
|
|
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
//
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
//
|
|
|
|
|
2022-04-20 06:06:05 +00:00
|
|
|
import { Ref, SortingOrder } from '@anticrm/core'
|
2022-03-31 08:32:42 +00:00
|
|
|
import type { Asset, IntlString } from '@anticrm/platform'
|
2022-04-23 16:59:57 +00:00
|
|
|
import {
|
|
|
|
IssuePriority,
|
|
|
|
Team,
|
|
|
|
IssuesGrouping,
|
|
|
|
IssuesOrdering,
|
|
|
|
Issue,
|
|
|
|
IssuesDateModificationPeriod
|
|
|
|
} from '@anticrm/tracker'
|
2022-04-22 06:13:57 +00:00
|
|
|
import { AnyComponent, getMillisecondsInMonth, MILLISECONDS_IN_WEEK } from '@anticrm/ui'
|
2022-04-08 06:27:02 +00:00
|
|
|
import tracker from './plugin'
|
2022-03-31 08:32:42 +00:00
|
|
|
|
|
|
|
export interface NavigationItem {
|
|
|
|
id: string
|
|
|
|
label: IntlString
|
|
|
|
icon: Asset
|
|
|
|
component: AnyComponent
|
|
|
|
componentProps?: Record<string, string>
|
|
|
|
top: boolean
|
|
|
|
}
|
|
|
|
|
|
|
|
export interface Selection {
|
|
|
|
currentTeam?: Ref<Team>
|
|
|
|
currentSpecial?: string
|
|
|
|
}
|
|
|
|
|
2022-04-08 06:27:02 +00:00
|
|
|
export const issuePriorities: Record<IssuePriority, { icon: Asset, label: IntlString }> = {
|
|
|
|
[IssuePriority.NoPriority]: { icon: tracker.icon.PriorityNoPriority, label: tracker.string.NoPriority },
|
|
|
|
[IssuePriority.Urgent]: { icon: tracker.icon.PriorityUrgent, label: tracker.string.Urgent },
|
|
|
|
[IssuePriority.High]: { icon: tracker.icon.PriorityHigh, label: tracker.string.High },
|
|
|
|
[IssuePriority.Medium]: { icon: tracker.icon.PriorityMedium, label: tracker.string.Medium },
|
|
|
|
[IssuePriority.Low]: { icon: tracker.icon.PriorityLow, label: tracker.string.Low }
|
|
|
|
}
|
2022-04-20 06:06:05 +00:00
|
|
|
|
|
|
|
export const issuesGroupByOptions: Record<IssuesGrouping, IntlString> = {
|
|
|
|
[IssuesGrouping.Status]: tracker.string.Status,
|
|
|
|
[IssuesGrouping.Assignee]: tracker.string.Assignee,
|
|
|
|
[IssuesGrouping.Priority]: tracker.string.Priority,
|
|
|
|
[IssuesGrouping.NoGrouping]: tracker.string.NoGrouping
|
|
|
|
}
|
|
|
|
|
|
|
|
export const issuesOrderByOptions: Record<IssuesOrdering, IntlString> = {
|
|
|
|
[IssuesOrdering.Status]: tracker.string.Status,
|
|
|
|
[IssuesOrdering.Priority]: tracker.string.Priority,
|
|
|
|
[IssuesOrdering.LastUpdated]: tracker.string.LastUpdated,
|
|
|
|
[IssuesOrdering.DueDate]: tracker.string.DueDate
|
|
|
|
}
|
|
|
|
|
2022-04-22 06:13:57 +00:00
|
|
|
export const issuesDateModificationPeriodOptions: Record<IssuesDateModificationPeriod, IntlString> = {
|
|
|
|
[IssuesDateModificationPeriod.All]: tracker.string.All,
|
|
|
|
[IssuesDateModificationPeriod.PastWeek]: tracker.string.PastWeek,
|
|
|
|
[IssuesDateModificationPeriod.PastMonth]: tracker.string.PastMonth
|
|
|
|
}
|
|
|
|
|
2022-04-23 16:59:57 +00:00
|
|
|
export type IssuesGroupByKeys = keyof Pick<Issue, 'status' | 'priority' | 'assignee'>
|
2022-04-20 06:06:05 +00:00
|
|
|
export type IssuesOrderByKeys = keyof Pick<Issue, 'status' | 'priority' | 'modifiedOn' | 'dueDate'>
|
|
|
|
|
|
|
|
export const issuesGroupKeyMap: Record<IssuesGrouping, IssuesGroupByKeys | undefined> = {
|
|
|
|
[IssuesGrouping.Status]: 'status',
|
|
|
|
[IssuesGrouping.Priority]: 'priority',
|
|
|
|
[IssuesGrouping.Assignee]: 'assignee',
|
|
|
|
[IssuesGrouping.NoGrouping]: undefined
|
|
|
|
}
|
|
|
|
|
|
|
|
export const issuesOrderKeyMap: Record<IssuesOrdering, IssuesOrderByKeys> = {
|
|
|
|
[IssuesOrdering.Status]: 'status',
|
|
|
|
[IssuesOrdering.Priority]: 'priority',
|
|
|
|
[IssuesOrdering.LastUpdated]: 'modifiedOn',
|
|
|
|
[IssuesOrdering.DueDate]: 'dueDate'
|
|
|
|
}
|
|
|
|
|
|
|
|
export const issuesSortOrderMap: Record<IssuesOrderByKeys, SortingOrder> = {
|
|
|
|
status: SortingOrder.Ascending,
|
|
|
|
priority: SortingOrder.Ascending,
|
|
|
|
modifiedOn: SortingOrder.Descending,
|
|
|
|
dueDate: SortingOrder.Descending
|
|
|
|
}
|
|
|
|
|
|
|
|
export const issuesGroupPresenterMap: Record<IssuesGroupByKeys, AnyComponent | undefined> = {
|
|
|
|
status: tracker.component.StatusPresenter,
|
|
|
|
priority: tracker.component.PriorityPresenter,
|
|
|
|
assignee: tracker.component.AssigneePresenter
|
|
|
|
}
|
2022-04-22 06:13:57 +00:00
|
|
|
|
|
|
|
export const defaultIssueCategories: Partial<Record<IssuesGroupByKeys, Array<Issue[IssuesGroupByKeys]> | undefined>> = {
|
|
|
|
priority: [IssuePriority.NoPriority, IssuePriority.Urgent, IssuePriority.High, IssuePriority.Medium, IssuePriority.Low]
|
|
|
|
}
|
|
|
|
|
|
|
|
export const getIssuesModificationDatePeriodTime = (
|
|
|
|
period: IssuesDateModificationPeriod | null
|
|
|
|
): number => {
|
|
|
|
const today = new Date(Date.now())
|
|
|
|
|
|
|
|
switch (period) {
|
|
|
|
case IssuesDateModificationPeriod.PastWeek: {
|
|
|
|
return today.getTime() - MILLISECONDS_IN_WEEK
|
|
|
|
}
|
|
|
|
case IssuesDateModificationPeriod.PastMonth: {
|
|
|
|
return today.getTime() - getMillisecondsInMonth(today)
|
|
|
|
}
|
|
|
|
default: {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|