Skip to content

Allow the creation of Project Wikis using the internal provider#24195

Open
mereghost wants to merge 17 commits into
impl/remove-wiki-project-modulefrom
impl/enable-project-internal-wiki
Open

Allow the creation of Project Wikis using the internal provider#24195
mereghost wants to merge 17 commits into
impl/remove-wiki-project-modulefrom
impl/enable-project-internal-wiki

Conversation

@mereghost

@mereghost mereghost commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This covers parts of OP#XWI-52, OP#XWI-53 and OP#XWI-54 on the OP#XWI-42 feature.

What is missing at this moment:

  • Updated Wiki enable/disable tests.
  • Update flash messages

@mereghost mereghost force-pushed the impl/enable-project-internal-wiki branch from 1269d5c to 464e5f6 Compare July 9, 2026 09:33
@mereghost mereghost force-pushed the impl/enable-project-internal-wiki branch from 464e5f6 to f46bdd8 Compare July 9, 2026 09:40
@mereghost mereghost force-pushed the impl/enable-project-internal-wiki branch from 9da6890 to 8605b87 Compare July 9, 2026 15:03
@opf opf deleted a comment from github-actions Bot Jul 10, 2026
@mereghost mereghost force-pushed the impl/enable-project-internal-wiki branch from f516674 to 8a81432 Compare July 10, 2026 12:15
@mereghost mereghost self-assigned this Jul 10, 2026
@mereghost mereghost marked this pull request as ready for review July 13, 2026 09:13
@mereghost mereghost requested a review from a team July 13, 2026 09:13
@github-actions

Copy link
Copy Markdown

Warning

This pull request does not link an OpenProject work package.

Please add a link to the work package in the description, or reference it in the
title in square brackets, e.g. [SLUG-123] My title here.

@mereghost

Copy link
Copy Markdown
Contributor Author

Early feedback is welcome. It builds upon its parent branch.

@NobodysNightmare NobodysNightmare left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some first preliminary feedback

Comment thread app/models/wiki.rb

def visible?(user = User.current)
!user.nil? && user.allowed_in_project?(:view_wiki_pages, project)
enabled && user&.allowed_in_project?(:view_wiki_pages, project)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nothing that you introduced, but I have to admit that I find it very weird to have a parameter user that can be passed in, that has a default value that can never be nil and then still perform a nil check as the first thing.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That was probably just some rubocop appeasing at some point.

Well... User.current could be nil

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am pretty sure that it can't. We always fall back to the anonymous user...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Even on test cases? 😮

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If not, the test cases would behave weird and we'd adapt code purely to work with test cases that behave different than reality.

I didn't check test cases, but I can confirm that opening a fresh rails console also gives me the anonymous user when calling User.current.

return project.reload.wiki if Wiki.exists?(project: @project)

Wiki.create!(project: @project, start_page: "Wiki")
@project.reload

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This method looks unfinished (aside from the TODO comment), I am wondering if it's doing what's intended:

  • 3 places call it @project, one place calls it project
  • The guard clause returns the wiki after reloading the project, the last clause returns the reloaded project
    • the return value is not used

Right now, I think what you need is

Wiki.create!(project: @project, start_page: "Wiki") unless Wiki.exists?(project: @project)

@project.reload

I also realize (and that's what your FIXME probably hints at) that this is the second place where a wiki is created during seeding, so maybe something can be improved/centralized here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this whole process got messy right now. It was handled by AR hooks and now we need a proper implementation / solution.

Comment thread db/migrate/20260708100831_adds_enabled_column_to_wikis_table.rb Outdated
::BasicData::PrioritySeeder,
::Bim::BasicData::SettingSeeder,
::Bim::BasicData::ThemeSeeder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😱 😱 😱

Primer::Forms::ToggleSwitchForm.new(
name: "enable_interal_wiki",
label: t("projects.settings.internal_wiki.enable"),
caption: t("projects.settings.internal_wiki.caption"),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Probably a good case for component-relative translations?

I.e. t(".enable") and t(".caption")

end

def wiki_enabled?
!!@project.wiki

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

That's a surprising consequence of a method overwrite I saw earlier.

I'd have expected that this would read @project.wiki.enabled?, because that would seem to make sense right?

However, the Project will act as if it has no wiki, unless the wiki is enabled. I guess that this is great for compatibility with existing code, but it definitely also leads to surprising places like this one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. The codebase used to check for the enabled module, now we need 2 different checks: Internal Provider and the Project Wiki.

I'll see if I can de-crapify some of the checks around it without breaking another 400 tests.


create_or_update_wiki
replace_via_turbo_stream(component: ProjectInternalWikiComponent.new(@project.reload))
render_success_flash_message_via_turbo_stream(message: "Internal wiki disenabled for this project.")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

TODO ^^

end

def create_or_update_wiki
if find_project_wiki

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is confusing. find_project_wiki is already a before_action, so this method was already executed and it would probably be enough to write if @wiki.

On the other hand, this is the only method that refers to @wiki at all, so I am wondering, whether this should be inlined or at least de-instance-variablified.

E.g.

def create_or_update_wiki
  wiki = Wiki.find_by(project: @project)
  if wiki
    wiki.toggle!(:enabled)
  else
    Wiki.create!(project: @project, start_page: "Wiki")
  end
end

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Oh... it is a remnant of a previous implementation. Good catch.

Comment thread modules/wikis/config/locales/en.yml Outdated
settings:
internal_wiki:
caption: >-
This enables OpenProject's native wiki module, which can exist alongside external wiki providers.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reminder to self that I wanted to talk to Parimal about this:

  • mention of "module" makes this sentence unnecessarily technical
  • should we even mention external wiki providers at all?
  • the final sentence is complex and does not seem to be correct (e.g. we even hide existing wiki pages, if an external provider exists)

@mereghost mereghost force-pushed the impl/enable-project-internal-wiki branch from 8853579 to 0b6493d Compare July 13, 2026 15:30
mereghost and others added 2 commits July 14, 2026 10:41
Co-authored-by: Jan Sandbrink <j.sandbrink@openproject.com>
@mereghost mereghost force-pushed the impl/enable-project-internal-wiki branch from 649a32a to 28baa76 Compare July 14, 2026 13:12
@github-actions

Copy link
Copy Markdown

Warning

Flaky specs

  • rspec ./spec/features/work_packages/table/switch_types_spec.rb[1:1:1]
🤖 Ask Copilot to investigate

Copy the prompt below into a new comment on this PR to delegate the investigation to GitHub Copilot. It will look into the flakiness and open a separate pull request with you as reviewer.

@copilot The following spec(s) are flaky in CI (first seen on PR #24195, linked for reference only):

- `rspec ./spec/features/work_packages/table/switch_types_spec.rb[1:1:1]`

Treat this as a standalone task, unrelated to PR #24195. Create a new branch from origin/dev and open a new pull request targeting dev — do not stack it on PR #24195 or reuse that branch.

Follow the playbook in docs/development/testing/handling-flaky-tests/README.md to find the root cause and fix the underlying race — do not skip, delete, or weaken the spec to make it pass; disabling is a last resort per the playbook, and only with a bug ticket. Verify the fix by running the spec(s) repeatedly (e.g. `script/bulk_run_rspec --run-count 10`).

If you cannot reproduce the flake or are not confident in a fix after reasonable investigation, do not fabricate a change or skip the spec to force CI green. Instead, leave the pull request in draft and document what you tried, the suspected cause, and any leads in its description, then assign @mereghost to take over.

Once the fix is verified, title the PR after the spec(s) it fixes, and use the PR description to explain the root cause, how the change resolves it, and the before/after results. Label the PR `flaky-spec`, assign @mereghost, and request a review from @mereghost.
On every commit, set @mereghost as the sole co-author with a `Co-authored-by:` trailer (use their GitHub no-reply email so it links to their account), so it is traceable who dispatched the fix.

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants