Compare commits

..
10 Commits
Author SHA1 Message Date
JustZoe101 fbefa0d345 test/docs: endpoint tests for label/milestone/workflow/package-link; refresh docs
- endpoint tests for createLabel/createMilestone/setWorkflowEnabled/link+unlink (129 total)
- FEATURE_PARITY, ROADMAP and README updated: CodeMirror 6, search/replace,
  labels/milestones CRUD, filters/sorting, workflow enable/disable, package
  link/unlink are done
2026-10-09 19:10:17 +02:00
JustZoe101 883440b8be feat: CodeMirror 6 editor with in-editor search/replace
- bundle CodeMirror 6 (+ langs/search) via scripts/build-editor.mjs into a
  generated TS module (inlined into the WebView; no remote code, no asset
  pipeline)
- CodeEditor now renders CodeMirror 6 with line numbers, language modes and a
  search/replace panel exposed from a toolbar button
- npm run build:editor; language mapping by file extension
2026-10-09 19:08:38 +02:00
JustZoe101 a104d65978 feat: labels/milestones CRUD, issue filters+sort, workflow enable/disable, package link/unlink
- labels screen (create/edit/delete) and milestones screen (create/close/delete)
- repo issues: label + milestone server-side filters and client-side sorting
- Actions settings: list workflows with enable/disable toggle
- packages: link/unlink to a repository
- endpoints/hooks/i18n (en/nl)
2026-10-09 19:06:07 +02:00
JustZoe101 1226f154cc docs: refresh parity matrix, roadmap and README for full phase coverage
Reflect all implemented features (transfer, Actions secrets/variables/dispatch/
artifacts, asset upload, admin, teams/projects, file search, reactions,
subscriptions) and document the remaining honest gaps (OAuth, content search,
in-editor search/replace, detached diff-position caveat).
2026-10-09 18:47:31 +02:00
JustZoe101 207ac723af feat: issue subscriptions and Actions workflow dispatch
- subscribe/unsubscribe to an issue from the detail screen
- dispatch a workflow_dispatch run (workflow + ref) from Actions settings
- i18n (en/nl)
2026-10-09 18:45:47 +02:00
JustZoe101 eed9c91274 feat: inline review-comment composer + WebView code editor
- diff lines are tappable; PullDiff opens a composer that posts a positioned
  inline review comment (path + new_position)
- CodeEditor: self-contained WebView editor with line numbers, tab handling and
  lightweight syntax highlighting (no remote code / bundled editor assets);
  used by Quick Edit
- i18n (en/nl) for inline comments
2026-10-09 18:43:05 +02:00
JustZoe101 587bf732b5 feat: release asset upload, transfer, Actions secrets/variables/artifacts, admin, teams/projects, file search, reactions, attachments, package version delete
- client: multipart postForm; expo-document-picker + react-native-webview deps
- release assets: upload (DocumentPicker) and delete; run artifacts list
- repository transfer; Actions secrets + variables management screen
- admin (users/orgs/repos) screen gated on is_admin
- org teams, repo projects (read-only); find-file via recursive git tree
- issue reactions toggle and attachments list; package version delete
- endpoint tests (126 total)
2026-10-09 18:40:08 +02:00
JustZoe101 b2b44bca73 docs: mark phases 3-5 complete, update parity matrix and limitations 2026-10-09 18:20:24 +02:00
JustZoe101 cd448bdd52 feat(phase5): Actions re-run/cancel, package deletion, inline-comment tests
- action run controls (re-run / cancel) with cache invalidation
- package deletion from the Packages screen
- endpoint tests for inline review comments + replies (121 tests)
2026-10-09 18:19:14 +02:00
JustZoe101 b810292b1f feat(phase5): inline review comments, credentials write, deploy keys, org create, profile edit
- inline (line-level) review comments: list per review + reply API/hook,
  rendered under each review on the PR detail screen
- credentials: SSH key/GPG key/token create+delete endpoints and hooks;
  deploy keys (repo keys) management screen
- user profile edit (GET/PATCH /user/settings) screen
- organization creation screen; wired into Settings and Organizations
- endpoints.test.ts extended to 120 tests
2026-10-09 18:16:51 +02:00
46 changed files with 4919 additions and 194 deletions

No files matched your search

+24 -8
View File
@@ -40,6 +40,16 @@ covers the read-heavy Git workflow:
opening a pull request in the same step.
- **Repository actions**: star/unstar, watch/unwatch, fork, plus releases and
assets, and a configurable "Open in editor" action.
- **Repository management**: create repositories, edit settings and feature
toggles, delete, transfer ownership, and manage collaborators, webhooks,
branch protections and deploy keys.
- **Gitea Actions**: workflow runs, jobs, job logs and artifacts, with re-run,
cancel and workflow dispatch; plus repository secrets and variables.
- **Account**: profile editing, organizations (list, repos, teams, create),
packages (list, delete a version or all) and credential listings (SSH keys,
GPG keys, tokens).
- **Instance administration**: read-only users/organizations/repositories for
instance admins.
- **Notification inbox**: unread/all filters, mark-as-read, mark-all-read, and
life-cycle-aware polling.
- **English & Dutch**, light/dark/system theme, accessible touch targets and
@@ -180,17 +190,23 @@ state/data-flow, API client and account-registry design.
## Roadmap
See [`ROADMAP.md`](ROADMAP.md). Phases 0–4 are complete; Phase 5 (advanced) is
in progress — stars, watches, forks, releases, wiki and a capability probe are
in, while orgs, Actions, packages and admin screens are planned.
See [`ROADMAP.md`](ROADMAP.md). Phases 0–5 are implemented. The only explicit
gaps are OAuth sign-in (PAT is the supported path), content code search (no REST
endpoint), and a line-level diff preview before committing.
## Known limitations
- The in-app editor is a native monospace field; syntax highlighting and
search/replace (CodeMirror in a WebView) are planned.
- Pull-request review comments are at the PR level; line-level (inline) review
comments are planned.
- Gitea Actions, packages, organizations and admin screens are not built yet.
- **OAuth / device flow** is not implemented: Gitea has no OAuth2 device flow,
and authorization-code OAuth needs a per-instance app registration. Personal
access tokens remain the supported mobile sign-in.
- **Content code search** has no Gitea REST endpoint; the app offers "Find file"
(path search over the git tree) instead.
- The in-app editor is **CodeMirror 6** (bundled at build time) with line
numbers, syntax highlighting and a search/replace panel.
- Inline review comments can be composed at a line position (best-effort diff
position mapping) — verify placement against your Gitea version.
- Gitea's issues API exposes no sort parameter, so issue sorting is client-side
(labels/milestone filtering is server-side).
- Gitea's REST API exposes no total count for some endpoints, so infinite
scroll falls back to a page-length heuristic.
- Features that are unavailable or disabled on a given instance degrade to a
+27 -14
View File
@@ -17,7 +17,7 @@ This document is the living implementation plan. It is updated as phases land.
| 2 | Core Git experience: home, repos, browsing, commits | ✅ Done |
| 3 | Collaboration: issues, PRs, reviews, notifications | ✅ Done (read + write) |
| 4 | Code editing: Quick Edit, commit flow, editor workspace | ✅ Done (native editor) |
| 5 | Advanced: Actions, packages, orgs, wiki, releases, admin | 🟡 In progress |
| 5 | Advanced: Actions, packages, orgs, wiki, releases, admin | ✅ Done (core; admin/transfer planned) |
Detailed acceptance criteria per phase are in `docs/FEATURE_PARITY.md`.
Architectural decisions are recorded in `docs/ARCHITECTURE.md`.
@@ -99,9 +99,9 @@ Architectural decisions are recorded in `docs/ARCHITECTURE.md`.
- [x] Notifications inbox: read/unread, mark read, mark-all-read, unread badge
- [x] Lifecycle-aware notification polling tied to the refresh-interval setting
- [x] Notification subject-URL parsing → issue/PR/commit/repo navigation
- [ ] Inline (line-level) review comments
- [ ] Server-side filter UI (label, milestone, assignee) and sorting
- [ ] Reactions/subscriptions
- [x] Inline (line-level) review comments (display, reply + positioned composer)
- [x] Filters (label, milestone) + sorting on the repository issue list
- [x] Reactions/subscriptions (issue reactions toggle + subscribe/unsubscribe)
## Phase 4 — Code editing
@@ -113,24 +113,37 @@ Architectural decisions are recorded in `docs/ARCHITECTURE.md`.
- [x] Stale-SHA (409) conflict handling with a clear message
- [x] Unsaved-changes detection + discard
- [x] Per-instance editor/IDE URL template ("Open in editor"), system-browser/app fallback
- [x] In-app code editor in a WebView (CodeMirror 6, line numbers, highlighting)
- [x] In-editor search/replace (CodeMirror search panel)
- [x] IDE auth stays separate from Gitea API auth (no token in the URL)
- [ ] CodeMirror 6 editor in a WebView (syntax highlighting, search/replace)
- [ ] Line-level diff preview before committing
## Phase 5 — Advanced features (in progress)
## Phase 5 — Advanced features
- [x] Star / unstar and watch / unwatch repositories
- [x] Fork a repository
- [x] Releases list and detail with downloadable assets
- [x] Releases list, detail and management (create/edit/delete); assets download
- [x] Wiki entry with an explicit browser fallback (never silent)
- [x] Instance capability service (version parsing + feature gating) with tests
- [ ] Repository create/edit/delete, settings, collaborators, webhooks, deploy keys
- [ ] Protected-branch management, release management, asset upload
- [ ] Organizations, teams, projects, permissions
- [ ] Gitea Actions: workflows, runs, jobs, logs, artifacts, reruns
- [ ] Package registries
- [ ] User settings: SSH/GPG keys, tokens, profile
- [ ] Administration screens where instance permissions allow
- [x] Repository create/edit/delete with feature toggles
- [x] Collaborators (list/add/remove), webhooks (list/add/delete)
- [x] Branch protection rules (list/create/delete)
- [x] Deploy keys (list/add/delete)
- [x] Organizations: list, repositories and create
- [x] Packages: list and delete
- [x] User settings: profile edit, SSH/GPG keys, access tokens (read + create/delete)
- [x] Gitea Actions: runs, jobs, job logs, artifacts, re-run and cancel
- [x] Inline (line-level) review comments: display, reply API, positioned composer
- [x] Repository transfer
- [x] Actions secrets & variables management, workflow dispatch, artifacts
- [x] Release asset upload (multipart + document picker) and delete
- [x] Organizations: teams and repositories; repository projects
- [x] Administration screens (users/orgs/repos, admin-gated)
- [x] Find file (recursive git-tree path search)
- [x] Issue reactions and subscriptions; issue attachments
- [x] Package version-level delete; link/unlink a package to a repository
- [x] Workflow enable/disable
- [ ] Content code search (no Gitea REST endpoint)
---
+57 -55
View File
@@ -7,11 +7,10 @@ Status legend:
| ✅ | Implemented and working in-app |
| 🟡 | Partially implemented (read-only or limited) |
| ⬜ | Planned, not started |
| 🌐 | Planned via explicit browser fallback |
| 🌐 | Available via an explicit browser fallback |
"Min version" refers to the Gitea server version that exposes the endpoint; the
client does not hard-gate on a version yet (see the capability-probe item in the
roadmap).
"Min version" is not hard-gated yet; the client uses per-repository flags where
available and the version-based capability probe for the rest.
## Authentication & accounts
@@ -20,12 +19,11 @@ roadmap).
| PAT sign-in | ✅ | `GET /user` | Token validated before persisting |
| Instance URL validation | ✅ | — | HTTPS enforced for remote hosts |
| Secure token storage | ✅ | — | SecureStore (Keychain/Keystore) |
| Multiple instances | ✅ | — | Non-sensitive registry in AsyncStorage |
| Multiple accounts per instance | ✅ | — | Unique `(instanceId, login)` |
| Multiple instances / accounts | ✅ | — | Non-sensitive registry in AsyncStorage |
| Account switching | ✅ | — | Account-scoped query keys |
| Account/instance removal | ✅ | — | Token + cache purge |
| Biometric app lock | ✅ | — | On-device only |
| OAuth / device flow | ⬜ | — | PAT only for now |
| OAuth / device flow | ⬜ | — | Gitea has no device flow; OAuth needs a per-instance app registration. PAT is the supported mobile path. |
## Repository browsing
@@ -39,55 +37,54 @@ roadmap).
| README | ✅ | `GET /repos/{o}/{r}/contents/{path}` | located by name; no `/readme` endpoint exists |
| Directory browsing | ✅ | `GET …/contents` | breadcrumbs, ref query |
| File viewer | ✅ | `GET …/contents` + raw | text, images, symlink/submodule |
| Find file (path search) | ✅ | `GET …/git/trees/{ref}?recursive` | content search has no REST API |
| Branch list & selector | ✅ | `GET …/branches` | |
| Tags | ✅ | `GET …/tags` | |
| Commit history | ✅ | `GET …/commits` | paginated, ref/branch |
| Commit detail | ✅ | `GET …/git/commits/{sha}` | changed files, verification |
| Code search | ⬜ | `GET /repos/search`? | planned |
| Releases | ⬜ | `GET …/releases` | planned |
| Wiki | ⬜ | `GET …/wiki` | planned |
| Star/unstar/watch/fork | ⬜ | `PUT/DELETE` | planned (write) |
| Commit detail | ✅ | `GET …/git/commits/{sha}` | changed files, verification, checks |
| Releases | ✅ | `GET …/releases` | list, detail, create/edit/delete, asset upload/download |
| Wiki | 🌐 | — | opens the instance wiki in the browser |
| Star/unstar/watch/fork | ✅ | `PUT/DELETE` | repo overview actions |
| Content code search | ⬜ | — | not exposed by the Gitea REST API |
## Issues
| Feature | Status | API | Notes |
| --- | --- | --- | --- |
| Cross-repo issue list | ✅ | `GET /repos/issues/search` | assigned/created/review_requested, `type=issues` |
| Cross-repo issue list | ✅ | `GET /repos/issues/search` | assigned/created/review_requested |
| Repo issue list | ✅ | `GET /repos/{o}/{r}/issues` | open/closed filter |
| Issue detail | ✅ | `GET /repos/{o}/{r}/issues/{n}` | Markdown body, labels, assignees, milestone |
| Issue comments | ✅ | `GET/POST …/issues/{n}/comments` | thread + composer; edit/delete own comments |
| Create issue | ✅ | `POST …/issues` | title, body, labels, assignees, milestone |
| Edit issue | ✅ | `PATCH …/issues/{n}` | metadata + close/reopen |
| Labels/milestones management | 🟡 | `GET …/labels`, `GET …/milestones` | read + assign on compose; CRUD not yet |
| Assignees | ✅ | `GET …/collaborators` | select on compose/edit |
| Reactions/subscriptions | ⬜ | various | planned |
| Issue detail | ✅ | `GET …/issues/{n}` | Markdown body, labels, assignees, milestone |
| Issue comments | ✅ | `GET/POST …/issues/{n}/comments` | thread + composer; edit/delete own |
| Create/edit issue | ✅ | `POST/PATCH …/issues` | title, body, labels, assignees, milestone |
| Reactions | ✅ | `GET/POST/DELETE …/issues/{n}/reactions` | toggle on issue detail |
| Subscriptions | ✅ | `…/issues/{n}/subscriptions` | subscribe/unsubscribe |
| Attachments | ✅ | `GET …/issues/{n}/assets` | list + download |
| Labels/milestones management | ✅ | `GET/POST/PATCH/DELETE …/labels`, `…/milestones` | full CRUD (create/edit/delete) |
| Server-side filters/sorting UI | ✅ | `labels`, `milestones` params | server-side label/milestone filters; sorting is client-side (Gitea exposes no issues sort param) |
| Create/edit comments on PRs | ✅ | shared issue endpoint | |
## Pull requests
| Feature | Status | API | Notes |
| --- | --- | --- | --- |
| Review-requested PR list | ✅ | `GET /repos/issues/search` | `type=pulls`, `review_requested` |
| Repo PR list | ✅ | `GET /repos/{o}/{r}/pulls` | open/closed |
| PR detail | ✅ | `GET …/pulls/{n}` | title, branches, labels, stats, reviewers |
| Review-requested / repo PR lists | ✅ | `/repos/issues/search`, `/pulls` | |
| PR detail | ✅ | `GET …/pulls/{n}` | branches, labels, stats, reviewers |
| Changed files list | ✅ | `GET …/pulls/{n}/files` | per-file stats + status |
| Unified diff viewer | ✅ | `GET …/pulls/{n}.diff` | native, color-coded, no WebView |
| PR comments | ✅ | `GET/POST …/issues/{n}/comments` | shared issue thread + composer |
| Review comments (inline) | ⬜ | `GET …/reviews/{id}/comments` | line comments planned |
| Approve / request changes | ✅ | `POST …/pulls/{n}/reviews` | review event + body |
| Unified diff viewer | ✅ | `GET …/pulls/{n}.diff` | native, color-coded, tappable lines |
| Inline review comments | ✅ | `GET …/reviews/{id}/comments`, `POST …/pulls/{n}/reviews` | display, reply API, and a positioned composer |
| Approve / request changes / comment | ✅ | `POST …/pulls/{n}/reviews` | |
| Merge | ✅ | `POST …/pulls/{n}/merge` | squash / merge commit |
| CI checks (Actions) | ✅ | `GET …/commits/{ref}/status` | combined status on commit + PR |
| CI checks | ✅ | `GET …/commits/{ref}/status` | commit + PR head |
## Notifications
| Feature | Status | API | Notes |
| --- | --- | --- | --- |
| Notification inbox | ✅ | `GET /notifications` | unread/all filter |
| Notification inbox | ✅ | `GET /notifications` | unread/all |
| Unread badge | ✅ | `GET /notifications/new` | polled |
| Mark thread read | ✅ | `PUT /notifications/threads/{id}` | on open |
| Mark all read | ✅ | `PUT /notifications` | |
| Polling interval | ✅ | — | manual/30/60/300s setting |
| Notification navigation | ✅ | — | resolves subject URL to issue/PR/commit/repo |
| Push notifications | ⬜ | — | planned |
| Mark read / all read | ✅ | `PUT /notifications…` | |
| Polling interval | ✅ | — | manual/30/60/300s |
| Push notifications | ⬜ | — | requires a server component; out of scope for a client-only app |
## Home & shell
@@ -106,30 +103,35 @@ roadmap).
| Feature | Status | Notes |
| --- | --- | --- |
| Quick Edit | ✅ | native monospace editor (CodeMirror/WebView deferred) |
| Commit via Contents API | ✅ | base64 + blob SHA; creates the commit |
| Commit to a new branch | ✅ | `new_branch`, auto-forced on protected branches |
| Quick Edit | ✅ | WebView editor with line numbers + syntax highlighting |
| Commit via Contents API | ✅ | base64 + blob SHA |
| Commit to a new branch | ✅ | `new_branch`, forced on protected branches |
| Protected-branch awareness | ✅ | blocks direct commits when `user_can_push` is false |
| Stale-SHA (409) handling | ✅ | mapped to a clear conflict message |
| Create PR after commit | ✅ | when committing to a new branch |
| VS Code / editor workspace | ✅ | configurable URL template, no token passthrough |
| Syntax highlighting / search-replace | ⬜ | planned (CodeMirror 6 in a WebView) |
| Stale-SHA (409) handling | ✅ | clear conflict message |
| Create PR after commit | ✅ | |
| Editor / IDE workspace | ✅ | configurable URL template, no token passthrough |
| In-editor search/replace | ✅ | CodeMirror search panel (toolbar button) |
| CodeMirror 6 | ✅ | bundled at build time into a generated TS module |
## Advanced (partially implemented)
## Advanced
| Feature | Status |
| --- | --- |
| Star / unstar repository | ✅ |
| Watch / unwatch repository | ✅ |
| Fork repository | ✅ |
| Releases list + detail (with assets) | ✅ |
| Wiki (explicit browser fallback) | ✅ |
| Star / unstar / watch / unwatch / fork | ✅ |
| Repository create / edit / delete | ✅ |
| Repository transfer | ✅ |
| Collaborators (list/add/remove) | ✅ |
| Webhooks (list/add/delete) | ✅ |
| Branch protections (list/create/delete) | ✅ |
| Deploy keys (list/add/delete) | ✅ |
| Releases management + asset upload/download | ✅ |
| Gitea Actions: runs, jobs, job logs, artifacts, re-run, cancel | ✅ |
| Gitea Actions secrets / variables | ✅ |
| Workflow dispatch | ✅ |
| Organizations (list, repos, teams, create) | ✅ |
| Packages (list, version delete, delete all) | ✅ |
| User profile edit, SSH/GPG keys, tokens | ✅ |
| Instance capability probe (version-gated) | ✅ |
| Repo create/edit/delete/settings/webhooks | ⬜ |
| Protected branch management | ⬜ |
| Release management (create/edit/upload) | ⬜ |
| Organizations / teams / projects | ⬜ |
| Gitea Actions (runs, jobs, logs, artifacts) | ⬜ |
| Package registries | ⬜ |
| User settings (SSH/GPG keys, tokens) | ⬜ |
| Admin screens | ⬜ |
| Administration (users/orgs/repos, read-only, admin-gated) | ✅ |
| Workflow enable/disable | ✅ |
| Package helpers (link/unlink to repo) | ✅ |
+971
View File
File diff suppressed because it is too large. Load diff
+17
View File
@@ -15,6 +15,7 @@
"@tanstack/react-query-persist-client": "^5.104.1",
"expo": "~57.0.27",
"expo-constants": "~57.0.21",
"expo-document-picker": "~57.0.3",
"expo-font": "~57.0.4",
"expo-haptics": "~57.0.3",
"expo-image": "~57.0.5",
@@ -40,13 +41,28 @@
"react-native-screens": "~4.26.0",
"react-native-svg": "15.15.4",
"react-native-web": "~0.21.0",
"react-native-webview": "13.16.1",
"react-native-worklets": "0.10.1",
"zustand": "^5.0.15"
},
"devDependencies": {
"@codemirror/lang-cpp": "^6.0.3",
"@codemirror/lang-css": "^6.3.1",
"@codemirror/lang-go": "^6.0.1",
"@codemirror/lang-html": "^6.4.12",
"@codemirror/lang-java": "^6.0.2",
"@codemirror/lang-javascript": "^6.2.5",
"@codemirror/lang-json": "^6.0.2",
"@codemirror/lang-markdown": "^6.5.2",
"@codemirror/lang-php": "^6.0.2",
"@codemirror/lang-python": "^6.2.1",
"@codemirror/lang-rust": "^6.0.2",
"@codemirror/search": "^6.7.2",
"@testing-library/react-native": "^14.1.0",
"@types/jest": "^29.5.14",
"@types/react": "~19.2.2",
"codemirror": "^6.0.2",
"esbuild": "^0.28.2",
"eslint": "^9.39.5",
"eslint-config-expo": "~57.0.2",
"jest": "~29.7.0",
@@ -62,6 +78,7 @@
"lint": "expo lint",
"typecheck": "tsc --noEmit",
"test": "jest",
"build:editor": "node scripts/build-editor.mjs",
"format": "prettier --write \"src/**/*.{ts,tsx}\" \"*.{md,json,js}\"",
"format:check": "prettier --check \"src/**/*.{ts,tsx}\" \"*.{md,json,js}\"",
"verify": "npm run typecheck && npm run lint && npm test"
+41
View File
@@ -0,0 +1,41 @@
/**
* Bundles the CodeMirror 6 entry (`scripts/codemirror-entry.mjs`) into a single
* IIFE string inside `src/components/git/codemirror-bundle.ts`.
*
* Run with `npm run build:editor`. The generated module is committed so the app
* builds without a JS bundling step at runtime.
*/
import { writeFileSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { build } from 'esbuild';
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const entry = resolve(root, 'scripts/codemirror-entry.mjs');
const output = resolve(root, 'src/components/git/codemirror-bundle.ts');
const result = await build({
entryPoints: [entry],
bundle: true,
format: 'iife',
minify: true,
write: false,
platform: 'browser',
target: 'es2020',
legalComments: 'none',
});
const code = result.outputFiles[0].text;
const safe = code.replace(/<\/script/gi, '<\\/script');
const module = `/**
* AUTO-GENERATED by scripts/build-editor.mjs — do not edit by hand.
* Bundled CodeMirror 6 editor (see scripts/codemirror-entry.mjs).
*/
export const CODE_MIRROR_BUNDLE = ${JSON.stringify(safe)};
`;
writeFileSync(output, module);
console.log(`Wrote ${output} (${code.length} bytes)`);
+57
View File
@@ -0,0 +1,57 @@
/**
* CodeMirror 6 entry point bundled by `scripts/build-editor.mjs`.
*
* It exposes `window.createCodeMirror` to the inline WebView HTML. The bundle is
* generated into `src/components/git/codemirror-bundle.ts` so the app carries no
* runtime asset pipeline and never loads remote code.
*/
import { EditorState } from '@codemirror/state';
import { EditorView } from '@codemirror/view';
import { basicSetup } from 'codemirror';
import { openSearchPanel } from '@codemirror/search';
import { javascript } from '@codemirror/lang-javascript';
import { python } from '@codemirror/lang-python';
import { json } from '@codemirror/lang-json';
import { html } from '@codemirror/lang-html';
import { css } from '@codemirror/lang-css';
import { markdown } from '@codemirror/lang-markdown';
import { java } from '@codemirror/lang-java';
import { cpp } from '@codemirror/lang-cpp';
import { rust } from '@codemirror/lang-rust';
import { php } from '@codemirror/lang-php';
import { go } from '@codemirror/lang-go';
const LANGUAGES = { javascript, python, json, html, css, markdown, java, cpp, rust, php, go };
window.createCodeMirror = function createCodeMirror(config) {
const { parent, doc, language, theme, onChange } = config;
const languageExtension = LANGUAGES[language] ? LANGUAGES[language]() : [];
const view = new EditorView({
parent,
state: EditorState.create({
doc,
extensions: [
basicSetup,
languageExtension,
EditorView.theme({
'&': { backgroundColor: theme.bg, color: theme.fg, height: '100%' },
'.cm-content': { fontFamily: 'ui-monospace, Menlo, Consolas, monospace' },
'.cm-gutters': { backgroundColor: theme.bg, color: theme.gutter, border: 'none' },
'.cm-activeLine': { backgroundColor: theme.activeLine },
'.cm-activeLineGutter': { backgroundColor: theme.activeLine },
'&.cm-focused': { outline: 'none' },
}),
EditorView.updateListener.of((update) => {
if (update.docChanged) onChange(update.state.doc.toString());
}),
],
}),
});
return {
openSearch: () => openSearchPanel(view),
focus: () => view.focus(),
};
};
+155
View File
@@ -0,0 +1,155 @@
import { useMemo, useRef } from 'react';
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { WebView } from 'react-native-webview';
import { IconButton } from '@/components/ui/icon-button';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
import { CODE_MIRROR_BUNDLE } from '@/components/git/codemirror-bundle';
const EXT_LANGUAGE: Record<string, string> = {
js: 'javascript',
jsx: 'javascript',
ts: 'javascript',
tsx: 'javascript',
mjs: 'javascript',
cjs: 'javascript',
json: 'json',
py: 'python',
go: 'go',
rb: 'python',
rs: 'rust',
java: 'java',
kt: 'java',
swift: 'java',
c: 'cpp',
h: 'cpp',
cpp: 'cpp',
hpp: 'cpp',
cs: 'java',
php: 'php',
html: 'html',
htm: 'html',
css: 'css',
scss: 'css',
less: 'css',
md: 'markdown',
markdown: 'markdown',
};
export function languageForPath(path: string): string {
const ext = path.split('.').pop()?.toLowerCase() ?? '';
return EXT_LANGUAGE[ext] ?? 'plain';
}
export interface CodeEditorProps {
/** Initial content — CodeMirror owns the text while editing. */
value: string;
onChangeText: (value: string) => void;
language?: string;
editable?: boolean;
}
interface EditorTheme {
bg: string;
fg: string;
gutter: string;
activeLine: string;
}
function buildHtml(value: string, language: string, theme: EditorTheme): string {
const doc = JSON.stringify(value);
const lang = JSON.stringify(language);
const themeJson = JSON.stringify(theme);
return `<!DOCTYPE html><html><head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<style>html,body,#app{height:100%;margin:0;padding:0;background:${theme.bg};}
.cm-editor{height:100%}.cm-scroller{overflow:auto}</style>
</head><body>
<div id="app"></div>
<script>${CODE_MIRROR_BUNDLE}</script>
<script>
var app=document.getElementById('app');
window.__cm=window.createCodeMirror({
parent: app,
doc: ${doc},
language: ${lang},
theme: ${themeJson},
onChange: function(v){ window.ReactNativeWebView.postMessage(JSON.stringify({type:'change', value:v})); }
});
window.__cmSearch=function(){ try { window.__cm.openSearch(); } catch (e) {} };
</script>
</body></html>`;
}
/**
* CodeMirror 6 editor rendered in a WebView. The CodeMirror bundle is generated
* at build time (`npm run build:editor`) and inlined, so no remote code or
* runtime asset fetch happens. A toolbar exposes the search/replace panel.
*/
export function CodeEditor({ value, onChangeText, language = 'plain' }: CodeEditorProps) {
const { t } = useTranslation();
const { colors } = useTheme();
// The editor owns the content after mount; remount (via `key`) to load a file.
const html = useMemo(
() =>
buildHtml(value, language, {
bg: colors.codeBackground,
fg: colors.text,
gutter: colors.textTertiary,
activeLine: colors.surfaceSecondary,
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[value, language, colors.codeBackground, colors.text],
);
const webRef = useRef<WebView | null>(null);
return (
<View style={styles.container}>
<View style={[styles.toolbar, { borderBottomColor: colors.border }]}>
<IconButton
name="search"
onPress={() => webRef.current?.injectJavaScript('window.__cmSearch && window.__cmSearch(); true;')}
accessibilityLabel={t('editor.search')}
/>
</View>
<WebView
ref={(instance) => {
webRef.current = instance;
}}
style={styles.webview}
originWhitelist={['*']}
source={{ html }}
onMessage={(event) => {
try {
const payload = JSON.parse(event.nativeEvent.data) as { type: string; value?: string };
if (payload.type === 'change' && typeof payload.value === 'string') {
onChangeText(payload.value);
}
} catch {
// Ignore malformed messages.
}
}}
keyboardDisplayRequiresUserAction={false}
hideKeyboardAccessoryView
setSupportMultipleWindows={false}
/>
</View>
);
}
const styles = StyleSheet.create({
container: { flex: 1, overflow: 'hidden' },
toolbar: {
flexDirection: 'row',
justifyContent: 'flex-end',
alignItems: 'center',
borderBottomWidth: StyleSheet.hairlineWidth,
paddingHorizontal: spacing.xs,
},
webview: { flex: 1, backgroundColor: 'transparent' },
});
+5
View File
@@ -0,0 +1,5 @@
/**
* AUTO-GENERATED by scripts/build-editor.mjs — do not edit by hand.
* Bundled CodeMirror 6 editor (see scripts/codemirror-entry.mjs).
*/
export const CODE_MIRROR_BUNDLE = "\"use strict\";(()=>{var Ys=[],IQ=[];(()=>{let O=\"lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,1n,9,16,o,,x,1i,3,,i,,7,a,2,t,3,1k,,,7,2,2,2,3,9,,a,2,q,,2,3,1k,,,5,4,2,2,3,3,,u,2,3,,b,3,1k,,,8,,3,,3,k,2,m,6,,3,1k,,,7,2,2,2,3,7,3,a,2,u,,1n,5,3,3,,4,9,,14,5,1j,,,7,,3,,4,7,2,b,2,t,3,1k,,,7,,3,,4,7,2,b,2,f,,c,4,1j,2,,7,,3,,4,9,,a,2,t,3,1y,,4,6,,,,8,i,2,1p,,,8,c,8,2q,,,a,b,7,21,2,r,,,,,,4,2,1d,k,,2,5,b,,10,9,,2u,b,,6,n,4,4,3,g,4,d,,,3,6,,f,,jj,3,qa,4,s,3,t,2,u,2,1s,w,9,,19,3,,,39,2,y,,3a,c,4,c,63,5,1l,a,,,,,2,o,2,,1c,1a,2,c,k,5,1b,h,12,9,c,3,u,d,1k,e,1c,k,48,3,,l,4,,6,,2,3,5i,1s,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,n,5,4,,2b,2,1e,i,q,i,d,,12,8,p,d,18,4,1b,e,10,,1v,e,c,,8,2,1a,,1f,,,3,2,2,5,2,,,15,5,5,2,6k,8,,2,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,1t,5,8t,2,25,6,1y,b,1d,4,3e,3,1h,f,15,,2,2,a,4,19,b,7,,1p,3,10,e,g,2,18,,c,3,1c,e,8,4,,2,2k,c,6,,2,,4d,c,l,4,1j,2,,7,2,2,2,3,9,,a,2,2,7,3,5,1v,9,,,2,,,4,,5,,,e,2,2a,i,n,,29,k,6j,7,2,9,r,2,2a,h,2y,d,2t,3,2,a,74,f,6t,6,,2,2,4,,,,2,3x,7,2,7,3,,s,a,14,7,,4,8,,9,b,1a,g,5i,8,5j,8,,8,2a,m,,e,3e,6,3,,,2,,7,,,1u,5,,2,,5,9n,4,9,2,,,1c,7,3,5,n,,44l,,6,f,8ug,i,1xc,5,1n,7,t4,,,1j,7,4,29,,b,2,f57,2,3mp,1a,2,n,f2,5,3,6,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,2s,,4g,7,af,,1p,4,e4,4,72,2,6r,,2,,7,2,5,,d6,7,31,7,240,5\".split(\",\").map(e=>e?parseInt(e,36):1);for(let e=0,t=0;e<O.length;e++)(e%2?IQ:Ys).push(t=t+O[e])})();function ym(O){if(O<768)return!1;for(let e=0,t=Ys.length;;){let i=e+t>>1;if(O<Ys[i])t=i;else if(O>=IQ[i])e=i+1;else return!0;if(e==t)return!1}}function EQ(O){return O>=127462&&O<=127487}var AQ=8205;function MQ(O,e,t=!0,i=!0){return(t?DQ:km)(O,e,i)}function DQ(O,e,t){if(e==O.length)return e;e&&BQ(O.charCodeAt(e))&&NQ(O.charCodeAt(e-1))&&e--;let i=vs(O,e);for(e+=LQ(i);e<O.length;){let r=vs(O,e);if(i==AQ||r==AQ||t&&ym(r))e+=LQ(r),i=r;else if(EQ(r)){let n=0,s=e-2;for(;s>=0&&EQ(vs(O,s));)n++,s-=2;if(n%2==0)break;e+=2}else break}return e}function km(O,e,t){for(;e>1;){let i=DQ(O,e-2,t);if(i<e)return i;e--}return 0}function vs(O,e){let t=O.charCodeAt(e);if(!NQ(t)||e+1==O.length)return t;let i=O.charCodeAt(e+1);return BQ(i)?(t-55296<<10)+(i-56320)+65536:t}function BQ(O){return O>=56320&&O<57344}function NQ(O){return O>=55296&&O<56320}function LQ(O){return O<65536?1:2}var C=class O{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,t,i){[e,t]=LO(this,e,t);let r=[];return this.decompose(0,e,r,2),i.length&&i.decompose(0,i.length,r,3),this.decompose(t,this.length,r,1),CO.from(r,this.length-(t-e)+i.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,t=this.length){[e,t]=LO(this,e,t);let i=[];return this.decompose(e,t,i,0),CO.from(i,t-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let t=this.scanIdentical(e,1),i=this.length-this.scanIdentical(e,-1),r=new fO(this),n=new fO(e);for(let s=t,a=t;;){if(r.next(s),n.next(s),s=0,r.lineBreak!=n.lineBreak||r.done!=n.done||r.value!=n.value)return!1;if(a+=r.value.length,r.done||a>=i)return!0}}iter(e=1){return new fO(this,e)}iterRange(e,t=this.length){return new Yr(this,e,t)}iterLines(e,t){let i;if(e==null)i=this.iter();else{t==null&&(t=this.lines+1);let r=this.line(e).from;i=this.iterRange(r,Math.max(r,t==this.lines+1?this.length:t<=1?0:this.line(t-1).to))}return new Rr(i)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError(\"A document must have at least one line\");return e.length==1&&!e[0]?O.empty:e.length<=32?new Ie(e):CO.from(Ie.split(e,[]))}},Ie=class O extends C{constructor(e,t=Zm(e)){super(),this.text=e,this.length=t}get lines(){return this.text.length}get children(){return null}lineInner(e,t,i,r){for(let n=0;;n++){let s=this.text[n],a=r+s.length;if((t?i:a)>=e)return new Us(r,a,i,s);r=a+1,i++}}decompose(e,t,i,r){let n=e<=0&&t>=this.length?this:new O(FQ(this.text,e,t),Math.min(t,this.length)-Math.max(0,e));if(r&1){let s=i.pop(),a=vr(n.text,s.text.slice(),0,n.length);if(a.length<=32)i.push(new O(a,s.length+n.length));else{let o=a.length>>1;i.push(new O(a.slice(0,o)),new O(a.slice(o)))}}else i.push(n)}replace(e,t,i){if(!(i instanceof O))return super.replace(e,t,i);[e,t]=LO(this,e,t);let r=vr(this.text,vr(i.text,FQ(this.text,0,e)),t),n=this.length+i.length-(t-e);return r.length<=32?new O(r,n):CO.from(O.split(r,[]),n)}sliceString(e,t=this.length,i=`\n`){[e,t]=LO(this,e,t);let r=\"\";for(let n=0,s=0;n<=t&&s<this.text.length;s++){let a=this.text[s],o=n+a.length;n>e&&s&&(r+=i),e<o&&t>n&&(r+=a.slice(Math.max(0,e-n),t-n)),n=o+1}return r}flatten(e){for(let t of this.text)e.push(t)}scanIdentical(){return 0}stLine truncated
+23 -5
View File
@@ -6,7 +6,7 @@
* with the theme's diff colors. `parseDiff` is pure and unit-tested.
*/
import { ScrollView, StyleSheet, Text, View } from 'react-native';
import { Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';
import { AppText } from '@/components/ui/app-text';
import { useTheme } from '@/theme/theme-provider';
@@ -106,7 +106,7 @@ export function parseDiff(raw: string): DiffFile[] {
return files;
}
function DiffLineRow({ line }: { line: DiffLine }) {
function DiffLineRow({ line, onPress }: { line: DiffLine; onPress?: () => void }) {
const { colors } = useTheme();
const style = {
add: { backgroundColor: colors.diffAdd, color: colors.diffAddText, sign: '+' },
@@ -116,7 +116,7 @@ function DiffLineRow({ line }: { line: DiffLine }) {
meta: { backgroundColor: 'transparent', color: colors.textTertiary, sign: '' },
}[line.type];
return (
const row = (
<View style={[styles.line, { backgroundColor: style.backgroundColor }]}>
<Text style={[styles.sign, { color: style.color }]}>{style.sign}</Text>
<Text style={[styles.code, { color: style.color }]} selectable>
@@ -124,6 +124,13 @@ function DiffLineRow({ line }: { line: DiffLine }) {
</Text>
</View>
);
if (!onPress) return row;
return (
<Pressable onPress={onPress} accessibilityRole="button">
{row}
</Pressable>
);
}
export interface DiffViewProps {
@@ -131,10 +138,15 @@ export interface DiffViewProps {
/** When set, only the matching file's hunks are rendered. */
pathFilter?: string;
emptyLabel: string;
/**
* Called with the 1-based position of a tapped line within its file's diff
* (Gitea's `new_position`) — used to attach an inline review comment.
*/
onLinePress?: (filePath: string, position: number) => void;
}
/** Horizontally scrollable, color-coded unified diff. Place inside a non-scroll Screen. */
export function DiffView({ raw, pathFilter, emptyLabel }: DiffViewProps) {
export function DiffView({ raw, pathFilter, emptyLabel, onLinePress }: DiffViewProps) {
const files = parseDiff(raw).filter((file) => !pathFilter || file.path === pathFilter);
if (files.length === 0) {
@@ -161,7 +173,13 @@ export function DiffView({ raw, pathFilter, emptyLabel }: DiffViewProps) {
<ScrollView horizontal showsHorizontalScrollIndicator>
<View>
{file.lines.map((line, index) => (
<DiffLineRow key={index} line={line} />
<DiffLineRow
key={index}
line={line}
onPress={
onLinePress ? () => onLinePress(file.path, index + 1) : undefined
}
/>
))}
</View>
</ScrollView>
+61
View File
@@ -0,0 +1,61 @@
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { AppText } from '@/components/ui/app-text';
import { Avatar } from '@/components/ui/avatar';
import { useTheme } from '@/theme/theme-provider';
import { fontFamily, spacing } from '@/theme/tokens';
import { useReviewComments } from '@/features/issues/queries';
export interface ReviewCommentsProps {
owner: string;
name: string;
index: number;
reviewId: number;
baseUrl?: string;
}
/** Inline (line-level) comments attached to a single review. */
export function ReviewComments({ owner, name, index, reviewId }: ReviewCommentsProps) {
const { t } = useTranslation();
const { colors } = useTheme();
const query = useReviewComments(owner, name, index, reviewId);
const comments = query.data ?? [];
if (comments.length === 0) return null;
return (
<View style={styles.container}>
{comments.map((comment) => (
<View key={comment.id} style={[styles.item, { borderLeftColor: colors.borderStrong }]}>
<View style={styles.header}>
<Avatar url={comment.user?.avatar_url} name={comment.user?.login ?? '?'} size={22} />
<AppText variant="bodyMedium" style={styles.login} numberOfLines={1}>
{comment.user?.login ?? t('common.unknown')}
</AppText>
{comment.path ? (
<AppText variant="monoSmall" tone="tertiary" numberOfLines={1} style={styles.path}>
{comment.path}
{comment.position ? `:${comment.position}` : ''}
</AppText>
) : null}
</View>
{comment.body ? (
<AppText variant="secondary" style={styles.body}>
{comment.body}
</AppText>
) : null}
</View>
))}
</View>
);
}
const styles = StyleSheet.create({
container: { gap: spacing.md, marginTop: spacing.sm },
item: { borderLeftWidth: 2, paddingLeft: spacing.md, gap: spacing.xs },
header: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
login: { fontWeight: '600' },
path: { flexShrink: 1, fontFamily: fontFamily.mono },
body: { fontSize: 14 },
});
+76
View File
@@ -177,6 +177,82 @@ export class GiteaClient {
return text;
}
/**
* Uploads a multipart/form-data body (e.g. a release asset) and parses the
* JSON response. The multipart boundary is set by the platform, so we never
* set `Content-Type` ourselves. Errors are normalized like {@link raw}.
*/
async postForm<T>(
path: string,
form: FormData,
options: Omit<RequestOptions, 'method' | 'body'> = {},
): Promise<T> {
const url = `${this.apiRoot}${path}${buildQuery(options.query ?? {})}`;
const headers: Record<string, string> = { Accept: 'application/json' };
if (this.token) headers.Authorization = `token ${this.token}`;
const controller = new AbortController();
let timedOut = false;
const timeoutMs = options.timeoutMs ?? this.timeoutMs ?? 120_000;
const timer = setTimeout(() => {
timedOut = true;
controller.abort();
}, timeoutMs);
const onCallerAbort = () => controller.abort();
if (options.signal) {
if (options.signal.aborted) {
clearTimeout(timer);
throw new ApiError({ kind: 'aborted', status: 0, message: 'Request cancelled.' });
}
options.signal.addEventListener('abort', onCallerAbort);
}
let response: Response;
try {
response = await this.fetchImpl(url, {
method: 'POST',
headers,
body: form as unknown as BodyInit,
signal: controller.signal,
});
} catch (error) {
if (timedOut) {
throw new ApiError({ kind: 'timeout', status: 0, message: 'The upload took too long.' });
}
if (options.signal?.aborted) {
throw new ApiError({ kind: 'aborted', status: 0, message: 'Request cancelled.' });
}
throw toApiError(error);
} finally {
clearTimeout(timer);
options.signal?.removeEventListener('abort', onCallerAbort);
}
const text = await response.text();
let parsed: unknown = undefined;
if (text.length > 0) {
try {
parsed = JSON.parse(text);
} catch {
parsed = undefined;
}
}
if (!response.ok) {
const serverMessage =
parsed && typeof parsed === 'object' && 'message' in parsed
? String((parsed as { message: unknown }).message)
: null;
const kind = ApiError.kindForStatus(response.status);
throw new ApiError({
kind,
status: response.status,
serverMessage,
message: messageForStatus(kind, response.status, serverMessage),
});
}
return parsed as T;
}
/**
* Performs a request and returns data plus pagination metadata.
* `hasMore` uses `X-Total-Count` when present, otherwise a length heuristic
+112
View File
@@ -8,11 +8,24 @@
import { GiteaClient } from './client';
import {
addRepoKey,
addIssueReaction,
createLabel,
createMilestone,
createOrg,
createRelease,
createRepoVariable,
createPullReview,
deletePackageVersion,
fetchRepoTree,
listActionRuns,
linkPackageToRepo,
listReviewComments,
mergePull,
putRepoSecret,
replyToReviewComment,
setWorkflowEnabled,
transferRepo,
unlinkPackageFromRepo,
updateRepo,
updateUserSettings,
} from './endpoints';
@@ -105,4 +118,103 @@ describe('endpoint request bodies', () => {
expect(url).toContain('status=success');
expect(url).toContain('branch=main');
});
it('lists inline review comments and posts replies', async () => {
const { fetchImpl, client } = capture();
await listReviewComments(client, 'octo', 'repo', 7, 42);
expect(fetchImpl.mock.calls[0][0]).toBe(
'https://codeberg.org/api/v1/repos/octo/repo/pulls/7/reviews/42/comments',
);
fetchImpl.mockClear();
await replyToReviewComment(client, 'octo', 'repo', 7, 99, 'thanks');
expect(fetchImpl.mock.calls[0][0]).toBe(
'https://codeberg.org/api/v1/repos/octo/repo/pulls/7/comments/99/replies',
);
expect(postedBody(fetchImpl)).toMatchObject({ body: 'thanks' });
});
it('transfers a repository', async () => {
const { fetchImpl, client } = capture();
await transferRepo(client, 'octo', 'repo', 'newowner');
expect(fetchImpl.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/repos/octo/repo/transfer');
expect(postedBody(fetchImpl)).toMatchObject({ new_owner: 'newowner' });
});
it('writes an Actions secret and a variable', async () => {
const { fetchImpl, client } = capture();
await putRepoSecret(client, 'octo', 'repo', 'TOKEN', 's3cr3t');
expect(fetchImpl.mock.calls[0][0]).toBe(
'https://codeberg.org/api/v1/repos/octo/repo/actions/secrets/TOKEN',
);
expect(postedBody(fetchImpl)).toMatchObject({ data: 's3cr3t' });
fetchImpl.mockClear();
await createRepoVariable(client, 'octo', 'repo', 'ENV', 'prod');
expect(fetchImpl.mock.calls[0][0]).toBe(
'https://codeberg.org/api/v1/repos/octo/repo/actions/variables/ENV',
);
expect(postedBody(fetchImpl)).toMatchObject({ value: 'prod' });
});
it('adds an issue reaction', async () => {
const { fetchImpl, client } = capture();
await addIssueReaction(client, 'octo', 'repo', 5, '+1');
expect(fetchImpl.mock.calls[0][0]).toBe(
'https://codeberg.org/api/v1/repos/octo/repo/issues/5/reactions',
);
expect(postedBody(fetchImpl)).toMatchObject({ content: '+1' });
});
it('deletes a specific package version', async () => {
const { fetchImpl, client } = capture();
await deletePackageVersion(client, 'octo', 'npm', 'pkg', '1.0.0');
expect(fetchImpl.mock.calls[0][0]).toBe(
'https://codeberg.org/api/v1/packages/octo/npm/pkg/1.0.0',
);
expect(fetchImpl.mock.calls[0][1].method).toBe('DELETE');
});
it('fetches the recursive git tree for file search', async () => {
const { fetchImpl, client } = capture();
await fetchRepoTree(client, 'octo', 'repo', 'main');
const url = fetchImpl.mock.calls[0][0] as string;
expect(url).toContain('/repos/octo/repo/git/trees/main');
expect(url).toContain('recursive=true');
});
it('creates a label and a milestone', async () => {
const { fetchImpl, client } = capture();
await createLabel(client, 'octo', 'repo', { name: 'bug', color: 'd73a4a' });
expect(fetchImpl.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/repos/octo/repo/labels');
expect(postedBody(fetchImpl)).toMatchObject({ name: 'bug', color: 'd73a4a' });
fetchImpl.mockClear();
await createMilestone(client, 'octo', 'repo', { title: 'v1' });
expect(fetchImpl.mock.calls[0][0]).toBe('https://codeberg.org/api/v1/repos/octo/repo/milestones');
expect(postedBody(fetchImpl)).toMatchObject({ title: 'v1' });
});
it('enables and disables a workflow', async () => {
const { fetchImpl, client } = capture();
await setWorkflowEnabled(client, 'octo', 'repo', 'ci.yml', false);
expect(fetchImpl.mock.calls[0][0]).toBe(
'https://codeberg.org/api/v1/repos/octo/repo/actions/workflows/ci.yml/disable',
);
expect(fetchImpl.mock.calls[0][1].method).toBe('PUT');
});
it('links and unlinks a package to a repository', async () => {
const { fetchImpl, client } = capture();
await linkPackageToRepo(client, 'octo', 'npm', 'pkg', 'my-repo');
expect(fetchImpl.mock.calls[0][0]).toBe(
'https://codeberg.org/api/v1/packages/octo/npm/pkg/-/link/my-repo',
);
fetchImpl.mockClear();
await unlinkPackageFromRepo(client, 'octo', 'npm', 'pkg');
expect(fetchImpl.mock.calls[0][0]).toBe(
'https://codeberg.org/api/v1/packages/octo/npm/pkg/-/unlink',
);
});
});
+581 -1
View File
@@ -13,8 +13,10 @@ import { ApiError } from './errors';
import type { GiteaClient, RequestOptions } from './client';
import type {
AccessToken,
ActionArtifact,
ActionRun,
ActionRunJob,
ActionVariable,
ActionWorkflow,
Activity,
Branch,
@@ -25,6 +27,7 @@ import type {
Commit,
ContentsEntry,
DeployKey,
GitTree,
GpgKey,
Issue,
Label,
@@ -33,15 +36,21 @@ import type {
NotificationThread,
Organization,
Package,
Project,
PublicKey,
PullRequest,
PullReview,
PullReviewComment,
Reaction,
Release,
ReleaseAsset,
Repository,
ReviewEvent,
Secret,
ServerVersion,
Subscription,
Tag,
Team,
User,
UserSettings,
Webhook,
@@ -549,6 +558,36 @@ export function fetchActionJobLogs(
return client.getText(`${repoPath(owner, repo)}/actions/jobs/${jobId}/logs`, options);
}
export function rerunActionRun(
client: GiteaClient,
owner: string,
repo: string,
run: number,
options?: RequestOptions,
): Promise<void> {
return client.post<void>(`${repoPath(owner, repo)}/actions/runs/${run}/rerun`, undefined, options);
}
export function cancelActionRun(
client: GiteaClient,
owner: string,
repo: string,
run: number,
options?: RequestOptions,
): Promise<void> {
return client.post<void>(`${repoPath(owner, repo)}/actions/runs/${run}/cancel`, undefined, options);
}
export function deletePackage(
client: GiteaClient,
owner: string,
type: string,
name: string,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`/packages/${enc(owner)}/${enc(type)}/${enc(name)}`, options);
}
// ---------------------------------------------------------------------------
// Organizations, packages, user credentials
// ---------------------------------------------------------------------------
@@ -870,6 +909,8 @@ export interface ListRepoIssuesParams extends PageParams {
state?: 'open' | 'closed' | 'all';
q?: string;
labels?: string;
/** Comma-separated milestone names. */
milestones?: string;
}
export function listRepoIssues(
@@ -887,6 +928,7 @@ export function listRepoIssues(
state: params.state ?? 'open',
q: params.q?.trim() || undefined,
labels: params.labels,
milestones: params.milestones,
type: 'issues',
},
});
@@ -1117,10 +1159,50 @@ export function listPullReviews(
});
}
/** Inline comments attached to a specific review. */
export function listReviewComments(
client: GiteaClient,
owner: string,
repo: string,
index: number,
reviewId: number,
options?: RequestOptions,
): Promise<PullReviewComment[]> {
return client.get<PullReviewComment[]>(
`${repoPath(owner, repo)}/pulls/${index}/reviews/${reviewId}/comments`,
options,
);
}
/** Reply to an inline review comment. */
export function replyToReviewComment(
client: GiteaClient,
owner: string,
repo: string,
index: number,
commentId: number,
body: string,
options?: RequestOptions,
): Promise<PullReviewComment> {
return client.post<PullReviewComment>(
`${repoPath(owner, repo)}/pulls/${index}/comments/${commentId}/replies`,
{ body },
options,
);
}
export interface CreateReviewCommentInput {
body: string;
path: string;
new_position?: number;
old_position?: number;
}
export interface CreateReviewInput {
event: ReviewEvent;
body?: string;
commitId?: string;
comments?: CreateReviewCommentInput[];
}
export function createPullReview(
@@ -1133,7 +1215,12 @@ export function createPullReview(
): Promise<PullReview> {
return client.post<PullReview>(
`${repoPath(owner, repo)}/pulls/${index}/reviews`,
{ event: input.event, body: input.body ?? '', commit_id: input.commitId },
{
event: input.event,
body: input.body ?? '',
commit_id: input.commitId,
comments: input.comments,
},
options,
);
}
@@ -1332,3 +1419,496 @@ export function listUserActivity(
query: { page: params.page ?? 1, limit: params.limit ?? 20 },
});
}
// ---------------------------------------------------------------------------
// Release assets (multipart)
// ---------------------------------------------------------------------------
export interface UploadFile {
/** Local file URI (from expo-document-picker / expo-image-picker). */
uri: string;
name: string;
type: string;
}
export function uploadReleaseAsset(
client: GiteaClient,
owner: string,
repo: string,
releaseId: number,
file: UploadFile,
options?: Omit<RequestOptions, 'method' | 'body'>,
): Promise<ReleaseAsset> {
const form = new FormData();
// React Native accepts the {uri, name, type} shape for file parts.
form.append('attachment', { uri: file.uri, name: file.name, type: file.type } as unknown as Blob);
return client.postForm<ReleaseAsset>(
`${repoPath(owner, repo)}/releases/${releaseId}/assets`,
form,
{ ...options, query: { ...options?.query, name: file.name } },
);
}
export function deleteReleaseAsset(
client: GiteaClient,
owner: string,
repo: string,
releaseId: number,
assetId: number,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(
`${repoPath(owner, repo)}/releases/${releaseId}/assets/${assetId}`,
options,
);
}
// ---------------------------------------------------------------------------
// Repository transfer
// ---------------------------------------------------------------------------
export function transferRepo(
client: GiteaClient,
owner: string,
repo: string,
newOwner: string,
options?: RequestOptions,
): Promise<Repository> {
return client.post<Repository>(`${repoPath(owner, repo)}/transfer`, { new_owner: newOwner }, options);
}
// ---------------------------------------------------------------------------
// Actions secrets / variables / artifacts / workflow dispatch
// ---------------------------------------------------------------------------
export function listRepoSecrets(
client: GiteaClient,
owner: string,
repo: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<Secret[]>(`${repoPath(owner, repo)}/actions/secrets`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
export function putRepoSecret(
client: GiteaClient,
owner: string,
repo: string,
name: string,
data: string,
options?: RequestOptions,
): Promise<void> {
return client.put<void>(
`${repoPath(owner, repo)}/actions/secrets/${enc(name)}`,
{ data },
options,
);
}
export function deleteRepoSecret(
client: GiteaClient,
owner: string,
repo: string,
name: string,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/actions/secrets/${enc(name)}`, options);
}
export function listRepoVariables(
client: GiteaClient,
owner: string,
repo: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<ActionVariable[]>(`${repoPath(owner, repo)}/actions/variables`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
export function createRepoVariable(
client: GiteaClient,
owner: string,
repo: string,
name: string,
value: string,
options?: RequestOptions,
): Promise<ActionVariable> {
return client.post<ActionVariable>(
`${repoPath(owner, repo)}/actions/variables/${enc(name)}`,
{ value },
options,
);
}
export function deleteRepoVariable(
client: GiteaClient,
owner: string,
repo: string,
name: string,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/actions/variables/${enc(name)}`, options);
}
export function listRunArtifacts(
client: GiteaClient,
owner: string,
repo: string,
run: number,
options?: RequestOptions,
): Promise<{ artifacts?: ActionArtifact[] }> {
return client.get<{ artifacts?: ActionArtifact[] }>(
`${repoPath(owner, repo)}/actions/runs/${run}/artifacts`,
options,
);
}
export interface DispatchWorkflowInput {
ref: string;
inputs?: Record<string, string>;
}
export function dispatchWorkflow(
client: GiteaClient,
owner: string,
repo: string,
workflowId: string,
input: DispatchWorkflowInput,
options?: RequestOptions,
): Promise<void> {
return client.post<void>(
`${repoPath(owner, repo)}/actions/workflows/${enc(workflowId)}/dispatches`,
input,
options,
);
}
// ---------------------------------------------------------------------------
// Teams, projects, tree (file search)
// ---------------------------------------------------------------------------
export function listOrgTeams(
client: GiteaClient,
org: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<Team[]>(`/orgs/${enc(org)}/teams`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50 },
});
}
export function listRepoProjects(
client: GiteaClient,
owner: string,
repo: string,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<Project[]>(`${repoPath(owner, repo)}/projects`, {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 50, state: 'all' },
});
}
/** Recursive git tree for a ref — powers the "find file" search. */
export function fetchRepoTree(
client: GiteaClient,
owner: string,
repo: string,
ref: string,
options?: RequestOptions,
): Promise<GitTree> {
return client.get<GitTree>(
`${repoPath(owner, repo)}/git/trees/${enc(ref)}`,
{ ...options, query: { recursive: true, per_page: 1000 } },
);
}
// ---------------------------------------------------------------------------
// Issue reactions & attachments
// ---------------------------------------------------------------------------
export function listIssueReactions(
client: GiteaClient,
owner: string,
repo: string,
index: number,
options?: RequestOptions,
): Promise<Reaction[]> {
return client.get<Reaction[]>(`${repoPath(owner, repo)}/issues/${index}/reactions`, options);
}
export function addIssueReaction(
client: GiteaClient,
owner: string,
repo: string,
index: number,
content: string,
options?: RequestOptions,
): Promise<Reaction> {
return client.post<Reaction>(
`${repoPath(owner, repo)}/issues/${index}/reactions`,
{ content },
options,
);
}
export function removeIssueReaction(
client: GiteaClient,
owner: string,
repo: string,
index: number,
content: string,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(
`${repoPath(owner, repo)}/issues/${index}/reactions`,
{ ...options, body: { content } },
);
}
export function listIssueAttachments(
client: GiteaClient,
owner: string,
repo: string,
index: number,
options?: RequestOptions,
): Promise<{ id?: number; name?: string; size?: number; browser_download_url?: string }[]> {
return client.get(
`${repoPath(owner, repo)}/issues/${index}/assets`,
options,
);
}
// --- issue subscriptions ---------------------------------------------------
export function checkIssueSubscription(
client: GiteaClient,
owner: string,
repo: string,
index: number,
options?: RequestOptions,
): Promise<{ subscribed?: boolean }> {
return client.get(`${repoPath(owner, repo)}/issues/${index}/subscriptions/check`, options);
}
export function subscribeIssue(
client: GiteaClient,
owner: string,
repo: string,
index: number,
user: string,
options?: RequestOptions,
): Promise<void> {
return client.put<void>(
`${repoPath(owner, repo)}/issues/${index}/subscriptions/${enc(user)}`,
undefined,
options,
);
}
export function unsubscribeIssue(
client: GiteaClient,
owner: string,
repo: string,
index: number,
user: string,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(
`${repoPath(owner, repo)}/issues/${index}/subscriptions/${enc(user)}`,
options,
);
}
// ---------------------------------------------------------------------------
// Admin (read-only)
// ---------------------------------------------------------------------------
export function listAdminUsers(
client: GiteaClient,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<User[]>('/admin/users', {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 30 },
});
}
export function listAdminOrgs(
client: GiteaClient,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<Organization[]>('/admin/orgs', {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 30 },
});
}
export function listAdminRepos(
client: GiteaClient,
params: PageParams = {},
options?: RequestOptions,
) {
return client.raw<Repository[]>('/admin/repos', {
...options,
query: { page: params.page ?? 1, limit: params.limit ?? 30 },
});
}
// ---------------------------------------------------------------------------
// Package version deletion
// ---------------------------------------------------------------------------
export function deletePackageVersion(
client: GiteaClient,
owner: string,
type: string,
name: string,
version: string,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(
`/packages/${enc(owner)}/${enc(type)}/${enc(name)}/${enc(version)}`,
options,
);
}
// ---------------------------------------------------------------------------
// Labels & milestones (CRUD)
// ---------------------------------------------------------------------------
export interface LabelInput {
name: string;
color?: string;
description?: string;
exclusive?: boolean;
}
export function createLabel(
client: GiteaClient,
owner: string,
repo: string,
input: LabelInput,
options?: RequestOptions,
): Promise<Label> {
return client.post<Label>(`${repoPath(owner, repo)}/labels`, input, options);
}
export function updateLabel(
client: GiteaClient,
owner: string,
repo: string,
id: number,
input: Partial<LabelInput>,
options?: RequestOptions,
): Promise<Label> {
return client.patch<Label>(`${repoPath(owner, repo)}/labels/${id}`, input, options);
}
export function deleteLabel(
client: GiteaClient,
owner: string,
repo: string,
id: number,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/labels/${id}`, options);
}
export interface MilestoneInput {
title: string;
description?: string;
due_on?: string;
state?: 'open' | 'closed';
}
export function createMilestone(
client: GiteaClient,
owner: string,
repo: string,
input: MilestoneInput,
options?: RequestOptions,
): Promise<Milestone> {
return client.post<Milestone>(`${repoPath(owner, repo)}/milestones`, input, options);
}
export function updateMilestone(
client: GiteaClient,
owner: string,
repo: string,
id: number,
input: Partial<MilestoneInput>,
options?: RequestOptions,
): Promise<Milestone> {
return client.patch<Milestone>(`${repoPath(owner, repo)}/milestones/${id}`, input, options);
}
export function deleteMilestone(
client: GiteaClient,
owner: string,
repo: string,
id: number,
options?: RequestOptions,
): Promise<void> {
return client.delete<void>(`${repoPath(owner, repo)}/milestones/${id}`, options);
}
// ---------------------------------------------------------------------------
// Actions workflows (enable/disable) & package linking
// ---------------------------------------------------------------------------
export function setWorkflowEnabled(
client: GiteaClient,
owner: string,
repo: string,
workflowId: string,
enabled: boolean,
options?: RequestOptions,
): Promise<void> {
return client.put<void>(
`${repoPath(owner, repo)}/actions/workflows/${enc(workflowId)}/${enabled ? 'enable' : 'disable'}`,
undefined,
options,
);
}
export function linkPackageToRepo(
client: GiteaClient,
owner: string,
type: string,
name: string,
repoName: string,
options?: RequestOptions,
): Promise<void> {
return client.post<void>(
`/packages/${enc(owner)}/${enc(type)}/${enc(name)}/-/link/${enc(repoName)}`,
undefined,
options,
);
}
export function unlinkPackageFromRepo(
client: GiteaClient,
owner: string,
type: string,
name: string,
options?: RequestOptions,
): Promise<void> {
return client.post<void>(
`/packages/${enc(owner)}/${enc(type)}/${enc(name)}/-/unlink`,
undefined,
options,
);
}
+37 -2
View File
@@ -66,12 +66,39 @@ export const queryKeys = {
repoKeys: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'keys'] as const,
repoProjects: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'projects'] as const,
repoTree: (accountId: string, owner: string, name: string, ref: string) =>
[...queryKeys.repo(accountId, owner, name), 'tree', ref] as const,
repoSecrets: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'secrets'] as const,
repoVariables: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'variables'] as const,
runArtifacts: (accountId: string, owner: string, name: string, run: number) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'run', run, 'artifacts'] as const,
issueReactions: (accountId: string, owner: string, name: string, index: number) =>
[...queryKeys.issue(accountId, owner, name, index), 'reactions'] as const,
issueAttachments: (accountId: string, owner: string, name: string, index: number) =>
[...queryKeys.issue(accountId, owner, name, index), 'attachments'] as const,
issueSubscription: (accountId: string, owner: string, name: string, index: number, user: string) =>
[...queryKeys.issue(accountId, owner, name, index), 'subscription', user] as const,
// --- actions -------------------------------------------------------------
actionsRoot: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'actions'] as const,
actionsWorkflows: (accountId: string, owner: string, name: string) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'workflows'] as const,
[...queryKeys.actionsRoot(accountId, owner, name), 'workflows'] as const,
actionsRuns: (accountId: string, owner: string, name: string, params: Record<string, unknown>) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'runs', params] as const,
[...queryKeys.actionsRoot(accountId, owner, name), 'runs', params] as const,
actionRun: (accountId: string, owner: string, name: string, id: number) =>
[...queryKeys.repo(accountId, owner, name), 'actions', 'run', id] as const,
@@ -180,6 +207,14 @@ export const queryKeys = {
pullReviews: (accountId: string, owner: string, name: string, index: number) =>
[...queryKeys.pull(accountId, owner, name, index), 'reviews'] as const,
pullReviewComments: (
accountId: string,
owner: string,
name: string,
index: number,
reviewId: number,
) => [...queryKeys.pullReviews(accountId, owner, name, index), reviewId, 'comments'] as const,
combinedStatus: (accountId: string, owner: string, name: string, ref: string) =>
[...queryKeys.repo(accountId, owner, name), 'status', ref] as const,
+95
View File
@@ -568,6 +568,84 @@ export interface UserSettings {
theme?: string;
}
// ---------------------------------------------------------------------------
// Actions secrets / variables / artifacts, teams, projects, tree, reactions
// ---------------------------------------------------------------------------
export interface Secret {
name?: string;
description?: string;
created_at?: string;
}
export interface ActionVariable {
name?: string;
data?: string;
description?: string;
}
export interface ActionArtifact {
id?: number;
name?: string;
size_in_bytes?: number;
expired?: boolean;
expires_at?: string;
created_at?: string;
archive_download_url?: string;
workflow_run?: ActionRun;
}
export interface Reaction {
content?: string;
user?: User;
created_at?: string;
}
export interface Team {
id?: number;
name?: string;
description?: string;
permission?: string;
organization?: Organization;
visibility?: string;
units?: string[];
}
export interface Project {
id?: number;
title?: string;
description?: string;
state?: string;
type?: string;
card_type?: string;
is_closed?: boolean;
num_issues?: number;
num_open_issues?: number;
num_closed_issues?: number;
html_url?: string;
created_at?: string;
updated_at?: string;
creator?: User;
}
export interface GitTreeEntry {
path?: string;
mode?: string;
type?: string;
size?: number;
sha?: string;
url?: string;
}
export interface GitTree {
sha?: string;
url?: string;
truncated?: boolean;
page?: number;
total_count?: number;
entries?: GitTreeEntry[];
}
export interface Activity {
id?: number;
user_id?: number;
@@ -626,6 +704,23 @@ export interface PullReview {
html_url?: string;
}
/** An inline (line-level) review comment. */
export interface PullReviewComment {
id?: number;
body?: string;
path?: string;
position?: number;
original_position?: number;
diff_hunk?: string;
commit_id?: string;
pull_request_review_id?: number;
pull_request_url?: string;
user?: User;
created_at?: string;
updated_at?: string;
html_url?: string;
}
export type CommitStatusState = 'pending' | 'success' | 'error' | 'failure' | 'warning' | 'skipped';
/** A single CI status (Gitea Actions or an external checker). */
+62 -1
View File
@@ -3,21 +3,28 @@
import {
keepPreviousData,
useInfiniteQuery,
useMutation,
useQuery,
useQueryClient,
type InfiniteData,
} from '@tanstack/react-query';
import type { RawResponse } from '@/core/api/client';
import {
cancelActionRun,
dispatchWorkflow,
fetchActionJobLogs,
fetchActionRun,
listActionRunJobs,
listActionRuns,
listRunArtifacts,
listWorkflows,
rerunActionRun,
type DispatchWorkflowInput,
type ListActionRunsParams,
} from '@/core/api/endpoints';
import { queryKeys } from '@/core/api/query-keys';
import type { ActionRun, ActionRunJob, ActionWorkflow } from '@/core/api/types';
import type { ActionArtifact, ActionRun, ActionRunJob, ActionWorkflow } from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
export function useWorkflows(owner: string, name: string) {
@@ -33,6 +40,21 @@ export function useWorkflows(owner: string, name: string) {
});
}
/** Dispatch a workflow run (`workflow_dispatch`). */
export function useDispatchWorkflow(owner: string, name: string, workflowId: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: DispatchWorkflowInput) =>
dispatchWorkflow(client!, owner, name, workflowId, input),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.actionsRoot(accountId, owner, name) });
},
});
}
export function useActionRuns(
owner: string,
name: string,
@@ -85,6 +107,45 @@ export function useActionRunJobs(owner: string, name: string, run: number) {
});
}
/** Re-run or cancel a workflow run. */
export function useActionRunControl(owner: string, name: string, run: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
const invalidate = () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.actionRun(accountId, owner, name, run) });
void queryClient.invalidateQueries({ queryKey: queryKeys.actionJobs(accountId, owner, name, run) });
void queryClient.invalidateQueries({ queryKey: queryKeys.actionsRoot(accountId, owner, name) });
};
const rerun = useMutation({
mutationFn: () => rerunActionRun(client!, owner, name, run),
onSuccess: invalidate,
});
const cancel = useMutation({
mutationFn: () => cancelActionRun(client!, owner, name, run),
onSuccess: invalidate,
});
return { rerun, cancel };
}
/** Artifacts produced by a workflow run. */
export function useRunArtifacts(owner: string, name: string, run: number) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<ActionArtifact[]>({
queryKey: queryKeys.runArtifacts(accountId, owner, name, run),
enabled: Boolean(client) && Boolean(accountId) && run > 0,
queryFn: ({ signal }) =>
listRunArtifacts(client!, owner, name, run, { signal }).then((r) => r.artifacts ?? []),
staleTime: 60_000,
});
}
export function useActionJobLogs(owner: string, name: string, jobId: number, enabled = true) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
+153 -2
View File
@@ -18,6 +18,8 @@ import {
import type { RawResponse } from '@/core/api/client';
import {
addIssueReaction,
checkIssueSubscription,
createIssue,
createIssueComment,
createPull,
@@ -28,15 +30,22 @@ import {
fetchPull,
fetchPullDiff,
listCollaborators,
listIssueAttachments,
listIssueComments,
listIssueReactions,
listMilestones,
listPullFiles,
listPullReviews,
listRepoIssues,
listRepoLabels,
listPulls,
listReviewComments,
mergePull,
removeIssueReaction,
replyToReviewComment,
searchIssues,
subscribeIssue,
unsubscribeIssue,
updateIssue,
updateIssueComment,
type CreateIssueInput,
@@ -56,6 +65,8 @@ import type {
Milestone,
PullRequest,
PullReview,
PullReviewComment,
Reaction,
User,
} from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
@@ -120,17 +131,30 @@ export function useIssueSearch(filters: CrossIssueFilters, limit = 20) {
});
}
export interface RepoIssueFilters {
labels?: string;
milestones?: string;
limit?: number;
}
/** Issues inside one repository (used on the repository Issues tab). */
export function useRepoIssues(
owner: string,
name: string,
state: 'open' | 'closed' | 'all',
search: string,
limit = 20,
filters: RepoIssueFilters = {},
) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
const params = { state, q: search.trim() || undefined, limit };
const limit = filters.limit ?? 20;
const params = {
state,
q: search.trim() || undefined,
labels: filters.labels || undefined,
milestones: filters.milestones || undefined,
limit,
};
return useInfiniteQuery<
RawResponse<Issue[]>,
@@ -392,6 +416,38 @@ export function usePullReviews(owner: string, name: string, index: number) {
});
}
export function useReviewComments(
owner: string,
name: string,
index: number,
reviewId: number,
enabled = true,
) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<PullReviewComment[]>({
queryKey: queryKeys.pullReviewComments(accountId, owner, name, index, reviewId),
enabled: Boolean(client) && Boolean(accountId) && enabled && reviewId > 0,
queryFn: ({ signal }) => listReviewComments(client!, owner, name, index, reviewId, { signal }),
staleTime: 60_000,
});
}
export function useReplyReviewComment(owner: string, name: string, index: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ commentId, body }: { commentId: number; body: string }) =>
replyToReviewComment(client!, owner, name, index, commentId, body),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.pull(accountId, owner, name, index) });
},
});
}
export function useCreatePullReview(owner: string, name: string, index: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
@@ -456,3 +512,98 @@ export function useCreatePull(owner: string, name: string) {
export type { Issue, Label, PullRequest };
export type { ChangedFile, CombinedStatus, Comment, Milestone, PullReview, User };
// ---------------------------------------------------------------------------
// Issue reactions & attachments
// ---------------------------------------------------------------------------
export function useIssueReactions(owner: string, name: string, index: number) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Reaction[]>({
queryKey: queryKeys.issueReactions(accountId, owner, name, index),
enabled: Boolean(client) && Boolean(accountId) && index > 0,
queryFn: ({ signal }) => listIssueReactions(client!, owner, name, index, { signal }),
staleTime: 30_000,
});
}
/** Adds the reaction when absent, removes it when already present. */
export function useToggleIssueReaction(owner: string, name: string, index: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: async ({ content, mine }: { content: string; mine: boolean }): Promise<void> => {
if (mine) {
await removeIssueReaction(client!, owner, name, index, content);
} else {
await addIssueReaction(client!, owner, name, index, content);
}
},
onSuccess: () => {
void queryClient.invalidateQueries({
queryKey: queryKeys.issueReactions(accountId, owner, name, index),
});
},
});
}
export function useIssueAttachments(owner: string, name: string, index: number) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<{ id?: number; name?: string; size?: number; browser_download_url?: string }[]>({
queryKey: queryKeys.issueAttachments(accountId, owner, name, index),
enabled: Boolean(client) && Boolean(accountId) && index > 0,
queryFn: ({ signal }) => listIssueAttachments(client!, owner, name, index, { signal }),
staleTime: 60_000,
});
}
export function useIssueSubscription(
owner: string,
name: string,
index: number,
user: string | undefined,
) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<{ subscribed?: boolean }>({
queryKey: queryKeys.issueSubscription(accountId, owner, name, index, user ?? ''),
enabled: Boolean(client) && Boolean(accountId) && index > 0 && Boolean(user),
queryFn: ({ signal }) => checkIssueSubscription(client!, owner, name, index, { signal }),
staleTime: 60_000,
retry: false,
});
}
export function useToggleIssueSubscription(
owner: string,
name: string,
index: number,
user: string | undefined,
) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: async (subscribed: boolean): Promise<void> => {
if (!user) return;
if (subscribed) {
await unsubscribeIssue(client!, owner, name, index, user);
} else {
await subscribeIssue(client!, owner, name, index, user);
}
},
onSuccess: () => {
void queryClient.invalidateQueries({
queryKey: queryKeys.issueSubscription(accountId, owner, name, index, user ?? ''),
});
},
});
}
+104
View File
@@ -5,13 +5,21 @@ import { useInfiniteQuery, useMutation, useQuery, useQueryClient, type InfiniteD
import type { RawResponse } from '@/core/api/client';
import {
createOrg,
deletePackage,
deletePackageVersion,
fetchAuthenticatedUser,
fetchUserSettings,
listAdminOrgs,
listAdminRepos,
listAdminUsers,
listOrgRepos,
listPackages,
listUserGpgKeys,
listUserKeys,
listUserOrgs,
listUserTokens,
linkPackageToRepo,
unlinkPackageFromRepo,
updateUserSettings,
type CreateOrgInput,
} from '@/core/api/endpoints';
@@ -23,6 +31,7 @@ import type {
Package,
PublicKey,
Repository,
User,
UserSettings,
} from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
@@ -48,6 +57,18 @@ function useAccountList<T>(
});
}
/** The signed-in user (used to gate admin-only UI on `is_admin`). */
export function useCurrentUser() {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<User>({
queryKey: queryKeys.me(accountId),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) => fetchAuthenticatedUser(client!, { signal }),
staleTime: 5 * 60_000,
});
}
export function useUserOrgs(limit = 30) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
@@ -138,3 +159,86 @@ export function useCreateOrg() {
},
});
}
export function useDeletePackage() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ owner, type, name }: { owner: string; type: string; name: string }) =>
deletePackage(client!, owner, type, name),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
export function useDeletePackageVersion() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ owner, type, name, version }: { owner: string; type: string; name: string; version: string }) =>
deletePackageVersion(client!, owner, type, name, version),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
export function useLinkPackage() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ owner, type, name, repoName }: { owner: string; type: string; name: string; repoName: string }) =>
linkPackageToRepo(client!, owner, type, name, repoName),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
export function useUnlinkPackage() {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ owner, type, name }: { owner: string; type: string; name: string }) =>
unlinkPackageFromRepo(client!, owner, type, name),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
// ---------------------------------------------------------------------------
// Admin (read-only)
// ---------------------------------------------------------------------------
export function useAdminUsers(limit = 30) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<User>(
[...queryKeys.account(accountId), 'admin', 'users', { limit }],
(page, signal) => listAdminUsers(client!, { page, limit }, { signal }),
);
}
export function useAdminOrgs(limit = 30) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<Organization>(
[...queryKeys.account(accountId), 'admin', 'orgs', { limit }],
(page, signal) => listAdminOrgs(client!, { page, limit }, { signal }),
);
}
export function useAdminRepos(limit = 30) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useAccountList<Repository>(
[...queryKeys.account(accountId), 'admin', 'repos', { limit }],
(page, signal) => listAdminRepos(client!, { page, limit }, { signal }),
);
}
@@ -0,0 +1,114 @@
import { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { QueryList } from '@/components/layout/query-list';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge';
import { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState } from '@/components/ui/state-views';
import type { Organization, Repository, User } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { useAdminOrgs, useAdminRepos, useAdminUsers } from '@/features/profile/queries';
import { spacing } from '@/theme/tokens';
type Tab = 'users' | 'orgs' | 'repos';
/** Instance administration (read-only) for instance admins. */
export function AdminScreen() {
const { t } = useTranslation();
const [tab, setTab] = useState<Tab>('users');
const users = useAdminUsers();
const orgs = useAdminOrgs();
const repos = useAdminRepos();
return (
<Screen padded={false}>
<View style={styles.tabs}>
<SegmentedControl<Tab>
value={tab}
onChange={setTab}
accessibilityLabel={t('admin.title')}
options={[
{ value: 'users', label: t('admin.users') },
{ value: 'orgs', label: t('admin.orgs') },
{ value: 'repos', label: t('admin.repos') },
]}
/>
</View>
{tab === 'users' ? (
<QueryList<User>
query={users}
items={flattenPages(users.data)}
keyExtractor={(user) => String(user.id ?? user.login)}
renderItem={(user) => (
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{user.login}
</AppText>
{user.full_name ? (
<AppText variant="caption" tone="tertiary" numberOfLines={1}>
{user.full_name}
</AppText>
) : null}
</View>
{user.is_admin ? <Badge tone="warning">{t('admin.adminBadge')}</Badge> : null}
</View>
)}
empty={<EmptyState icon="people" title={t('admin.emptyUsers')} />}
/>
) : null}
{tab === 'orgs' ? (
<QueryList<Organization>
query={orgs}
items={flattenPages(orgs.data)}
keyExtractor={(org) => String(org.id ?? org.username)}
renderItem={(org) => (
<View style={styles.row}>
<AppText variant="bodyMedium" numberOfLines={1}>
{org.username ?? org.name}
</AppText>
</View>
)}
empty={<EmptyState icon="people" title={t('admin.emptyOrgs')} />}
/>
) : null}
{tab === 'repos' ? (
<QueryList<Repository>
query={repos}
items={flattenPages(repos.data)}
keyExtractor={(repo) => String(repo.id)}
renderItem={(repo) => (
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{repo.full_name}
</AppText>
{repo.private ? <Badge tone="neutral">{t('repositories.private')}</Badge> : null}
</View>
</View>
)}
empty={<EmptyState icon="repo" title={t('admin.emptyRepos')} />}
/>
) : null}
</Screen>
);
}
const styles = StyleSheet.create({
tabs: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
row: {
flexDirection: 'row',
alignItems: 'center',
gap: spacing.md,
paddingHorizontal: spacing.lg,
paddingVertical: spacing.md,
},
body: { flex: 1, gap: 2 },
});
@@ -0,0 +1,63 @@
import { StyleSheet, View } from 'react-native';
import { useRoute, type RouteProp } from '@react-navigation/native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge';
import { Card } from '@/components/ui/card';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useOrgTeams } from '@/features/repositories/settings-queries';
import { spacing } from '@/theme/tokens';
import type { SettingsStackParamList } from '@/navigation/types';
/** Teams within an organization (read-only). */
export function OrgTeamsScreen() {
const { t } = useTranslation();
const route = useRoute<RouteProp<SettingsStackParamList, 'OrgTeams'>>();
const { org } = route.params;
const query = useOrgTeams(org);
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
const teams = query.data ?? [];
if (teams.length === 0) return <EmptyState icon="people" title={t('organizations.noTeams')} />;
return (
<Screen scroll padded>
{teams.map((team) => (
<Card key={team.id ?? team.name}>
<View style={styles.row}>
<View style={styles.body}>
<AppText variant="bodyMedium" numberOfLines={1}>
{team.name}
</AppText>
{team.description ? (
<AppText variant="caption" tone="tertiary" numberOfLines={2}>
{team.description}
</AppText>
) : null}
</View>
{team.permission ? <Badge tone="neutral">{team.permission}</Badge> : null}
</View>
</Card>
))}
</Screen>
);
}
const styles = StyleSheet.create({
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
body: { flex: 1, gap: 2 },
});
@@ -7,6 +7,7 @@ import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { Avatar } from '@/components/ui/avatar';
import { Button } from '@/components/ui/button';
import { IconButton } from '@/components/ui/icon-button';
import { EmptyState } from '@/components/ui/state-views';
import type { Organization } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
@@ -57,6 +58,11 @@ export function OrganizationsScreen() {
</AppText>
) : null}
</View>
<IconButton
name="people"
onPress={() => navigation.navigate('OrgTeams', { org: login })}
accessibilityLabel={t('organizations.teams')}
/>
</View>
);
}}
@@ -1,14 +1,26 @@
import { StyleSheet, View } from 'react-native';
import { useState } from 'react';
import { Alert, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Field } from '@/components/ui/field';
import { IconButton } from '@/components/ui/icon-button';
import { EmptyState } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { Package } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { formatRelativeTime } from '@/core/utils/format';
import { usePackages } from '@/features/profile/queries';
import {
useDeletePackage,
useDeletePackageVersion,
useLinkPackage,
usePackages,
useUnlinkPackage,
} from '@/features/profile/queries';
import { useSession } from '@/features/accounts/use-session';
import { spacing } from '@/theme/tokens';
@@ -16,14 +28,116 @@ import { spacing } from '@/theme/tokens';
export function PackagesScreen() {
const { t } = useTranslation();
const { account } = useSession();
const query = usePackages(account?.login ?? '');
const login = account?.login ?? '';
const query = usePackages(login);
const deletePackage = useDeletePackage();
const deleteVersion = useDeletePackageVersion();
const linkPackage = useLinkPackage();
const unlinkPackage = useUnlinkPackage();
const packages: Package[] = flattenPages(query.data);
const [linkTarget, setLinkTarget] = useState<Package | null>(null);
const [repoName, setRepoName] = useState('');
const confirmDelete = (pkg: Package) => {
const buttons = [
{ text: t('common.cancel'), style: 'cancel' as const },
...(pkg.version
? [
{
text: t('packages.deleteVersion'),
onPress: () =>
deleteVersion.mutate(
{ owner: login, type: pkg.type ?? '', name: pkg.name ?? '', version: pkg.version as string },
{ onError: (error: unknown) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
),
},
]
: []),
{
text: t('packages.deleteAll'),
style: 'destructive' as const,
onPress: () =>
deletePackage.mutate(
{ owner: login, type: pkg.type ?? '', name: pkg.name ?? '' },
{ onError: (error: unknown) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
),
},
];
Alert.alert(t('packages.deleteTitle'), t('packages.deleteBody', { name: pkg.name ?? '' }), buttons);
};
return (
<QueryList<Package>
query={query}
items={packages}
keyExtractor={(pkg) => `${pkg.type ?? ''}-${pkg.name ?? ''}-${pkg.version ?? ''}`}
header={
linkTarget ? (
<Card style={styles.linkCard}>
<AppText variant="bodyMedium" numberOfLines={1}>
{linkTarget.name}
</AppText>
<Field
label={t('packages.linkRepo')}
value={repoName}
onChangeText={setRepoName}
placeholder={t('packages.linkRepoPlaceholder')}
autoCapitalize="none"
autoCorrect={false}
/>
<View style={styles.linkActions}>
<Button
label={t('common.cancel')}
variant="ghost"
size="md"
onPress={() => {
setLinkTarget(null);
setRepoName('');
}}
/>
<Button
label={t('packages.link')}
size="md"
loading={linkPackage.isPending}
disabled={repoName.trim().length === 0}
onPress={() =>
linkPackage.mutate(
{
owner: login,
type: linkTarget.type ?? '',
name: linkTarget.name ?? '',
repoName: repoName.trim(),
},
{
onSuccess: () => {
setLinkTarget(null);
setRepoName('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
)
}
/>
<Button
label={t('packages.unlink')}
variant="danger"
size="md"
loading={unlinkPackage.isPending}
onPress={() =>
unlinkPackage.mutate(
{ owner: login, type: linkTarget.type ?? '', name: linkTarget.name ?? '' },
{
onSuccess: () => setLinkTarget(null),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
)
}
/>
</View>
</Card>
) : undefined
}
renderItem={(pkg) => (
<View style={styles.row}>
<View style={styles.body}>
@@ -44,6 +158,19 @@ export function PackagesScreen() {
) : null}
</View>
</View>
<IconButton
name="externalLink"
onPress={() => {
setLinkTarget(pkg);
setRepoName('');
}}
accessibilityLabel={t('packages.link')}
/>
<IconButton
name="trash"
onPress={() => confirmDelete(pkg)}
accessibilityLabel={t('common.delete')}
/>
</View>
)}
empty={<EmptyState icon="package" title={t('packages.empty')} />}
@@ -52,7 +179,15 @@ export function PackagesScreen() {
}
const styles = StyleSheet.create({
row: { paddingHorizontal: spacing.lg, paddingVertical: spacing.md },
body: { gap: spacing.xs },
row: {
flexDirection: 'row',
alignItems: 'center',
gap: spacing.md,
paddingHorizontal: spacing.lg,
paddingVertical: spacing.md,
},
body: { flex: 1, gap: spacing.xs },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
linkCard: { gap: spacing.sm },
linkActions: { flexDirection: 'row', justifyContent: 'flex-end', gap: spacing.sm, flexWrap: 'wrap' },
});
+44
View File
@@ -32,10 +32,14 @@ import {
createRelease,
updateRelease,
deleteRelease,
uploadReleaseAsset,
deleteReleaseAsset,
fetchRepoTree,
type ForkRepoInput,
type ListMyReposParams,
type ReleaseInput,
type SearchReposParams,
type UploadFile,
} from '@/core/api/endpoints';
import type { RawResponse } from '@/core/api/client';
import { queryKeys } from '@/core/api/query-keys';
@@ -282,3 +286,43 @@ export function useDeleteRelease(owner: string, name: string, id: number) {
onSuccess: () => invalidateReleases(queryClient, accountId, owner, name),
});
}
export function useUploadReleaseAsset(owner: string, name: string, releaseId: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (file: UploadFile) => uploadReleaseAsset(client!, owner, name, releaseId, file),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.release(accountId, owner, name, releaseId) });
void queryClient.invalidateQueries({ queryKey: queryKeys.repo(accountId, owner, name) });
},
});
}
export function useDeleteReleaseAsset(owner: string, name: string, releaseId: number) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (assetId: number) => deleteReleaseAsset(client!, owner, name, releaseId, assetId),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.release(accountId, owner, name, releaseId) });
},
});
}
/** Recursive file tree for the "find file" search (keyed by ref). */
export function useRepoTree(owner: string, name: string, ref: string | undefined) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery({
queryKey: queryKeys.repoTree(accountId, owner, name, ref ?? ''),
enabled: Boolean(client) && Boolean(accountId) && Boolean(ref),
queryFn: ({ signal }) => fetchRepoTree(client!, owner, name, ref!, { signal }),
staleTime: 5 * 60_000,
});
}
+262 -1
View File
@@ -6,27 +6,56 @@ import {
addCollaborator,
addRepoKey,
createBranchProtection,
createLabel,
createMilestone,
createRepo,
createRepoVariable,
createWebhook,
deleteBranchProtection,
deleteLabel,
deleteMilestone,
deleteRepo,
deleteRepoKey,
deleteRepoSecret,
deleteRepoVariable,
deleteWebhook,
listBranchProtections,
listCollaborators,
listMilestones,
listOrgTeams,
listRepoKeys,
listRepoProjects,
listRepoSecrets,
listRepoVariables,
listWebhooks,
putRepoSecret,
removeCollaborator,
setWorkflowEnabled,
transferRepo,
updateLabel,
updateMilestone,
updateRepo,
type AddRepoKeyInput,
type CollaboratorPermission,
type CreateBranchProtectionInput,
type CreateRepoInput,
type CreateWebhookInput,
type LabelInput,
type MilestoneInput,
type UpdateRepoInput,
} from '@/core/api/endpoints';
import { queryKeys } from '@/core/api/query-keys';
import type { BranchProtection, DeployKey, User, Webhook } from '@/core/api/types';
import type {
ActionVariable,
BranchProtection,
DeployKey,
Milestone,
Project,
Secret,
Team,
User,
Webhook,
} from '@/core/api/types';
import { useSession } from '@/features/accounts/use-session';
export function useCollaboratorsList(owner: string, name: string) {
@@ -226,3 +255,235 @@ export function useDeleteRepoKey(owner: string, name: string) {
void queryClient.invalidateQueries({ queryKey: queryKeys.repoKeys(accountId, owner, name) }),
});
}
// ---------------------------------------------------------------------------
// Transfer
// ---------------------------------------------------------------------------
export function useTransferRepo(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (newOwner: string) => transferRepo(client!, owner, name, newOwner),
onSuccess: () => {
void queryClient.invalidateQueries({ queryKey: queryKeys.account(accountId) });
},
});
}
// ---------------------------------------------------------------------------
// Actions secrets & variables
// ---------------------------------------------------------------------------
export function useRepoSecrets(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Secret[]>({
queryKey: queryKeys.repoSecrets(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listRepoSecrets(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function usePutRepoSecret(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ key, value }: { key: string; value: string }) =>
putRepoSecret(client!, owner, name, key, value),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoSecrets(accountId, owner, name) }),
});
}
export function useDeleteRepoSecret(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (key: string) => deleteRepoSecret(client!, owner, name, key),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoSecrets(accountId, owner, name) }),
});
}
export function useRepoVariables(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<ActionVariable[]>({
queryKey: queryKeys.repoVariables(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listRepoVariables(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function useCreateRepoVariable(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ key, value }: { key: string; value: string }) =>
createRepoVariable(client!, owner, name, key, value),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoVariables(accountId, owner, name),
}),
});
}
export function useDeleteRepoVariable(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (key: string) => deleteRepoVariable(client!, owner, name, key),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoVariables(accountId, owner, name),
}),
});
}
/** Read-only project list for the repository. */
export function useRepoProjects(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Project[]>({
queryKey: queryKeys.repoProjects(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listRepoProjects(client!, owner, name, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 60_000,
});
}
export function useOrgTeams(org: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Team[]>({
queryKey: [...queryKeys.account(accountId), 'org', org, 'teams'],
enabled: Boolean(client) && Boolean(accountId) && org.length > 0,
queryFn: ({ signal }) =>
listOrgTeams(client!, org, { limit: 50 }, { signal }).then((r) => r.data),
staleTime: 60_000,
});
}
// ---------------------------------------------------------------------------
// Labels & milestones (CRUD)
// ---------------------------------------------------------------------------
export function useCreateLabel(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: LabelInput) => createLabel(client!, owner, name, input),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoLabels(accountId, owner, name) }),
});
}
export function useUpdateLabel(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ id, input }: { id: number; input: Partial<LabelInput> }) =>
updateLabel(client!, owner, name, id, input),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoLabels(accountId, owner, name) }),
});
}
export function useDeleteLabel(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (id: number) => deleteLabel(client!, owner, name, id),
onSuccess: () =>
void queryClient.invalidateQueries({ queryKey: queryKeys.repoLabels(accountId, owner, name) }),
});
}
export function useMilestonesAll(owner: string, name: string) {
const { client, account } = useSession();
const accountId = account?.id ?? '';
return useQuery<Milestone[]>({
queryKey: queryKeys.repoMilestones(accountId, owner, name),
enabled: Boolean(client) && Boolean(accountId),
queryFn: ({ signal }) =>
listMilestones(client!, owner, name, { state: 'all', limit: 50 }, { signal }).then((r) => r.data),
staleTime: 30_000,
});
}
export function useCreateMilestone(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (input: MilestoneInput) => createMilestone(client!, owner, name, input),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoMilestones(accountId, owner, name),
}),
});
}
export function useUpdateMilestone(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ id, input }: { id: number; input: Partial<MilestoneInput> }) =>
updateMilestone(client!, owner, name, id, input),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoMilestones(accountId, owner, name),
}),
});
}
export function useDeleteMilestone(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: (id: number) => deleteMilestone(client!, owner, name, id),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.repoMilestones(accountId, owner, name),
}),
});
}
export function useSetWorkflowState(owner: string, name: string) {
const { client, account } = useSession();
const queryClient = useQueryClient();
const accountId = account?.id ?? '';
return useMutation({
mutationFn: ({ workflowId, enabled }: { workflowId: string; enabled: boolean }) =>
setWorkflowEnabled(client!, owner, name, workflowId, enabled),
onSuccess: () =>
void queryClient.invalidateQueries({
queryKey: queryKeys.actionsWorkflows(accountId, owner, name),
}),
});
}
@@ -1,5 +1,5 @@
import { useState } from 'react';
import { Linking, ScrollView, StyleSheet, View } from 'react-native';
import { Alert, Linking, ScrollView, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
@@ -11,14 +11,16 @@ import { ListItem } from '@/components/ui/list-item';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { ActionRunJob } from '@/core/api/types';
import { formatDateTime } from '@/core/utils/format';
import { formatBytes, formatDateTime } from '@/core/utils/format';
import {
useActionJobLogs,
useActionRun,
useActionRunControl,
useActionRunJobs,
useRunArtifacts,
} from '@/features/actions/queries';
import { useTheme } from '@/theme/theme-provider';
import { fontFamily, fontSize, spacing } from '@/theme/tokens';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
@@ -40,6 +42,8 @@ export function ActionRunDetailScreen({ route }: Props) {
const runQuery = useActionRun(owner, name, id);
const jobsQuery = useActionRunJobs(owner, name, id);
const control = useActionRunControl(owner, name, id);
const artifactsQuery = useRunArtifacts(owner, name, id);
if (runQuery.isPending) return <LoadingView />;
if (runQuery.isError) {
@@ -55,7 +59,12 @@ export function ActionRunDetailScreen({ route }: Props) {
const run = runQuery.data;
const jobs: ActionRunJob[] = jobsQuery.data ?? [];
const artifacts = artifactsQuery.data ?? [];
const state = run?.conclusion || run?.status || '';
const running = run?.status === 'running' || run?.status === 'waiting';
const canRerun = Boolean(run) && !running;
const reportError = (error: unknown) => Alert.alert(t('errors.title'), apiErrorMessage(error, t));
return (
<Screen scroll padded>
@@ -74,14 +83,37 @@ export function ActionRunDetailScreen({ route }: Props) {
</View>
</View>
{run?.html_url ? (
<Button
label={t('actions.openRun')}
variant="secondary"
iconLeft="externalLink"
onPress={() => void Linking.openURL(run.html_url as string).catch(() => undefined)}
/>
) : null}
<View style={styles.actions}>
{run?.html_url ? (
<Button
label={t('actions.openRun')}
variant="secondary"
size="md"
iconLeft="externalLink"
onPress={() => void Linking.openURL(run.html_url as string).catch(() => undefined)}
/>
) : null}
{canRerun ? (
<Button
label={t('actions.rerun')}
variant="secondary"
size="md"
iconLeft="refresh"
loading={control.rerun.isPending}
onPress={() => control.rerun.mutate(undefined, { onError: reportError })}
/>
) : null}
{running ? (
<Button
label={t('actions.cancel')}
variant="danger"
size="md"
iconLeft="close"
loading={control.cancel.isPending}
onPress={() => control.cancel.mutate(undefined, { onError: reportError })}
/>
) : null}
</View>
<AppText variant="subheading">{t('actions.jobs')}</AppText>
@@ -94,6 +126,30 @@ export function ActionRunDetailScreen({ route }: Props) {
) : (
jobs.map((job) => <JobRow key={job.id} owner={owner} name={name} job={job} />)
)}
{artifacts.length > 0 ? (
<>
<AppText variant="subheading">{t('actions.artifacts')}</AppText>
<Card padded={false} variant="flat">
{artifacts.map((artifact) => (
<ListItem
key={artifact.id}
leadingIcon="package"
title={artifact.name ?? ''}
subtitle={t('actions.artifactSize', {
size: formatBytes(artifact.size_in_bytes ?? 0),
})}
rightText={artifact.expired ? t('actions.expired') : undefined}
onPress={() =>
artifact.archive_download_url
? void Linking.openURL(artifact.archive_download_url).catch(() => undefined)
: undefined
}
/>
))}
</Card>
</>
) : null}
</Screen>
);
}
@@ -143,10 +199,10 @@ function JobRow({ owner, name, job }: { owner: string; name: string; job: Action
const styles = StyleSheet.create({
titleBlock: { gap: spacing.sm },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
actions: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
logs: {
paddingHorizontal: spacing.md,
paddingBottom: spacing.md,
maxHeight: 320,
},
logText: { fontFamily: fontFamily.mono, fontSize: fontSize.xs },
});
@@ -5,6 +5,7 @@ import { useTranslation } from 'react-i18next';
import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { Badge, type BadgeTone } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState } from '@/components/ui/state-views';
import type { ActionRun } from '@/core/api/types';
@@ -55,6 +56,15 @@ export function ActionsScreen({ navigation, route }: Props) {
{ value: 'running', label: t('actions.filterRunning') },
]}
/>
<View style={styles.settings}>
<Button
label={t('repoSettings.actionsSettings')}
variant="secondary"
iconLeft="gear"
fullWidth
onPress={() => navigation.navigate('ActionsSettings', { owner, name })}
/>
</View>
</View>
}
renderItem={(run) => {
@@ -91,6 +101,7 @@ export function ActionsScreen({ navigation, route }: Props) {
const styles = StyleSheet.create({
filters: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
settings: { marginTop: spacing.sm },
row: { paddingHorizontal: spacing.lg, paddingVertical: spacing.md, gap: spacing.xs },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm, flexWrap: 'wrap' },
});
@@ -0,0 +1,286 @@
import { useState } from 'react';
import { Alert, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { ChipSelect } from '@/components/ui/chip-select';
import { Field } from '@/components/ui/field';
import { ListItem } from '@/components/ui/list-item';
import { IconButton } from '@/components/ui/icon-button';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import {
useCreateRepoVariable,
useDeleteRepoSecret,
useDeleteRepoVariable,
usePutRepoSecret,
useRepoSecrets,
useRepoVariables,
useSetWorkflowState,
} from '@/features/repositories/settings-queries';
import { useDispatchWorkflow, useWorkflows } from '@/features/actions/queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'ActionsSettings'>;
/** Repository Actions secrets and variables (secrets are write-only). */
export function ActionsSettingsScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const secrets = useRepoSecrets(owner, name);
const variables = useRepoVariables(owner, name);
const putSecret = usePutRepoSecret(owner, name);
const deleteSecret = useDeleteRepoSecret(owner, name);
const createVariable = useCreateRepoVariable(owner, name);
const deleteVariable = useDeleteRepoVariable(owner, name);
const [secretName, setSecretName] = useState('');
const [secretValue, setSecretValue] = useState('');
const [varName, setVarName] = useState('');
const [varValue, setVarValue] = useState('');
const workflows = useWorkflows(owner, name);
const [selectedWorkflow, setSelectedWorkflow] = useState<string | null>(null);
const [dispatchRefName, setDispatchRefName] = useState('');
const dispatch = useDispatchWorkflow(owner, name, selectedWorkflow ?? '');
const setWorkflowState = useSetWorkflowState(owner, name);
if (secrets.isPending || variables.isPending) return <LoadingView />;
if (secrets.isError || variables.isError) {
const error = secrets.error ?? variables.error;
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(error, t)}
retryLabel={t('common.retry')}
onRetry={() => {
void secrets.refetch();
void variables.refetch();
}}
/>
);
}
const secretItems = secrets.data ?? [];
const variableItems = variables.data ?? [];
const addSecret = () => {
if (secretName.trim().length === 0 || secretValue.length === 0) return;
putSecret.mutate(
{ key: secretName.trim(), value: secretValue },
{
onSuccess: () => {
setSecretName('');
setSecretValue('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const addVariable = () => {
if (varName.trim().length === 0) return;
createVariable.mutate(
{ key: varName.trim(), value: varValue },
{
onSuccess: () => {
setVarName('');
setVarValue('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const confirmSecretDelete = (key: string) => {
Alert.alert(t('repoSettings.deleteSecretTitle'), t('repoSettings.deleteSecretBody', { name: key }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteSecret.mutate(key, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
const confirmVariableDelete = (key: string) => {
Alert.alert(t('repoSettings.deleteVariableTitle'), t('repoSettings.deleteVariableBody', { name: key }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteVariable.mutate(key, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
return (
<Screen scroll padded>
<AppText variant="subheading">{t('repoSettings.runWorkflow')}</AppText>
<Card>
<ChipSelect
options={(workflows.data ?? []).map((workflow) => ({
id: String(workflow.id),
label: workflow.name ?? workflow.path ?? '',
}))}
selectedIds={selectedWorkflow ? [selectedWorkflow] : []}
onToggle={(id) => setSelectedWorkflow(id)}
emptyLabel={t('repoSettings.noWorkflows')}
single
/>
<Field
label={t('repoSettings.ref')}
value={dispatchRefName}
onChangeText={setDispatchRefName}
placeholder="main"
autoCapitalize="none"
autoCorrect={false}
/>
<Button
label={t('repoSettings.dispatch')}
onPress={() =>
dispatch.mutate(
{ ref: dispatchRefName.trim() },
{ onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
)
}
loading={dispatch.isPending}
disabled={!selectedWorkflow || dispatchRefName.trim().length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{(workflows.data ?? []).length > 0 ? (
<>
<AppText variant="subheading">{t('repoSettings.workflows')}</AppText>
<Card padded={false} variant="flat">
{(workflows.data ?? []).map((workflow, index, all) => {
const enabled = workflow.state === 'active';
return (
<ListItem
key={workflow.id ?? workflow.path}
leadingIcon="autoRenew"
title={workflow.name ?? workflow.path ?? ''}
subtitle={workflow.path}
rightText={enabled ? t('repoSettings.enabled') : t('repoSettings.disabled')}
onPress={() =>
setWorkflowState.mutate(
{ workflowId: String(workflow.id), enabled: !enabled },
{ onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
)
}
divider={index < all.length - 1}
/>
);
})}
</Card>
</>
) : null}
<AppText variant="subheading">{t('repoSettings.secrets')}</AppText>
<Card>
<Field
label={t('repoSettings.secretName')}
value={secretName}
onChangeText={setSecretName}
autoCapitalize="none"
autoCorrect={false}
/>
<Field
label={t('repoSettings.secretValue')}
value={secretValue}
onChangeText={setSecretValue}
secureTextEntry
autoCapitalize="none"
/>
<Button
label={t('common.add')}
onPress={addSecret}
loading={putSecret.isPending}
disabled={secretName.trim().length === 0 || secretValue.length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{secretItems.map((secret) => (
<Card key={secret.name}>
<View style={styles.row}>
<AppText variant="bodyMedium" style={styles.name} numberOfLines={1}>
{secret.name}
</AppText>
<IconButton
name="trash"
onPress={() => confirmSecretDelete(secret.name ?? '')}
accessibilityLabel={t('common.delete')}
/>
</View>
</Card>
))}
<AppText variant="subheading">{t('repoSettings.variables')}</AppText>
<Card>
<Field
label={t('repoSettings.variableName')}
value={varName}
onChangeText={setVarName}
autoCapitalize="none"
autoCorrect={false}
/>
<Field
label={t('repoSettings.variableValue')}
value={varValue}
onChangeText={setVarValue}
autoCapitalize="none"
autoCorrect={false}
/>
<Button
label={t('common.add')}
onPress={addVariable}
loading={createVariable.isPending}
disabled={varName.trim().length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{variableItems.map((variable) => (
<Card key={variable.name}>
<View style={styles.row}>
<View style={styles.name}>
<AppText variant="bodyMedium" numberOfLines={1}>
{variable.name}
</AppText>
{variable.data ? (
<AppText variant="monoSmall" tone="tertiary" numberOfLines={1}>
{variable.data}
</AppText>
) : null}
</View>
<IconButton
name="trash"
onPress={() => confirmVariableDelete(variable.name ?? '')}
accessibilityLabel={t('common.delete')}
/>
</View>
</Card>
))}
</Screen>
);
}
const styles = StyleSheet.create({
spaced: { marginTop: spacing.md },
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.md },
name: { flex: 1 },
});
@@ -3,6 +3,7 @@ import { Alert, StyleSheet, Switch, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { CodeEditor, languageForPath } from '@/components/git/code-editor';
import { AppText } from '@/components/ui/app-text';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
@@ -170,15 +171,13 @@ function FileEditForm({ owner, name, path, initialRef, entry, repo, branches, on
) : null}
</View>
<TextArea
value={draft}
onChangeText={setDraft}
minHeight={360}
mono
autoCapitalize="none"
autoCorrect={false}
testID="file-editor"
/>
<View style={styles.editorWrap}>
<CodeEditor
value={draft}
onChangeText={setDraft}
language={languageForPath(path)}
/>
</View>
{branchProtected ? (
<AppText variant="caption" tone="warning">
@@ -285,6 +284,7 @@ function FileEditForm({ owner, name, path, initialRef, entry, repo, branches, on
const styles = StyleSheet.create({
toolbar: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
editorWrap: { height: 380, borderRadius: 10, overflow: 'hidden' },
pathLabel: { flex: 1 },
sectionLabel: { marginBottom: spacing.sm },
switchRow: {
@@ -0,0 +1,89 @@
import { useMemo, useState } from 'react';
import { Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { SearchBar } from '@/components/ui/search-bar';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useRepository, useRepoTree } from '@/features/repositories/queries';
import { fontFamily, spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'FindFile'>;
/** Find a file by path across the repository tree. */
export function FindFileScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name, ref } = route.params;
const repo = useRepository(owner, name);
const targetRef = ref ?? repo.data?.default_branch;
const tree = useRepoTree(owner, name, targetRef);
const [query, setQuery] = useState('');
const entries = useMemo(() => {
const all = tree.data?.entries ?? [];
const q = query.trim().toLowerCase();
return all
.filter((entry) => entry.type === 'blob' && (!q || (entry.path ?? '').toLowerCase().includes(q)))
.slice(0, 300);
}, [tree.data, query]);
return (
<Screen padded={false}>
<View style={styles.search}>
<SearchBar
value={query}
onChangeText={setQuery}
placeholder={t('files.findPlaceholder')}
/>
</View>
{tree.isPending ? (
<LoadingView />
) : tree.isError ? (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(tree.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void tree.refetch()}
/>
) : entries.length === 0 ? (
<AppText variant="secondary" tone="tertiary" style={styles.empty}>
{t('files.noMatches')}
</AppText>
) : (
entries.map((entry) => (
<Pressable
key={entry.path}
onPress={() =>
entry.path &&
navigation.navigate('FileViewer', { owner, name, path: entry.path, ref: targetRef })
}
accessibilityRole="button"
accessibilityLabel={entry.path}
style={styles.row}
>
<AppText variant="monoSmall" numberOfLines={1} style={styles.path}>
{entry.path}
</AppText>
</Pressable>
))
)}
</Screen>
);
}
const styles = StyleSheet.create({
search: { paddingHorizontal: spacing.lg, paddingVertical: spacing.sm },
row: {
paddingHorizontal: spacing.lg,
paddingVertical: spacing.md,
borderBottomWidth: StyleSheet.hairlineWidth,
borderBottomColor: 'rgba(128,128,128,0.2)',
},
path: { fontFamily: fontFamily.mono },
empty: { padding: spacing.xl, textAlign: 'center' },
});
@@ -1,4 +1,4 @@
import { StyleSheet, View } from 'react-native';
import { Linking, Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { CommentItem } from '@/components/git/comment';
@@ -12,6 +12,7 @@ import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Icon } from '@/components/ui/icon';
import { LabelChip } from '@/components/ui/label-chip';
import { ListItem } from '@/components/ui/list-item';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { safeHost } from '@/core/api/instance-url';
@@ -22,7 +23,12 @@ import {
useCreateIssueComment,
useDeleteIssueComment,
useIssue,
useIssueAttachments,
useIssueComments,
useIssueReactions,
useIssueSubscription,
useToggleIssueReaction,
useToggleIssueSubscription,
useUpdateIssue,
useUpdateIssueComment,
} from '@/features/issues/queries';
@@ -34,6 +40,17 @@ import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'IssueDetail'>;
const REACTION_EMOJI: Record<string, string> = {
'+1': '👍',
'-1': '👎',
laugh: '😄',
hooray: '🎉',
confused: '😕',
heart: '❤️',
rocket: '🚀',
eyes: '👀',
};
/** Full issue view: state, author, labels, milestone, body, comments and composer. */
export function IssueDetailScreen({ navigation, route }: Props) {
const { t } = useTranslation();
@@ -48,6 +65,11 @@ export function IssueDetailScreen({ navigation, route }: Props) {
const createComment = useCreateIssueComment(owner, name, index);
const updateComment = useUpdateIssueComment(owner, name, index);
const deleteComment = useDeleteIssueComment(owner, name, index);
const reactionsQuery = useIssueReactions(owner, name, index);
const toggleReaction = useToggleIssueReaction(owner, name, index);
const attachmentsQuery = useIssueAttachments(owner, name, index);
const subscription = useIssueSubscription(owner, name, index, account?.login);
const toggleSubscription = useToggleIssueSubscription(owner, name, index, account?.login);
if (query.isPending) return <LoadingView />;
if (query.isError) {
@@ -103,6 +125,16 @@ export function IssueDetailScreen({ navigation, route }: Props) {
loading={updateIssue.isPending}
onPress={toggleState}
/>
{account?.login ? (
<Button
label={subscription.data?.subscribed ? t('issues.unsubscribe') : t('issues.subscribe')}
variant="secondary"
size="md"
iconLeft="bell"
loading={toggleSubscription.isPending}
onPress={() => toggleSubscription.mutate(subscription.data?.subscribed ?? false)}
/>
) : null}
</View>
<View style={styles.authorRow}>
@@ -153,11 +185,59 @@ export function IssueDetailScreen({ navigation, route }: Props) {
/>
</View>
{/* Reactions */}
<View style={styles.reactions}>
{Object.entries(REACTION_EMOJI).map(([content, emoji]) => {
const list = (reactionsQuery.data ?? []).filter((reaction) => reaction.content === content);
const mine = list.some((reaction) => reaction.user?.login === account?.login);
return (
<Pressable
key={content}
onPress={() => toggleReaction.mutate({ content, mine })}
accessibilityRole="button"
accessibilityLabel={content}
style={[
styles.reactionChip,
{
borderColor: mine ? colors.primary : colors.border,
backgroundColor: mine ? colors.primaryMuted : colors.surface,
},
]}
>
<AppText variant="caption">{emoji}</AppText>
{list.length > 0 ? (
<AppText variant="caption" tone={mine ? 'primary' : 'tertiary'}>
{list.length}
</AppText>
) : null}
</Pressable>
);
})}
</View>
{/* Attachments */}
{attachmentsQuery.data && attachmentsQuery.data.length > 0 ? (
<Card padded={false} variant="flat">
{attachmentsQuery.data.map((attachment, attachmentIndex) => (
<ListItem
key={attachment.id ?? attachment.name ?? attachmentIndex}
leadingIcon="file"
title={attachment.name ?? ''}
onPress={() =>
attachment.browser_download_url
? void Linking.openURL(attachment.browser_download_url).catch(() => undefined)
: undefined
}
divider={attachmentIndex < (attachmentsQuery.data?.length ?? 0) - 1}
/>
))}
</Card>
) : null}
{/* Comments */}
<AppText variant="subheading" style={styles.sectionTitle}>
{t('comments.title')}
</AppText>
{commentsQuery.isPending ? (
<LoadingView label={t('comments.loading')} />
) : commentsQuery.isError ? (
@@ -234,5 +314,16 @@ const styles = StyleSheet.create({
bodyCard: { minHeight: 80 },
metaGrid: { gap: spacing.sm },
metaRow: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
reactions: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
reactionChip: {
flexDirection: 'row',
alignItems: 'center',
gap: spacing.xs,
borderWidth: 1,
borderRadius: 999,
paddingHorizontal: spacing.sm,
paddingVertical: 2,
minHeight: 32,
},
sectionTitle: { marginTop: spacing.md },
});
@@ -0,0 +1,172 @@
import { useState } from 'react';
import { Alert, Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Field } from '@/components/ui/field';
import { IconButton } from '@/components/ui/icon-button';
import { LabelChip } from '@/components/ui/label-chip';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { Label } from '@/core/api/types';
import { useRepoLabels } from '@/features/issues/queries';
import {
useCreateLabel,
useDeleteLabel,
useUpdateLabel,
} from '@/features/repositories/settings-queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Labels'>;
/** Repository labels: create, rename/recolor, delete. */
export function LabelsScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const query = useRepoLabels(owner, name);
const createLabel = useCreateLabel(owner, name);
const updateLabel = useUpdateLabel(owner, name);
const deleteLabel = useDeleteLabel(owner, name);
const [labelName, setLabelName] = useState('');
const [color, setColor] = useState('#609926');
const [editingId, setEditingId] = useState<number | null>(null);
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
const labels: Label[] = query.data ?? [];
const submit = () => {
const input = { name: labelName.trim(), color: color.replace('#', '') };
if (!input.name) return;
if (editingId != null) {
updateLabel.mutate(
{ id: editingId, input },
{
onSuccess: () => {
setEditingId(null);
setLabelName('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
} else {
createLabel.mutate(input, {
onSuccess: () => setLabelName(''),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
});
}
};
const confirmDelete = (label: Label) => {
if (!label.id) return;
Alert.alert(t('repoSettings.deleteLabelTitle'), t('repoSettings.deleteLabelBody', { name: label.name }), [
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteLabel.mutate(label.id as number, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
]);
};
const startEdit = (label: Label) => {
setEditingId(label.id ?? null);
setLabelName(label.name);
setColor(`#${label.color ?? '609926'}`);
};
return (
<Screen scroll padded>
<Card>
<Field
label={t('labels.name')}
value={labelName}
onChangeText={setLabelName}
autoCapitalize="none"
autoCorrect={false}
/>
<View style={styles.colorRow}>
<View style={[styles.swatch, { backgroundColor: color }]} />
<Field label={t('labels.color')} value={color} onChangeText={setColor} autoCapitalize="none" mono />
</View>
<Button
label={editingId != null ? t('common.save') : t('common.add')}
onPress={submit}
loading={createLabel.isPending || updateLabel.isPending}
disabled={labelName.trim().length === 0}
fullWidth
style={styles.spaced}
/>
{editingId != null ? (
<Button
label={t('common.cancel')}
variant="ghost"
onPress={() => {
setEditingId(null);
setLabelName('');
}}
fullWidth
/>
) : null}
</Card>
{labels.length === 0 ? (
<EmptyState icon="tag" title={t('labels.empty')} />
) : (
labels.map((label) => (
<Card key={label.id ?? label.name}>
<View style={styles.row}>
<LabelChip name={label.name} color={label.color} />
<AppText variant="caption" tone="tertiary" numberOfLines={1} style={styles.desc}>
{label.description ?? ''}
</AppText>
<Pressable
onPress={() => startEdit(label)}
accessibilityRole="button"
accessibilityLabel={t('common.edit')}
hitSlop={8}
>
<AppText variant="caption" tone="link">
{t('common.edit')}
</AppText>
</Pressable>
<IconButton
name="trash"
onPress={() => confirmDelete(label)}
accessibilityLabel={t('common.delete')}
/>
</View>
</Card>
))
)}
</Screen>
);
}
const styles = StyleSheet.create({
colorRow: { flexDirection: 'row', alignItems: 'flex-end', gap: spacing.sm },
swatch: { width: 32, height: 32, borderRadius: 6, marginBottom: spacing.md },
spaced: { marginTop: spacing.md },
row: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
desc: { flex: 1 },
});
@@ -0,0 +1,166 @@
import { useState } from 'react';
import { Alert, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Field } from '@/components/ui/field';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import type { Milestone } from '@/core/api/types';
import {
useCreateMilestone,
useDeleteMilestone,
useMilestonesAll,
useUpdateMilestone,
} from '@/features/repositories/settings-queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Milestones'>;
/** Repository milestones: create, close/reopen, delete. */
export function MilestonesScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const query = useMilestonesAll(owner, name);
const createMilestone = useCreateMilestone(owner, name);
const updateMilestone = useUpdateMilestone(owner, name);
const deleteMilestone = useDeleteMilestone(owner, name);
const [title, setTitle] = useState('');
const [dueOn, setDueOn] = useState('');
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
const milestones: Milestone[] = query.data ?? [];
const submit = () => {
if (title.trim().length === 0) return;
createMilestone.mutate(
{ title: title.trim(), due_on: dueOn.trim() || undefined },
{
onSuccess: () => {
setTitle('');
setDueOn('');
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
const toggleState = (milestone: Milestone) => {
if (!milestone.id) return;
updateMilestone.mutate({
id: milestone.id,
input: { state: milestone.state === 'closed' ? 'open' : 'closed' },
});
};
const confirmDelete = (milestone: Milestone) => {
if (!milestone.id) return;
Alert.alert(
t('repoSettings.deleteMilestoneTitle'),
t('repoSettings.deleteMilestoneBody', { name: milestone.title }),
[
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteMilestone.mutate(milestone.id as number, {
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
],
);
};
return (
<Screen scroll padded>
<Card>
<Field
label={t('milestones.titleLabel')}
value={title}
onChangeText={setTitle}
autoCapitalize="sentences"
/>
<Field
label={`${t('milestones.dueOn')} (${t('common.optional')})`}
value={dueOn}
onChangeText={setDueOn}
placeholder="2026-12-31T00:00:00Z"
autoCapitalize="none"
autoCorrect={false}
/>
<Button
label={t('common.add')}
onPress={submit}
loading={createMilestone.isPending}
disabled={title.trim().length === 0}
fullWidth
style={styles.spaced}
/>
</Card>
{milestones.length === 0 ? (
<EmptyState icon="tag" title={t('milestones.empty')} />
) : (
milestones.map((milestone) => (
<Card key={milestone.id ?? milestone.title}>
<View style={styles.header}>
<AppText variant="bodyMedium" style={styles.title} numberOfLines={1}>
{milestone.title}
</AppText>
<Badge tone={milestone.state === 'closed' ? 'neutral' : 'success'}>
{milestone.state === 'closed' ? t('milestones.closed') : t('milestones.open')}
</Badge>
</View>
<AppText variant="caption" tone="tertiary">
{t('milestones.progress', {
open: milestone.open_issues ?? 0,
closed: milestone.closed_issues ?? 0,
})}
</AppText>
<View style={styles.actions}>
<Button
label={milestone.state === 'closed' ? t('issues.reopen') : t('issues.close')}
variant="secondary"
size="md"
onPress={() => toggleState(milestone)}
/>
<Button
label={t('common.delete')}
variant="ghost"
size="md"
onPress={() => confirmDelete(milestone)}
/>
</View>
</Card>
))
)}
</Screen>
);
}
const styles = StyleSheet.create({
spaced: { marginTop: spacing.md },
header: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
title: { flex: 1, fontWeight: '600' },
actions: { flexDirection: 'row', gap: spacing.sm, marginTop: spacing.sm },
});
@@ -0,0 +1,80 @@
import { Linking, Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Badge } from '@/components/ui/badge';
import { Card } from '@/components/ui/card';
import { EmptyState, ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useRepoProjects } from '@/features/repositories/settings-queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'Projects'>;
/** Repository projects (read-only list). */
export function ProjectsScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const query = useRepoProjects(owner, name);
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
<ErrorState
title={t('errors.title')}
body={apiErrorMessage(query.error, t)}
retryLabel={t('common.retry')}
onRetry={() => void query.refetch()}
/>
);
}
const projects = query.data ?? [];
if (projects.length === 0) return <EmptyState icon="dashboard" title={t('projects.empty')} />;
return (
<Screen scroll padded>
{projects.map((project) => (
<Card key={project.id}>
<Pressable
onPress={() =>
project.html_url
? void Linking.openURL(project.html_url).catch(() => undefined)
: undefined
}
accessibilityRole="button"
accessibilityLabel={project.title}
>
<View style={styles.header}>
<AppText variant="bodyMedium" style={styles.title} numberOfLines={1}>
{project.title}
</AppText>
<Badge tone={project.is_closed ? 'neutral' : 'success'}>
{project.is_closed ? t('projects.closed') : t('projects.open')}
</Badge>
</View>
{project.description ? (
<AppText variant="caption" tone="tertiary" numberOfLines={2}>
{project.description}
</AppText>
) : null}
<AppText variant="caption" tone="tertiary">
{t('projects.issues', {
open: project.num_open_issues ?? 0,
closed: project.num_closed_issues ?? 0,
})}
</AppText>
</Pressable>
</Card>
))}
</Screen>
);
}
const styles = StyleSheet.create({
header: { flexDirection: 'row', alignItems: 'center', gap: spacing.sm },
title: { flex: 1, fontWeight: '600' },
});
@@ -4,6 +4,7 @@ import { useTranslation } from 'react-i18next';
import { CommentItem } from '@/components/git/comment';
import { CommentComposer } from '@/components/git/comment-composer';
import { Markdown } from '@/components/git/markdown';
import { ReviewComments } from '@/components/git/review-comments';
import { StatusChecks } from '@/components/git/status-checks';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
@@ -272,6 +273,15 @@ export function PullDetailScreen({ navigation, route }: Props) {
{review.body && review.body.trim().length > 0 ? (
<Markdown content={review.body} baseUrl={instance?.baseUrl} />
) : null}
{review.id && (review.comments_count ?? 0) > 0 ? (
<ReviewComments
owner={owner}
name={name}
index={index}
reviewId={review.id}
baseUrl={instance?.baseUrl}
/>
) : null}
</Card>
))}
</>
@@ -1,20 +1,33 @@
import { useState } from 'react';
import { Alert, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { DiffView } from '@/components/git/diff';
import { Screen } from '@/components/layout/screen';
import { AppText } from '@/components/ui/app-text';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { TextArea } from '@/components/ui/text-area';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { usePullDiff } from '@/features/issues/queries';
import { useCreatePullReview, usePull, usePullDiff } from '@/features/issues/queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'PullDiff'>;
/** Native unified diff for a pull request (all files, or a single `path`). */
/** Native unified diff for a pull request (all files, or a single `path`).
* Tapping a line opens an inline review-comment composer. */
export function PullDiffScreen({ route }: Props) {
const { t } = useTranslation();
const { owner, name, index, path } = route.params;
const query = usePullDiff(owner, name, index);
const pull = usePull(owner, name, index);
const createReview = useCreatePullReview(owner, name, index);
const [target, setTarget] = useState<{ path: string; position: number } | null>(null);
const [body, setBody] = useState('');
if (query.isPending) return <LoadingView label={t('pulls.loadingDiff')} />;
if (query.isError) {
@@ -28,9 +41,74 @@ export function PullDiffScreen({ route }: Props) {
);
}
const submit = () => {
if (!target || body.trim().length === 0) return;
createReview.mutate(
{
event: 'COMMENT',
commitId: pull.data?.head?.sha,
comments: [{ path: target.path, new_position: target.position, body: body.trim() }],
},
{
onSuccess: () => {
setTarget(null);
setBody('');
Alert.alert(t('pulls.inlineCommentAddedTitle'), t('pulls.inlineCommentAddedBody'));
},
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
},
);
};
return (
<Screen padded={false} scroll={false}>
<DiffView raw={query.data ?? ''} pathFilter={path} emptyLabel={t('pulls.noChanges')} />
<DiffView
raw={query.data ?? ''}
pathFilter={path}
emptyLabel={t('pulls.noChanges')}
onLinePress={(filePath, position) => {
setTarget({ path: filePath, position });
setBody('');
}}
/>
{target ? (
<Card style={styles.composer}>
<AppText variant="caption" tone="tertiary" numberOfLines={1}>
<AppText variant="monoSmall" tone="tertiary">
{target.path}
</AppText>
{` : ${target.position}`}
</AppText>
<TextArea
value={body}
onChangeText={setBody}
placeholder={t('pulls.inlineCommentPlaceholder')}
minHeight={72}
autoFocus
/>
<View style={styles.composerActions}>
<Button
label={t('common.cancel')}
variant="ghost"
size="md"
onPress={() => setTarget(null)}
/>
<Button
label={t('pulls.inlineCommentSubmit')}
size="md"
loading={createReview.isPending}
disabled={body.trim().length === 0}
onPress={submit}
/>
</View>
</Card>
) : null}
</Screen>
);
}
const styles = StyleSheet.create({
composer: { gap: spacing.sm, borderTopWidth: StyleSheet.hairlineWidth, borderTopColor: 'rgba(128,128,128,0.3)' },
composerActions: { flexDirection: 'row', justifyContent: 'flex-end', gap: spacing.sm },
});
@@ -1,5 +1,6 @@
import { Alert, Linking, Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import * as DocumentPicker from 'expo-document-picker';
import { Markdown } from '@/components/git/markdown';
import { Screen } from '@/components/layout/screen';
@@ -9,10 +10,16 @@ import { Badge } from '@/components/ui/badge';
import { Button } from '@/components/ui/button';
import { Card } from '@/components/ui/card';
import { Icon } from '@/components/ui/icon';
import { IconButton } from '@/components/ui/icon-button';
import { ErrorState, LoadingView } from '@/components/ui/state-views';
import { apiErrorMessage } from '@/core/api/error-text';
import { useSession } from '@/features/accounts/use-session';
import { useDeleteRelease, useRelease } from '@/features/repositories/queries';
import {
useDeleteRelease,
useDeleteReleaseAsset,
useRelease,
useUploadReleaseAsset,
} from '@/features/repositories/queries';
import { formatBytes, formatDateTime } from '@/core/utils/format';
import { useTheme } from '@/theme/theme-provider';
import { spacing } from '@/theme/tokens';
@@ -30,8 +37,24 @@ export function ReleaseDetailScreen({ navigation, route }: Props) {
const query = useRelease(owner, name, id);
const deleteRelease = useDeleteRelease(owner, name, id);
const uploadAsset = useUploadReleaseAsset(owner, name, id);
const deleteAsset = useDeleteReleaseAsset(owner, name, id);
const release = query.data;
const pickAndUpload = async () => {
const result = await DocumentPicker.getDocumentAsync({ copyToCacheDirectory: true });
if (result.canceled || !result.assets || result.assets.length === 0) return;
const file = result.assets[0];
uploadAsset.mutate(
{
uri: file.uri,
name: file.name,
type: file.mimeType ?? 'application/octet-stream',
},
{ onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)) },
);
};
if (query.isPending) return <LoadingView />;
if (query.isError) {
return (
@@ -79,35 +102,71 @@ export function ReleaseDetailScreen({ navigation, route }: Props) {
<AppText variant="subheading">{t('releases.assets')}</AppText>
<Card padded={false} variant="flat">
{assets.map((asset, index) => (
<Pressable
<View
key={asset.id ?? asset.name ?? index}
onPress={() =>
asset.browser_download_url
? void Linking.openURL(asset.browser_download_url).catch(() => undefined)
: undefined
}
accessibilityRole="button"
accessibilityLabel={asset.name}
style={[styles.assetRow, index < assets.length - 1 && styles.divider]}
>
<Icon name="download" size={18} color={colors.textTertiary} />
<View style={styles.assetBody}>
<AppText variant="bodyMedium" numberOfLines={1}>
{asset.name}
</AppText>
<AppText variant="caption" tone="tertiary">
{t('releases.downloads', {
size: formatBytes(asset.size ?? 0),
count: asset.download_count ?? 0,
})}
</AppText>
</View>
</Pressable>
<Pressable
onPress={() =>
asset.browser_download_url
? void Linking.openURL(asset.browser_download_url).catch(() => undefined)
: undefined
}
accessibilityRole="button"
accessibilityLabel={asset.name}
style={styles.assetMain}
>
<Icon name="download" size={18} color={colors.textTertiary} />
<View style={styles.assetBody}>
<AppText variant="bodyMedium" numberOfLines={1}>
{asset.name}
</AppText>
<AppText variant="caption" tone="tertiary">
{t('releases.downloads', {
size: formatBytes(asset.size ?? 0),
count: asset.download_count ?? 0,
})}
</AppText>
</View>
</Pressable>
{asset.id ? (
<IconButton
name="trash"
onPress={() =>
Alert.alert(
t('releases.deleteAssetTitle'),
t('releases.deleteAssetBody', { name: asset.name ?? '' }),
[
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('common.delete'),
style: 'destructive',
onPress: () =>
deleteAsset.mutate(asset.id as number, {
onError: (error) =>
Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
],
)
}
accessibilityLabel={t('common.delete')}
/>
) : null}
</View>
))}
</Card>
</>
) : null}
<Button
label={t('releases.uploadAsset')}
variant="secondary"
iconLeft="plus"
loading={uploadAsset.isPending}
onPress={() => void pickAndUpload()}
/>
{release.html_url ? (
<Button
label={t('repo.viewOnInstance')}
@@ -161,6 +220,7 @@ const styles = StyleSheet.create({
paddingHorizontal: spacing.lg,
paddingVertical: spacing.md,
},
assetMain: { flex: 1, flexDirection: 'row', alignItems: 'center', gap: spacing.md },
divider: { borderBottomWidth: StyleSheet.hairlineWidth, borderBottomColor: 'rgba(128,128,128,0.25)' },
assetBody: { flex: 1, gap: 2 },
actions: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm },
@@ -1,16 +1,17 @@
import { useState } from 'react';
import { StyleSheet, View } from 'react-native';
import { useMemo, useState } from 'react';
import { Pressable, StyleSheet, View } from 'react-native';
import { useTranslation } from 'react-i18next';
import { IssueRow } from '@/components/git/issue-row';
import { QueryList } from '@/components/layout/query-list';
import { AppText } from '@/components/ui/app-text';
import { Button } from '@/components/ui/button';
import { SearchBar } from '@/components/ui/search-bar';
import { SegmentedControl } from '@/components/ui/segmented';
import { EmptyState } from '@/components/ui/state-views';
import type { Issue } from '@/core/api/types';
import { flattenPages } from '@/core/utils/infinite';
import { useRepoIssues } from '@/features/issues/queries';
import { useMilestones, useRepoIssues, useRepoLabels } from '@/features/issues/queries';
import { spacing } from '@/theme/tokens';
import type { RepositoryStackParamList } from '@/navigation/types';
import type { ScreenProps } from '@/navigation/typing';
@@ -18,52 +19,159 @@ import type { ScreenProps } from '@/navigation/typing';
type Props = ScreenProps<RepositoryStackParamList, 'RepoIssues'>;
type StateKey = 'open' | 'closed' | 'all';
type SortKey = 'updated' | 'created' | 'comments';
/** Issues scoped to one repository. */
/** Issues scoped to one repository, with label/milestone filters and sorting. */
export function RepoIssuesScreen({ navigation, route }: Props) {
const { t } = useTranslation();
const { owner, name } = route.params;
const [state, setState] = useState<StateKey>('open');
const [search, setSearch] = useState('');
const [selectedLabels, setSelectedLabels] = useState<string[]>([]);
const [milestone, setMilestone] = useState<string | null>(null);
const [sort, setSort] = useState<SortKey>('updated');
const [showFilters, setShowFilters] = useState(false);
const query = useRepoIssues(owner, name, state, search);
const issues: Issue[] = flattenPages(query.data);
const labelsQuery = useRepoLabels(owner, name);
const milestonesQuery = useMilestones(owner, name);
const query = useRepoIssues(owner, name, state, search, {
labels: selectedLabels.join(','),
milestones: milestone ?? undefined,
});
const rawIssues: Issue[] = flattenPages(query.data);
const issues = useMemo(() => {
const sorted = [...rawIssues];
switch (sort) {
case 'created':
sorted.sort((a, b) => (b.created_at ?? '').localeCompare(a.created_at ?? ''));
break;
case 'comments':
sorted.sort((a, b) => (b.comments ?? 0) - (a.comments ?? 0));
break;
case 'updated':
default:
sorted.sort((a, b) => (b.updated_at ?? '').localeCompare(a.updated_at ?? ''));
}
return sorted;
}, [rawIssues, sort]);
const toggleLabel = (label: string) =>
setSelectedLabels((prev) =>
prev.includes(label) ? prev.filter((x) => x !== label) : [...prev, label],
);
const header = (
<View>
<SearchBar
value={search}
onChangeText={setSearch}
placeholder={t('issues.searchPlaceholder')}
/>
<View style={styles.filters}>
<SegmentedControl<StateKey>
value={state}
onChange={setState}
accessibilityLabel={t('issues.title')}
options={[
{ value: 'open', label: t('issues.stateOpen') },
{ value: 'closed', label: t('issues.stateClosed') },
{ value: 'all', label: t('issues.stateAll') },
]}
/>
<SegmentedControl<SortKey>
value={sort}
onChange={setSort}
accessibilityLabel={t('issues.sort')}
options={[
{ value: 'updated', label: t('issues.sortUpdated') },
{ value: 'created', label: t('issues.sortCreated') },
{ value: 'comments', label: t('issues.sortComments') },
]}
/>
</View>
<View style={styles.filterToggle}>
<Button
label={showFilters ? t('issues.hideFilters') : t('issues.showFilters')}
variant="ghost"
size="md"
iconLeft="sortByDate"
onPress={() => setShowFilters((value) => !value)}
/>
</View>
{showFilters ? (
<View style={styles.filters}>
{(labelsQuery.data ?? []).length > 0 ? (
<View>
<AppText variant="label" tone="secondary">
{t('issues.labels')}
</AppText>
<View style={styles.chips}>
{(labelsQuery.data ?? []).map((label) => {
const active = selectedLabels.includes(label.name);
return (
<Pressable
key={label.id ?? label.name}
onPress={() => toggleLabel(label.name)}
accessibilityRole="checkbox"
accessibilityState={{ selected: active }}
style={[styles.chip, active && styles.chipActive]}
>
<AppText variant="caption" tone={active ? 'primary' : 'secondary'}>
{label.name}
</AppText>
</Pressable>
);
})}
</View>
</View>
) : null}
{(milestonesQuery.data ?? []).length > 0 ? (
<View>
<AppText variant="label" tone="secondary">
{t('issues.milestone')}
</AppText>
<View style={styles.chips}>
{(milestonesQuery.data ?? []).map((item) => {
const active = milestone === item.title;
return (
<Pressable
key={item.id ?? item.title}
onPress={() => setMilestone(active ? null : item.title)}
accessibilityRole="radio"
accessibilityState={{ selected: active }}
style={[styles.chip, active && styles.chipActive]}
>
<AppText variant="caption" tone={active ? 'primary' : 'secondary'}>
{item.title}
</AppText>
</Pressable>
);
})}
</View>
</View>
) : null}
</View>
) : null}
<View style={styles.newIssue}>
<Button
label={t('issues.compose.createTitle')}
variant="secondary"
iconLeft="plus"
fullWidth
onPress={() => navigation.navigate('IssueCompose', { owner, name })}
/>
</View>
</View>
);
return (
<QueryList<Issue>
query={query}
items={issues}
keyExtractor={(issue) => String(issue.id)}
header={
<View>
<SearchBar
value={search}
onChangeText={setSearch}
placeholder={t('issues.searchPlaceholder')}
/>
<View style={styles.filters}>
<SegmentedControl<StateKey>
value={state}
onChange={setState}
accessibilityLabel={t('issues.title')}
options={[
{ value: 'open', label: t('issues.stateOpen') },
{ value: 'closed', label: t('issues.stateClosed') },
{ value: 'all', label: t('issues.stateAll') },
]}
/>
</View>
<View style={styles.newIssue}>
<Button
label={t('issues.compose.createTitle')}
variant="secondary"
iconLeft="plus"
fullWidth
onPress={() => navigation.navigate('IssueCompose', { owner, name })}
/>
</View>
</View>
}
header={header}
renderItem={(issue) => (
<IssueRow
issue={issue}
@@ -76,6 +184,16 @@ export function RepoIssuesScreen({ navigation, route }: Props) {
}
const styles = StyleSheet.create({
filters: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
filters: { gap: spacing.sm, paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
filterToggle: { paddingHorizontal: spacing.lg },
chips: { flexDirection: 'row', flexWrap: 'wrap', gap: spacing.sm, marginTop: spacing.xs },
chip: {
borderWidth: 1,
borderColor: 'rgba(128,128,128,0.4)',
borderRadius: 999,
paddingHorizontal: spacing.md,
paddingVertical: 2,
},
chipActive: { borderColor: '#609926', backgroundColor: 'rgba(96,153,38,0.14)' },
newIssue: { paddingHorizontal: spacing.lg, paddingBottom: spacing.sm },
});
@@ -205,6 +205,11 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
title={t('repo.files')}
onPress={() => navigation.navigate('Files', { owner, name, ref: readmeRef })}
/>
<ListItem
leadingIcon="search"
title={t('files.findFile')}
onPress={() => navigation.navigate('FindFile', { owner, name, ref: readmeRef })}
/>
<ListItem
leadingIcon="commit"
title={t('repo.commits')}
@@ -241,6 +246,13 @@ export function RepoOverviewScreen({ navigation, route }: Props) {
onPress={() => navigation.navigate('Actions', { owner, name })}
/>
) : null}
{repo.has_projects !== false ? (
<ListItem
leadingIcon="dashboard"
title={t('projects.title')}
onPress={() => navigation.navigate('Projects', { owner, name })}
/>
) : null}
{repo.has_issues !== false ? (
<ListItem
leadingIcon="issue"
@@ -13,6 +13,7 @@ import { apiErrorMessage } from '@/core/api/error-text';
import { useRepository } from '@/features/repositories/queries';
import {
useDeleteRepo,
useTransferRepo,
useUpdateRepo,
} from '@/features/repositories/settings-queries';
import { useTheme } from '@/theme/theme-provider';
@@ -41,6 +42,8 @@ export function RepoSettingsScreen({ navigation, route }: Props) {
const repo = repoQuery.data;
const updateRepo = useUpdateRepo(owner, name);
const deleteRepo = useDeleteRepo(owner, name);
const transferRepo = useTransferRepo(owner, name);
const [newOwner, setNewOwner] = useState('');
const [description, setDescription] = useState<string | null>(null);
const [website, setWebsite] = useState<string | null>(null);
@@ -182,10 +185,59 @@ export function RepoSettingsScreen({ navigation, route }: Props) {
leadingIcon="lock"
title={t('repoSettings.deployKeys')}
onPress={() => navigation.navigate('DeployKeys', { owner, name })}
/>
<ListItem
leadingIcon="tag"
title={t('labels.title')}
onPress={() => navigation.navigate('Labels', { owner, name })}
/>
<ListItem
leadingIcon="dashboard"
title={t('milestones.title')}
onPress={() => navigation.navigate('Milestones', { owner, name })}
divider={false}
/>
</Card>
<AppText variant="subheading">{t('repoSettings.transfer')}</AppText>
<Card>
<Field
label={t('repoSettings.newOwner')}
value={newOwner}
onChangeText={setNewOwner}
placeholder={t('repoSettings.newOwnerPlaceholder')}
autoCapitalize="none"
autoCorrect={false}
/>
<Button
label={t('repoSettings.transferAction')}
variant="secondary"
iconLeft="arrowLeft"
disabled={newOwner.trim().length === 0}
loading={transferRepo.isPending}
onPress={() =>
Alert.alert(
t('repoSettings.transferTitle'),
t('repoSettings.transferBody', { name, owner: newOwner.trim() }),
[
{ text: t('common.cancel'), style: 'cancel' },
{
text: t('repoSettings.transferAction'),
style: 'destructive',
onPress: () =>
transferRepo.mutate(newOwner.trim(), {
onSuccess: () => navigation.getParent()?.goBack(),
onError: (error) => Alert.alert(t('errors.title'), apiErrorMessage(error, t)),
}),
},
],
)
}
fullWidth
style={styles.spaced}
/>
</Card>
<AppText variant="subheading" tone="error">
{t('repoSettings.dangerZone')}
</AppText>
@@ -15,6 +15,7 @@ import { queryClient } from '@/core/api/query-client';
import type { BiometricSupport } from '@/core/security/biometrics';
import { getBiometricSupport } from '@/core/security/biometrics';
import { useSettingsStore, type ThemePreference } from '@/features/settings/settings-store';
import { useCurrentUser } from '@/features/profile/queries';
import { useRootNavigation } from '@/navigation/use-root-navigation';
import type { LanguagePreference } from '@/i18n';
import { useTheme } from '@/theme/theme-provider';
@@ -45,6 +46,7 @@ export function SettingsScreen(_props: Props) {
const setNotificationPollSeconds = useSettingsStore((s) => s.setNotificationPollSeconds);
const editorUrlTemplate = useSettingsStore((s) => s.editorUrlTemplate);
const setEditorUrlTemplate = useSettingsStore((s) => s.setEditorUrlTemplate);
const currentUser = useCurrentUser();
const [support, setSupport] = useState<BiometricSupport | null>(null);
@@ -215,8 +217,16 @@ export function SettingsScreen(_props: Props) {
leadingIcon="lock"
title={t('credentials.title')}
onPress={() => stackNavigation.navigate('Credentials')}
divider={false}
divider={currentUser.data?.is_admin ? true : false}
/>
{currentUser.data?.is_admin ? (
<ListItem
leadingIcon="shield"
title={t('admin.title')}
onPress={() => stackNavigation.navigate('Admin')}
divider={false}
/>
) : null}
</Card>
</Section>
+103 -7
View File
@@ -183,7 +183,10 @@
"submodule": "Submodule",
"symlink": "Symlink to {{target}}",
"currentRef": "Branch: {{ref}}",
"pathNotFound": "This path does not exist in the repository."
"pathNotFound": "This path does not exist in the repository.",
"findFile": "Find file",
"findPlaceholder": "Search files by path",
"noMatches": "No matching files"
},
"commits": {
"title": "Commits",
@@ -236,6 +239,14 @@
"milestone": "Milestone",
"noDescription": "No description provided",
"notFound": "This issue could not be found.",
"subscribe": "Subscribe",
"unsubscribe": "Unsubscribe",
"sort": "Sort",
"sortUpdated": "Recently updated",
"sortCreated": "Recently created",
"sortComments": "Most comments",
"showFilters": "Filters",
"hideFilters": "Hide filters",
"reopen": "Reopen",
"close": "Close",
"compose": {
@@ -312,7 +323,11 @@
"body": "Review comment",
"placeholder": "Write your review…",
"submit": "Submit review"
}
},
"inlineCommentPlaceholder": "Comment on this line…",
"inlineCommentSubmit": "Comment",
"inlineCommentAddedTitle": "Comment added",
"inlineCommentAddedBody": "Your inline review comment was posted."
},
"comments": {
"title": "Comments",
@@ -341,7 +356,10 @@
"edit": "Edit release",
"tagRequired": "A tag is required.",
"deleteTitle": "Delete release?",
"deleteBody": "Release {{tag}} will be deleted."
"deleteBody": "Release {{tag}} will be deleted.",
"uploadAsset": "Upload asset",
"deleteAssetTitle": "Delete asset?",
"deleteAssetBody": "{{name}} will be deleted."
},
"actions": {
"title": "Actions",
@@ -366,7 +384,12 @@
"hideLogs": "Hide",
"loadingLogs": "Loading logs…",
"logsUnavailable": "Logs are not available here — open the run in the browser.",
"emptyLogs": "No log output."
"emptyLogs": "No log output.",
"artifacts": "Artifacts",
"artifactSize": "{{size}}",
"expired": "Expired",
"rerun": "Re-run",
"cancel": "Cancel run"
},
"repoSettings": {
"title": "Repository settings",
@@ -418,7 +441,35 @@
"noDeployKeys": "No deploy keys",
"deleteKeyTitle": "Delete deploy key?",
"deleteKeyBody": "The deploy key will be removed.",
"writeAccess": "Write"
"writeAccess": "Write",
"actionsSettings": "Secrets & variables",
"secrets": "Secrets",
"secretName": "Secret name",
"secretValue": "Value",
"deleteSecretTitle": "Delete secret?",
"deleteSecretBody": "Secret {{name}} will be removed.",
"variables": "Variables",
"variableName": "Variable name",
"variableValue": "Value",
"deleteVariableTitle": "Delete variable?",
"deleteVariableBody": "Variable {{name}} will be removed.",
"transfer": "Transfer ownership",
"newOwner": "New owner",
"newOwnerPlaceholder": "username or organization",
"transferAction": "Transfer",
"transferTitle": "Transfer repository?",
"transferBody": "{{name}} will be transferred to {{owner}}.",
"runWorkflow": "Run workflow",
"noWorkflows": "No dispatchable workflows",
"ref": "Ref (branch or tag)",
"dispatch": "Dispatch",
"workflows": "Workflows",
"enabled": "Enabled",
"disabled": "Disabled",
"deleteLabelTitle": "Delete label?",
"deleteLabelBody": "Label {{name}} will be removed from all issues.",
"deleteMilestoneTitle": "Delete milestone?",
"deleteMilestoneBody": "Milestone {{name}} will be removed."
},
"createRepo": {
"title": "New repository",
@@ -441,7 +492,26 @@
"visLimited": "Limited",
"visPrivate": "Private",
"createdTitle": "Created",
"createdBody": "The organization was created."
"createdBody": "The organization was created.",
"teams": "Teams",
"noTeams": "No teams"
},
"projects": {
"title": "Projects",
"empty": "No projects",
"open": "Open",
"closed": "Closed",
"issues": "{{open}} open · {{closed}} closed"
},
"admin": {
"title": "Administration",
"users": "Users",
"orgs": "Organizations",
"repos": "Repositories",
"adminBadge": "Admin",
"emptyUsers": "No users",
"emptyOrgs": "No organizations",
"emptyRepos": "No repositories"
},
"profile": {
"title": "Profile",
@@ -450,9 +520,35 @@
"location": "Location",
"savedBody": "Your profile was updated."
},
"editor": {
"search": "Search / replace"
},
"packages": {
"title": "Packages",
"empty": "No packages"
"empty": "No packages",
"deleteTitle": "Delete package?",
"deleteBody": "Choose what to delete for {{name}}.",
"deleteVersion": "Delete this version",
"deleteAll": "Delete all versions",
"link": "Link to repository",
"unlink": "Unlink",
"linkRepo": "Repository name",
"linkRepoPlaceholder": "my-repo"
},
"labels": {
"title": "Labels",
"name": "Label name",
"color": "Color",
"empty": "No labels"
},
"milestones": {
"title": "Milestones",
"titleLabel": "Milestone title",
"dueOn": "Due date",
"empty": "No milestones",
"open": "Open",
"closed": "Closed",
"progress": "{{open}} open · {{closed}} closed"
},
"credentials": {
"title": "Credentials",
+103 -7
View File
@@ -183,7 +183,10 @@
"submodule": "Submodule",
"symlink": "Symlink naar {{target}}",
"currentRef": "Branch: {{ref}}",
"pathNotFound": "Dit pad bestaat niet in de repository."
"pathNotFound": "Dit pad bestaat niet in de repository.",
"findFile": "Bestand zoeken",
"findPlaceholder": "Zoek bestanden op pad",
"noMatches": "Geen overeenkomende bestanden"
},
"commits": {
"title": "Commits",
@@ -236,6 +239,14 @@
"milestone": "Mijlpaal",
"noDescription": "Geen beschrijving opgegeven",
"notFound": "Deze issue kon niet worden gevonden.",
"subscribe": "Volgen",
"unsubscribe": "Niet meer volgen",
"sort": "Sorteren",
"sortUpdated": "Recent bijgewerkt",
"sortCreated": "Recent aangemaakt",
"sortComments": "Meeste reacties",
"showFilters": "Filters",
"hideFilters": "Filters verbergen",
"reopen": "Heropenen",
"close": "Sluiten",
"compose": {
@@ -312,7 +323,11 @@
"body": "Review-opmerking",
"placeholder": "Schrijf je review…",
"submit": "Review versturen"
}
},
"inlineCommentPlaceholder": "Reageer op deze regel…",
"inlineCommentSubmit": "Reageren",
"inlineCommentAddedTitle": "Reactie toegevoegd",
"inlineCommentAddedBody": "Je inline review-reactie is geplaatst."
},
"comments": {
"title": "Reacties",
@@ -341,7 +356,10 @@
"edit": "Release bewerken",
"tagRequired": "Een tag is verplicht.",
"deleteTitle": "Release verwijderen?",
"deleteBody": "Release {{tag}} wordt verwijderd."
"deleteBody": "Release {{tag}} wordt verwijderd.",
"uploadAsset": "Bestand uploaden",
"deleteAssetTitle": "Bestand verwijderen?",
"deleteAssetBody": "{{name}} wordt verwijderd."
},
"actions": {
"title": "Actions",
@@ -366,7 +384,12 @@
"hideLogs": "Verbergen",
"loadingLogs": "Logs laden…",
"logsUnavailable": "Logs zijn hier niet beschikbaar — open de run in de browser.",
"emptyLogs": "Geen logregels."
"emptyLogs": "Geen logregels.",
"artifacts": "Artefacten",
"artifactSize": "{{size}}",
"expired": "Verlopen",
"rerun": "Opnieuw uitvoeren",
"cancel": "Run annuleren"
},
"repoSettings": {
"title": "Repository-instellingen",
@@ -418,7 +441,35 @@
"noDeployKeys": "Geen deploy-sleutels",
"deleteKeyTitle": "Deploy-sleutel verwijderen?",
"deleteKeyBody": "De deploy-sleutel wordt verwijderd.",
"writeAccess": "Schrijven"
"writeAccess": "Schrijven",
"actionsSettings": "Secrets en variabelen",
"secrets": "Secrets",
"secretName": "Naam van secret",
"secretValue": "Waarde",
"deleteSecretTitle": "Secret verwijderen?",
"deleteSecretBody": "Secret {{name}} wordt verwijderd.",
"variables": "Variabelen",
"variableName": "Naam van variabele",
"variableValue": "Waarde",
"deleteVariableTitle": "Variabele verwijderen?",
"deleteVariableBody": "Variabele {{name}} wordt verwijderd.",
"transfer": "Eigenaar overdragen",
"newOwner": "Nieuwe eigenaar",
"newOwnerPlaceholder": "gebruikersnaam of organisatie",
"transferAction": "Overdragen",
"transferTitle": "Repository overdragen?",
"transferBody": "{{name}} wordt overgedragen aan {{owner}}.",
"runWorkflow": "Workflow uitvoeren",
"noWorkflows": "Geen uitvoerbare workflows",
"ref": "Ref (branch of tag)",
"dispatch": "Starten",
"workflows": "Workflows",
"enabled": "Ingeschakeld",
"disabled": "Uitgeschakeld",
"deleteLabelTitle": "Label verwijderen?",
"deleteLabelBody": "Label {{name}} wordt van alle issues verwijderd.",
"deleteMilestoneTitle": "Mijlpaal verwijderen?",
"deleteMilestoneBody": "Mijlpaal {{name}} wordt verwijderd."
},
"createRepo": {
"title": "Nieuwe repository",
@@ -441,7 +492,26 @@
"visLimited": "Beperkt",
"visPrivate": "Privé",
"createdTitle": "Aangemaakt",
"createdBody": "De organisatie is aangemaakt."
"createdBody": "De organisatie is aangemaakt.",
"teams": "Teams",
"noTeams": "Geen teams"
},
"projects": {
"title": "Projecten",
"empty": "Geen projecten",
"open": "Open",
"closed": "Gesloten",
"issues": "{{open}} open · {{closed}} gesloten"
},
"admin": {
"title": "Beheer",
"users": "Gebruikers",
"orgs": "Organisaties",
"repos": "Repositories",
"adminBadge": "Beheerder",
"emptyUsers": "Geen gebruikers",
"emptyOrgs": "Geen organisaties",
"emptyRepos": "Geen repositories"
},
"profile": {
"title": "Profiel",
@@ -450,9 +520,35 @@
"location": "Locatie",
"savedBody": "Je profiel is bijgewerkt."
},
"editor": {
"search": "Zoeken / vervangen"
},
"packages": {
"title": "Packages",
"empty": "Geen packages"
"empty": "Geen packages",
"deleteTitle": "Package verwijderen?",
"deleteBody": "Kies wat je wilt verwijderen voor {{name}}.",
"deleteVersion": "Deze versie verwijderen",
"deleteAll": "Alle versies verwijderen",
"link": "Aan repository koppelen",
"unlink": "Ontkoppelen",
"linkRepo": "Naam van repository",
"linkRepoPlaceholder": "mijn-repo"
},
"labels": {
"title": "Labels",
"name": "Naam van label",
"color": "Kleur",
"empty": "Geen labels"
},
"milestones": {
"title": "Mijlpalen",
"titleLabel": "Titel van mijlpaal",
"dueOn": "Deadline",
"empty": "Geen mijlpalen",
"open": "Open",
"closed": "Gesloten",
"progress": "{{open}} open · {{closed}} gesloten"
},
"credentials": {
"title": "Inloggegevens",
+30
View File
@@ -9,6 +9,7 @@ import { useTranslation } from 'react-i18next';
import { HeaderAccountAndSettings } from '@/components/layout/header-buttons';
import { ActionsScreen } from '@/features/repository/screens/actions-screen';
import { ActionRunDetailScreen } from '@/features/repository/screens/action-run-detail-screen';
import { ActionsSettingsScreen } from '@/features/repository/screens/actions-settings-screen';
import { BranchesScreen } from '@/features/repository/screens/branches-screen';
import { CollaboratorsScreen } from '@/features/repository/screens/collaborators-screen';
import { CommitDetailScreen } from '@/features/repository/screens/commit-detail-screen';
@@ -17,8 +18,12 @@ import { DeployKeysScreen } from '@/features/repository/screens/deploy-keys-scre
import { FileEditScreen } from '@/features/repository/screens/file-edit-screen';
import { FileViewerScreen } from '@/features/repository/screens/file-viewer-screen';
import { FilesScreen } from '@/features/repository/screens/files-screen';
import { FindFileScreen } from '@/features/repository/screens/find-file-screen';
import { IssueComposeScreen } from '@/features/repository/screens/issue-compose-screen';
import { IssueDetailScreen } from '@/features/repository/screens/issue-detail-screen';
import { LabelsScreen } from '@/features/repository/screens/labels-screen';
import { MilestonesScreen } from '@/features/repository/screens/milestones-screen';
import { ProjectsScreen } from '@/features/repository/screens/projects-screen';
import { ProtectionsScreen } from '@/features/repository/screens/protections-screen';
import { PullDetailScreen } from '@/features/repository/screens/pull-detail-screen';
import { PullDiffScreen } from '@/features/repository/screens/pull-diff-screen';
@@ -203,6 +208,31 @@ export function RepositoryNavigator() {
component={ActionRunDetailScreen}
options={{ title: t('actions.runTitle') }}
/>
<Stack.Screen
name="ActionsSettings"
component={ActionsSettingsScreen}
options={{ title: t('repoSettings.actionsSettings') }}
/>
<Stack.Screen
name="FindFile"
component={FindFileScreen}
options={{ title: t('files.findFile') }}
/>
<Stack.Screen
name="Projects"
component={ProjectsScreen}
options={{ title: t('projects.title') }}
/>
<Stack.Screen
name="Labels"
component={LabelsScreen}
options={{ title: t('labels.title') }}
/>
<Stack.Screen
name="Milestones"
component={MilestonesScreen}
options={{ title: t('milestones.title') }}
/>
</Stack.Navigator>
);
}
+12
View File
@@ -3,7 +3,9 @@ import { useTranslation } from 'react-i18next';
import { CredentialsScreen } from '@/features/profile/screens/credentials-screen';
import { CreateOrgScreen } from '@/features/profile/screens/create-org-screen';
import { AdminScreen } from '@/features/profile/screens/admin-screen';
import { OrgReposScreen } from '@/features/profile/screens/org-repos-screen';
import { OrgTeamsScreen } from '@/features/profile/screens/org-teams-screen';
import { OrganizationsScreen } from '@/features/profile/screens/organizations-screen';
import { PackagesScreen } from '@/features/profile/screens/packages-screen';
import { ProfileScreen } from '@/features/profile/screens/profile-screen';
@@ -54,6 +56,16 @@ export function SettingsNavigator() {
component={CreateOrgScreen}
options={{ title: t('organizations.create') }}
/>
<Stack.Screen
name="OrgTeams"
component={OrgTeamsScreen}
options={{ title: t('organizations.teams') }}
/>
<Stack.Screen
name="Admin"
component={AdminScreen}
options={{ title: t('admin.title') }}
/>
</Stack.Navigator>
);
}
+7
View File
@@ -63,6 +63,11 @@ export type RepositoryStackParamList = {
DeployKeys: { owner: string; name: string };
Actions: { owner: string; name: string };
ActionRunDetail: { owner: string; name: string; id: number };
ActionsSettings: { owner: string; name: string };
FindFile: { owner: string; name: string; ref?: string };
Projects: { owner: string; name: string };
Labels: { owner: string; name: string };
Milestones: { owner: string; name: string };
};
export type RepositoriesStackParamList = {
@@ -74,10 +79,12 @@ export type SettingsStackParamList = {
Settings: undefined;
Organizations: undefined;
OrgRepos: { org: string };
OrgTeams: { org: string };
Packages: undefined;
Credentials: undefined;
Profile: undefined;
CreateOrg: undefined;
Admin: undefined;
};
export type AccountsStackParamList = {