Skip to content

Commit

Permalink
Feature: Mobile - Use GraphQL query for search
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Aug 12, 2022
1 parent 5ecce31 commit 147c90a
Show file tree
Hide file tree
Showing 43 changed files with 664 additions and 279 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,7 @@ yarn-error.log
# Cypress
.cypress/screenshots/*
.cypress/videos/*
.cypress/**/__diff_output__/**
.cypress/**/__diff_output__/**

# Auto Generated
schema.graphql
16 changes: 16 additions & 0 deletions .graphqlrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Zammad GraphQL Schema",
"schemaPath": "schema.graphql",
"documents": ["./app/frontend/**/fragments/*.graphql"],
"extensions": {
"endpoints": {
"Default GraphQL Endpoint": {
"url": "http://localhost:3000/graphql",
"headers": {
"SkipAuthenticityTokenCheck": "true"
},
"introspect": true
}
}
}
}
3 changes: 2 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
**/graphql/**/*.ts
**/graphql/**/*.ts
!**/graphql/**/mocks/*.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Template = createTemplate<Props>(OrganizationItem)

const organization = {
id: '54321',
internalId: 2,
ticketsCount: 2,
name: 'Lorem Ipsum',
active: false,
Expand All @@ -24,23 +25,19 @@ export const Default = Template.create({
updatedAt: new Date(2022, 1, 2).toISOString(),
updatedBy: {
id: '456',
firstname: 'Jane',
lastname: 'Doe',
fullname: 'Jane Doe',
},
members: {
edges: [
{
node: { fullname: 'Erik Wise' },
},
{
node: { fullname: 'Peter Smith' },
},
],
totalCount: 3,
},
members: [
{
lastname: 'Wise',
firstname: 'Erik',
},
{
lastname: 'Smith',
firstname: 'Peter',
},
{
lastname: "O'Hara",
firstname: 'Nils',
},
],
},
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ const users = computed(() => {
const { members } = props.entity
if (!members) return ''

let usersString = members
const users = members.edges
.map((edge) => edge.node.fullname)
.filter((fullname) => fullname && fullname !== '-')
.slice(0, 2)
.map((user) => {
return [user.firstname, user.lastname].filter(Boolean).join(' ')
})
.join(', ')

const length = members.length - 2
let usersString = users.join(', ')

const length = members.totalCount - users.length

if (length > 0) {
usersString += `, +${length}`
Expand All @@ -36,28 +36,34 @@ const users = computed(() => {
</script>

<template>
<div class="flex">
<div class="mt-4 w-12">
<div class="flex ltr:pr-3 rtl:pl-3">
<div class="mt-4 flex w-14 justify-center">
<CommonOrganizationAvatar class="bg-gray" :entity="entity" />
</div>
<div
class="flex flex-1 flex-col border-b border-white/10 py-3 text-gray-100"
class="flex flex-1 flex-col overflow-hidden border-b border-white/10 py-3 text-gray-100"
>
<div class="flex">
<div>
{{
entity.ticketsCount === 1
? `1 ${$t('ticket')}`
: $t('%s tickets', entity.ticketsCount)
}}
</div>
<div v-if="users" class="px-1">·</div>
<div>{{ users }}</div>
</div>
<div class="mb-1 text-lg font-bold">
<span class="overflow-hidden text-ellipsis whitespace-nowrap">
{{
entity.ticketsCount === 1
? `1 ${$t('ticket')}`
: $t('%s tickets', entity.ticketsCount || 0)
}}
<template v-if="users">
·
{{ users }}
</template>
</span>
<span
class="mb-1 whitespace-normal text-lg font-bold leading-5 line-clamp-3"
>
<slot> {{ entity.name }} </slot>
</div>
<div v-if="stringUpdated" data-test-id="stringUpdated" class="text-gray">
</span>
<div
v-if="stringUpdated"
data-test-id="stringUpdated"
class="overflow-hidden text-ellipsis text-gray"
>
{{ stringUpdated }}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,27 +19,24 @@ describe('ticket item display', () => {
const organization: OrganizationItemData = {
id: '54321',
ticketsCount: 2,
internalId: 3,
name: 'lorem ipsum',
active: true,
members: [
{
lastname: 'Wise',
firstname: 'Erik',
},
{
lastname: 'Smith',
firstname: 'Peter',
},
{
lastname: "O'Hara",
firstname: 'Nils',
},
],
members: {
edges: [
{
node: { fullname: 'Erik Wise' },
},
{
node: { fullname: 'Peter Smith' },
},
],
totalCount: 3,
},
updatedAt: new Date(2022, 1, 1, 10, 0, 0, 0).toISOString(),
updatedBy: {
id: '456',
firstname: 'Jane',
lastname: 'Doe',
fullname: 'Jane Doe',
},
}

Expand All @@ -51,9 +48,9 @@ describe('ticket item display', () => {
})

expect(view.getByText('lorem ipsum')).toBeInTheDocument()
expect(view.getByText('2 tickets')).toBeInTheDocument()
expect(view.getByText('·')).toBeInTheDocument()
expect(view.getByText('Erik Wise, Peter Smith, +1')).toBeInTheDocument()
expect(view.getByText(/2 tickets/)).toBeInTheDocument()
expect(view.getByText(/·/)).toBeInTheDocument()
expect(view.getByText(/Erik Wise, Peter Smith, \+1/)).toBeInTheDocument()

expect(
view.getByText('edited 10 hours ago by Jane Doe'),
Expand All @@ -63,6 +60,7 @@ describe('ticket item display', () => {
it('renders when something is missing', () => {
const organization: OrganizationItemData = {
id: '54321',
internalId: 2,
ticketsCount: 1,
name: 'lorem ipsum',
active: true,
Expand All @@ -76,8 +74,8 @@ describe('ticket item display', () => {
})

expect(view.getByText('lorem ipsum')).toBeInTheDocument()
expect(view.getByText('1 ticket')).toBeInTheDocument()
expect(view.queryByIconName('·')).not.toBeInTheDocument()
expect(view.getByText(/1 ticket/)).toBeInTheDocument()
expect(view.queryByIconName(/·/)).not.toBeInTheDocument()

expect(view.queryByTestId('stringUpdated')).not.toBeInTheDocument()
})
Expand Down
16 changes: 10 additions & 6 deletions app/frontend/apps/mobile/components/Organization/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,21 @@

export interface OrganizationItemData {
id: string
ticketsCount: number
internalId: number
ticketsCount?: number
members?: {
lastname?: Maybe<string>
firstname?: Maybe<string>
}[]
edges: {
node: {
fullname: string
}
}[]
totalCount: number
}
active: boolean
name: string
updatedAt?: string
updatedBy?: {
id: string
firstname?: Maybe<string>
lastname?: Maybe<string>
fullname?: Maybe<string>
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ export const Default = Template.create({
updatedAt: new Date(2022, 1, 2).toISOString(),
updatedBy: {
id: '456',
firstname: 'Jane',
lastname: 'Doe',
fullname: 'Jane Doe',
},
priority: {
name: 'HIGH',
Expand Down
9 changes: 3 additions & 6 deletions app/frontend/apps/mobile/components/Ticket/TicketItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ const customer = computed(() => {
</script>

<template>
<CommonLink
:link="`/tickets/${entity.internalId}`"
class="flex cursor-pointer ltr:pr-3 rtl:pl-3"
>
<div class="flex cursor-pointer ltr:pr-3 rtl:pl-3">
<div class="flex w-14 items-center justify-center">
<!-- TODO label? -->
<CommonTicketStateIndicator :status="entity.state.name" label="" />
Expand All @@ -54,12 +51,12 @@ const customer = computed(() => {
<div
v-if="stringUpdated"
data-test-id="stringUpdated"
class="text-gray"
class="overflow-hidden text-ellipsis text-gray"
>
{{ stringUpdated }}
</div>
</div>
<CommonTicketPriorityIndicator :priority="entity.priority" />
</div>
</CommonLink>
</div>
</template>
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,12 @@ describe('ticket item display', () => {
state: { name: TicketState.Open },
title: 'test ticket',
customer: {
firstname: 'John',
lastname: 'Doe',
fullname: 'John Doe',
},
updatedAt: new Date(2022, 1, 1, 10, 0, 0, 0).toISOString(),
updatedBy: {
id: '456',
firstname: 'Jane',
lastname: 'Doe',
fullname: 'Jane Doe',
},
priority: {
name: 'high',
Expand Down Expand Up @@ -81,7 +78,7 @@ describe('ticket item display', () => {
})

expect(view.getByText('#12345')).toBeInTheDocument()
expect(view.queryByText('·')).not.toBeInTheDocument()
expect(view.queryByText(/·/)).not.toBeInTheDocument()
expect(view.getByText('test ticket')).toBeInTheDocument()

expect(view.queryByTestId('stringUpdated')).not.toBeInTheDocument()
Expand Down
10 changes: 1 addition & 9 deletions app/frontend/apps/mobile/components/Ticket/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import type { TicketState } from '@shared/entities/ticket/types'

// TODO 2022-05-31 Sheremet V.A. base types on actual usage
export interface TicketItemData {
id: string
internalId: number
Expand All @@ -16,19 +15,12 @@ export interface TicketItemData {
defaultCreate: boolean
uiColor?: Maybe<string>
}
owner?: {
firstname?: Maybe<string>
lastname?: Maybe<string>
}
customer?: {
firstname?: Maybe<string>
lastname?: Maybe<string>
fullname?: Maybe<string>
}
updatedAt?: string
updatedBy?: {
id: string
firstname?: Maybe<string>
lastname?: Maybe<string>
fullname?: Maybe<string>
}
}
3 changes: 1 addition & 2 deletions app/frontend/apps/mobile/components/User/UserItem.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ export const Default = Template.create({
updatedAt: new Date(2022, 1, 2).toISOString(),
updatedBy: {
id: '456',
firstname: 'Jane',
lastname: 'Doe',
fullname: 'Jane Doe',
},
},
})
Expand Down
Loading

0 comments on commit 147c90a

Please sign in to comment.