Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class WikiProvidersController < ApplicationController
before_action :require_admin
before_action :find_wiki_provider, only: %i[edit update destroy confirm_destroy edit_general_info replace_oauth_application]

menu_item :wiki_providers
menu_item :external_wiki_providers

def index
@wiki_providers = editable_wiki_providers
Expand Down
43 changes: 43 additions & 0 deletions modules/wikis/app/forms/wikis/admin/internal_provider_form.rb
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
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)

Copy link
Copy Markdown
Member

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-000000000000

WDYT?

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.

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 0 the same way that we could use 00000000-0000-0000-0000-000000000000 or file_not_found.

Copy link
Copy Markdown
Member

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 internal just didn't catch me. :D But leave it, if there is no pain felt on your side.

end

def applicable?
!::Wikis::InternalProvider.exists?
end
end
end
end
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) },
Comment thread
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
%>
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ See COPYRIGHT and LICENSE files for more details.
header.with_breadcrumbs(
[
{ href: admin_index_path, text: t(:label_administration) },
{ href: admin_settings_wiki_providers_path, text: t("menus.admin.wikis") },
{ href: admin_settings_wiki_providers_path, text: t(:project_module_wiki_platforms) },
page_title
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ See COPYRIGHT and LICENSE files for more details.
<% header.with_description { t("wikis.admin.wiki_providers.index_description") } %>
<% header.with_breadcrumbs([
{ href: admin_index_path, text: t(:label_administration) },
{ href: admin_settings_wiki_providers_path, text: t("menus.admin.wikis") },
t(:project_module_wiki_platforms)
]) %>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ See COPYRIGHT and LICENSE files for more details.

<% header.with_breadcrumbs([
{ href: admin_index_path, text: t(:label_administration) },
{ href: admin_settings_wiki_providers_path, text: t("menus.admin.wikis") },
{ href: admin_settings_wiki_providers_path, text: t(:project_module_wiki_platforms) },
t("wikis.admin.wiki_providers.label_new_provider")
]) %>
Expand Down
11 changes: 11 additions & 0 deletions modules/wikis/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ en:
wikis/xwiki_provider:
one: XWiki provider
other: XWiki providers
menus:
admin:
external_wiki_providers: Wiki providers
internal_wiki_provider: Internal wiki
wikis: "Wikis"
permission_manage_wiki_page_links: Manage Wiki Page Links
project_module_wiki_platforms: Wiki providers
wikis:
Expand Down Expand Up @@ -113,6 +118,12 @@ en:
no_health_report: No report available
no_health_report_description: Run the checks now for a full health status report for this wiki provider.
title: Health Report
internal_provider_form:
checkbox_caption: Allow projects to use the internal OpenProject wiki along with external Wiki providers
checkbox_label: Enable the internal OpenProject wiki
internal_wiki_provider:
show:
description: Choose to enable or disable the internal OpenProject wiki
oauth_application_info_component:
confirm_replace_oauth_application: This action will reset the current OAuth credentials. After confirming you will have to reenter the credentials in your XWiki instance and all users will have to reauthorize. Are you sure you want to proceed?
label_oauth_client_id: OAuth Client ID
Expand Down
1 change: 1 addition & 0 deletions modules/wikis/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
Rails.application.routes.draw do
namespace :admin do
namespace :settings do
resource :internal_wiki_provider, controller: "/wikis/admin/internal_wiki_provider", only: %i[show update]
resources :wiki_providers, controller: "/wikis/admin/wiki_providers", except: [:show] do
member do
get :confirm_destroy
Expand Down
18 changes: 16 additions & 2 deletions modules/wikis/lib/open_project/wikis/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,23 @@ class Engine < ::Rails::Engine
menu :admin_menu,
:wiki_providers,
{ controller: "/wikis/admin/wiki_providers", action: :index },
if: ->(_) { OpenProject::FeatureDecisions.wiki_enhancements_active? },
caption: :project_module_wiki_platforms,
if: ->(_) { User.current.admin? && OpenProject::FeatureDecisions.wiki_enhancements_active? },
caption: :"menus.admin.wikis",
icon: :book

menu :admin_menu,
:internal_wiki_provider,
{ controller: "/wikis/admin/internal_wiki_provider", action: :show },
parent: :wiki_providers,
if: ->(_) { User.current.admin? && OpenProject::FeatureDecisions.wiki_enhancements_active? },
caption: :"menus.admin.internal_wiki_provider"

menu :admin_menu,
:external_wiki_providers,
{ controller: "/wikis/admin/wiki_providers", action: :index },
parent: :wiki_providers,
if: ->(_) { User.current.admin? && OpenProject::FeatureDecisions.wiki_enhancements_active? },
caption: :"menus.admin.external_wiki_providers"
end

patch_with_namespace :WikiPages, :CreateService
Expand Down
63 changes: 63 additions & 0 deletions modules/wikis/spec/features/admin/internal_provider_spec.rb
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
Loading