Commit graph

12687 commits

Author SHA1 Message Date
jenkins-bot 8c4989c1be Merge "Fix parameter search being to relaxed on unknown params" 2021-07-02 15:47:11 +00:00
Thiemo Kreuz 07344fce0f Rename misleading "extend" method in template spec class
This doesn't "extend". It was never used like this. What it
actually does is to link between a (cached) TemplateData blob
and the spec class that want's to use it.

Is this the best possible name?
* fillFromTemplateData( … )?
* propagateTemplateDocumentation( … )?
* readDocumentationFrom( templateData )?
* …?

Do we want to rename the "spec" class as well?
* MWTemplateDocumentation?
* MWTemplateMetadata?
* MWTemplateDataAccessor?
* …?

Bug: T285483
Change-Id: I6c52ef42d411c2f47fc0080768d36ebda4dd2a55
2021-07-02 11:26:04 +00:00
Thiemo Kreuz bc1885c36f Store TemplateData JSON as is instead of copying values
Just store the JSON blob from the TemplateData API as is.

This comes with a bunch of nice consequences:
* Less code.
* Less class properties that don't do anything but copy what's
  in the TemplateData blob.
* Easier to understand what's going on. The `this.templateData`
  property is now a reference to the *actual* TemplateData
  documentation.
* No need to cache the documentedParamOrder. Just do it when
  needed.

This also removes an unused feature from the `extend()` method
that didn't made sense anyway. Before it was possible to merge
conflicting documentations. But this is not only unused, it's
impossible to have multiple documentations for the same
template.

The method acts as a straight setter now. The next patch will
rename it accordingly.

Bug: T285483
Change-Id: I3ffc202577e9a20fc7491234601ccd981113f866
2021-07-02 11:25:47 +00:00
Thiemo Kreuz 0d9cb6f1bb Track seen parameter names in separate data structure
Instead of faking entries in this.params, let's use a separate
tiny data structure to keep track of parameters we have seen so
far, and in which order.

This finally allows to easily distinguish between documented and
undocumented parameters.

Bug: T285483
Change-Id: Idf62b0661178a3bbef7e817edf016dbd572d415b
2021-07-02 13:24:43 +02:00
jenkins-bot 2e4ac455f0 Merge "Add more edge-case test cases for template spec class" 2021-07-01 18:57:51 +00:00
Thiemo Kreuz fecded9f70 Fix parameter search being to relaxed on unknown params
When what you type is a partial match, you can't add it as an
unknown parameter, even if that would be the correct action. The
reason for this unexpected edge-case is a mistake in the code
where a variable called "exactMatch" is set when a *partial*
"nameMatch" was found.

Bug: T285940
Change-Id: I6d12e2d7251a19d7d5f8be544c3c32a3ac14fcf0
2021-07-01 20:09:51 +02:00
Thiemo Kreuz 99523b855c Use and document the term "known parameter" in template code
The so called "spec" class keeps track of parameters that have
been used before, no matter if documented via TemplateData or
not. Removed parameters are still "known" (i.e. have been seen
before).

This feature allows to easily find previously used parameters
names when an undocumented parameter was removed and the user
tries to add it again.

Bug: T285483
Change-Id: Ia1555eea87cd99e7a3f386f4279ec5a80fb98a79
2021-07-01 12:03:38 +00:00
jenkins-bot 7afb7981d1 Merge "Rewrite MWTemplateDialog.setApplicableStatus for readability" 2021-07-01 11:56:30 +00:00
jenkins-bot 5028f4eaf3 Merge "Remove unused "insert" action from MWTemplateDialog" 2021-07-01 11:52:21 +00:00
jenkins-bot 50f293019c Merge "Rewrite MWTransclusionNode.isSingleTemplate for readability" 2021-07-01 11:21:44 +00:00
jenkins-bot 3709dfbee2 Merge "Update documentation for all getWikitext()/serialize() methods" 2021-07-01 11:18:08 +00:00
Thiemo Kreuz f1a66c17e4 Rewrite MWTemplateDialog.setApplicableStatus for readability
I rearranged this piece of code like a dozen times before I
finally understood what it actually does. This should be much
more obvious now.

The idea is:
* If no edit was made the button is always disabled.
* You can save pretty much everything, except when the
  transclusion still starts with a placeholder.
* You can also click the done button when the dialog is empty.
  This feels a bit odd, but was like this before. I think this
  codepath is unreachable. But it probably doesn't hurt to
  keep it.

Bug: T284895
Change-Id: Ic483201b64fd64f414c5b1ec4c44198b8eadb9f2
2021-07-01 11:20:50 +02:00
Thiemo Kreuz d8f4da199d Add more edge-case test cases for template spec class
Bug: T285483
Change-Id: I0a9bf7fe51242161dbc57c9301f360c9e8f35b93
2021-07-01 10:13:00 +02:00
Thiemo Kreuz db531ddba5 Add missing search result limitation to template search
Bug: T274903
Change-Id: If57d28f7796d69825a25fa9b67bcd5c127c9e3b7
2021-07-01 09:33:52 +02:00
jenkins-bot f9cb2e3519 Merge "Don't create a checkbox for ve.ui.MWParameterPlaceholderPage" 2021-06-30 14:31:59 +00:00
jenkins-bot 0e3bf54e3f Merge "Add documentation to ve.ui.MWTemplateOutlineTemplateWidget" 2021-06-30 14:31:57 +00:00
jenkins-bot 217793ebd1 Merge "Use the parameter's label in the sidebar" 2021-06-30 14:31:55 +00:00
jenkins-bot 127ea9ea27 Merge "Avoid the term "canonical order" in template related docs" 2021-06-30 11:35:27 +00:00
jenkins-bot 5943b5a25e Merge "Fix spec.fillFromTemplate() not skipping aliases any more" 2021-06-30 11:11:24 +00:00
jenkins-bot 6aaec0c88b Merge "Rename temporary "x" variable in spec class tests" 2021-06-30 11:09:54 +00:00
jenkins-bot 8ca3fa3c99 Merge "Fix broken template serialization test setup" 2021-06-30 11:06:24 +00:00
Thiemo Kreuz 84329a40c8 Rename temporary "x" variable in spec class tests
I forgot to give this variable a proper name. The "x" was not
meant to stay.

Bug: T285483
Change-Id: I482b9282676082f44d5f98a574e5ada05dfb6318
2021-06-30 12:16:50 +02:00
Thiemo Kreuz 466e428a81 Fix spec.fillFromTemplate() not skipping aliases any more
In I04b8a14fbec7be5a1c4defabf92e94f694c1e638 we sepearted params from
aliases. There we missed that re-filling the parameters from the 
template could re-add the aliases.

Bug: T285483
Bug: T285843
Change-Id: I1928b443a5f708bc8c57efa5ad0a86b5915b159c
2021-06-30 10:14:43 +00:00
Thiemo Kreuz bc4aeed86e Avoid the term "canonical order" in template related docs
While the term "canonical" is not wrong, I find it still
somewhat ambiguous.

1. "Canonical" could mean different things. E.g. is the order
of parameters as they appear in the article's wikitext the
"canonical" one? It's possible to argue like this, esp. if a
template doesn't have TemplateData documentation. In this case
the only order known is the one from the wikitext.

2. "Canonical" sounds like the parameters must be reordered.
But this should never happen. Not having dirty diffs is more
important than having the parameters in a specific order.

Bug: T285483
Change-Id: I23658d37fea50b727667677ac6a49066673b2135
2021-06-30 09:38:28 +02:00
jenkins-bot f442bbfd55 Merge "Remove unused MWTransclusionModel.specCache property" 2021-06-29 21:47:14 +00:00
Andrew Kostka 0c141e2581 Add documentation to ve.ui.MWTemplateOutlineTemplateWidget
Change-Id: Ibc0b39fd417fa7eef5cf1cd52b9769c6514ce85d
2021-06-29 21:50:41 +02:00
Andrew Kostka 30917c8ba3 Don't create a checkbox for ve.ui.MWParameterPlaceholderPage
Change-Id: Ia02e86e026e618a4ace31306fe50f003c49080ae
2021-06-29 21:21:19 +02:00
Andrew Kostka 526a49672e Use the parameter's label in the sidebar
Change-Id: Ic2c00f51088d67453bb50ff0fa15f22c9fbd8e56
2021-06-29 20:44:17 +02:00
Thiemo Kreuz 8dca99d38c Fix broken template serialization test setup
This was not really testing anything before. Introduced in
I76c6fe8.

Bug: T285382
Change-Id: I5f8343c9805b9a1adc2efdd13a103a7f1196e15b
2021-06-29 16:29:11 +02:00
jenkins-bot 7426139a41 Merge "Fix possibly uninitialized variable in template dialog" 2021-06-29 13:47:06 +00:00
jenkins-bot 802be178e3 Merge "Extract MWTemplateTitleInputWidget.addExactMatch into a method" 2021-06-29 13:47:03 +00:00
jenkins-bot 17cc6831bc Merge "Revert "Extract "show all" to placeholder class"" 2021-06-29 09:55:53 +00:00
jenkins-bot 82821f6889 Merge "Rename ambiguous "lang" to languageCode in spec class" 2021-06-29 09:46:51 +00:00
jenkins-bot 297cb53e33 Merge "Remove spec documentation that literally repeats the code" 2021-06-29 09:46:49 +00:00
jenkins-bot d588a736c2 Merge "Fix all spec methods to not crash on unknown parameters" 2021-06-29 09:41:07 +00:00
jenkins-bot c84dd3d44f Merge "Use separate data structure to store aliases in spec" 2021-06-29 09:41:05 +00:00
jenkins-bot 73fe8f7a38 Merge "Add icons to the show/hide button in the ExpandableContentElement" 2021-06-29 08:55:46 +00:00
jenkins-bot b3d23f59b3 Merge "Fix the show/hide button for the ExpandableContentElement on mobile" 2021-06-29 08:49:41 +00:00
Andrew Kostka 2c0f44df83 Add icons to the show/hide button in the ExpandableContentElement
Bug: T282996
Change-Id: I2013c00696af2320d871e12c6d523f0da1dcb277
2021-06-29 08:33:22 +00:00
Thiemo Kreuz 121bf88f48 Remove unused MWTransclusionModel.specCache property
This property is a reference to a static variable with the
same name, initialized at the very top of the file. All
instances of the class use the same cache. They all use the
shared specCache directly, not the reference.

Depends-On: I0084410b7eab29048451ad67c18d6c2180c4f1b1
Change-Id: I9fd79ce3abd533dbb48a210e596802ea9e692855
2021-06-29 08:20:21 +02:00
jenkins-bot 9fcba8bac8 Merge "Minor documentation updates in template related classes" 2021-06-28 14:46:11 +00:00
Andrew Kostka e5cbe69187 Fix the show/hide button for the ExpandableContentElement on mobile
Bug: T283943
Change-Id: I23ae2350dfb9100ed6604fc93628c616c41ab2e1
2021-06-28 15:18:38 +02:00
Thiemo Kreuz (WMDE) e6d3828429 Revert "Extract "show all" to placeholder class"
This reverts commit 950a5300dc.

Reason for revert: This broke several workflows. The reason is
that MWParameterPlaceholderPage & MWParameterSearchWidget both
hold references to the MWTemplateModel. This model is not
always the same. The dialog might be the same when a template
is edited multiple times. But the model might be a new one.
From this point on the MWParameterSearchWidget pulls data from
an outdated model.

Bug: T284636
Bug: T285571
Change-Id: I7b9ea8cab8f17705ec8020f07e3732da6ba0e73c
2021-06-28 14:04:12 +02:00
jenkins-bot 8da60b7864 Merge "Hotfix for broken "Extract show all to placeholder class"" 2021-06-28 11:24:50 +00:00
Thiemo Kreuz 6b346442ad Hotfix for broken "Extract show all to placeholder class"
This does not revert commit 950a5300 but applies the most
minimal hotfix I could come up with.

The reason for the breakage is that MWParameterPlaceholderPage
& MWParameterSearchWidget both hold references to the
MWTemplateModel. This model is not always the same. The dialog
might be the same when a template is edited multiple times.
But the model might be a new one. From this point on the
MWParameterSearchWidget pulls data from an outdated model.

This extra check compares this model reference and creates a
new widget when it changed.

Bug: T284636
Bug: T285571
Change-Id: Ib3eca52bbff90ffbf56a257e3984adcbe02b310b
2021-06-27 18:29:23 +02:00
Thiemo Kreuz b3bede3ba0 Extract MWTemplateTitleInputWidget.addExactMatch into a method
Same as in TemplateWizard, see I128bc00.

Bug: T274903
Change-Id: I8693b85625a8640e44c213300d7c6862430bec47
2021-06-25 17:07:32 +02:00
Thiemo Kreuz 4b62bc5bf1 Rewrite MWTransclusionNode.isSingleTemplate for readability
* Introduce variable names that explain better what's going on.
* Add comments.

Bug: T284895
Change-Id: Id5e8be9e52342ce049bdceec71f0f7cd01a6e2e9
2021-06-25 16:51:53 +02:00
Thiemo Kreuz 2966b69609 Fix possibly uninitialized variable in template dialog
There is a codepath where `modelPromise` is undefined and
calling `modelPromise.then()` fails. This codepath implies
that the dialog is empty and there is nothing to update. We
can just close the dialog then.

I found this while debugging the actions in this dialog.
This happens when the dialog is empty (except for a
placeholder) but you submit it anyway. This is typically
not possible as the button is supposed to be disabled.
Still I think it's a good idea to make this code less
fragile.

The relevant code was introduced in Ibc2fc66 (2016).

Change-Id: Ia6b723548456c211b944a2320949bfc23b0afa16
2021-06-25 16:49:30 +02:00
Thiemo Kreuz 26b0322ff0 Minor documentation updates in template related classes
Bug: T285483
Change-Id: I1cf17d7bfb01326b93bc781b2501a492d50f0aab
2021-06-25 16:46:59 +02:00
Thiemo Kreuz 6f2d98ee68 Rename ambiguous "lang" to languageCode in spec class
Change-Id: I1382a453cd3dda2b584ae8b0993fb3e4ac963ce0
2021-06-25 08:40:16 +02:00