Skip to content
Open
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
2 changes: 1 addition & 1 deletion app/components/homescreen/announcement_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ See COPYRIGHT and LICENSE files for more details.
++#%>

<%= render(Primer::Alpha::Banner.new(scheme: :default)) { format_text announcement.text } %>
<%= render(Primer::Alpha::Banner.new(scheme: :default, mb: 3)) { format_text announcement.text } %>
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,9 @@

module Homescreen
module Blocks
class Users < Grids::WidgetComponent
include IconsHelper
include OpenProject::ObjectLinking
include Redmine::I18n

def initialize(*)
super

@newest_users = User.active.newest.take(3)
end

def title
I18n.t(:label_user_plural)
class Meetings < Grids::WidgetComponent
def call
render(::Meetings::Widgets::Meetings.new(limit: 3))
end
end
end
Expand Down
23 changes: 0 additions & 23 deletions app/components/homescreen/blocks/users.html.erb

This file was deleted.

3 changes: 1 addition & 2 deletions config/initializers/homescreen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@
if: Proc.new { OpenProject::Configuration.show_community_links? }
},
{
name: "users",
if: Proc.new { User.current.admin? }
name: "meetings"
},
{
name: "my_account",
Expand Down
4 changes: 0 additions & 4 deletions modules/grids/app/components/grids/widgets/subitems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ def has_subitems?
displayed_subitems.any?
end

def wrapper_arguments
{ full_width: true }
end

def can_create_sub_programs?
project.portfolio? && can_create_sub_projects?
end
Expand Down
76 changes: 76 additions & 0 deletions modules/meeting/app/components/meetings/widgets/meetings.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
<%# -- 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.

++# %>

<%=
widget_wrapper do |container|
if newest.empty?
render(Primer::Beta::Blankslate.new(test_selector: "meetings-widget-empty")) do |component|
component.with_visual_icon(icon: :"comment-discussion")
component.with_heading(tag: :h3).with_content(t("meeting.widgets.blankslate.heading"))
component.with_description { t("meeting.widgets.blankslate.description") }

if can_manage_meetings?
component.with_primary_action(
data: { controller: "async-dialog" },
href: polymorphic_path([:new_dialog, @project, :meetings]),
test_selector: "meetings-widget-add-button",
scheme: :secondary
) do |button|
button.with_leading_visual_icon(icon: :plus)
t(:label_meeting)
end
end
end
else
newest.each do |item|
container.with_row do
render(Primer::Box.new(classes: "meeting-widget-item")) do
component_collection do |body|
body.with_component(
flex_layout(flex_wrap: :wrap) do |layout|
layout.with_column do
render(Primer::Beta::Link.new(font_weight: :bold, href: project_meeting_path(item.project, item))) { item.title }
end
end
)

body.with_component(
render(Primer::Beta::Text.new(tag: :p, color: :subtle)) { details_row_string(item) }
)
end
end
end
end

container.with_row do
render(Primer::Beta::Link.new(href: all_meetings_link)) { t("meeting.widgets.view_details") }
end
end
end
%>
102 changes: 102 additions & 0 deletions modules/meeting/app/components/meetings/widgets/meetings.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
# 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 Meetings
module Widgets
class Meetings < Grids::WidgetComponent
MEETINGS_LIMIT = 5
private_constant :MEETINGS_LIMIT

param :project, optional: true

option :limit, default: -> { MEETINGS_LIMIT }

def newest
@newest ||= meetings.limit(limit).to_a
end

def meetings
@meetings ||=
if project_scoped?
project.meetings.visible(current_user).upcoming
else
::Meeting
.visible(current_user)
.upcoming
.includes(:project)
end
end

def title
t(:label_meeting_plural)
end

def render?
global_scoped? || project.module_enabled?("meetings")
end

private

def project_scoped? = project.present?

def global_scoped? = !project_scoped?

def can_manage_meetings?
if project_scoped?
current_user.allowed_in_project?(:create_meetings, project)
else
current_user.allowed_in_any_project?(:create_meetings)
end
end

def details_row_string(meeting)
details = []
details << helpers.format_time(meeting.start_time)
if meeting.duration.present?
details << meeting_duration(meeting)
end
details << "#{t(:label_project).capitalize}: #{meeting.project.name}" if global_scoped?
details.join(", ")
end

def all_meetings_link
if global_scoped?
meetings_path
else
project_meetings_path(project)
end
end

def meeting_duration(meeting)
OpenProject::Common::DurationComponent.new(meeting.duration, :hours, abbreviated: true).text
end
end
end
end
6 changes: 6 additions & 0 deletions modules/meeting/config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,12 @@ en:
update_failed: "Could not update participation status."
meeting_not_found: "Meeting not found for the given UID."

widgets:
blankslate:
heading: "No upcoming meetings"
description: "Upcoming meetings where you are the organizer or a participant will appear here."
view_details: "View all meetings"

meeting_section:
untitled_title: "Untitled section"
delete_confirmation: "Deleting the section will also delete all of its agenda items. Are you sure you want to do this?"
Expand Down
Loading
Loading