Updated Pull requests layout. Fixed uitest. (#6833)

Signed-off-by: Alexander Platov <alexander.platov@hardcoreeng.com>
This commit is contained in:
Alexander Platov 2024-10-07 19:32:19 +03:00 committed by GitHub
parent b0ec9759b3
commit 9fc50c9485
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 55 deletions

View File

@ -80,11 +80,11 @@
const getTimeFormat = (hour: number, min: number = 0): string => {
if (min === 0) {
return ampm
? `${hour > 12 ? hour - 12 : hour}${hour < 12 ? 'am' : 'pm'}`
? `${hour > 12 ? hour - 12 : hour}${hour < 12 || hour === 24 ? 'am' : 'pm'}`
: `${addZero(hour === 24 ? 0 : hour)}:00`
} else {
return ampm
? `${hour > 12 ? hour - 12 : hour}:${addZero(min)}${hour < 12 ? 'am' : 'pm'}`
? `${hour > 12 ? hour - 12 : hour}:${addZero(min)}${hour < 12 || hour === 24 ? 'am' : 'pm'}`
: `${addZero(hour === 24 ? 0 : hour)}:${addZero(min)}`
}
}

View File

@ -1,7 +1,7 @@
<script lang="ts">
import { DocumentQuery, Ref, Space, WithLookup } from '@hcengineering/core'
import { IntlString, translate, translateCB } from '@hcengineering/platform'
import { Button, IModeSelector, IconDetails, IconDetailsFilled, themeStore } from '@hcengineering/ui'
import { IntlString, translateCB } from '@hcengineering/platform'
import { IModeSelector, themeStore } from '@hcengineering/ui'
import { ViewOptions, Viewlet } from '@hcengineering/view'
import { FilterBar, SpaceHeader, ViewletContentView, ViewletSettingButton } from '@hcengineering/view-resources'
import { GithubPullRequest } from '@hcengineering/github'
@ -11,7 +11,6 @@
export let query: DocumentQuery<GithubPullRequest> = {}
export let title: IntlString | undefined = undefined
export let label: string = ''
export let panelWidth: number = 0
export let modeSelectorProps: IModeSelector | undefined = undefined
let viewlet: WithLookup<Viewlet> | undefined = undefined
@ -30,18 +29,6 @@
label = res
})
}
let asideFloat: boolean = false
let asideShown: boolean = true
$: if (panelWidth < 900 && !asideFloat) asideFloat = true
$: if (panelWidth >= 900 && asideFloat) {
asideFloat = false
asideShown = false
}
let docWidth: number
let docSize: boolean = false
$: if (docWidth <= 900 && !docSize) docSize = true
$: if (docWidth > 900 && docSize) docSize = false
</script>
<SpaceHeader
@ -54,24 +41,12 @@
{space}
{modeSelectorProps}
>
<svelte:fragment slot="header-tools">
<ViewletSettingButton bind:viewOptions bind:viewlet />
</svelte:fragment>
<svelte:fragment slot="label_selector">
<slot name="label_selector" />
</svelte:fragment>
<svelte:fragment slot="extra">
<ViewletSettingButton bind:viewOptions bind:viewlet />
{#if asideFloat && $$slots.aside}
<div class="buttons-divider" />
<Button
icon={asideShown ? IconDetailsFilled : IconDetails}
kind={'ghost'}
size={'medium'}
selected={asideShown}
on:click={() => {
asideShown = !asideShown
}}
/>
{/if}
</svelte:fragment>
</SpaceHeader>
{#if viewlet && viewOptions}
<FilterBar
@ -86,10 +61,5 @@
{#if viewlet}
<ViewletContentView _class={github.class.GithubPullRequest} {viewlet} query={resultQuery} {space} {viewOptions} />
{/if}
{#if $$slots.aside !== undefined && asideShown}
<div class="popupPanel-body__aside" class:shown={asideShown}>
<slot name="aside" />
</div>
{/if}
</div>
{/if}

View File

@ -6,8 +6,7 @@ import {
generateTestData,
getTimeForPlanner,
getSecondPageByInvite,
getInviteLink,
convertDate
getInviteLink
} from '../utils'
import { PlanningPage } from '../model/planning/planning-page'
import { NewToDo } from '../model/planning/types'
@ -351,18 +350,13 @@ test.describe('Planning ToDo tests', () => {
const today = new Date()
const date = new Date()
date.setDate(date.getDate() + 3)
const time = getTimeForPlanner(0, 2)
const timeStart = getTimeForPlanner(-1, 2)
const timeEnd = getTimeForPlanner(2, 2)
const toDoWithLabel: NewToDo = {
title: `ToDo to change duration-${generateId()}`,
description: 'Description for ToDo to change duration',
slots: [
{
dateStart: convertDate(date),
timeStart: '1400',
dateEnd: convertDate(date),
timeEnd: '1500'
}
]
description: 'Description for ToDo to change duration'
}
await test.step('Prepare ToDo', async () => {
@ -373,12 +367,12 @@ test.describe('Planning ToDo tests', () => {
if (diff < 0) await planningPage.clickButtonPrevDayInSchedule()
else await planningPage.clickButtonNextDayInSchedule()
}
await planningPage.selectTimeCell('10am').scrollIntoViewIfNeeded()
await planningPage.dragToCalendar(toDoWithLabel.title, 1, time)
})
await test.step('Resize ToDo', async () => {
await planningPage.moveToDoBorderByMouse(toDoWithLabel.title, 1, '4pm', 'bottom')
await planningPage.moveToDoBorderByMouse(toDoWithLabel.title, 1, '1pm', 'top')
await planningPage.moveToDoBorderByMouse(toDoWithLabel.title, 1, timeEnd, 'bottom')
await planningPage.moveToDoBorderByMouse(toDoWithLabel.title, 1, timeStart, 'top')
})
await test.step('Check time changes', async () => {

View File

@ -36,11 +36,12 @@ export function generateTestData (): TestData {
}
}
export function getTimeForPlanner (plusHours?: number): string {
export function getTimeForPlanner (plusHours: number = 0, cropHours: number = 0): string {
let hour = new Date().getHours()
if (typeof plusHours === 'number') hour += plusHours
const ampm = hour < 13 ? 'am' : 'pm'
hour = hour < 1 ? 1 : hour >= 11 && hour < 13 ? 11 : hour >= 22 ? 10 : hour > 12 ? hour - 12 : hour
hour = hour < 1 + cropHours ? 1 + cropHours : hour >= 22 - cropHours ? 22 - cropHours : hour
hour += plusHours
const ampm = hour < 12 || hour === 24 ? 'am' : 'pm'
hour -= hour > 12 ? 12 : 0
return `${hour}${ampm}`
}