diff --git a/api/handlers/author/authorHandler.go b/api/handlers/author/authorHandler.go index b28367d..26c5461 100644 --- a/api/handlers/author/authorHandler.go +++ b/api/handlers/author/authorHandler.go @@ -152,6 +152,11 @@ func parseAuthorId(r *http.Request) (uint32, error) { return uint32(id), err } +type ownAuthorResponse struct { + domain.Author + SlugAdjusted bool `json:"slug_adjusted"` +} + func presentAuthor(a domain.Author) domain.Author { if a.SocialLinks == nil { a.SocialLinks = []domain.SocialLink{} @@ -325,7 +330,7 @@ func (h *Handler) CreateMine(w http.ResponseWriter, r *http.Request) { writeAuthorError(w, err) return } - writeJSON(w, http.StatusCreated, presentAuthor(created)) + writeJSON(w, http.StatusCreated, ownAuthorResponse{Author: presentAuthor(created.Author), SlugAdjusted: created.SlugAdjusted}) } func (h *Handler) Update(w http.ResponseWriter, r *http.Request) { diff --git a/docs/api.md b/docs/api.md index 330877d..75e929b 100644 --- a/docs/api.md +++ b/docs/api.md @@ -176,7 +176,7 @@ article is allowed and never blocks publishing. | --- | --- | --- | | `GET /v1/author/` | verified session or API key | The authors newest first. Query `q` (name or slug, accent and case insensitive), `page` (default 1), `size` (5, 25, 50 or 100, default 25). Body `{ items, total, page, size }`; a bad query is 400 with the body-mismatch message. | | `POST /v1/author/` | owner or admin, session only | Create. 201 with the author. `user_id` links an account that has no author. | -| `POST /v1/author/me` | any verified session | Create the caller's own author from the display name (or the username). A taken slug gets `-2`, `-3`... silently. | +| `POST /v1/author/me` | any verified session | Create the caller's own author from the display name (or the username). A taken slug gets `-2`, `-3`... silently. 201 with the author plus `slug_adjusted`: `true` when the stored slug differs from the plain slug of the name (a collision suffix was added), `false` otherwise. No other author response carries this field. | | `PATCH /v1/author/{id}` | owner or admin on any author; any verified session on the author linked to it; session only | Edit `name`, `slug`, `bio`, `avatar_id`, `website`, `social_links`, `user_id`. Absent fields are untouched, `avatar_id`, `website` and `user_id` accept `null`, `social_links` is replaced as a whole. `user_id` links or unlinks the account and is owner or admin only. | | `DELETE /v1/author/{id}?reassign_to={id\|none}` | owner or admin, session only | 204. An author credited on articles needs `reassign_to`: an author id (that author takes the deleted one's position and is never duplicated on an article) or `none` (the credit is removed). The move and the delete are one transaction. `reassign_to` is ignored when the author has no article. The linked account is untouched. | diff --git a/features/authors_backend.feature b/features/authors_backend.feature index e8ead0c..d35d30c 100644 --- a/features/authors_backend.feature +++ b/features/authors_backend.feature @@ -218,6 +218,7 @@ Feature: Authors backend, public bylines that articles credit in order Then the status is 201 And the author name is "" and the slug is "" And the author has user_id of the caller and is_linked true + And slug_adjusted is false Examples: | display | username | name | slug | @@ -239,6 +240,7 @@ Feature: Authors backend, public bylines that articles credit in order When "Marta Alves" sends POST /v1/author/me Then the status is 201 And the slug is "marta-alves-3" + And slug_adjusted is true And no error is returned Scenario: The suffix still fits in the slug limit @@ -246,6 +248,12 @@ Feature: Authors backend, public bylines that articles credit in order When the caller sends POST /v1/author/me Then the status is 201 And the slug is at most 100 characters and ends with "-2" + And slug_adjusted is true + + Scenario: Only the own-author creation carries slug_adjusted + When the owner sends POST /v1/author/ with {"name": "Camille Roche"} + Then the 201 body has no slug_adjusted field + And GET /v1/author/ items and GET /v1/auth/me author have no slug_adjusted field Scenario: A caller who already has an author is refused Given the caller is linked to an author diff --git a/features/sites_authors_integration.feature b/features/sites_authors_integration.feature new file mode 100644 index 0000000..c4d1f90 --- /dev/null +++ b/features/sites_authors_integration.feature @@ -0,0 +1,528 @@ +Feature: Sites and authors in the Editor, Articles and Profile screens + + As a RenewCMS user who can edit articles + I want to choose an article's site and bylines in the editor, see them in the articles list, and create my own author profile + So that every article belongs to the right frontend and credits the right people + + Background: + Given the screens are EditorView (/article/:id/edit), ArticlesView (/article) and ProfileView (/profile), + inside DashboardShell, per docs/design/routes.md + And the visual spec of record is docs/design/screens/editor.md (group "Editor: site and authors"), + articles.md (group "Articles: sites and authors") and profile.md (group "Profile: author profile"), + with the error copy in docs/design/states.md. Exact copy is read from those files and is not repeated here + And this feature supersedes the lines of features/sites_authors_screens.feature that said + POST /v1/author/me is not exposed in the UI and that Editor, Articles and Profile are not modified + And POST /v1/author/me answers 201 with the author and slug_adjusted, true when the stored slug differs from the plain slug of the name + And the SPA calls, with relative URLs through useApi only: + GET /v1/site/, GET /v1/author/ (page, size in 5, 25, 50 or 100, and q), POST /v1/author/, POST /v1/author/me, + GET /v1/auth/me, GET /v1/article/{id}, PATCH /v1/article/{id} with site_id and author_ids, + and GET /v1/article/?site={key} + And an article carries site_id and authors [{id, name, slug, ...}] in list order, and the first author is the primary byline + And GET /v1/auth/me carries "author" (the linked author, or null) and the SPA keeps it in the session store + And the sites fixture is Renew (id 1, renew.example, default), Journal (id 2, journal.renew.example), Projects (id 3) and Archive (id 4) + And the authors fixture is Inès Duarte (id 2), Jonas Pereira, Camille Roche and the Marta Alves of the design + And an author is drawn as AuthorAvatar (initials fallback, square), several as AuthorStack + And the domain defines only the roles "owner" and "admin" (internal/domain/user, RoleOwner and RoleAdmin) + And "author rights" means owner and admin: they may create authors and edit any author + And "verified" below names a verified account without the owner or admin role, which has no author rights + And "several sites" means GET /v1/site/ returned more than one site + And every visible string goes through t(...) with the English text as the key and a French entry in web/src/i18n/messages.ts + And a scenario tagged @not-in-design uses copy or behaviour that docs/design does not define: it takes the + proposal of this feature, has a French entry, and is listed in the .qa.md to be fed back to the design + And the screens use Nuxt UI components and design tokens only, with no raw colors + And the board frames of docs/design/source/AppFrame.dc.html and DirectoryFrame.dc.html are the layout tiebreaker + + Rule: Editor: the "Site and authors" section (MetaSection) + + Scenario: Collapsed by default with one site and an author + Given the install has one site and article 12 has the author "Inès Duarte" + And nothing is remembered for this browser + When the user opens /article/12/edit on desktop + Then the details sidebar shows a collapsed "Site and authors" section with the one-line summary "Inès Duarte" + And no Site select is rendered + And the section sits in the same place in every editor state that has the details sidebar + + Scenario: Loading and not found + When GET /v1/article/12 is pending + Then the section header is shown with a skeleton summary + When GET /v1/article/12 answers 404 + Then the "Not found" state shows no section + + Scenario Outline: The section opens by itself when it needs attention + Given nothing is remembered for this browser + And the install has and the article has + When the user opens the editor on desktop + Then the section is + + Examples: + | sites | authors | state | + | one site | an author | collapsed | + | several sites | an author | open | + | one site | no authors | open | + | several sites | no authors | open | + + Scenario: The choice is remembered per browser and wins over auto-open + Given the section is collapsed by default + When the user opens it and later opens another article in the same browser + Then the section is open there too + When the user collapses it and reloads + Then it is collapsed even if the install has several sites or the article has no authors + And the choice is kept in localStorage and nothing is sent to the API + + Scenario: Mobile: inside the Details sheet, closed by default + Given the viewport is 390 px wide + When the user opens the editor + Then the section is not visible until the Details sheet is opened + And inside the sheet it is closed unless a choice is remembered + When the user opens it, closes the sheet and opens it again + Then the section keeps the choice made in the sheet + And the sheet and the desktop sidebar share the same storage key + + @not-in-design + Scenario Outline: Collapsed summary line variants + Given the section is collapsed + And the install has and the article has + Then the summary line reads + + Examples: + | sites | authors | summary | + | one site | Inès Duarte | "Inès Duarte" | + | one site | Inès Duarte, Jonas Pereira, Camille Roche | "Inès Duarte +2" | + | one site | no authors | "No authors" | + | several sites | Inès Duarte on Journal | "Journal · Inès Duarte" | + | several sites | no authors on Journal | "Journal · No authors" | + + Rule: Site select + + Scenario: One site: no Site select + Given the install has one site + When the section is open + Then there is no Site select and the "Authors" list is the first control + + Scenario: Several sites: Site select above the authors + Given the install has several sites and article 12 is on "Journal" + When the section is open + Then a "Site" select above the authors shows "Journal" with "journal.renew.example" + And the helper text reads "Canonical host: journal.renew.example" + And the select is available to every role that can edit the article + + Scenario: Site select options + When the user opens the Site select + Then each option shows the site name and its host, and the default site is first + + Scenario: Changing the site is an edit + Given the editor shows "Saved" and the article is on "Renew" + When the user chooses "Journal" + Then the status becomes "Unsaved changes" and Save is enabled + And no request is sent yet + When the user activates Save + Then exactly one PATCH /v1/article/12 is sent containing site_id 2 + And on 200 the status is "Saved" and the helper text shows the new host + + Rule: Author list + + Scenario: Authors are an ordered list; the first is the primary byline + Given article 12 has four authors + When the section is open + Then the first row shows the label "Primary" (@not-in-design) + And each row has a drag handle and a remove button + And the hint "Drag to reorder. The first author is the primary byline." is shown + And a long name is truncated with an ellipsis and carries the full name in title and aria-label + + Scenario: Reorder with the keyboard + Given an author list of three with "Jonas Pereira" second + When the user focuses the handle of "Jonas Pereira" and presses Space or Enter + Then a live region announces the grabbed-row message of the design (position 2 of 3 and the key instructions) + When the user presses ArrowUp + Then the row moves to position 1 and the new position is announced + When the user presses Space + Then the row is dropped there and the status becomes "Unsaved changes" + When the user grabs a row, moves it and presses Escape + Then the row returns to its original position and the status does not change + + @not-in-design + Scenario: Dropped and cancelled announcements + Given a row was grabbed + When the user drops it with Space + Then the live region announces the dropped message with the final position + When the user cancels with Escape + Then the live region announces the cancelled message and the original position + + Scenario: Reorder with the pointer + When the user drags a row + Then the row lifts and a line shows the drop position + When the user drops it + Then the list takes the new order and the status becomes "Unsaved changes" + + Scenario: Remove an author + Given the list has "Inès Duarte" and "Jonas Pereira" + When the user activates the remove button of "Inès Duarte" + Then "Jonas Pereira" becomes "Primary" and the status becomes "Unsaved changes" + When the last author is removed + Then the list shows "No authors. This article will have no byline." + + Scenario: Saving authors + Given the author list was reordered to [Jonas Pereira, Inès Duarte] + When the user activates Save + Then exactly one PATCH /v1/article/12 is sent whose author_ids follow the list order + And a list emptied by the user is sent as author_ids [] + And fields that did not change are not sent + + Rule: Add author + + Scenario: The combobox + When the user activates "Add an author" + Then a combobox opens with a "Search authors" field and GET /v1/author/ is requested with size 100 + And authors already on the article are checked and dimmed + When the user activates a checked author + Then nothing happens and the author is not added twice + When the user picks "Camille Roche" + Then she is appended to the list and the status becomes "Unsaved changes" + + Scenario: Searching beyond the first 100 authors + Given the install has more than 100 authors + When the user types "Zoe" in "Search authors" + Then GET /v1/author/ is requested with q "Zoe" and the list shows the matches + + Scenario Outline: "Create author…" only for roles with author rights + Given the session role is "" + When the combobox is open + Then the "Create author…" row is + + Examples: + | role | visible | + | owner | shown | + | admin | shown | + | verified | absent | + + Scenario Outline: No match + Given the session role is "" + When the user types "Zoe Lambert" and nobody matches + Then the message "No author matches "Zoe Lambert"." is shown + And + + Examples: + | role | create | + | owner | the row Create author "Zoe Lambert"… is shown | + | verified | no create row is shown | + + Scenario Outline: Authors could not be loaded + When GET /v1/author/ fails with as the combobox opens + Then the combobox shows "Couldn't load authors", "Check your connection and try again." and "Try again" + And the article's authors in the list are untouched + When the user activates "Try again" + Then GET /v1/author/ is requested again + + Examples: + | failure | + | status 500 | + | a network error | + + Rule: Create author dialog (owner and admin) + + Scenario: Open the dialog from the combobox + Given the session role is "owner" + When the user activates Create author "Zoe Lambert"… + Then the dialog "Create author" opens over the editor, with Name prefilled "Zoe Lambert", Slug "zoe-lambert" (Auto, same SlugField as Authors), "Cancel" and "Create author" + And the unsaved text of the article is untouched + + Scenario: Create succeeds + Given the Create author dialog is filled with name "Zoe Lambert" and slug "zoe-lambert" + When the user activates "Create author" + Then exactly one POST /v1/author/ is sent with name and slug + And the dialog closes, "Zoe Lambert" is appended to the author list and the status becomes "Unsaved changes" + And the article's authors are not sent to the API until Save + + Scenario: "This is me" only when the user has no author profile + Given the session role is "owner" and GET /v1/auth/me has author null + When the Create author dialog is open + Then the checkbox "This is me" shows "Links the author to marta@renew.example." + And it is unchecked until the user checks it + When it is checked and the user creates the author + Then POST /v1/author/ is sent with user_id of the current user + And the session store now holds that author, so the hint and the Profile card show the profile + + Scenario: No "This is me" when the user already has an author + Given GET /v1/auth/me carries an author + When the Create author dialog is open + Then there is no "This is me" checkbox and no user_id is ever sent + + Scenario: Slug taken + When POST /v1/author/ answers 409 author_slug_taken + Then the dialog shows "The slug "zoe-lambert" is already used by another author." and the action "Use zoe-lambert-2" + And activating the action sets the slug and keeps the name + + Scenario Outline: Create author failed + When POST /v1/author/ fails with + Then the dialog stays open with "Couldn't create the author" and "The article is unchanged. Try again in a moment." + And the values are kept and the article is unchanged + + Examples: + | failure | + | status 500 | + | a network error | + + Scenario: Role changed while the dialog was open + When POST /v1/author/ answers 403 + Then the error toast of states.md "Only an owner or admin can change authors" shows and the dialog closes + + Rule: "Create my author profile" hint (every role) + + Scenario Outline: The hint appears + Given the session role is "", GET /v1/auth/me has author null, the article has no authors and the hint was never dismissed + When the section is open + Then the dismissible hint "You don't have an author profile yet" with "Create my author profile" is shown + And the list shows "No authors. This article will have no byline." + + Examples: + | role | + | owner | + | admin | + | verified | + + Scenario Outline: The hint stays away + Given + Then the hint is not shown + + Examples: + | condition | + | the user already has an author profile | + | the article has an author | + | the hint was dismissed by this user | + + Scenario: Create my author profile + Given the hint is shown + When the user activates "Create my author profile" + Then exactly one POST /v1/author/me is sent with no body and no dialog opens + And on 201 the new author is added to the list as the primary author + And the status becomes "Unsaved changes" and the hint disappears + And the session store holds the author, so /profile shows the "Created" card + + @not-in-design + Scenario: The hint-success toast + When POST /v1/author/me answers 201 + Then a success toast shows "Author profile created" and "Marta Alves is now your byline." (the Profile copy) + + Scenario Outline: Create my author profile fails + When POST /v1/author/me fails with + Then the hint stays, an error toast shows "Couldn't create your author profile" and "Try again in a moment." + And the article is unchanged + + Examples: + | failure | + | status 500 | + | a network error | + + Scenario: The profile already exists (409) + When POST /v1/author/me answers 409 user_already_linked + Then GET /v1/auth/me is requested again, the hint disappears and the existing author is offered in the combobox + + Scenario: Dismissing the hint + When the user dismisses the hint + Then it disappears and does not come back for this user in this browser, on later visits to any article + And the dismissal is kept in localStorage keyed by user id + And dismissing sends no request + + Rule: Editor failures and keyboard + + Scenario: The sites could not be loaded + Given GET /v1/site/ fails + When the user opens the editor + Then the editor still loads, no Site select is rendered and no notice is shown + + Scenario Outline: Save is refused for a site or author that no longer exists + Given the user changed the + When PATCH /v1/article/12 answers 404 + Then the existing "Save failed" state is shown with the changes kept + And an info toast "" shows and the lists are reloaded + + Examples: + | what | code | toast | + | site | site_not_found | That site no longer exists | + | author | author_not_found | That author no longer exists | + + Scenario: Existing save behaviour is kept + Given the user changed only the site or the authors + Then "Save and publish", the leave-confirmation dialog, Ctrl/Cmd S and the draft kept in sessionStorage after a session expiry treat the change like any other edit + And the restored draft shows "Unsaved changes" with the chosen site and author order + + Rule: Articles list: Authors column, Site column and Site filter + + Scenario Outline: Authors column on every frame + Given an article with + When the list is shown + Then the Authors cell shows + + Examples: + | authors | cell | + | no authors | "—" | + | one author | one avatar | + | three | three avatars, no "+N" | + | five | three avatars and "+2" | + + Scenario: Mobile Authors cell, and no site on the cards + Given the viewport is 390 px wide + Then the card shows the avatars with the first name of the first author, as drawn in the board + And the card shows no site, as in the design + + Scenario: One site: no Site column and no filter + Given the install has one site + Then the list has an Authors column, no Site column and no Site filter + + Scenario: Several sites: Site column and Site filter + Given the install has several sites + Then the list has a Site column showing the site name as read-only text for every role + And the toolbar has a Site select with "All sites" and every site name + + Scenario: Choosing a site + Given the list is on page 3 + When the user chooses "Journal" in the Site filter + Then the URL becomes /article?site=journal with the page omitted + And GET /v1/article/?site=journal is requested with the current q, status and sort + And the tab counts still show the full list + + Scenario Outline: Other changes keep the site + Given the URL holds ?site=journal + When the user + Then ?site=journal stays in the URL + + Examples: + | action | + | searches for "plaster" | + | changes the tab | + | changes the sort | + | goes to page 2 | + | changes the page size | + + Scenario: Choosing "All sites" + Given the URL holds ?site=journal + When the user chooses "All sites" + Then site leaves the URL, the page resets to 1 and the full list is requested + + Scenario: Opening a URL with a site + When the user opens /article?site=journal&page=2 + Then the Site filter shows "Journal" and GET /v1/article/?site=journal&page=2 is requested + + Scenario Outline: A site key that cannot be used is dropped silently + Given the URL holds + Then the key is removed from the URL with no notice and the unfiltered list is requested + + Examples: + | query | + | ?site=nope | + | ?site=renew on a one-site install | + + Scenario: No articles on a site + Given ?site=archive and the response is empty with no search and the tab "All" + Then the state shows "No articles on "Archive"", "Move articles here from the editor, or choose another site." and "Show all sites" + When the user activates "Show all sites" + Then site leaves the URL and the full list is requested + + Scenario: Zero results on a site with a search or another tab + Given ?site=archive and a search or a tab other than "All" is active + Then the existing "No results" or "No drafts" state is shown + + Scenario: Existing states keep working with a site + Then Loading, Empty, row actions, delete and pagination states behave as in docs/design/screens/articles.md with the site filter applied + + Scenario: The sites could not be loaded + Given GET /v1/site/ fails + Then the list renders as a single-site install, with no Site column and no Site filter + + Rule: Profile: the Author profile card + + Scenario: Position and roles + Then in every Profile frame the "Author profile" card sits between "Account" and "Password" + And it is shown to every role + + Scenario: Loading + When GET /v1/auth/me is pending + Then the card shows a skeleton + + Scenario: No author profile + Given GET /v1/auth/me has author null + Then the card shows the copy of state 1, a "Create my author profile" button and the line "Uses your display name, Marta Alves. You can change it afterwards." + + @not-in-design + Scenario: No author profile and no display name + Given GET /v1/auth/me has author null and no display name + Then the line reads "Uses your username, marta. You can change it afterwards." + + Scenario: Create succeeds + When the user activates "Create my author profile" + Then exactly one POST /v1/author/me is sent + And on 201 the card shows "Author profile created", "Marta Alves is now your byline." and "Edit author" with "Linked to your account. New articles start with this author." + And the session store holds the author + + Scenario: Slug adjusted + Given the 201 answer has slug_adjusted true and the slug "marta-alves-2" + Then no error is shown and the card also shows "Your slug is marta-alves-2" with "marta-alves was already used by another author. You can change it in Edit author." + + Scenario Outline: The notice follows slug_adjusted, never the slug itself + Given the author's name is "" + And the 201 answer has the slug "" and slug_adjusted + Then the card the "Your slug is" notice + + Examples: + | name | returned | flag | notice | + | Marta Alves | marta-alves | false | does not show | + | Marta Alves | marta-alves-2 | true | shows | + | Inès Duarte | ines-duarte-2 | true | shows | + | Jean-Luc O'Neil | jean-luc-o-neil | false | does not show | + | Zoë Müller | zoe-muller | false | does not show | + | Agent 007 | agent-007 | false | does not show | + | Agent 007 | agent-007-2 | true | shows | + + Scenario Outline: Create fails + When POST /v1/author/me fails with + Then the card shows "Couldn't create your author profile" and "Try again in a moment." and the button stays available + + Examples: + | failure | + | status 500 | + | a network error | + + Scenario: Profile already exists (409) + When POST /v1/author/me answers 409 user_already_linked + Then GET /v1/auth/me is requested again and the card shows the existing author + + Scenario: Existing author on load + Given GET /v1/auth/me carries an author + Then the card shows the author's name, "Edit author" and "Linked to your account. New articles start with this author." without the "Created" banner + + Scenario: Edit own author without author rights + Given the session role has no author rights and has a linked author + When the user activates "Edit author" + Then the author form opens titled "Edit Marta Alves" with Linked user "marta@renew.example" locked, "This is your author profile. Only an owner or admin can change the link." and "Save changes" + And there is no "Unlink" and no delete action on the form or on the screen + When the user saves a change + Then exactly one PATCH /v1/author/{id} is sent with only the changed fields + + @not-in-design + Scenario: Edit author as owner or admin + Given the session role is "owner" or "admin" with a linked author + When the user activates "Edit author" on /profile + Then the existing AuthorFormPanel opens in place, on /profile, with "Unlink" allowed + + Scenario: Language and session + Given the language is "fr" + Then every new string on the three screens is the French message + And a 401 on any new call lands on /login?redirect=&reason=expired and a 403 from an unverified account lands on /register/pending + + Rule: Catalogue and copy left over from the Sites and Authors screens + + Scenario: Authors routes in the API catalogue + Then web/src/data/apiCatalogue.ts has an "Authors" group and an "Authors · owner and admin" group covering every /v1/author route, including POST /v1/author/me as a session-only route + And web/src/data/__tests__/apiCatalogue.spec.ts covers them + + Scenario: French strings for the catalogue groups + Given the language is "fr" + Then the catalogue group titles "Sites", "Sites · owner only", "Authors" and "Authors · owner and admin" and their descriptions have French entries + + Scenario: Session-only rows + Then the session-only routes of Sites and Authors appear in SESSION_GROUPS with SESSION_REQUIRED_MESSAGE + + Scenario: The owner_only copy of the design board + Then the 403 page copy "You don't have access to Sites" with "Only the owner can manage sites. Ask the owner of this site if you need a change." + And the action toast "Only the owner can manage sites" with "Ask the owner of this site." + exist in the SPA and have French entries diff --git a/features/sites_authors_integration.qa.md b/features/sites_authors_integration.qa.md new file mode 100644 index 0000000..262934e --- /dev/null +++ b/features/sites_authors_integration.qa.md @@ -0,0 +1,64 @@ +# QA: Sites and authors in Editor, Articles and Profile + +SPA slice only. No Go change: the API already exists (commits "Sites feature backend" and "Authors feature backend"). A wrong contract is reported as a backend defect. + +Roles: the domain defines only `owner` and `admin` (`internal/domain/user`). There is no "member" constant. "verified" in the feature and below is a verified account without the owner or admin role, which has no author rights. The earlier `sites_authors_screens` files still say "member" for the same account; that wording is left as is. + +## Automated SPA (Vitest + Vue Test Utils, `task test:web`) + +Mock `useApi`'s `request` per case for GET /v1/site/, GET /v1/author/, POST /v1/author/, POST /v1/author/me, GET /v1/auth/me, GET and PATCH /v1/article/{id} and GET /v1/article/. Mount EditorView, ArticlesView and ProfileView inside DashboardShell with a resolved session and a test router. Roles: "owner" (Marta Alves, no author), "admin", "verified". Mock matchMedia for desktop and mobile. Use localStorage fakes for the remembered section state and the dismissed hint. Do not freeze the system date. Report the web tests as run or NOT RUN, never as passing when not run. + +Regression: every existing Editor, Articles, ArticlesPagination, ArticlesPageSizeMemory and Profile spec now sees the new calls. Give them default mocks (one site, one author, author null where relevant) rather than loosening unmocked-call checks, and show that they still pass. + +1. MetaSection: collapsed summary "Inès Duarte"; open/closed Examples (sites x authors); remembered choice wins over auto-open; same key in the desktop sidebar and the mobile sheet; mobile closed in the Details sheet; loading skeleton; no section on 404; summary variants. +2. SiteSelect: absent with one site; present with helper "Canonical host: ..."; options with name and host and the default first; choosing marks "Unsaved changes"; the PATCH contains `site_id` and only the changed fields; GET /v1/site/ failure renders no select and no notice. +3. AuthorList: Primary label, handle, remove, truncation with title and aria-label; keyboard reorder (grab, ArrowUp/Down, drop, Escape, live region text including dropped and cancelled); pointer reorder (use the sortable test helper; assert order and "Unsaved changes"); removing the last author shows the no-byline text; PATCH `author_ids` order, `[]` when emptied, absent when unchanged. +4. AuthorSelect: opens with GET /v1/author/ size 100; only sizes 5, 25, 50 or 100 are ever sent (other sizes answer 400); `q` search beyond the first 100; checked and dimmed items do nothing when activated; append on pick; "Create author…" per role (owner, admin, verified); no-match message with and without the create row; error state with "Try again". +5. Create author dialog: prefilled name and auto slug; POST body; appended to the list and "Unsaved changes"; the article's authors are not sent before Save; "This is me" only when author is null (default unchecked) and sends `user_id`; session store updated; slug taken and the "Use zoe-lambert-2" action; failure Examples; 403 toast. +6. CreateAuthorHint: shown by role Examples; hidden for author present, article with authors, dismissed; POST /v1/author/me with no body and no dialog; list and toast; session updated; failure Examples; 409 refetch; dismissal stored in localStorage by user id and never re-shown; no request on dismiss. +7. Editor save: a site-only or author-only edit enables Save, "Save and publish", leave-confirmation and the sessionStorage draft restore; 404 `site_not_found` / `author_not_found` handling with the "Save failed" state and the info toast. +8. ArticlesView: Authors cell Examples (0, 1, 3, 5 authors); mobile cell and no site on the cards; Site column and filter only with several sites; `?site=` read, written, combined with q/tab/sort/size/page and page reset; "All sites"; unknown key and single-site key dropped silently; "No articles on "Archive"" and "Show all sites"; "No results"/"No drafts" with a site and a search or tab; GET /v1/site/ failure falls back to single-site; tab counts unchanged. +9. ProfileView AuthorProfileCard: position between Account and Password for all roles; skeleton while loading; states 1 to 5 (no profile, error, created, created with adjusted slug, edit own author with locked link and no Unlink or delete); owner/admin Edit author reuses AuthorFormPanel with Unlink allowed; POST /v1/author/me count; 409 refetch; author present on load. +10. Slug adjusted comes from the server: POST /v1/author/me returns `slug_adjusted` and the SPA shows the "Your slug is" notice from that flag only. Vitest cases feed mocked responses (accented names, apostrophes, collision `marta-alves-2`, `agent-007` with the flag false) and check `baseSlugOf` strips only the one collision suffix. The slug rule itself is covered in Go (`features/authors_backend.feature`, `test/authors_backend_http_test.go`). +11. i18n: every new `t()` key has a French entry (extend the i18n spec); one French walk through the three screens. +12. Catalogue group (final scenario group): the Authors routes and groups in `apiCatalogue.ts` and its spec, French titles and descriptions for the Sites and Authors groups, Sites and Authors rows in `SESSION_GROUPS` with `SESSION_REQUIRED_MESSAGE`, and the owner_only 403 page and toast copy with French entries. + +Handoff note for the coder: a grep of the SPA after the earlier commit found the Sites catalogue groups ("Sites", "Sites · owner only") but no `/v1/author` group, no French entry for "Sites · owner only", and no `owner_only` copy in `web/src`; `SESSION_REQUIRED_MESSAGE` and `SESSION_GROUPS` exist. Treat item 12 as work to do, and verify each part before adding it. + +## Visual (`task visual:check -- `, desktop and mobile, light and dark) + +Setups go in `web/visual/states.ts` (one setup per state, mocked /v1, the board's own sample data, no `skip` unless the state depends on the date). Hard gate: every capture within 10 %, with no per-state exception. Reference frames: `AppFrame.dc.html` (section, Articles columns, Profile card) and `DirectoryFrame.dc.html` (section content). + +- Editor, all existing frames that show the sidebar: the section collapsed with the summary "Inès Duarte" (one site, one author). Their existing setups need default mocks for /v1/site/ and the article's authors. Not found has none. Loading shows the skeleton summary. +- Editor: site and authors (16): open one site, several sites, Site select open, no authors with hint, many authors, add open, no match, add open (no create), no match (no create), add error, reorder keyboard, reorder pointer, create dialog, for me, slug taken, failed. The "(no create)" frames use a verified session. +- Articles (existing frames + pagination frames): the Authors column in every frame. Articles: sites and authors (3): several sites, Site filter open, no articles on a site. +- Profile (existing frames): the Author profile card in its default state in every frame. Profile: author profile (5): no profile, error, created, slug adjusted, edit own author. +- Re-run Settings, Users and Home too: report any capture that moves above 10 %. Any failure needs the user's decision (an `approvedBy` exception or a design update). + +## Exit conditions + +- All existing Editor, Articles and Profile frames pass `task visual:check`, with no per-state exception. +- The new frames pass. +- Settings, Users and Home are re-run for regressions. +- Vitest specs are reported honestly, run or NOT RUN. + +## Copy and behaviour not in the design (feed back to docs/design later) + +Each has a French entry in `web/src/i18n/messages.ts`. + +1. Editor hint-success toast: "Author profile created" / "Marta Alves is now your byline." (reuses the Profile copy). +2. The row label "Primary". +3. The "dropped" and "cancelled" live-region announcements (only "grabbed" is in the design). +4. Collapsed-summary variants: "Inès Duarte +2", "No authors", "Journal · Inès Duarte", "Journal · No authors". +5. Profile line without a display name: "Uses your username, marta. You can change it afterwards." +6. Profile "Edit author" for owner and admin: AuthorFormPanel in place on /profile with Unlink allowed. + +## Known gap (no change in this slice) + +`GET /media/{id}/usage` returns articles only. An image used as an author avatar or a site social image can therefore look unused in the Media detail panel and in the delete confirmation. This needs a Go change and is not part of this slice. + +## Manual checks screenshots cannot cover + +- Keyboard: tab order through the section, the Site select, handles, remove buttons, "Add an author", the dialog and the hint close button; focus returns to the opener after the dialog; the live region reads the grabbed, moved, dropped and cancelled messages in a screen reader. +- Pointer: drag feel, the drop line, scroll while dragging on mobile. +- Real `task dev`: an owner creates an author inline with "This is me", then opens /profile; a verified account creates a profile from the hint, saves, and the Authors column shows the avatar; filter by site and share the URL. diff --git a/features/sites_authors_screens.feature b/features/sites_authors_screens.feature index 67968f5..874eaf5 100644 --- a/features/sites_authors_screens.feature +++ b/features/sites_authors_screens.feature @@ -11,7 +11,7 @@ Feature: Sites and Authors screens DirectoryList, DirectoryPanel (the slide-over), ReassignDialog, SlugField and MediaField And the screens call, with relative URLs through useApi only, GET, POST, PATCH and DELETE on /v1/site/ and /v1/author/, PATCH /v1/site/{id}/default and GET /v1/user/ - And POST /v1/author/me is not exposed in the UI by this slice + And POST /v1/author/me and the changes to the Editor, Articles and Profile screens are specified in features/sites_authors_integration.feature And a site has the fields id, name, key, base_url, default_social_image_id, default_robots ("index" or "noindex"), locale, is_default and article_count And an author has the fields id, name, slug, bio, avatar_id, website, social_links, user_id, @@ -630,5 +630,5 @@ Feature: Sites and Authors screens When the user opens each state of both screens Then every visible string is the French message and none falls back to English - Scenario: Existing screens are unchanged - Then the Editor, Articles and Profile views and their specs are not modified by this slice + Scenario: Editor, Articles and Profile + Then their changes are specified in features/sites_authors_integration.feature diff --git a/features/sites_authors_screens.qa.md b/features/sites_authors_screens.qa.md index bfb0ba7..0642ce2 100644 --- a/features/sites_authors_screens.qa.md +++ b/features/sites_authors_screens.qa.md @@ -32,12 +32,12 @@ Authors (AuthorsView): 19. Row menu: guest has Edit, Link user, Delete…; linked has Edit, Delete…; mobile sheet. 20. Read-only list and detail for member (no button, no menu, no bottom button, search works, no email); `?edit=` opens the read-only detail. 21. Form: Add empty copy; slug from the name; add succeeds with the exact POST body; slug collision and suggestions; validation Examples; server codes Examples (bio_too_long, invalid_url, user_already_linked); social links (types, placeholders, limit of 5, bad link); linked user options computed from GET /v1/user/ minus user_ids paged from GET /v1/author/?size=100, and "Every user already has an author."; edit linked; unlink (PATCH user_id null, toast); re-link; avatar picker; save failed Examples; 403 author_rights toast; deep link and unknown slug toast. -22. Own author by deep link only: member opens `/authors?edit=` (own author from GET /v1/auth/me), form with locked link and no delete, PATCH on save; another slug opens the read-only detail. No test calls POST /v1/author/me, because the UI does not expose it in this slice. +22. Own author by deep link only: member opens `/authors?edit=` (own author from GET /v1/auth/me), form with locked link and no delete, PATCH on save; another slug opens the read-only detail. POST /v1/author/me is covered by features/sites_authors_integration.qa.md. 23. Delete: reassign (copy, linked line, first other author preselected, one DELETE ?reassign_to=2, "Reassigning…", toast); choose who (no deleted author, "Nobody" last); nobody sends `reassign_to=none`; failed Examples; 409 fallback dialog and "Reassign articles"; no articles; 404. 24. 401 and 403 app-wide redirects on both routes. 25. French: `setLocale('fr')`, walk the list, form, delete and 403 page of each screen, no English source string remains. 26. Messages: every new `t()` key has a French entry (extend the i18n spec). Router: /settings/sites and /authors are registered and verified. -27. Regression: the existing Editor, Articles, Profile specs pass unchanged. +27. Editor, Articles and Profile changes and their regression specs are covered by features/sites_authors_integration.qa.md. ## Visual (`task visual:check -- `, desktop and mobile, light and dark) diff --git a/internal/infrastructure/useCases/CreateMyAuthor.go b/internal/infrastructure/useCases/CreateMyAuthor.go index 2c1881a..c5344d0 100644 --- a/internal/infrastructure/useCases/CreateMyAuthor.go +++ b/internal/infrastructure/useCases/CreateMyAuthor.go @@ -11,6 +11,11 @@ import ( const maxOwnSlugAttempts = 50 +type MyAuthorCreated struct { + Author author.Author + SlugAdjusted bool +} + type CreateMyAuthorUseCase struct { authors author.Repository users user.Repository @@ -21,10 +26,10 @@ func NewCreateMyAuthorUseCase(authors author.Repository, users user.Repository, return &CreateMyAuthorUseCase{authors: authors, users: users, recorder: recorder} } -func (u *CreateMyAuthorUseCase) Create(ctx context.Context, userID uint32) (author.Author, error) { +func (u *CreateMyAuthorUseCase) Create(ctx context.Context, userID uint32) (MyAuthorCreated, error) { caller, err := u.users.Get(userID) if err != nil { - return author.Author{}, err + return MyAuthorCreated{}, err } name := authorNameOf(caller) event := audit.NewEvent(audit.ActionAuthorCreate, audit.CategoryAuthors) @@ -32,11 +37,11 @@ func (u *CreateMyAuthorUseCase) Create(ctx context.Context, userID uint32) (auth created, err := u.create(caller, name) if err != nil { recordFailure(ctx, u.recorder, event, err) - return author.Author{}, err + return MyAuthorCreated{}, err } event.Target = authorTarget(created) u.recorder.Record(ctx, event) - return created, nil + return MyAuthorCreated{Author: created, SlugAdjusted: created.Slug != author.GenerateSlug(name)}, nil } func authorNameOf(caller user.User) string { diff --git a/test/author_domain_test.go b/test/author_domain_test.go index 3c79f92..d086557 100644 --- a/test/author_domain_test.go +++ b/test/author_domain_test.go @@ -100,9 +100,10 @@ func TestAuthorUseCases(t *testing.T) { authors.fail.failNextWith("Create", author.ErrSlugTaken) uc := useCases.NewCreateMyAuthorUseCase(authors, users, discardRecorder) - created, err := uc.Create(context.Background(), 1) + result, err := uc.Create(context.Background(), 1) + created := result.Author - if err != nil || created.Slug != "marta-alves-2" { + if err != nil || created.Slug != "marta-alves-2" || !result.SlugAdjusted { t.Errorf("created %+v %v", created, err) } }) diff --git a/test/author_mutation_test.go b/test/author_mutation_test.go index de3a1d7..76203c1 100644 --- a/test/author_mutation_test.go +++ b/test/author_mutation_test.go @@ -60,9 +60,10 @@ func TestAuthorUseCaseGuards(t *testing.T) { } uc := useCases.NewCreateMyAuthorUseCase(authors, users, discardRecorder) - created, err := uc.Create(context.Background(), 1) + result, err := uc.Create(context.Background(), 1) + created := result.Author - if err != nil || created.Slug != author.SlugWithSuffix(base, 50) { + if err != nil || created.Slug != author.SlugWithSuffix(base, 50) || !result.SlugAdjusted { t.Errorf("created %+v %v", created, err) } }) diff --git a/test/authors_backend_http_test.go b/test/authors_backend_http_test.go index 86c8c96..ba696ea 100644 --- a/test/authors_backend_http_test.go +++ b/test/authors_backend_http_test.go @@ -420,7 +420,7 @@ func TestAuthorsBackendOwnAuthor(t *testing.T) { rec := e.as(t, authorEditorID, http.MethodPost, "/v1/author/me", "") body := decodeAuthorBody(t, rec) - if rec.Code != http.StatusCreated || body["name"] != c.name || body["slug"] != c.slug || body["user_id"] != float64(authorEditorID) || body["is_linked"] != true { + if rec.Code != http.StatusCreated || body["name"] != c.name || body["slug"] != c.slug || body["user_id"] != float64(authorEditorID) || body["is_linked"] != true || body["slug_adjusted"] != false { t.Errorf("status %d body %v", rec.Code, body) } }) @@ -446,7 +446,7 @@ func TestAuthorsBackendOwnAuthor(t *testing.T) { rec := e.as(t, authorEditorID, http.MethodPost, "/v1/author/me", "") - if body := decodeAuthorBody(t, rec); rec.Code != http.StatusCreated || body["slug"] != "marta-alves-3" { + if body := decodeAuthorBody(t, rec); rec.Code != http.StatusCreated || body["slug"] != "marta-alves-3" || body["slug_adjusted"] != true { t.Errorf("status %d body %v", rec.Code, body) } }) @@ -459,9 +459,20 @@ func TestAuthorsBackendOwnAuthor(t *testing.T) { rec := e.as(t, authorEditorID, http.MethodPost, "/v1/author/me", "") - slug, _ := decodeAuthorBody(t, rec)["slug"].(string) - if rec.Code != http.StatusCreated || utf8.RuneCountInString(slug) > 100 || !strings.HasSuffix(slug, "-2") { - t.Errorf("status %d slug %q", rec.Code, slug) + body := decodeAuthorBody(t, rec) + slug, _ := body["slug"].(string) + if rec.Code != http.StatusCreated || utf8.RuneCountInString(slug) > 100 || !strings.HasSuffix(slug, "-2") || body["slug_adjusted"] != true { + t.Errorf("status %d slug %q body %v", rec.Code, slug, body) + } + }) + + t.Run("Only the own-author creation carries slug_adjusted", func(t *testing.T) { + e := newAuthorEnv(t) + + rec := e.as(t, apiKeyOwnerId, http.MethodPost, "/v1/author/", `{"name": "Camille Roche"}`) + + if _, present := decodeAuthorBody(t, rec)["slug_adjusted"]; rec.Code != http.StatusCreated || present { + t.Errorf("status %d body %s", rec.Code, rec.Body.String()) } }) diff --git a/web/src/components/AccountMenuSheet.vue b/web/src/components/AccountMenuSheet.vue index 7a34b58..f0c7ae7 100644 --- a/web/src/components/AccountMenuSheet.vue +++ b/web/src/components/AccountMenuSheet.vue @@ -125,7 +125,9 @@ function moveFocus(event: KeyboardEvent) {
-
{{ t('Theme') }}
+
+ {{ t('Theme') }} +
= { - ok: { class: 'border border-accented bg-transparent text-toned', icon: 'i-lucide-check' }, - fail: { class: 'bg-(--rc-error-soft) text-error', icon: 'i-lucide-circle-x' }, - security: { class: 'bg-(--rc-warning-soft) text-warning', icon: 'i-lucide-shield-alert' }, + ok: { + class: 'border border-accented bg-transparent text-toned', + icon: 'i-lucide-check', + }, + fail: { + class: 'bg-(--rc-error-soft) text-error', + icon: 'i-lucide-circle-x', + }, + security: { + class: 'bg-(--rc-warning-soft) text-warning', + icon: 'i-lucide-shield-alert', + }, deleted: { class: 'border border-accented bg-transparent text-toned', icon: 'i-lucide-trash-2', @@ -29,6 +38,9 @@ const config = computed(() => TONES[props.tone]) :label="label" :icon="config.icon" :class="config.class" - :ui="{ base: 'h-5 shrink-0 gap-1 px-1.5 whitespace-nowrap', leadingIcon: 'size-3' }" + :ui="{ + base: 'h-5 shrink-0 gap-1 px-1.5 whitespace-nowrap', + leadingIcon: 'size-3', + }" /> diff --git a/web/src/components/ActivityDetailsPanel.vue b/web/src/components/ActivityDetailsPanel.vue index 5d3176e..6c21d07 100644 --- a/web/src/components/ActivityDetailsPanel.vue +++ b/web/src/components/ActivityDetailsPanel.vue @@ -136,19 +136,27 @@ function onOpenChange(isOpen: boolean) { }}
{{ t('Actor') }}
-
+
+ +
{{ t('Source') }}
-
{{ sourceLabel(current.source) }}
+
+ {{ sourceLabel(current.source) }} +
{{ t('IP address') }}
{{ current.ip }}
-
{{ t('Not applicable') }}
+
+ {{ t('Not applicable') }} +
{{ t('Browser') }}
{{ current.user_agent }}
-
{{ t('Not applicable') }}
+
+ {{ t('Not applicable') }} +
-

{{ t('Target') }}

+

+ {{ t('Target') }} +

diff --git a/web/src/components/ActivityFiltersSheet.vue b/web/src/components/ActivityFiltersSheet.vue index 22c27a7..ce7f978 100644 --- a/web/src/components/ActivityFiltersSheet.vue +++ b/web/src/components/ActivityFiltersSheet.vue @@ -72,7 +72,12 @@ function onOutcome(outcome: OutcomeFilter) { {{ t('Category') }}
diff --git a/web/src/components/ApiKeyReveal.vue b/web/src/components/ApiKeyReveal.vue index 8e44a6a..4618677 100644 --- a/web/src/components/ApiKeyReveal.vue +++ b/web/src/components/ApiKeyReveal.vue @@ -74,7 +74,10 @@ function keepOpenOnOutsideInteraction(event: Event) { :close="false" icon="i-lucide-triangle-alert" :title="t('You won\'t be able to see this key again.')" - :ui="{ root: 'gap-2.5 px-3 py-2.5', title: 'text-sm font-medium' }" + :ui="{ + root: 'gap-2.5 px-3 py-2.5', + title: 'text-sm font-medium', + }" /> {{ diff --git a/web/src/components/AppPaginator.vue b/web/src/components/AppPaginator.vue index 7171372..3e1d6a8 100644 --- a/web/src/components/AppPaginator.vue +++ b/web/src/components/AppPaginator.vue @@ -42,7 +42,10 @@ const summary = computed(() => { }) const sizeItems = computed(() => - ARTICLE_PAGE_SIZES.map((value) => ({ label: t('{0} per page', [value]), value })), + ARTICLE_PAGE_SIZES.map((value) => ({ + label: t('{0} per page', [value]), + value, + })), ) const FOCUS_RING = diff --git a/web/src/components/ArticleCardList.vue b/web/src/components/ArticleCardList.vue index 5be7d47..3cc43de 100644 --- a/web/src/components/ArticleCardList.vue +++ b/web/src/components/ArticleCardList.vue @@ -3,6 +3,8 @@ import { t } from '@/i18n' import { useRouter } from 'vue-router' import ArticleStatusBadge from '@/components/ArticleStatusBadge.vue' +import AuthorStack from '@/components/AuthorStack.vue' +import { authorsSummary } from '@/lib/articleMeta' import { formatRelativeDate } from '@/lib/relativeDate' import type { Article } from '@/composables/useArticles' @@ -140,6 +142,14 @@ function onRowClick(article: Article, event: MouseEvent) { {{ formatRelativeDate(article.updated_at, now) }}
+
+ + {{ authorsSummary(article.authors ?? []) }} +
+
{{ t('Created') }}
{{ createdLabel }}
@@ -144,9 +145,28 @@ async function copyUrl() {
- + diff --git a/web/src/components/ArticleSiteFilter.vue b/web/src/components/ArticleSiteFilter.vue new file mode 100644 index 0000000..8a6051b --- /dev/null +++ b/web/src/components/ArticleSiteFilter.vue @@ -0,0 +1,46 @@ + + + diff --git a/web/src/components/ArticleTable.vue b/web/src/components/ArticleTable.vue index a7bc419..c6bf7aa 100644 --- a/web/src/components/ArticleTable.vue +++ b/web/src/components/ArticleTable.vue @@ -4,6 +4,8 @@ import { t } from '@/i18n' import { computed, ref, watchPostEffect } from 'vue' import { useRouter } from 'vue-router' import ArticleStatusBadge from '@/components/ArticleStatusBadge.vue' +import AuthorStack from '@/components/AuthorStack.vue' +import type { Site } from '@/composables/useSites' import { formatAbsoluteDateFromIso, formatRelativeDate } from '@/lib/relativeDate' import type { Article } from '@/composables/useArticles' import { DEFAULT_ARTICLE_SORT, type ArticleSortField } from '@/lib/articleListQuery' @@ -15,9 +17,10 @@ const props = withDefaults( skeletonRows?: number sort?: string busyIds: Set + sites?: Site[] now?: Date }>(), - { skeletonRows: 5, sort: DEFAULT_ARTICLE_SORT }, + { skeletonRows: 5, sort: DEFAULT_ARTICLE_SORT, sites: () => [] }, ) const emit = defineEmits<{ @@ -30,8 +33,13 @@ const emit = defineEmits<{ const router = useRouter() -const columnWidths = - '[&:nth-child(2)]:w-27.5 [&:nth-child(3)]:w-32.5 [&:nth-child(4)]:w-35 [&:nth-child(5)]:w-11' +const SINGLE_SITE_WIDTHS = + '[&:nth-child(2)]:w-26 [&:nth-child(3)]:w-27.5 [&:nth-child(4)]:w-32.5 [&:nth-child(5)]:w-35 [&:nth-child(6)]:w-11' +const SEVERAL_SITES_WIDTHS = + '[&:nth-child(2)]:w-26 [&:nth-child(3)]:w-32.5 [&:nth-child(4)]:w-27.5 [&:nth-child(5)]:w-32.5 [&:nth-child(6)]:w-35 [&:nth-child(7)]:w-11' + +const showSite = computed(() => props.sites.length > 1) +const columnWidths = computed(() => (showSite.value ? SEVERAL_SITES_WIDTHS : SINGLE_SITE_WIDTHS)) const sorting = computed(() => { const [id, direction] = props.sort.split(':') @@ -44,7 +52,7 @@ const SORTABLE_COLUMNS = ['title', 'status', 'created_at', 'updated_at'] watchPostEffect(() => { const [active, direction] = props.sort.split(':') tableRoot.value?.querySelectorAll('thead th').forEach((header, index) => { - if (SORTABLE_COLUMNS[index] === active) { + if (SORTABLE_COLUMNS.includes(active!) && columns.value[index]?.id === active) { header.setAttribute('aria-sort', direction === 'desc' ? 'descending' : 'ascending') } else { header.removeAttribute('aria-sort') @@ -70,14 +78,33 @@ const caption = computed(() => { ]) }) -const columns = [ +const columns = computed(() => [ { accessorKey: 'title', + id: 'title', get header() { return t('Title') }, enableSorting: false, }, + { + id: 'authors', + get header() { + return t('Authors') + }, + enableSorting: false, + }, + ...(showSite.value + ? [ + { + id: 'site', + get header() { + return t('Site') + }, + enableSorting: false, + }, + ] + : []), { accessorKey: 'is_online', id: 'status', @@ -89,6 +116,7 @@ const columns = [ }, { accessorKey: 'created_at', + id: 'created_at', get header() { return t('Created') }, @@ -97,6 +125,7 @@ const columns = [ }, { accessorKey: 'updated_at', + id: 'updated_at', get header() { return t('Updated') }, @@ -104,7 +133,15 @@ const columns = [ enableSorting: false, }, { id: 'actions', header: '', size: 44 }, -] +]) + +function siteNameOf(article: Article) { + return props.sites.find((site) => site.id === article.site_id)?.name ?? '' +} + +function authorNames(article: Article) { + return (article.authors ?? []).map((author) => author.name).join(', ') +} function sortIcon(field: string) { const [id, direction] = props.sort.split(':') @@ -188,6 +225,8 @@ function onSelect(_event: Event, row: { original: Article }) { class="flex h-11 items-center gap-3 border-t border-muted px-3 first:border-t-0" > + + @@ -290,6 +329,20 @@ function onSelect(_event: Event, row: { original: Article }) { + + + + diff --git a/web/src/components/variants/VariantFormFields.vue b/web/src/components/variants/VariantFormFields.vue index dfaed78..6c638ea 100644 --- a/web/src/components/variants/VariantFormFields.vue +++ b/web/src/components/variants/VariantFormFields.vue @@ -186,7 +186,10 @@ function setFormat(value: unknown) { :highlight="Boolean(errors.width)" autocomplete="off" class="w-full" - :ui="{ base: `${FIELD_BASE} pe-10`, trailing: 'pe-3' }" + :ui="{ + base: `${FIELD_BASE} pe-10`, + trailing: 'pe-3', + }" @blur="emit('blur', 'width')" >