Skip to content

Commit

Permalink
tidy up work, rename files and make new helper
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickpatrickpatrick committed Jan 24, 2024
1 parent e8e2fa9 commit f726ab0
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 65 deletions.
4 changes: 3 additions & 1 deletion app/assets/config/manifest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
//= link_tree ../images
//= link application.js
//= link design-system.js
//= link application.css

//= link legacy-application.js
//= link legacy-application.css
25 changes: 2 additions & 23 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,2 @@
//= require select2
//= require jquery-ui/widgets/sortable
//= require moment
//= require mousetrap
//= require jquery-ui.custom.min
//= require_directory ./vendor
//= require_directory .
//= require_directory ./modules
//= require jquery_nested_form

// System wide behaviours
$(function () {
$('a.preview').attr('target', '_blank')
$('form.preview').attr('target', '_blank')
$('.select2').select2({ allowClear: true })
})

// System wide library functions
var GovUKGuideUtils = { // eslint-disable-line no-unused-vars
convertToSlug: function (title) {
return title.toLowerCase().replace(/[^\w ]+/g, '').replace(/ +/g, '-')
}
}
//= require govuk_publishing_components/dependencies
//= require govuk_publishing_components/all_components
2 changes: 0 additions & 2 deletions app/assets/javascripts/design-system.js

This file was deleted.

23 changes: 23 additions & 0 deletions app/assets/javascripts/legacy-application.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
//= require select2
//= require jquery-ui/widgets/sortable
//= require moment
//= require mousetrap
//= require jquery-ui.custom.min
//= require_directory ./vendor
//= require_directory .
//= require_directory ./modules
//= require jquery_nested_form

// System wide behaviours
$(function () {
$('a.preview').attr('target', '_blank')
$('form.preview').attr('target', '_blank')
$('.select2').select2({ allowClear: true })
})

// System wide library functions
var GovUKGuideUtils = { // eslint-disable-line no-unused-vars
convertToSlug: function (title) {
return title.toLowerCase().replace(/[^\w ]+/g, '').replace(/ +/g, '-')
}
}
23 changes: 0 additions & 23 deletions app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
@@ -1,25 +1,2 @@
@import "govuk_admin_template";
@import "select2";
@import "./vendor/select2-bootstrap";
@import "colors";
@import "bootstrap_and_overrides";
@import "forms";

// Components
@import "sidebar_nav";
@import "sortable_accordion";
@import "sortable_table";
@import "panel_part";
@import "diff";
@import "notes";
@import "workflow";
@import "broken_links_report";
@import "error_summary";

// Pages
@import "downtime";
@import "smart_answer_builder";
@import "smart_answer_flowchart";

// GOVUK Design System
@import "govuk_publishing_components/all_components";
25 changes: 25 additions & 0 deletions app/assets/stylesheets/legacy-application.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@import "govuk_admin_template";
@import "select2";
@import "./vendor/select2-bootstrap";
@import "colors";
@import "bootstrap_and_overrides";
@import "forms";

// Components
@import "sidebar_nav";
@import "sortable_accordion";
@import "sortable_table";
@import "panel_part";
@import "diff";
@import "notes";
@import "workflow";
@import "broken_links_report";
@import "error_summary";

// Pages
@import "downtime";
@import "smart_answer_builder";
@import "smart_answer_flowchart";

// GOVUK Design System
@import "govuk_publishing_components/all_components";
29 changes: 29 additions & 0 deletions app/helpers/navigation_items_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module NavigationItemsHelper
# [
# {
# text: "Publications", href: root_path
# },
# ].concat(current_user.govuk_editor? ? [
# { text: 'Add artefact', href: new_artefact_path },
# { text: 'Downtime', href: downtimes_path }
# ]: []).concat([
# { text: 'Reports', href: reports_path },
# { text: 'Search by user', href: user_search_path },
# { text: 'Sign out', href: '/auth/gds/sign_out' }
# ]

def navigation_items(is_editor)
list = [
{ text: "Publications", href: root_path }
]

if is_editor
list << { text: 'Add artefact', href: new_artefact_path }
list << { text: 'Downtime', href: downtimes_path }
end

list << { text: 'Reports', href: reports_path }
list << { text: 'Search by user', href: user_search_path }
list << { text: 'Sign out', href: '/auth/gds/sign_out' }
end
end
4 changes: 2 additions & 2 deletions app/views/layouts/application.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= favicon_link_tag "govuk_admin_template/#{favicon}" %>
<% end %>
<% content_for :head do %>
<%= stylesheet_link_tag "application", :media => "all" %>
<%= stylesheet_link_tag "legacy-application", :media => "all" %>
<%= csrf_meta_tag %>
<%= yield :extra_headers %>
<% end %>
Expand Down Expand Up @@ -54,7 +54,7 @@
<% content_for :footer_version, ENV.fetch("SENTRY_RELEASE", "null")[0..18] %>
<% content_for :body_end do %>
<%= javascript_include_tag "application" %>
<%= javascript_include_tag "legacy-application" %>
<%= yield :extra_javascript %>
<% end %>
Expand Down
36 changes: 22 additions & 14 deletions app/views/layouts/design_system.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,42 @@
<%= render "govuk_publishing_components/components/layout_for_admin", product_title: "Publisher", browser_title: yield(:page_title), environment: environment do %>
<% render "layouts/google_tag_manager" %>
<%= render "govuk_publishing_components/components/skip_link" %>
<% user = current_user %>
<%= render "govuk_publishing_components/components/layout_header", {
product_name: "Publisher",
environment: environment,
navigation_items: [
{
text: "Publications", href: root_path
},
].concat(current_user.govuk_editor? ? [
{ text: 'Add artefact', href: new_artefact_path },
{ text: 'Downtime', href: downtimes_path }
]: []).concat([
{ text: 'Reports', href: reports_path },
{ text: 'Search by user', href: user_search_path },
{ text: 'Sign out', href: '/auth/gds/sign_out' }
]),
navigation_items: navigation_items(current_user.govuk_editor?)
} %>

<div class="govuk-width-container">
<% [:success, :info, :warning, :danger, :notice, :alert].select { |k| flash[k].present? }.each do |k| %>
<%
case k
when :notice
alert_class = "success"
when :alert
alert_class = "danger"
else
alert_class = k
end
%>
<div class="alert alert-<%= alert_class %>"
data-module="auto-track-event"
data-track-action="alert-<%= alert_class %>"
data-track-label="<%= strip_tags(flash[k]) %>">
<%= flash[k] %>
</div>
<% end %>
<%= yield %>
</div>

<%= render "govuk_publishing_components/components/layout_footer", {
navigation: [],
} %>
<% end %>
<%= javascript_include_tag "design-system" %>

0 comments on commit f726ab0

Please sign in to comment.