Skip to content

Commit

Permalink
Merge pull request #9507 from alphagov/content-modelling/610-change-name
Browse files Browse the repository at this point in the history
Content modelling/610 change name to Content Block Manager
  • Loading branch information
Harriethw authored Oct 10, 2024
2 parents a49a5d3 + f3e4b30 commit 09cd479
Show file tree
Hide file tree
Showing 120 changed files with 481 additions and 481 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ $govuk-page-width: 1140px;
@import "./admin/views/whats-new";
@import "./admin/views/worldwide-organisations-choose-main-office";

@import "../../../lib/engines/content_object_store/app/assets/stylesheets/content_object_store/application";
@import "../../../lib/engines/content_block_manager/app/assets/stylesheets/content_block_manager/application";

.app-js-only {
display: none;
Expand Down
2 changes: 1 addition & 1 deletion config/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@
# default: true,
# description: "Take over the world."
feature :govspeak_visual_editor, description: "Enables a visual editor for Govspeak fields", default: false
feature :content_object_store, description: "Enables the object store for sharable content", default: Rails.env.development? || Whitehall.integration_or_staging?
feature :content_block_manager, description: "Enables the object store for sharable content", default: Rails.env.development? || Whitehall.integration_or_staging?
feature :override_government, description: "Enables GDS Editors and Admins to override the government associated with a document", default: false
end
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -459,5 +459,5 @@ def redirect(path, options = { prefix: Whitehall.router_prefix })

mount GovukPublishingComponents::Engine, at: "/component-guide" unless Rails.env.production?

mount ContentObjectStore::Engine, at: "government/admin/content-object-store", as: "content_object_store"
mount ContentBlockManager::Engine, at: "content-block-manager", as: "content_block_manager"
end
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class AddLatestEditionInfoToContentBlockDocuments < ActiveRecord::Migration[7.1]
def up
ContentObjectStore::ContentBlock::Document.find_each do |document|
ContentBlockManager::ContentBlock::Document.find_each do |document|
if document.latest_edition_id.nil? || document.live_edition_id.nil?
document.update!(
latest_edition_id: document.content_block_editions.last.id,
Expand All @@ -11,7 +11,7 @@ def up
end

def down
ContentObjectStore::ContentBlock::Document.update_all(
ContentBlockManager::ContentBlock::Document.update_all(
latest_edition_id: nil,
live_edition_id: nil,
)
Expand Down
File renamed without changes
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ContentObjectStore::ContentBlock::Document::Index::SummaryCardComponent < ContentObjectStore::ContentBlock::Document::Show::SummaryListComponent
class ContentBlockManager::ContentBlock::Document::Index::SummaryCardComponent < ContentBlockManager::ContentBlock::Document::Show::SummaryListComponent
private

def rows
Expand All @@ -18,7 +18,7 @@ def summary_card_actions
[
{
label: "View/edit",
href: helpers.content_object_store.content_object_store_content_block_document_path(content_block_document),
href: helpers.content_block_manager.content_block_manager_content_block_document_path(content_block_document),
},
]
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ContentObjectStore::ContentBlock::Document::Show::DocumentTimelineComponent < ViewComponent::Base
class ContentBlockManager::ContentBlock::Document::Show::DocumentTimelineComponent < ViewComponent::Base
include ActionView::Helpers::RecordTagHelper
def initialize(content_block_versions:)
@content_block_versions = content_block_versions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true

class ContentObjectStore::ContentBlock::Document::Show::HostEditionsTableComponent < ViewComponent::Base
class ContentBlockManager::ContentBlock::Document::Show::HostEditionsTableComponent < ViewComponent::Base
def initialize(caption:, host_content_items:)
@caption = caption
@host_content_items = host_content_items
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ContentObjectStore::ContentBlock::Document::Show::SummaryListComponent < ViewComponent::Base
class ContentBlockManager::ContentBlock::Document::Show::SummaryListComponent < ViewComponent::Base
def initialize(content_block_document:)
@content_block_document = content_block_document
end
Expand Down Expand Up @@ -77,7 +77,7 @@ def scheduled_item

def edit_action
{
href: helpers.content_object_store.new_content_object_store_content_block_document_edition_path(content_block_document),
href: helpers.content_block_manager.new_content_block_manager_content_block_document_edition_path(content_block_document),
link_text: "Change",
}
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ContentObjectStore::ContentBlockEdition::New::ErrorSummaryComponent < ViewComponent::Base
class ContentBlockManager::ContentBlockEdition::New::ErrorSummaryComponent < ViewComponent::Base
def initialize(error_message:)
@error_message = error_message
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ContentObjectStore::ContentBlockEdition::New::SelectSchemaComponent < ViewComponent::Base
class ContentBlockManager::ContentBlockEdition::New::SelectSchemaComponent < ViewComponent::Base
def initialize(schemas:, heading:, heading_caption:, error_message:)
@heading = heading
@heading_caption = heading_caption
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ContentObjectStore::ContentBlockEdition::Show::ConfirmSummaryListComponent < ViewComponent::Base
class ContentBlockManager::ContentBlockEdition::Show::ConfirmSummaryListComponent < ViewComponent::Base
def initialize(content_block_edition:)
@content_block_edition = content_block_edition
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
class ContentObjectStore::BaseController < Admin::BaseController
before_action :check_object_store_feature_flag, :set_sentry_tags, :prepend_views
class ContentBlockManager::BaseController < Admin::BaseController
before_action :check_block_manager_feature_flag, :set_sentry_tags, :prepend_views

def check_object_store_feature_flag
forbidden! unless Flipflop.content_object_store?
def check_block_manager_feature_flag
forbidden! unless Flipflop.content_block_manager?
end

def scheduled_publication_params
Expand Down Expand Up @@ -30,16 +30,16 @@ def edition_params
end

def set_sentry_tags
Sentry.set_tags(engine: "content_object_store")
Sentry.set_tags(engine: "content_block_manager")
end

def product_name
"Content Object Store"
"Content Block Manager"
end

# This ensures we can override views if we need to without altering the Engine's load order, which
# may have unintended consequences
def prepend_views
prepend_view_path Rails.root.join("lib/engines/content_object_store/app/views")
prepend_view_path Rails.root.join("lib/engines/content_block_manager/app/views")
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
class ContentBlockManager::ContentBlock::DocumentsController < ContentBlockManager::BaseController
def index
@content_block_documents = ContentBlockManager::ContentBlock::Document.live
end

def show
@content_block_document = ContentBlockManager::ContentBlock::Document.find(params[:id])
@content_block_versions = @content_block_document.versions

@host_content_items = ContentBlockManager::GetHostContentItems.by_embedded_document(
content_block_document: @content_block_document,
)
end

def new
@schemas = ContentBlockManager::ContentBlock::Schema.all
end

def new_document_options_redirect
if params[:block_type].present?
redirect_to content_block_manager.new_content_block_manager_content_block_edition_path(block_type: params.require(:block_type))
else
redirect_to content_block_manager.new_content_block_manager_content_block_document_path, flash: { error: "You must select a block type" }
end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class ContentObjectStore::ContentBlock::Editions::WorkflowController < ContentObjectStore::BaseController
class ContentBlockManager::ContentBlock::Editions::WorkflowController < ContentBlockManager::BaseController
NEW_BLOCK_STEPS = {
review: "review",
}.freeze
Expand All @@ -10,8 +10,8 @@ class ContentObjectStore::ContentBlock::Editions::WorkflowController < ContentOb

def show
step = params[:step]
@content_block_edition = ContentObjectStore::ContentBlock::Edition.find(params[:id])
@schema = ContentObjectStore::ContentBlock::Schema.find_by_block_type(@content_block_edition.document.block_type)
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id])
@schema = ContentBlockManager::ContentBlock::Schema.find_by_block_type(@content_block_edition.document.block_type)

case step
when UPDATE_BLOCK_STEPS[:review_links]
Expand All @@ -25,12 +25,12 @@ def show

def update
step = params[:step]
@content_block_edition = ContentObjectStore::ContentBlock::Edition.find(params[:id])
@schema = ContentObjectStore::ContentBlock::Schema.find_by_block_type(@content_block_edition.document.block_type)
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id])
@schema = ContentBlockManager::ContentBlock::Schema.find_by_block_type(@content_block_edition.document.block_type)

case step
when UPDATE_BLOCK_STEPS[:review_links]
redirect_to content_object_store.content_object_store_content_block_workflow_path(id: @content_block_edition.id, step: :schedule_publishing)
redirect_to content_block_manager.content_block_manager_content_block_workflow_path(id: @content_block_edition.id, step: :schedule_publishing)
when UPDATE_BLOCK_STEPS[:schedule_publishing]
schedule_or_publish
when NEW_BLOCK_STEPS[:review]
Expand All @@ -41,14 +41,14 @@ def update
private

def review
@content_block_edition = ContentObjectStore::ContentBlock::Edition.find(params[:id])
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id])

render :review
end

def review_links
@content_block_document = @content_block_edition.document
@host_content_items = ContentObjectStore::GetHostContentItems.by_embedded_document(
@host_content_items = ContentBlockManager::GetHostContentItems.by_embedded_document(
content_block_document: @content_block_document,
)

Expand All @@ -62,28 +62,28 @@ def schedule_publishing
end

def schedule_or_publish
@content_block_edition = ContentObjectStore::ContentBlock::Edition.find(params[:id])
@schema = ContentObjectStore::ContentBlock::Schema.find_by_block_type(@content_block_edition.document.block_type)
@content_block_edition = ContentBlockManager::ContentBlock::Edition.find(params[:id])
@schema = ContentBlockManager::ContentBlock::Schema.find_by_block_type(@content_block_edition.document.block_type)

if params[:schedule_publishing].blank?
@content_block_edition.errors.add(:schedule_publishing, "cannot be blank")
raise ActiveRecord::RecordInvalid, @content_block_edition
elsif params[:schedule_publishing] == "schedule"
ContentObjectStore::ScheduleEditionService.new(@schema).call(@content_block_edition, scheduled_publication_params)
ContentBlockManager::ScheduleEditionService.new(@schema).call(@content_block_edition, scheduled_publication_params)
message = "#{@content_block_edition.block_type.humanize} scheduled successfully"
else
publish and return
end

redirect_to content_object_store.content_object_store_content_block_document_path(@content_block_edition.document),
redirect_to content_block_manager.content_block_manager_content_block_document_path(@content_block_edition.document),
flash: { notice: message }
rescue ActiveRecord::RecordInvalid
render "content_object_store/content_block/editions/workflow/schedule_publishing"
render "content_block_manager/content_block/editions/workflow/schedule_publishing"
end

def publish
new_edition = ContentObjectStore::PublishEditionService.new(@schema).call(@content_block_edition)
redirect_to content_object_store.content_object_store_content_block_document_path(new_edition.document),
new_edition = ContentBlockManager::PublishEditionService.new(@schema).call(@content_block_edition)
redirect_to content_block_manager.content_block_manager_content_block_document_path(new_edition.document),
flash: { notice: "#{new_edition.block_type.humanize} created successfully" }
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
class ContentBlockManager::ContentBlock::EditionsController < ContentBlockManager::BaseController
def new
if params[:document_id]
@content_block_document = ContentBlockManager::ContentBlock::Document.find(params[:document_id])
@schema = ContentBlockManager::ContentBlock::Schema.find_by_block_type(@content_block_document.block_type)
content_block_edition = @content_block_document.latest_edition
else
@schema = ContentBlockManager::ContentBlock::Schema.find_by_block_type(params[:block_type].underscore)
content_block_edition = ContentBlockManager::ContentBlock::Edition.new
end
@form = ContentBlockManager::ContentBlock::EditionForm.for(
content_block_edition:,
schema: @schema,
)
end

def create
@schema = ContentBlockManager::ContentBlock::Schema.find_by_block_type(block_type_param)
new_edition = ContentBlockManager::CreateEditionService.new(@schema).call(edition_params, document_id: params[:document_id])
step = params[:document_id] ? ContentBlockManager::ContentBlock::Editions::WorkflowController::UPDATE_BLOCK_STEPS[:review_links] : ContentBlockManager::ContentBlock::Editions::WorkflowController::NEW_BLOCK_STEPS[:review]
redirect_to content_block_manager.content_block_manager_content_block_workflow_path(id: new_edition.id, step:)
rescue ActiveRecord::RecordInvalid => e
@form = ContentBlockManager::ContentBlock::EditionForm.for(content_block_edition: e.record, schema: @schema)
render "content_block_manager/content_block/editions/new"
end

private

def block_type_param
params.require("content_block/edition").require("document_attributes").require(:block_type)
end
end
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# A form object to reuse the same form partial for creating and editing a content block edition
# - Creating an object requires dynamic attributes from a schema
# # - Editing an object requires attributes from the object itself
class ContentObjectStore::ContentBlock::EditionForm
include ContentObjectStore::Engine.routes.url_helpers
class ContentBlockManager::ContentBlock::EditionForm
include ContentBlockManager::Engine.routes.url_helpers

attr_reader :content_block_edition, :schema

Expand All @@ -22,31 +22,31 @@ def attributes
end
end

class Create < ContentObjectStore::ContentBlock::EditionForm
class Create < ContentBlockManager::ContentBlock::EditionForm
def title
"Create a new #{schema.name}"
end

def url
content_object_store_content_block_editions_path
content_block_manager_content_block_editions_path
end

def back_path
new_content_object_store_content_block_document_path
new_content_block_manager_content_block_document_path
end
end

class Update < ContentObjectStore::ContentBlock::EditionForm
class Update < ContentBlockManager::ContentBlock::EditionForm
def title
"Change #{schema.name}"
end

def url
content_object_store_content_block_document_editions_path(document_id: @content_block_edition.document.id)
content_block_manager_content_block_document_editions_path(document_id: @content_block_edition.document.id)
end

def back_path
content_object_store_content_block_document_path(@content_block_edition.document)
content_block_manager_content_block_document_path(@content_block_edition.document)
end
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ContentObjectStore
module ContentBlockManager
module Publishable
class PublishingFailureError < StandardError; end

Expand Down Expand Up @@ -37,7 +37,7 @@ def schedule_with_rollback
content_block_edition = yield

content_block_edition.schedule!
ContentObjectStore::SchedulePublishingWorker.queue(content_block_edition)
ContentBlockManager::SchedulePublishingWorker.queue(content_block_edition)
end
end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ContentObjectStore
module ContentBlockManager
module ContentBlock
def self.table_name_prefix
"content_block_"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module ContentObjectStore
module ContentBlockManager
module ContentBlock
class Document < ApplicationRecord
has_many :editions,
-> { order(created_at: :asc, id: :asc) },
inverse_of: :document

enum :block_type, ContentObjectStore::ContentBlock::Schema.valid_schemas.index_with(&:to_s)
enum :block_type, ContentBlockManager::ContentBlock::Schema.valid_schemas.index_with(&:to_s)
attr_readonly :block_type

validates :block_type, :title, presence: true

has_one :latest_edition,
-> { joins(:document).where("content_block_documents.latest_edition_id = content_block_editions.id") },
class_name: "ContentObjectStore::ContentBlock::Edition",
class_name: "ContentBlockManager::ContentBlock::Edition",
inverse_of: :document

has_many :versions, through: :editions, source: :versions
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ContentObjectStore
module ContentBlockManager
module ContentBlock
class Edition < ApplicationRecord
include Documentable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ContentObjectStore
module ContentBlockManager
module ContentBlock::Edition::Documentable
extend ActiveSupport::Concern

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module ContentObjectStore
module ContentBlockManager
module ContentBlock::Edition::HasAuditTrail
extend ActiveSupport::Concern

Expand Down
Loading

0 comments on commit 09cd479

Please sign in to comment.