Feature: Support multiple action status per release (#69)

* feat: move release actions to separate table

* chore: update sqlite driver
This commit is contained in:
Ludvig Lundgren 2022-01-08 15:40:31 +01:00 committed by GitHub
parent 2ea2293745
commit e03eac24ba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 284 additions and 91 deletions

View file

@ -177,7 +177,6 @@ export interface Config {
export interface Release {
id: number;
filter_status: string;
push_status: string;
rejections: string[];
indexer: string;
filter: string;
@ -186,6 +185,17 @@ export interface Release {
size: number;
raw: string;
timestamp: Date
action_status: ReleaseActionStatus[]
}
export interface ReleaseActionStatus {
id: number;
status: string;
action: string;
type: string;
rejections: string[];
timestamp: Date
// raw: string;
}
export interface ReleaseFindResponse {

View file

@ -6,6 +6,7 @@ import APIClient from '../api/APIClient'
import { useQuery } from 'react-query'
import { ReleaseFindResponse, ReleaseStats } from '../domain/interfaces'
import { EmptyListState } from '../components/emptystates'
import { ReleaseStatusCell } from './Releases'
export function Dashboard() {
return (
@ -660,9 +661,9 @@ function DataTablee() {
// Cell: StatusPill,
// },
{
Header: "Push Status",
accessor: 'push_status',
Cell: StatusPill,
Header: "Actions",
accessor: 'action_status',
Cell: ReleaseStatusCell,
},
{
Header: "Indexer",

View file

@ -1,10 +1,13 @@
import { ChevronDoubleLeftIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDoubleRightIcon } from "@heroicons/react/solid"
import { ExclamationCircleIcon } from "@heroicons/react/outline"
import ClockIcon from "@heroicons/react/outline/ClockIcon"
import { ChevronDoubleLeftIcon, ChevronLeftIcon, ChevronRightIcon, ChevronDoubleRightIcon, CheckIcon } from "@heroicons/react/solid"
import { formatDistanceToNowStrict } from "date-fns"
import React from "react"
import { useQuery } from "react-query"
import { useTable, useSortBy, usePagination } from "react-table"
import APIClient from "../api/APIClient"
import { EmptyListState } from "../components/emptystates"
import { ReleaseActionStatus } from "../domain/interfaces"
import { classNames } from "../utils"
export function Releases() {
@ -98,6 +101,7 @@ export function StatusPill({ value }: any) {
);
};
export function AgeCell({ value, column, row }: any) {
const formatDate = formatDistanceToNowStrict(
@ -116,6 +120,31 @@ export function ReleaseCell({ value, column, row }: any) {
)
}
interface ReleaseStatusCellProps {
value: ReleaseActionStatus[];
column: any;
row: any;
}
export function ReleaseStatusCell({ value, column, row }: ReleaseStatusCellProps) {
const statusMap: any = {
"PUSH_REJECTED": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-pink-100 text-pink-800 hover:bg-pink-300">
<ExclamationCircleIcon className="h-5 w-5" aria-hidden="true" />
</span>,
"PUSH_APPROVED": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-green-100 text-green-800 hover:bg-green-300">
<CheckIcon className="h-5 w-5" aria-hidden="true" />
</span>,
"PENDING": <span className="mr-1 inline-flex items-center rounded text-xs font-semibold uppercase bg-yellow-100 text-yellow-800 hover:bg-yellow-200">
<ClockIcon className="h-5 w-5" aria-hidden="true" />
</span>,
}
return (
<div className="flex text-sm font-medium text-gray-900 dark:text-gray-300">
{value.map(v => <div title={`action: ${v.action}, type: ${v.type}, status: ${v.status}, ;time: ${v.timestamp}`}>{statusMap[v.status]}</div>)}
</div>
)
}
const initialState = {
queryPageIndex: 0,
queryPageSize: 10,
@ -166,9 +195,9 @@ function Table() {
// Cell: StatusPill,
// },
{
Header: "Push Status",
accessor: 'push_status',
Cell: StatusPill,
Header: "Actions",
accessor: 'action_status',
Cell: ReleaseStatusCell,
},
{
Header: "Indexer",