Support plone.restapi's @content-types, @behaviors and @workflows services
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 12/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
Direzione di ricerca
Start from SITE_TYPE in restapi/dexterityTypes.ts, which the issue says assumes Plone Site and must detect @content-types another way. The type, behavior and workflow json tables named in the issue are the data sources. Scope is the whole endpoint table, staged in four steps, so a first contribution would be one step, not the full issue. Done means the listed endpoints respond with the documented shapes and return 404 for unknown types and workflows.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
plone.restapi is getting new services for managing content types, behaviors and workflows (plone/plone.restapi#2061). The new content types control panel, @plone/controlpanels, uses them in Plone Aurora (plone/aurora#269, merged) and Volto (plone/volto#8500). Nick should support them too, so Nick sites get the whole control panel.
[!NOTE]
The plone.restapi PRs are in review, so details may still change: plone/plone.restapi#2070 (@content-types), plone/plone.restapi#2080 (@behaviors), plone/plone.restapi#2081 (@workflowsand workflow changes) and plone/plone.restapi#2090 (the workflow chain). The full documentation, with example requests and responses, is in the stack's top branch: content-types.md, behaviors.md, workflows.md and types.md, and the example responses (content_types_*,behaviors_*,workflows_*,types_get_with_behaviors*).
Today
The control panel works on Nick already, through @controlpanels/dexterity-types and @types: listing, adding and deleting types, a type's title, description and allowed types, and its fields. Everything else is turned off, because those endpoints don't have it.
The services
All of them are at the site root, and need the "Plone Site Setup: Types" permission in Plone.
| Method | Path | Result |
|---|---|---|
GET |
/@content-types |
Every content type with its settings. |
GET |
/@content-types/{type} |
One content type with its settings. |
POST |
/@content-types |
Create a type, or copy one with copy_from. |
PATCH |
/@content-types/{type} |
Change some settings of a type. |
DELETE |
/@content-types/{type} |
Delete a type that has no items. |
GET |
/@content-types/{type}/workflow |
The workflow of a type. |
POST |
/@content-types/{type}/workflow |
Change a type's workflow, with a dry_run preview. |
GET |
/@behaviors |
The behaviors, and the fields each one adds. |
GET |
/@workflows |
The workflows, and the default workflow. |
GET |
/@workflows/{id} |
One workflow, with its states and transitions. |
POST |
/@workflows |
Change the default workflow, with a dry_run preview. |
GET |
/@types/{type}?behaviors=a,b |
The type's schema with these behaviors, in this order, without changing the type. |
Type IDs are URL-encoded in paths. Unknown types and workflows return 404.
@content-types
A type looks like this (shortened from content_types_get_item.resp):
{
"@id": "http://localhost:55001/plone/@content-types/Event",
"id": "Event",
"title": "Event",
"content_count": 0,
"schema": { "fieldsets": [{ "id": "general", "title": "General", "fields": ["title", "description"] }], "properties": {}, "required": [] },
"data": {
"title": "Event",
"description": "Events can be shown in calendars.",
"global_allow": true,
"allowed_content_types_mode": { "token": "none", "title": "No types" },
"allowed_content_types": [],
"searchable": true,
"default_page": true,
"in_navigation": true,
"allow_discussion": false,
"behaviors": [{ "token": "plone.dublincore", "title": "Dublin Core metadata" }],
"versioning": { "token": "automatic", "title": "Automatic" }
},
"workflow": { "chain": ["simple_publication_workflow"], "follows_default": true }
}
-
content_count: the number of items of the type, including those the user can't see. -
schemaanddata: the settings come as a JSON schema with fieldsets, and their values. The frontend renders the fieldsets it doesn't know, so add-ons can add their own settings to every type. Choices are{ token, title }, like in control panels. -
The core settings, by fieldset:
Fieldset Field Value generaltitle,descriptionNot empty, and free text. contentsglobal_allowWhether the type can be added inside types that allow every type. contentsallowed_content_types_modeall,selectedornone.contentsallowed_content_typesThe selected type IDs. selectedneeds at least one,noneneeds none, andallkeeps them for later.visibilitysearchableWhether items show in search results. visibilitydefault_pageWhether items can be a folder's default page. visibilityin_navigationWhether items show in the navigation. commentsallow_discussionWhether items allow comments. Only when comments are enabled. behaviorsbehaviorsThe complete, ordered list of the type's behaviors. Their order sets where their fields appear in the edit form. versioningversioningoff,manualorautomatic. -
workflow(read-only here):chainlists the type's workflows in order, the first one setting the state, and is empty without a workflow.follows_defaultistruewhen the type uses the site's default workflow. -
PATCH: only the fields sent change. A choice is its token or a{ token }object. Every change is validated before any is stored: invalid, unknown or read-only fields return400with the field names and messages.behaviorsreplaces the whole list. -
POST:titleis required,idanddescriptionare optional (the ID comes from the title). An existing ID returns409.copy_fromcopies the schema, behaviors, settings and workflow of another type. -
DELETE: returns409with the number of items while the type has items. It also removes the type from the allowed types of the others.
Workflow changes
POST /@content-types/{type}/workflow takes workflow (an ID, or null for none) or follows_default: true, an optional state_map (current state → new state, "" for items without a workflow), and dry_run.
With dry_run, it changes nothing and returns the plan, which the control panel shows as a mapping step:
{
"workflow": "intranet_workflow",
"current": "simple_publication_workflow",
"states": [
{ "id": "private", "count": 1, "suggested": "private" },
{ "id": "published", "count": 1, "suggested": "external" }
],
"unaffected": 0
}
Without it, it assigns the workflow, moves the items to their new states (states left out of state_map get the suggested one), updates their security, and returns { "workflow", "follows_default", "changed" }.
POST /@workflows changes the default workflow the same way, with default instead of workflow. Its plan also lists the types that follow the default.
The suggested state keeps who can see the items: the most visible state of the new workflow that isn't more visible than the current one. Ties go to the state with the same ID, then the same title, then the initial state.
@workflows
The list has default (the default workflow's ID, or null) and items, each with @id, id, title, description, initial_state and the IDs of its states. GET /@workflows/{id} adds:
states, each withid,title,description, itstransitions,permission_roles(permission → roles), and itsvisibility, from the roles withView:anyone(Anonymous),members(Authenticated or Member),restricted(only other roles) orunknown. The control panel colors the states with it.transitions, each withid,title,description,new_stateand aguard.types: the types using the workflow.
@behaviors
items sorted by name, each with name, title, description and fieldsets (id, title, fields): the fields the behavior adds. The control panel shows them when adding behaviors, and searches by name. The plone.restapi.Behaviors vocabulary lists them for the behaviors setting.
For Nick
Nick has most of what this needs:
- Types: the
typetable hasglobal_allow,filter_content_types,allowed_content_types, the behaviors inschema.behaviors, and oneworkflowper type. - Behaviors: the
behaviortable, with each behavior's schema, so@behaviorsand the preview can be built from it, withmergeSchemas. - Workflows: the
jsonof each workflow has its states with roles → permissions, sovisibilitycomes from the roles withView. - Jobs:
@jobscould run workflow changes on large sites later. The control panel's driver already expects workflow changes as jobs, so this can come later.
Open questions:
- The default workflow: Nick assigns one workflow to each type, and has no default workflow. Either Nick gets one, or
follows_defaultis alwaysfalse, andPOST /@workflowswaits. - The chain: Nick has one workflow per type, so
chainhas one item. - Where
searchable,default_page,in_navigation,allow_discussionandversioninglive:in_navigationmatchesdisplayed_typesin the navigation control panel, andversioningtheversioningbehavior. The others may need new storage. - Add-on settings: in plone.restapi, each fieldset is an adapter, and add-ons register their own. Nick could let profiles contribute fieldsets.
In the frontend
@plone/controlpanels detects the services with GET /@content-types/Plone%20Site, GET /@behaviors and GET /@workflows. A 404 means a service is missing. Nick's site type is Site, so the frontend needs to detect @content-types another way, and not assume Plone Site (SITE_TYPE in restapi/dexterityTypes.ts). plone/aurora#438 makes that change: the driver reads the site root's type, and asks for /@content-types/{that type}.
Suggested order
GETandPATCH /@content-typesfor the settings Nick already has, andPOST,DELETEandcopy_from.@behaviors, the orderedbehaviorssetting, and@types/{type}?behaviors=.@workflows, and changing a type's workflow, withdry_run.- The other settings, the default workflow, and add-on fieldsets.
Assisted-by: Claude Opus 5.5
- Lingua principale
- TypeScript
- Stelle
- 20
- Fork
- 6
- Merge medio
- 8h 30m
- PR unite (30g)
- 43
Preparare l'ambiente
- Include un Dockerfile o un file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di plone/nick
-
03 type: feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
I maintainer di solito rispondono entro 1 giorno
-
01 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
01 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
I maintainer di solito rispondono entro 1 giorno
-
01 type: bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
Add the @upgrade endpointAperta03 type: feature
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 1 giorno
Issue simili
-
api bug priority:low ready-for-agent
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
wondermoney/wondermoney#862 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
rootsiemen/seo-agent-tools#70 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
alvinunreal/oh-my-opencode-slim#1971 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
elecnix/bellwether#467 ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno