feat(frontend): edit projects and show semantic match evidence
This commit is contained in:
1 parent
5a731c25b7
commit
bc00d6901f
52 files changed
+2992
-111
No files matched your search
@@ -37,3 +37,4 @@ export { AttentionDot, Tag, type TagTone } from "./tag/tag";
|
||||
export { TrustLevel } from "./trust-level/trust-level";
|
||||
export { trustLevelLabels, type TrustLevelValue } from "./trust-level/trust-level-labels";
|
||||
export { VisuallyHidden } from "./visually-hidden/visually-hidden";
|
||||
export { PublishedProjects, type PublishedProject } from "./published-projects/published-projects";
|
||||
@@ -0,0 +1,71 @@
|
||||
.root {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.list,
|
||||
.chips {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.list {
|
||||
display: grid;
|
||||
gap: var(--space-3);
|
||||
}
|
||||
|
||||
.project {
|
||||
display: grid;
|
||||
gap: var(--space-2);
|
||||
min-width: 0;
|
||||
padding-block-end: var(--space-3);
|
||||
border-block-end: var(--line-thin) solid var(--color-divider);
|
||||
}
|
||||
|
||||
.project:last-child {
|
||||
padding-block-end: 0;
|
||||
border-block-end: 0;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-1) var(--space-3);
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.title {
|
||||
color: var(--color-text-strong);
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
/* The candidate's own line breaks stay; long words wrap. */
|
||||
.description {
|
||||
margin: 0;
|
||||
color: var(--color-text);
|
||||
font-size: var(--font-size-s);
|
||||
line-height: var(--line-height-body);
|
||||
white-space: pre-wrap;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
|
||||
.chips {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: var(--space-2);
|
||||
}
|
||||
|
||||
.chips li {
|
||||
min-width: 0;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.note {
|
||||
margin: 0;
|
||||
color: var(--color-text-secondary);
|
||||
font-size: var(--font-size-xs);
|
||||
line-height: var(--line-height-body);
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { PublishedProjects } from "./published-projects";
|
||||
|
||||
describe("PublishedProjects", () => {
|
||||
it("shows the title, the description, and the tags of a project", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<PublishedProjects
|
||||
projects={[
|
||||
{
|
||||
title: "Платежный шлюз",
|
||||
description: "Проводки и сверки.",
|
||||
stack: ["Go", "PostgreSQL"],
|
||||
repositoryVerified: false,
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(html).toContain("Платежный шлюз");
|
||||
expect(html).toContain("Проводки и сверки.");
|
||||
expect(html).toContain(">PostgreSQL<");
|
||||
expect(html).not.toContain("Подтвержден публичным репозиторием");
|
||||
expect(html).not.toContain("Авторство она не доказывает");
|
||||
});
|
||||
|
||||
it("marks a verified project and says what the mark proves", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<PublishedProjects
|
||||
projects={[
|
||||
{ title: "Каталог", description: null, stack: [], repositoryVerified: true },
|
||||
{ title: "Поиск", description: null, stack: [], repositoryVerified: false },
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(html.match(/Подтвержден публичным репозиторием/g)).toHaveLength(1);
|
||||
expect(html).toContain("Авторство она не доказывает");
|
||||
expect(html).not.toContain("github.com");
|
||||
});
|
||||
|
||||
it("renders candidate text as text, never as markup", () => {
|
||||
const html = renderToStaticMarkup(
|
||||
<PublishedProjects
|
||||
projects={[
|
||||
{
|
||||
title: "<img src=x onerror=alert(1)>",
|
||||
description: "<script>alert(1)</script>",
|
||||
stack: ["<b>Go</b>"],
|
||||
repositoryVerified: false,
|
||||
},
|
||||
]}
|
||||
/>,
|
||||
);
|
||||
|
||||
expect(html).not.toContain("<img");
|
||||
expect(html).not.toContain("<script");
|
||||
expect(html).not.toContain("<b>");
|
||||
expect(html).toContain("<img");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
import { Tag } from "../tag/tag";
|
||||
import styles from "./published-projects.module.css";
|
||||
|
||||
/** One project exactly as an organization reads it: text and a verification flag, never an address. */
|
||||
export type PublishedProject = {
|
||||
title: string;
|
||||
description: string | null;
|
||||
stack: readonly string[];
|
||||
/** True when the server found the linked repository public; it does not prove authorship. */
|
||||
repositoryVerified: boolean;
|
||||
};
|
||||
|
||||
type PublishedProjectsProps = {
|
||||
projects: readonly PublishedProject[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Projects a candidate published on the anonymous card. Titles, descriptions,
|
||||
* and tags are free text of the candidate, so they are rendered as text only.
|
||||
* The badge states what the check proved: a public repository exists.
|
||||
*/
|
||||
export function PublishedProjects({ projects }: PublishedProjectsProps) {
|
||||
const anyVerified = projects.some((project) => project.repositoryVerified);
|
||||
return (
|
||||
<div className={styles.root}>
|
||||
<ul className={styles.list}>
|
||||
{projects.map((project, index) => (
|
||||
<li key={`${index}:${project.title}`} className={styles.project}>
|
||||
<div className={styles.header}>
|
||||
<strong className={styles.title}>{project.title}</strong>
|
||||
{project.repositoryVerified ? (
|
||||
<Tag tone="success" dot>
|
||||
Подтвержден публичным репозиторием
|
||||
</Tag>
|
||||
) : null}
|
||||
</div>
|
||||
{project.description ? (
|
||||
<p className={styles.description}>{project.description}</p>
|
||||
) : null}
|
||||
{project.stack.length > 0 ? (
|
||||
<ul className={styles.chips} aria-label="Технологии проекта">
|
||||
{project.stack.map((tag) => (
|
||||
<li key={tag}>
|
||||
<Tag tone="stack">{tag}</Tag>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{anyVerified ? (
|
||||
<p className={styles.note}>
|
||||
Отметка значит только, что публичный репозиторий проекта существует. Авторство она не
|
||||
доказывает, а адрес репозитория компаниям не показывается.
|
||||
</p>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -80,6 +80,11 @@ const codeMessages: Partial<Record<ApiErrorCode, ErrorMessage>> = {
|
||||
title: "Запрос не прошел проверку",
|
||||
description: "Проверьте введенные данные и повторите попытку.",
|
||||
},
|
||||
service_unavailable: {
|
||||
title: "Сервис пока не готов",
|
||||
description:
|
||||
"Он загружается или временно перегружен. Ничего не потеряно: повторите попытку через минуту.",
|
||||
},
|
||||
not_implemented: {
|
||||
title: "Функция еще не реализована",
|
||||
description: "Этот раздел появится в одной из следующих версий.",
|
||||
|
||||
@@ -113,6 +113,21 @@ describe("describeError", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("names the service_unavailable code as a service that is not ready yet", () => {
|
||||
const error = new ApiRequestError({
|
||||
status: 503,
|
||||
code: "service_unavailable",
|
||||
title: "Service unavailable",
|
||||
});
|
||||
const html = renderToStaticMarkup(<ErrorState error={error} onRetry={() => undefined} />);
|
||||
|
||||
expect(describeError(error)).toMatchObject({
|
||||
title: "Сервис пока не готов",
|
||||
technical: { code: "service_unavailable", status: 503 },
|
||||
});
|
||||
expect(text(html)).toContain("Повторить");
|
||||
});
|
||||
|
||||
it("treats a CSRF rejection as an error, not as missing access", () => {
|
||||
const error = new ApiRequestError({ status: 403, code: "csrf_check_failed", title: "csrf" });
|
||||
const html = renderToStaticMarkup(<ErrorState error={error} onRetry={() => undefined} />);
|
||||
|
||||
Reference in new issue
Block a user