Skip to content

Wiki比較パネルの初期表示不一致を修正 - #827

Open
NishikawaKoharu wants to merge 1 commit into
RCOSDP:developfrom
NishikawaKoharu:feature/fix-wiki-compare-default-current
Open

NishikawaKoharu wants to merge 1 commit into
RCOSDP:developfrom
NishikawaKoharu:feature/fix-wiki-compare-default-current

Conversation

@NishikawaKoharu

Copy link
Copy Markdown

Purpose

Fix a Wiki Compare bug: opening Compare shows "(Current)" in the compare dropdown, but the actual diff is against the previous version. Selecting the previous version does not change the diff; selecting "(Current)" again is required before the comparison matches the label.

Companion frontend PR: RDM-wiki-develop feature/fix-wiki-compare-default-current.

Changes

  • Change Compare default from previous to current (JS and views.py)
  • Remap server-side previous to the real dropdown value (version number)
  • Add resolveCompareVersion() on the Milkdown side (client-side safeguard)
  • Add regression tests in test_wiki.py

Changed files:

  • addons/wiki/static/wikiPageMilkdown.js
  • addons/wiki/static/wikiPage.js
  • website/static/js/pages/wiki-edit-page.js
  • addons/wiki/views.py
  • addons/wiki/tests/test_wiki.py

QA Notes

  • Does this change require a data migration? If so, what data will we migrate?
    • No.
  • What is the level of risk?
    • Low to medium. Limited to Wiki edit UI (Compare).
    • Any permissions code touched?
      • No.
    • Is this an additive or subtractive change, other?
      • Behavioral fix (existing Compare bug).
  • How can QA verify? (Through UI, API, AdminApp or AdminAdminApp?)
    • Through UI — Wiki edit page with 2+ versions.
    1. Open Compare: dropdown shows "(Current)" and the diff is against the current saved version
    2. Change compare target to the previous version → diff changes; select "(Current)" again → returns to the previous state
  • What features or workflows might this change impact?
    • Wiki Compare panel initial selection and diff display
  • How will this impact performance?
    • Negligible.

Documentation

  • No documentation updates required.

Side Effects

  • Compare initially targets Current (the previous "one version back" behavior is still available by explicit dropdown selection).

Ticket

https://redmine.devops.rcos.nii.ac.jp/issues/63974

@yacchin1205 yacchin1205 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントさせていただきました。ご確認ください。
.jsのコードはユニットテストがなく、問題が本番で顕在化することが予想されるため、予期しないケースではなんらかの痕跡を残しておくのが良いのかなと感じます。


function getEditorMarkdown() {
var content = '';
if (mEdit && typeof mEdit.action === 'function') {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この関数は、エディタが予期しない状態であったときも、実際に空の内容であった場合も、同様に空文字列を返すため、何かトラブルが起きたときに調査しづらいコードに見えます。if (mEdit && typeof mEdit.action === 'function') { が成立しない場合に、エラーとまではしなくても、consoleにwarning等は出力できると良いかもしれません。ご検討ください。

if (compareVersion !== 'previous') {
return String(compareVersion);
}
var select = document.getElementById('compareVersionSelect');

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous を指定しても、対応する選択肢を取得できなかった場合は、黙って current に切り替わる点が気になりました。過去版が存在しない場合の扱いと、DOMを取得できない等の想定外の状態を区別し、後者はwarning等で確認できるとよいかもしれません。ご検討ください。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants