italia / italia/publiccode-editor

Don't show the `publiccodeYmlVersion` field to the user

Open
#518 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
32
Forks
33
Avg merge
3d 15h
Merged PRs (30d)
16

Description

When you load a `publiccode.yml` with `publiccodeYmlVersion` set to a previous version, this field appears:

Image

Image

On the surface it has two immediate issues:
* The label being "_hidden field for actual publiccode version_", which is extremely confusing to the user. "_Why is it hidden? Why am I seeing it if it's is hidden? Is it the publiccode **.yml** version?_"
* In the combo it says "Current" and "Latest", which are somewhat synonymous

But the real issue is that the field is not useful to the user, and even misleading:
* You can set "0.3" in the combo, but the editor **always** targets the latest version. You then have an editor-generated file saying `publiccodeYmlVersion: "0.3"` using fields from 0.4
* When you load a file with `publiccodeYmlVersion: "0"` (which is preferable over "0.x"), the combo appears and gives you the option to change it to the "latest version", as if `"0"` is not the latest of v0. See the image below.
Image
* When you use an invalid version, it shows in the combo as it was a valid option to pick from

### How to fix it

The editor always deals with the latest major, so the correct way should be:
1. Load a file, detect the _major_ (v0, v1 - v1 doesn't exist yet but will eventually)
2. If it's not the latest _minor_ (fe `"0.3"`), autofix[^1] `publiccodeYmlVersion` to that specific major (fe `"0"`)

* (actually I'd say always autofix it to just the major even if it's the latest (fe. `"0.4.0"` -> `"0"`)
3. Present the UI accordingly, with fields and validations from v0 or v1, depending on the `publiccodeYmlVersion`
4. If `publiccodeYmlVersion` has an invalid minor/patch, but a valid major, autofix it to the valid major ((fe. `"0.11.0"` -> `"0"`)
5. If `publiccodeYmlVersion` has an invalid version or is not there, autofix it to the latest major (Let's pretend v1 is already out for this: `"99"` -> `"1"`)

[^1]: when I say autofixing, I'm also imagining a warning or information message in the errors/warnings pane

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.