Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Frontend basic #17

Merged
merged 23 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/build-rock.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ jobs:
id: test_image
run: |
sleep 30
curl -k https://localhost:3000 2>&1 | grep GoCert
docker logs gocert
curl -k https://localhost:3000/certificate_requests.html 2>&1 | grep "Certificate Requests"

- uses: actions/upload-artifact@v4
if: steps.test_image.outcome == 'success'
Expand Down
125 changes: 116 additions & 9 deletions ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@
"build": "next build",
"start": "next start",
"lint": "next lint",
"test": "vitest run"
"test": "vitest run",
"test-live": "vitest"
},
"dependencies": {
"next": "14.2.3",
"react": "^18",
"react-dom": "^18",
"next": "14.2.3"
"sass": "^1.77.4",
"vanilla-framework": "^4.11.0"
},
"devDependencies": {
"@testing-library/react": "^15.0.4",
Expand All @@ -29,4 +32,4 @@
"overrides": {
"rollup": "npm:@rollup/wasm-node@*"
}
}
}
8 changes: 8 additions & 0 deletions ui/src/app/certificate_requests/page.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { expect, test } from 'vitest'
import { render, screen } from '@testing-library/react'
import CertificateRequests from './page'

test('CertificateRequestsPage', () => {
render(< CertificateRequests />)
expect(screen.getByRole('table', {})).toBeDefined()
})
9 changes: 9 additions & 0 deletions ui/src/app/certificate_requests/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"use client"

import { CertificateRequestsTable } from "./table"

export default function CertificateRequests() {
return (
<CertificateRequestsTable />
)
}
11 changes: 11 additions & 0 deletions ui/src/app/certificate_requests/row.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { expect, test } from 'vitest'
import { render, screen } from '@testing-library/react'
import Row from './row'

test('Certificate Requests Table Row', () => {
render(<Row id={1} csr='' certificate='' />)
expect(screen.getByText('1')).toBeDefined()
})
// TODO: when certificate rejected => rejected status
// TODO: when certificate empty => outstanding status
// TODO: when certificate anything else => certificate.NotAfter
78 changes: 78 additions & 0 deletions ui/src/app/certificate_requests/row.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { useState, Dispatch, SetStateAction } from "react"
const extractCSR = (csrPemString: string) => {
//TODO
}

const extractCert = (certPemString: string) => {
//TODO
}

type rowProps = {
id: number,
csr: string,
certificate: string

ActionMenuExpanded: number
setActionMenuExpanded: Dispatch<SetStateAction<number>>
}
export default function Row({ id, csr, certificate, ActionMenuExpanded, setActionMenuExpanded }: rowProps) {
const [detailsMenuOpen, setDetailsMenuOpen] = useState<boolean>(false)

const toggleActionMenu = () => {
if (ActionMenuExpanded == id) {
setActionMenuExpanded(0)
}else{
setActionMenuExpanded(id)
}
}
return (
<tr>
<td className="" width={5} data-test-column="id">{id}</td>
<td className="">
<button
className="u-toggle p-contextual-menu__toggle p-button--base is-small"
aria-controls="expanded-row"
aria-expanded={detailsMenuOpen? "true": "false"}
onClick={() => setDetailsMenuOpen(!detailsMenuOpen)}>
<i className="p-icon--chevron-down p-contextual-menu__indicator"></i>
</button>
<span> example.com</span>
</td>
<td className="" data-test-column="status">{certificate == "" ? "outstanding" : (certificate == "rejected" ? "rejected" : "fulfilled")}</td>
<td className="" data-test-column="status">{certificate == "" ? "" : (certificate == "rejected" ? "" : "date")}</td>
<td className="has-overflow" data-heading="Actions">
<span className="p-contextual-menu--center u-no-margin--bottom">
gruyaume marked this conversation as resolved.
Show resolved Hide resolved
<button
gruyaume marked this conversation as resolved.
Show resolved Hide resolved
className="p-contextual-menu__toggle p-button--base is-small u-no-margin--bottom"
aria-controls="action-menu"
aria-expanded={ActionMenuExpanded == id ? "true": "false"}
aria-haspopup="true"
onClick={toggleActionMenu}
onBlur={toggleActionMenu}>
<i className="p-icon--menu p-contextual-menu__indicator"></i>
</button>
<span className="p-contextual-menu__dropdown" id="action-menu" aria-hidden={ActionMenuExpanded == id? "false": "true"}>
<span className="p-contextual-menu__group">
<button className="p-contextual-menu__link">Copy Certificate Request to Clipboard</button>
<button className="p-contextual-menu__link">Download Certificate Request</button>
<button className="p-contextual-menu__link">Reject Certificate Request</button>
<button className="p-contextual-menu__link">Delete Certificate Request</button>
</span>
<span className="p-contextual-menu__group">
<button className="p-contextual-menu__link">Upload Certificate</button>
<button className="p-contextual-menu__link">Revoke Certificate</button>
</span>
</span>
</span>
</td>
<td id="expanded-row" className="p-table__expanding-panel" aria-hidden={detailsMenuOpen? "false": "true"}>
<div className="row">
<div className="col-8">
<p><b>Common Name</b>: example.com</p>
<p><b>Subject Alternative Names</b>: example.com, 127.0.0.1, 1.2.3.4.5.56</p>
</div>
</div>
</td>
</tr>
)
}
Loading
Loading