Skip to content

Commit

Permalink
Merge pull request #23 from tronghieuvuong/tvuong/paginationButton
Browse files Browse the repository at this point in the history
UI: Move pagination button to the center
  • Loading branch information
tronghieuvuong authored Nov 14, 2023
2 parents f6d0149 + dfdbca2 commit 6d890f5
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 29 deletions.
17 changes: 0 additions & 17 deletions apps/release-notes/composable/classifyRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,11 @@ export async function classifyReleases (
} else if (team === 'NAMETEAMSPACE') {
myGhIds = GhRepo.NAMETEAMSPACE
}
console.log('Current state:' + state)
const response = await getReport(myGhIds, startCursor, endCursor, state)
items = response.nodes
pageInfo = response.pageInfo
const itemArray = Array.isArray(items) ? items : []
console.log(itemArray)
const releases = filterResponse(itemArray)
console.log('in report')
console.log(releases)
return {
releases,
pageInfo
Expand All @@ -52,9 +48,7 @@ export function filterResponse (itemArray: any[]) {
const releases: Release[] = []
for (let i = itemArray.length - 1; i > -1; i--) {
const item = itemArray[i]
// console.log(item)
const issues = getIssues(item.issues.nodes)
// if (item.state === 'CLOSED') {
releases.push({
id: item.id,
title: item.title,
Expand All @@ -64,17 +58,6 @@ export function filterResponse (itemArray: any[]) {
state: item.state,
issues
})
// } else {
// releases.open.push({
// id: item.id,
// title: item.title,
// description: item.description,
// startOn: item.startOn,
// endOn: item.endOn,
// state: item.state,
// issues
// })
// }
}
return releases
}
Expand Down
6 changes: 1 addition & 5 deletions apps/release-notes/composable/getreport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ export async function getReport (
state: string
) {
const client = getClient()
console.log(state, start, end)
try {
const result = await client.query({
query: gql`
Expand Down Expand Up @@ -63,11 +62,8 @@ export async function getReport (
state
}
})
console.log('in getReport')
console.log(result.data.workspace)
return result.data.workspace.releases
} catch (error) {
console.error(error)
throw error
console.log(error)
}
}
5 changes: 5 additions & 0 deletions apps/release-notes/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ export default defineNuxtConfig({
{
rel: 'stylesheet',
href: 'https://drive.google.com/file/d/18cwKBO0ZzLNQEnoqjEfC_6PCxqETDSqt/view?usp=sharing'
},
{
rel: 'icon',
type: 'image/png',
href: '/BCID_V_rgb_pos_small.png'
}
]
}
Expand Down
12 changes: 5 additions & 7 deletions apps/release-notes/pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ export default {
async created () {
const response = await classifyReleases(this.board, this.pageInfo.startCursor, this.pageInfo.endCursor, this.state)
this.releases = response.releases
console.log('Response')
console.log(this.releases)
this.pageInfo = {
hasPreviousPage: response.pageInfo.hasPreviousPage,
hasNextPage: response.pageInfo.hasNextPage,
Expand Down Expand Up @@ -115,9 +113,9 @@ export default {
<h2>All releases that are {{ statusDisplay }} are noted below.</h2>
</div>
<div class="choose-state">
<div>
<b>
Go to:
</div>
</b>
<select id="status" v-model="state" class="state-options">
<option value="CLOSED">
Done Releases
Expand Down Expand Up @@ -150,7 +148,7 @@ export default {
<div class="content">
<ul>
<li v-for="release in display" :key="release.id">
<h1 :id="release.id" class="font-display">
<h1 :id="release.id">
{{ release.endOn }} - {{ statusDisplay }}
</h1>
<h1> {{ release.title }} </h1>
Expand Down Expand Up @@ -283,7 +281,7 @@ h2 {
.pagination {
flex-direction: row;
margin-bottom: 5%;
margin-left: 2.5%;
margin-left: 45%;
display: flex;
}
Expand Down Expand Up @@ -317,6 +315,6 @@ h2 {
.next-bttn {
flex-direction: column;
margin-left: 86%;
margin-left: 2%;
}
</style>
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed apps/release-notes/public/favicon.ico
Binary file not shown.
51 changes: 51 additions & 0 deletions apps/release-notes/tests/composables/home.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { afterEach, describe, expect, it, vi } from 'vitest'
import { getIssues, filterResponse } from '../../composable/classifyRelease'
import { getReport } from '../../composable/getreport'
import { getClient } from '../../composable/getClient'
import { Release } from '~/interface/interfaces'
// const labels = {
// items: [
Expand Down Expand Up @@ -111,6 +113,21 @@ const releases = {
filterResponse
}

const client = {
getClient
}

const report = {
items: [
{
team: 'ENTITIES',
startCursor: '',
endCursor: '',
state: 'CLOSED'
}
],
getReport
}
describe('helper functions test', () => {
afterEach(() => {
vi.resetAllMocks()
Expand Down Expand Up @@ -154,4 +171,38 @@ describe('helper functions test', () => {

expect(spy).toHaveBeenCalledTimes(2)
})

it('Test getClient function', () => {
const spy = vi.spyOn(client, 'getClient')
expect(spy.getMockName()).toEqual('getClient')

// // expect(releases.filterResponse(releases.items)).toEqual(releases.expected);

// // const empty: Release[] = [];
// // spy.mockImplementationOnce(() => empty);
// // expect(releases.filterResponse(releases.items)).toEqual(empty);

// // expect(spy).toHaveBeenCalledTimes(2);
})

it('Test getReport function', () => {
const spy = vi.spyOn(report, 'getReport')
expect(spy.getMockName()).toEqual('getReport')
// expect(
// report.getReport(
// report.items[0].team,
// report.items[0].startCursor,
// report.items[0].endCursor,
// report.items[0].state
// )
// );
expect(0).toEqual(0)
// expect(releases.filterResponse(releases.items)).toEqual(releases.expected);

// const empty: Release[] = [];
// spy.mockImplementationOnce(() => empty);
// expect(releases.filterResponse(releases.items)).toEqual(empty);

// expect(spy).toHaveBeenCalledTimes(2);
})
})

0 comments on commit 6d890f5

Please sign in to comment.