Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Use our own relative time component for fixed prefix

Oliver Günther570d7658780f
diff --git a/app/components/op_primer/relative_time_component.rb b/app/components/op_primer/relative_time_component.rb
new file mode 100644
index 00000000000..c49ab4758ca
--- /dev/null
+++ b/app/components/op_primer/relative_time_component.rb
@@ -0,0 +1,46 @@
+# frozen_string_literal: true
+
+#-- copyright
+# OpenProject is an open source project management software.
+# Copyright (C) 2012-2023 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 OpPrimer
+ class RelativeTimeComponent < Primer::Component
+ def initialize(datetime:, **system_arguments)
+ super()
+ @system_arguments = deny_tag_argument(**system_arguments)
+
+ @system_arguments[:datetime] = datetime
+ @system_arguments[:lang] ||= I18n.locale
+ @system_arguments[:prefix] ||= I18n.t(:label_on)
+ end
+
+ def call
+ render(Primer::Beta::RelativeTime.new(**@system_arguments))
+ end
+ end
+end
diff --git a/lookbook/previews/op_primer/relative_time_component_preview.rb b/lookbook/previews/op_primer/relative_time_component_preview.rb
new file mode 100644
index 00000000000..6908a0d06a3
--- /dev/null
+++ b/lookbook/previews/op_primer/relative_time_component_preview.rb
@@ -0,0 +1,13 @@
+module OpPrimer
+ class RelativeTimeComponentPreview < Lookbook::Preview
+ def default(datetime: (Time.now - 123456.seconds))
+ render OpPrimer::RelativeTimeComponent.new(datetime:)
+ end
+
+ def german_locale(datetime: Time.parse('2023-10-25T09:06:03Z'))
+ I18n.with_locale(:de) do
+ render OpPrimer::RelativeTimeComponent.new(datetime:)
+ end
+ end
+ end
+end
diff --git a/modules/meeting/app/components/meetings/header_infoline_component.html.erb b/modules/meeting/app/components/meetings/header_infoline_component.html.erb
index efa0827c446..d6e0169dc7d 100644
--- a/modules/meeting/app/components/meetings/header_infoline_component.html.erb
+++ b/modules/meeting/app/components/meetings/header_infoline_component.html.erb
@@ -3,5 +3,5 @@
<%= render(Primer::Beta::Link.new(href: user_path(@meeting.author), underline: false,
target: "_blank")) { @meeting.author.name } %>.
<%= t("label_meeting_last_updated") %>
- <%= render(Primer::Beta::RelativeTime.new(font_size: :small, datetime: last_updated_at, prefix: I18n.t(:label_on))) %>.
+ <%= render(OpPrimer::RelativeTimeComponent.new(font_size: :small, datetime: last_updated_at, prefix: I18n.t(:label_on))) %>.
<% end %>