From ff47eb45b0436255908b39aae9c4df748ba93950 Mon Sep 17 00:00:00 2001 From: Mike Roberts Date: Mon, 6 May 2024 16:54:01 -0400 Subject: [PATCH] Drop use of lower-level custom HTML formatting Cleaner now to use hiccough-defined HTML output --- .../web/domainComponents/pushComponents.ts | 12 ++--- .../domainComponents/repoElementComponents.ts | 17 ++---- .../web/domainComponents/userComponents.ts | 6 +-- .../domainComponents/workflowComponents.ts | 23 +++----- src/app/web/views/showRepoView.ts | 20 +++---- .../functional/web/latestActivity.test.ts | 54 +++++++++++++++---- test/local/functional/web/viewRepo.test.ts | 30 +++++++++-- 7 files changed, 96 insertions(+), 66 deletions(-) diff --git a/src/app/web/domainComponents/pushComponents.ts b/src/app/web/domainComponents/pushComponents.ts index 16db7e4..7a3bc25 100644 --- a/src/app/web/domainComponents/pushComponents.ts +++ b/src/app/web/domainComponents/pushComponents.ts @@ -5,7 +5,6 @@ import { latestCommitInPush } from '../../domain/github/githubPush' import { commitCell, githubRepoUrl, repoCell } from './repoElementComponents' import { userCell } from './userComponents' import { GithubRepositoryElement } from '../../domain/types/GithubRepositoryElement' -import { inlineChildren, withOptions } from '../hiccough/hiccoughElement' import { githubAnchor } from './genericComponents' export type PushRowOptions = { @@ -39,13 +38,10 @@ export function repoCellForPush(push: GithubPush) { } function branchCell(push: GithubRepositoryElement & Pick) { - return withOptions( - inlineChildren, - td( - push.ref.split('/')[2], - `  `, - githubAnchor(`${githubRepoUrl(push)}/tree/${push.ref.split('/')[2]}`) - ) + return td( + push.ref.split('/')[2], + ` `, + githubAnchor(`${githubRepoUrl(push)}/tree/${push.ref.split('/')[2]}`) ) } diff --git a/src/app/web/domainComponents/repoElementComponents.ts b/src/app/web/domainComponents/repoElementComponents.ts index f282d64..5029b27 100644 --- a/src/app/web/domainComponents/repoElementComponents.ts +++ b/src/app/web/domainComponents/repoElementComponents.ts @@ -1,5 +1,4 @@ import { GithubRepositoryElement } from '../../domain/types/GithubRepositoryElement' -import { inlineChildren, withOptions } from '../hiccough/hiccoughElement' import { a, td } from '../hiccough/hiccoughElements' import { githubAnchor } from './genericComponents' @@ -11,10 +10,7 @@ export function repoCell({ }: GithubRepositoryElement & { repoHtmlUrl: string }) { - return withOptions( - inlineChildren, - td(a(`/app/account/${ownerId}/repo/${repoId}`, repoName), '  ', githubAnchor(repoHtmlUrl)) - ) + return td(a(`/app/account/${ownerId}/repo/${repoId}`, repoName), ' ', githubAnchor(repoHtmlUrl)) } export function githubRepoUrl({ @@ -32,12 +28,9 @@ export function commitCell( } ) { const { repoHtmlUrl, message, sha } = event - return withOptions( - inlineChildren, - td( - message.length < 40 ? message : `${message.substring(0, 40)}...`, - '  ', - githubAnchor(`${repoHtmlUrl ?? githubRepoUrl(event)}/commit/${sha}`) - ) + return td( + message.length < 40 ? message : `${message.substring(0, 40)}...`, + ' ', + githubAnchor(`${repoHtmlUrl ?? githubRepoUrl(event)}/commit/${sha}`) ) } diff --git a/src/app/web/domainComponents/userComponents.ts b/src/app/web/domainComponents/userComponents.ts index 1a8d8ee..a00da33 100644 --- a/src/app/web/domainComponents/userComponents.ts +++ b/src/app/web/domainComponents/userComponents.ts @@ -1,12 +1,8 @@ import { td } from '../hiccough/hiccoughElements' -import { inlineChildren, withOptions } from '../hiccough/hiccoughElement' import { githubAnchor } from './genericComponents' export function userCell(actor?: { login: string }) { return actor === undefined ? td() - : withOptions( - inlineChildren, - td(actor.login, `  `, githubAnchor(`https://github.com/${actor.login}`)) - ) + : td(actor.login, ` `, githubAnchor(`https://github.com/${actor.login}`)) } diff --git a/src/app/web/domainComponents/workflowComponents.ts b/src/app/web/domainComponents/workflowComponents.ts index 3634daf..ff1ac4a 100644 --- a/src/app/web/domainComponents/workflowComponents.ts +++ b/src/app/web/domainComponents/workflowComponents.ts @@ -1,6 +1,5 @@ import { GithubWorkflowRunEvent } from '../../domain/types/GithubWorkflowRunEvent' import { GithubRepositoryElement } from '../../domain/types/GithubRepositoryElement' -import { inlineChildren, withOptions } from '../hiccough/hiccoughElement' import { a, td, tr } from '../hiccough/hiccoughElements' import { Clock, displayDateTime } from '../../util/dateAndTime' import { githubAnchor } from './genericComponents' @@ -55,16 +54,13 @@ export function workflowCell( Pick ) { const workflowPath = `${event.path.substring(event.path.indexOf('/') + 1)}` - return withOptions( - inlineChildren, - td( - a( - `/app/account/${event.ownerId}/repo/${event.repoId}/workflow/${event.workflowId}`, - event.workflowName ?? workflowPath - ), - '  ', - githubAnchor(event.workflowHtmlUrl ?? `${githubRepoUrl(event)}/actions/${workflowPath}`) - ) + return td( + a( + `/app/account/${event.ownerId}/repo/${event.repoId}/workflow/${event.workflowId}`, + event.workflowName ?? workflowPath + ), + ' ', + githubAnchor(event.workflowHtmlUrl ?? `${githubRepoUrl(event)}/actions/${workflowPath}`) ) } @@ -77,10 +73,7 @@ const successfulRunResultCell = td('Success') const failedRunResultCell = td('Failed') export function workflowRunCell(clock: Clock, event: GithubWorkflowRunEvent) { - return withOptions( - inlineChildren, - td(displayDateTime(clock, event.updatedAt), '  ', githubAnchor(event.htmlUrl)) - ) + return td(displayDateTime(clock, event.updatedAt), ' ', githubAnchor(event.htmlUrl)) } export function commitCellForWorkflowRunEvent(event: GithubWorkflowRunEvent) { diff --git a/src/app/web/views/showRepoView.ts b/src/app/web/views/showRepoView.ts index 48a5217..e86e911 100644 --- a/src/app/web/views/showRepoView.ts +++ b/src/app/web/views/showRepoView.ts @@ -4,7 +4,6 @@ import { GithubWorkflowRunEvent } from '../../domain/types/GithubWorkflowRunEven import { githubAnchor } from '../domainComponents/genericComponents' import { GithubRepository } from '../../domain/types/GithubRepository' import { h3, h4, table, tbody, th, thead, tr } from '../hiccough/hiccoughElements' -import { inlineChildren, withOptions } from '../hiccough/hiccoughElement' import { pageViewResultWithoutHtmx } from './viewResultWrappers' import { workflowRow } from '../domainComponents/workflowComponents' import { pushRow } from '../domainComponents/pushComponents' @@ -17,17 +16,14 @@ export function createShowRepoResponse( activity: GithubActivity[] ) { const contents = [ - withOptions( - inlineChildren, - h3( - `Repository: ${repo.ownerName}/${repo.name}`, - `  `, - githubAnchor( - githubRepoUrl({ - ...repo, - repoName: repo.name - }) - ) + h3( + `Repository: ${repo.ownerName}/${repo.name}`, + ` `, + githubAnchor( + githubRepoUrl({ + ...repo, + repoName: repo.name + }) ) ), h4('GitHub Actions Status'), diff --git a/test/local/functional/web/latestActivity.test.ts b/test/local/functional/web/latestActivity.test.ts index 07fa25c..2113df3 100644 --- a/test/local/functional/web/latestActivity.test.ts +++ b/test/local/functional/web/latestActivity.test.ts @@ -114,12 +114,32 @@ test('latest-activity', async () => { - org-test-repo-one   - Test Repo One Workflow   + + org-test-repo-one +  + + + + Test Repo One Workflow +  + + Success - 2024-03-06T19:25:42Z   - mikebroberts   - Test Repo One Workflow   + +2024-03-06T19:25:42Z +  + + + +mikebroberts +  + + + +Test Repo One Workflow +  + + @@ -136,11 +156,27 @@ test('latest-activity', async () => { - org-test-repo-one   - main   + + org-test-repo-one +  + + + +main +  + + 2024-03-06T17:00:40Z - mikebroberts   - test workflow   + +mikebroberts +  + + + +test workflow +  + + diff --git a/test/local/functional/web/viewRepo.test.ts b/test/local/functional/web/viewRepo.test.ts index 9394668..5dd79a6 100644 --- a/test/local/functional/web/viewRepo.test.ts +++ b/test/local/functional/web/viewRepo.test.ts @@ -92,7 +92,11 @@ test('view-repo', async () => {

Cicada

-

Repository: cicada-test-org/org-test-repo-one  

+

+Repository: cicada-test-org/org-test-repo-one +  + +

GitHub Actions Status

@@ -120,10 +124,26 @@ test('view-repo', async () => { - - - - + + + +
Successful RunTest Repo One Workflow  2024-03-06T19:25:42Z  mikebroberts  Test Repo One Workflow   + Test Repo One Workflow +  + + +2024-03-06T19:25:42Z +  + + +mikebroberts +  + + +Test Repo One Workflow +  + +