Skip to content

Commit 0b6493d

Browse files
committed
Incorporates some of NobodyNightmare feedback
1 parent 85958a2 commit 0b6493d

5 files changed

Lines changed: 37 additions & 35 deletions

File tree

modules/wikis/app/components/wikis/project_settings/project_internal_wiki_component.html.erb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ See COPYRIGHT and LICENSE files for more details.
3232
render(
3333
Primer::Forms::ToggleSwitchForm.new(
3434
name: "enable_interal_wiki",
35-
label: t("projects.settings.internal_wiki.enable"),
36-
caption: t("projects.settings.internal_wiki.caption"),
35+
label: t(".enable"),
36+
caption: t(".caption"),
3737
src: project_settings_wiki_path(@project),
3838
csrf_token: form_authenticity_token,
3939
status_label_position: :start,
4040
checked: wiki_enabled?,
4141
data: { turbo: true },
42-
mb: 3
42+
mb: 3,
43+
test_selector: "project-settings-enable-wiki"
4344
)
4445
)
4546
%>

modules/wikis/app/controllers/wikis/project_settings/wiki_controller.rb

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,30 +36,25 @@ class WikiController < Projects::SettingsController
3636

3737
menu_item :settings_project_wiki
3838

39-
before_action :find_project_wiki
40-
4139
def create
42-
Wiki.find_by(project: @project)
40+
if new_or_changed_wiki.save
41+
status = @wiki.enabled? ? ".enabled" : ".disabled"
42+
render_success_flash_message_via_turbo_stream(message: t(".success", status: t(".status.#{status}")))
43+
else
44+
render_error_flash_message_via_turbo_stream(message:)
45+
end
4346

44-
create_or_update_wiki
4547
replace_via_turbo_stream(component: ProjectInternalWikiComponent.new(@project.reload))
46-
render_success_flash_message_via_turbo_stream(message: "Internal wiki disenabled for this project.")
47-
4848
respond_with_turbo_streams
4949
end
5050

5151
private
5252

53-
def find_project_wiki
54-
@wiki = Wiki.find_by(project: @project)
55-
end
53+
def new_or_changed_wiki
54+
@wiki = Wiki.find_or_initialize_by(project: @project, start_page: "Wiki")
55+
@wiki.toggle(:enabled) unless @wiki.new_record?
5656

57-
def create_or_update_wiki
58-
if find_project_wiki
59-
@wiki.toggle!(:enabled)
60-
else
61-
Wiki.create!(project: @project, start_page: "Wiki")
62-
end
57+
@wiki
6358
end
6459
end
6560
end

modules/wikis/app/views/wikis/project_settings/wiki/show.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ See COPYRIGHT and LICENSE files for more details.
2929

3030
<%=
3131
render Primer::OpenProject::PageHeader.new do |header|
32-
header.with_title { I18n.t("projects.settings.internal_wiki.title") }
32+
header.with_title { I18n.t("projects_settings_wiki.title") }
3333
header.with_breadcrumbs(
3434
[{ href: project_overview_path(@project.id), text: @project.name },
3535
{ href: project_settings_general_path(@project.id), text: I18n.t("label_project_settings") },
36-
I18n.t("projects.settings.internal_wiki.title")]
36+
I18n.t("projects_settings_wiki.title")]
3737
)
3838
end
3939
%>

modules/wikis/config/locales/en.yml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,8 @@ en:
4545
permission_manage_wiki_page_links: Manage Wiki Page Links
4646
project_module_wiki_internal: Internal wiki
4747
project_module_wiki_platforms: Wiki providers
48-
projects:
49-
settings:
50-
internal_wiki:
51-
caption: >-
52-
This enables OpenProject's native wiki module, which can exist alongside external wiki providers.
53-
Disabling it when there are no external providers configured will remove wiki capabilities for this
54-
project and hide any existing wiki pages.
55-
enable: Enable the internal wiki for this project
56-
title: Internal wiki
48+
projects_settings_wiki:
49+
title: Internal wiki
5750
wikis:
5851
admin:
5952
destroy_confirmation_dialog_component:
@@ -194,6 +187,18 @@ en:
194187
page_access_forbidden: You do not have permission to access this wiki page
195188
page_not_found: Linked wiki page no longer available
196189
unexpected: An unexpected error occurred
190+
project_settings:
191+
wiki:
192+
success: Internal wiki %{status} successfully.
193+
status:
194+
disabled: disabled
195+
enabled: enabled
196+
project_internal_wiki_component:
197+
caption: >-
198+
This enables OpenProject's native wiki module, which can exist alongside external wiki providers.
199+
Disabling it when there are no external providers configured will remove wiki capabilities for this
200+
project and hide any existing wiki pages.
201+
enable: Enable the internal wiki for this project
197202
provider_types:
198203
xwiki:
199204
name: XWiki

spec/features/wiki/adding_editing_history_spec.rb

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
require "spec_helper"
3232

3333
RSpec.describe "wiki pages", :js, :selenium, with_settings: { journal_aggregation_time_minutes: 0 } do
34+
shared_let(:internal_provider) { create(:internal_wiki_provider) }
35+
3436
let(:project) do
3537
create(:project, enabled_module_names: [:news])
3638
end
@@ -46,6 +48,7 @@
4648
edit_wiki_pages
4749
view_wiki_edits
4850
select_project_modules
51+
manage_wiki
4952
edit_project])
5053
end
5154
let(:content_first_version) do
@@ -65,16 +68,14 @@
6568
login_as user
6669
end
6770

68-
it "adding, editing and history", skip: "Wiki activation changed, needs update" do
69-
visit project_settings_modules_path(project)
71+
it "adding, editing and history" do
72+
visit project_settings_wiki_path(project)
7073

7174
expect(page).to have_no_css(".menu-sidebar .main-item-wrapper", text: "Wiki")
7275

73-
within "#content" do
74-
check "Wiki"
76+
page.find_test_selector("project-settings-enable-wiki").click
7577

76-
click_button "Save"
77-
end
78+
visit project_path(project)
7879

7980
expect(page).to have_css(".wiki-menu--main-item", text: "Wiki", visible: :all)
8081

0 commit comments

Comments
 (0)