-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Add UI for internal wiki provider #23528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
modules/wikis/app/controllers/wikis/admin/internal_wiki_provider_controller.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| #-- copyright | ||
| # OpenProject is an open source project management software. | ||
| # Copyright (C) the OpenProject GmbH | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License version 3. | ||
| # | ||
| # OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| # Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| # Copyright (C) 2010-2013 the ChiliProject Team | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| # | ||
| # See COPYRIGHT and LICENSE files for more details. | ||
| #++ | ||
|
|
||
| module Wikis | ||
| module Admin | ||
| class InternalWikiProviderController < ApplicationController | ||
| layout "admin" | ||
|
|
||
| before_action :require_admin | ||
|
|
||
| menu_item :internal_wiki_provider | ||
|
|
||
| def show | ||
| @provider = Wikis::InternalProvider.first | ||
| end | ||
|
|
||
| def update | ||
| provider = Wikis::InternalProvider.first | ||
| provider.update!(enabled: internal_provider_params[:enabled]) | ||
| redirect_to admin_settings_internal_wiki_provider_path | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def internal_provider_params | ||
| params.expect(wikis_internal_provider: :enabled) | ||
| end | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
modules/wikis/app/forms/wikis/admin/internal_provider_form.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| #-- copyright | ||
| # OpenProject is an open source project management software. | ||
| # Copyright (C) the OpenProject GmbH | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License version 3. | ||
| # | ||
| # OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| # Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| # Copyright (C) 2010-2013 the ChiliProject Team | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| # | ||
| # See COPYRIGHT and LICENSE files for more details. | ||
| #++ | ||
|
|
||
| module Wikis::Admin | ||
| class InternalProviderForm < ApplicationForm | ||
| form do |f| | ||
| f.check_box( | ||
| name: :enabled, | ||
| label: I18n.t("wikis.admin.internal_provider_form.checkbox_label"), | ||
| caption: I18n.t("wikis.admin.internal_provider_form.checkbox_caption") | ||
| ) | ||
|
|
||
| f.submit(name: :save, label: I18n.t("button_save"), scheme: :primary) | ||
| end | ||
| end | ||
| end |
43 changes: 43 additions & 0 deletions
43
modules/wikis/app/seeders/basic_data/wikis/internal_provider_seeder.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| #-- copyright | ||
| # OpenProject is an open source project management software. | ||
| # Copyright (C) the OpenProject GmbH | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License version 3. | ||
| # | ||
| # OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| # Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| # Copyright (C) 2010-2013 the ChiliProject Team | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| # | ||
| # See COPYRIGHT and LICENSE files for more details. | ||
| #++ | ||
|
|
||
| module BasicData | ||
| module Wikis | ||
| class InternalProviderSeeder < Seeder | ||
| def seed_data! | ||
| ::Wikis::InternalProvider.create!(universal_identifier: "internal", name: "internal", enabled: true) | ||
| end | ||
|
|
||
| def applicable? | ||
| !::Wikis::InternalProvider.exists? | ||
| end | ||
| end | ||
| end | ||
| end | ||
48 changes: 48 additions & 0 deletions
48
modules/wikis/app/views/wikis/admin/internal_wiki_provider/show.html.erb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| <%#-- copyright | ||
| OpenProject is an open source project management software. | ||
| Copyright (C) the OpenProject GmbH | ||
|
|
||
| This program is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU General Public License version 3. | ||
|
|
||
| OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| Copyright (C) 2010-2013 the ChiliProject Team | ||
|
|
||
| This program is free software; you can redistribute it and/or | ||
| modify it under the terms of the GNU General Public License | ||
| as published by the Free Software Foundation; either version 2 | ||
| of the License, or (at your option) any later version. | ||
|
|
||
| This program is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU General Public License | ||
| along with this program; if not, write to the Free Software | ||
| Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
|
|
||
| See COPYRIGHT and LICENSE files for more details. | ||
|
|
||
| ++#%> | ||
|
|
||
| <% html_title t(:label_administration), Wikis::InternalProvider.model_name.human %> | ||
|
|
||
| <% content_for :content_header do %> | ||
| <%= render(Primer::OpenProject::PageHeader.new) do |header| %> | ||
| <% header.with_title { Wikis::InternalProvider.model_name.human } %> | ||
| <% header.with_description { t(".description") } %> | ||
| <% header.with_breadcrumbs([ | ||
| { href: admin_index_path, text: t(:label_administration) }, | ||
|
Kharonus marked this conversation as resolved.
|
||
| { href: admin_settings_wiki_providers_path, text: t("menus.admin.wikis") }, | ||
| Wikis::InternalProvider.model_name.human | ||
| ]) %> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <%= | ||
| primer_form_with(model: @provider, url: admin_settings_internal_wiki_provider_path) do |form| | ||
| render(Wikis::Admin::InternalProviderForm.new(form)) | ||
| end | ||
| %> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
modules/wikis/spec/features/admin/internal_provider_spec.rb
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| #-- copyright | ||
| # OpenProject is an open source project management software. | ||
| # Copyright (C) the OpenProject GmbH | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License version 3. | ||
| # | ||
| # OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows: | ||
| # Copyright (C) 2006-2013 Jean-Philippe Lang | ||
| # Copyright (C) 2010-2013 the ChiliProject Team | ||
| # | ||
| # This program is free software; you can redistribute it and/or | ||
| # modify it under the terms of the GNU General Public License | ||
| # as published by the Free Software Foundation; either version 2 | ||
| # of the License, or (at your option) any later version. | ||
| # | ||
| # This program is distributed in the hope that it will be useful, | ||
| # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| # GNU General Public License for more details. | ||
| # | ||
| # You should have received a copy of the GNU General Public License | ||
| # along with this program; if not, write to the Free Software | ||
| # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
| # | ||
| # See COPYRIGHT and LICENSE files for more details. | ||
| #++ | ||
|
|
||
| require "spec_helper" | ||
|
|
||
| RSpec.describe "Updating internal wiki provider", :js, :selenium, driver: :firefox_en do | ||
| shared_let(:admin) { create(:admin, preferences: { time_zone: "Etc/UTC" }) } | ||
| shared_let(:auth_provider) { create(:oidc_provider) } | ||
|
|
||
| let!(:provider) { create(:internal_wiki_provider, enabled: true) } | ||
|
|
||
| current_user { admin } | ||
|
|
||
| it "can enable and disable the internal provider", :aggregate_failures, with_ee: [:scim_api] do | ||
| visit admin_settings_internal_wiki_provider_path | ||
| expect(page).to be_axe_clean.within("#content") | ||
|
|
||
| expect(page).to have_checked_field("Enable the internal OpenProject wiki") | ||
|
|
||
| uncheck "Enable the internal OpenProject wiki" | ||
| click_on "Save" | ||
|
|
||
| SeleniumHubWaiter.wait | ||
|
|
||
| expect(page).to have_unchecked_field("Enable the internal OpenProject wiki") | ||
| expect(provider.reload).not_to be_enabled | ||
|
|
||
| check "Enable the internal OpenProject wiki" | ||
| click_on "Save" | ||
|
|
||
| SeleniumHubWaiter.wait | ||
|
|
||
| expect(page).to have_checked_field("Enable the internal OpenProject wiki") | ||
| expect(provider.reload).to be_enabled | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❓ I wondered, if we should give the internal wiki a universal identifier that represents more the absence of a value. Like the "NULL" uuid:
00000000-0000-0000-0000-000000000000WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the one hand, I don't think that we need to represent the absence of a value. The internal wiki can have an identifier that it's findable by. Why not?
On the other hand, I'd find it weird and arbitrary that we set a useless UUID for a field that doesn't care about the exact format of its data. We could use
0the same way that we could use00000000-0000-0000-0000-000000000000orfile_not_found.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, all fine. The word
internaljust didn't catch me. :D But leave it, if there is no pain felt on your side.