Commit ea4c807a authored by René Rösner's avatar René Rösner
Browse files

Merge branch 'fix/401-replace-status-datasource' into 'main'

Fix: get status from tags (planning#401)

See merge request !24
parents 4a7dff5c d13c2d29
# http://editorconfig.org
root = true
[*.{json, yaml, yml, md, mdx, js, jsx}]
end_of_line = lf
indent_size = 2
indent_style = space
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Files: .env.example .gitignore package.json README.md yarn.lock
ci/* components/* lib/* pages/* views/*.tsx styles/*.scss
Files: .env.example .editorconfig .gitignore package.json README.md
yarn.lock ci/* components/* lib/* pages/* views/*.tsx styles/*.scss
public/*.png public/*.svg public/*.svg public/robots.txt
*.js *.ts
Copyright: 2022 FIT-Connect contributors
License: EUPL-1.2
\ No newline at end of file
License: EUPL-1.2
......@@ -34,6 +34,12 @@ export type Tag = {
}
}
export type Filter = {
label: string,
id: string,
value: string,
}
export async function fetchServices(): Promise<Entry<any>[]> {
const services = await client.getEntries({
content_type: 'service',
......
import { Header } from '@/views/Service'
import Link from "next/link"
import { fetchServices, fetchService } from '@/lib/contentful'
import { fetchServices, fetchService, Filter, ServiceType, Tag } from '@/lib/contentful'
import { removeFromObjRecursive, replaceEmailsRecursive } from '@/lib/utils'
import { documentToHtmlString } from '@contentful/rich-text-html-renderer'
import { IconChevronLeft } from '@tabler/icons'
import filterData from '@/lib/assets/data/currentFilter.json'
function getServiceTag(service: ServiceType): Tag {
const ONLY_STATUS_TAG = 0
const statusTag = service.tags?.filter((tag: Tag) => tag.fields?.name.startsWith('status'))[ONLY_STATUS_TAG]
return statusTag
}
function getTagLabelValue(tag: Tag): string {
const ONLY_MATCHING_FILTER = 0
const TAG_LABEL_EXPRESSION = 1
const STATUS_FILTER_DEFINITION = 1
const tagLabelParts = tag?.fields?.name.split(':')
const statusFilter = tag ? filterData.filter[STATUS_FILTER_DEFINITION].options.filter((option: Filter) => option.id === tagLabelParts[TAG_LABEL_EXPRESSION]) : null
return statusFilter ? statusFilter[ONLY_MATCHING_FILTER].label : 'Unbekannt'
}
export default function ({ service }) {
const statusTag = getServiceTag(service)
const statusLabel = getTagLabelValue(statusTag)
return (
<div className={'mx-auto max-w-screen-xl'}>
<nav className="relative max-w-7xl flex">
......@@ -47,7 +68,7 @@ export default function ({ service }) {
name: service.developer.fields.name,
link: service.developer.fields.link,
}}
status={service.status}
statusLabel={statusLabel}
documentationURL={service.documentation}
sourceURL={service.sourcecodeURL}
resources={service.ressource?.map(resource => {return { name: resource.fields.name, slug: resource.fields.slug}})
......
......@@ -3,8 +3,6 @@ import Link from 'next/link'
import PageHeaderCard from '@/components/PageHeaderCard'
import { decodeEmail } from '@/lib/utils'
type ServiceStatus = 'Alpha' | 'Beta' | 'Live'
type HeaderOptions = {
title: string
description: string
......@@ -20,7 +18,7 @@ type HeaderOptions = {
name: string
mailTo: string
}
status: ServiceStatus
statusLabel: string
documentationURL: string
sourceURL?: string
tosURL?: string
......@@ -35,7 +33,7 @@ export function Header({
developer,
contact,
tosURL,
status,
statusLabel,
documentationURL,
sourceURL,
issuesURL,
......@@ -69,11 +67,11 @@ export function Header({
</dd>
</div>
)}
{status && (
{statusLabel && (
<div className="sm:col-span-1">
<dt className="text-sm font-medium text-gray-500">Status</dt>
<dd className="ml-0 mt-1 text-sm text-gray-900">
{status}
{statusLabel}
</dd>
</div>
)}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment