Skip to content
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
293 changes: 293 additions & 0 deletions .devspark.work/pr-review/pr-7.md

Large diffs are not rendered by default.

18 changes: 16 additions & 2 deletions .documentation/guides/DOCKER_DEPLOYMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ Sources live in a SQLite registry (`/app/config/registry.db`, in the `spark-conf
survives container recreation). Manage them from the worker container (uses its `GITHUB_TOKEN`):

```sh
docker compose exec worker python -m spark.registry add org MyOrg --client "Acme"
docker compose exec worker python -m spark.registry add org MyOrg --client "Acme" --create
docker compose exec worker python -m spark.registry add repo owner/name
docker compose exec worker python -m spark.registry list
docker compose exec worker python -m spark.registry exclude owner/name
Expand All @@ -93,6 +93,9 @@ docker compose exec worker python -m spark.registry disable 3
`python -m spark.registry prune`.
- Full per-repository analytics (`data/users/<name>/...`, the dashboard) still run for `user` sources.
Organization and explicit-repository sources currently appear in `portfolio.json` only.
- Client, project and application names must already exist (create them on the admin **Lists**
tab); an unknown name is rejected so a typo never creates a second client. Pass `--create` to
`add` or `assign` to create a missing name on purpose.
- Back up `registry.db` (stop the worker, or use `sqlite3 registry.db ".backup out.db"`).

## Admin UI (sign-in, sources, tokens)
Expand All @@ -115,7 +118,18 @@ dashboard shows a **Sources** page only when the API answers; on GitHub Pages it
- **Sources:** add an organization, user or repository. Access is validated against GitHub first;
a source that cannot be read is not saved and the error says what to fix. Disable, re-enable or
remove sources; removing never deletes collected repositories.
- **Repositories:** include/exclude and assign to a client, project and application.
- **Repositories:** include/exclude, assign to a client, project and application from dropdowns, and
classify by domain (one repository at a time, or select several and classify them in bulk). The
**Show** filter lists repositories with no client or no value in a domain.
- **Lists:** create, rename, retire, restore and merge clients, projects and applications. A project
with no client is internal. Retiring hides an entry from the dropdowns but keeps it on whatever
already uses it; merging moves every repository and source onto the entry that stays. Likely
duplicates (for example "Acme" and "Acme, Inc.") are suggested, never merged on their own.
- **Domains:** named lists of allowed values. Tier, Type, Lifecycle (one value each) and Stack
(several values) are provided and editable; add your own. A value's key never changes, its label
can. A value or domain in use can only be retired, not deleted. Classifications are written to
`data/portfolio.json` (every active domain is listed per repository, empty when unassigned) on
the worker's next cycle.
- **Tokens:** save fine-grained personal access tokens (read-only; one per user or organization),
encrypted at rest. A token's expiry is tracked: the page warns when one is within 14 days, and a
source whose token has expired reports `connection_unusable` instead of silently using another.
Expand Down
117 changes: 117 additions & 0 deletions frontend/src/components/Admin/Admin.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,120 @@
.login {
max-width: 360px;
}

.inlineForm {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
font-size: 14px;
}

.inlineForm label {
font-weight: 600;
}

.fieldset {
display: flex;
flex-wrap: wrap;
gap: 4px 12px;
margin: 0;
padding: 8px 10px;
border: 1px solid var(--color-border);
border-radius: 6px;
font-size: 14px;
}

.fieldset legend {
font-weight: 600;
padding: 0 4px;
}

.check {
display: inline-flex;
align-items: center;
gap: 6px;
min-height: 44px;
font-size: 14px;
}

.bulk {
padding: 10px 12px;
border: 1px solid var(--color-border);
border-radius: 6px;
background: var(--color-surface-alt);
}

.tags {
display: grid;
gap: 2px;
margin: 0;
font-size: 13px;
}

.tags div {
display: flex;
gap: 6px;
}

.tags dt {
color: var(--color-text-secondary);
}

.tags dd {
margin: 0;
}

.tree {
list-style: none;
margin: 0;
padding-left: 0;
display: flex;
flex-direction: column;
gap: 6px;
}

.tree .tree {
padding-left: 20px;
border-left: 1px solid var(--color-border);
margin-top: 6px;
}

.entry {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 8px;
}

.domain {
display: flex;
flex-direction: column;
gap: 8px;
padding-top: 12px;
border-top: 1px solid var(--color-border);
}

.titleRow {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 8px;
}

.titleRow h3 {
margin: 0;
}

.srOnly {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
109 changes: 109 additions & 0 deletions frontend/src/components/Admin/BulkClassify.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { useState } from "react";
import PropTypes from "prop-types";
import { Button } from "@/components/Brand";
import { domainChoices } from "./portfolioOptions";
import styles from "./Admin.module.css";

/**
* Classify every selected repository in one domain at once. A single-choice
* domain sets (or clears) the value; a multi-choice domain can add or remove
* values without touching the others each repository holds.
*/
export default function BulkClassify({ count, domains, onApply, onClear }) {
const choices = domainChoices(domains);
const [domainKey, setDomainKey] = useState(choices[0]?.key || "");
const [value, setValue] = useState("");
const [mode, setMode] = useState("add");
const domain = choices.find((d) => d.key === domainKey);

const apply = (event) => {
event.preventDefault();
if (!domain) return;
if (domain.multi) {
if (value) onApply({ domain: domain.key, values: [value], mode });
} else {
onApply({
domain: domain.key,
values: value ? [value] : [],
mode: "set",
});
}
};

return (
<form
className={`${styles.form} ${styles.bulk}`}
onSubmit={apply}
aria-label="Classify selected repositories"
>
<p className={styles.muted} role="status" aria-live="polite">
{count} selected
</p>
<div className={styles.field}>
<label htmlFor="bulk-domain">Domain</label>
<select
id="bulk-domain"
className={styles.input}
value={domainKey}
onChange={(event) => {
setDomainKey(event.target.value);
setValue("");
}}
>
{choices.map((d) => (
<option key={d.key} value={d.key}>
{d.label}
</option>
))}
</select>
</div>
{domain?.multi && (
<div className={styles.field}>
<label htmlFor="bulk-mode">Change</label>
<select
id="bulk-mode"
className={styles.input}
value={mode}
onChange={(event) => setMode(event.target.value)}
>
<option value="add">Add value</option>
<option value="remove">Remove value</option>
</select>
</div>
)}
<div className={styles.field}>
<label htmlFor="bulk-value">Value</label>
<select
id="bulk-value"
className={styles.input}
value={value}
onChange={(event) => setValue(event.target.value)}
>
<option value="">
{domain?.multi ? "Choose a value" : "Not set"}
</option>
{(domain?.values || []).map((v) => (
<option key={v.key} value={v.key}>
{v.label}
</option>
))}
</select>
</div>
<div className={styles.actions}>
<Button type="submit" size="sm" disabled={domain?.multi && !value}>
Apply to {count}
</Button>
<Button size="sm" variant="ghost" onClick={onClear}>
Clear selection
</Button>
</div>
</form>
);
}

BulkClassify.propTypes = {
count: PropTypes.number.isRequired,
domains: PropTypes.arrayOf(PropTypes.object),
onApply: PropTypes.func.isRequired,
onClear: PropTypes.func.isRequired,
};
Loading
Loading