Re-add video dialog removed in Angular

This commit is contained in:
Oliver Günther
2025-06-12 15:55:28 +02:00
parent 93369f0832
commit 53e0340063
7 changed files with 115 additions and 46 deletions
@@ -0,0 +1,33 @@
<%=
render(
Primer::Alpha::Dialog.new(
id: "enterprise-trial-welcome-dialog",
data: {
"application-target": "dynamic",
controller: "auto-show-dialog"
},
title: I18n.t("ee.trial.welcome_title"),
size: :large
)
) do |dialog|
dialog.with_header(variant: :large)
dialog.with_body do
flex_layout do |flex|
flex.with_row do
render(Primer::Beta::Text.new(color: :subtle)) { I18n.t("ee.trial.welcome_description") }
end
flex.with_row(mt: 2) do
content_tag :div, class: "onboarding--video iframe-target-wrapper" do
content_tag(:iframe,
"",
frameborder: "0",
height: "400",
width: "100%",
src: OpenProject::Static::Links.links[:enterprise_welcome_video][:href],
allowfullscreen: true)
end
end
end
end
end
%>
@@ -0,0 +1,38 @@
# 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 EnterpriseTrials
class WelcomeDialogComponent < ApplicationComponent
include ApplicationHelper
include OpenProject::FormTagHelper
include OpTurbo::Streamable
include OpPrimer::ComponentHelpers
end
end
@@ -30,6 +30,7 @@
class EnterpriseTokensController < ApplicationController
include OpTurbo::DialogStreamHelper
include OpTurbo::ComponentStream
include OpModalFlashable
layout "admin"
menu_item :enterprise
@@ -117,23 +118,34 @@ class EnterpriseTokensController < ApplicationController
end
def check_trial_status
token_saved_flash
@trial_key = Token::EnterpriseTrialKey.find_by(user_id: User.system.id)
return if @trial_key.nil?
@trial_status = EnterpriseTrials::AugurLoadTrialService.new(@trial_key).call
case @trial_status.result
when EnterpriseTrials::AugurLoadTrialService::STATUS_TOKEN_SAVED
token_saved_flash
when EnterpriseTrials::AugurLoadTrialService::STATUS_WAITING_CONFIRMATION
flash.now[:warning] = {
message: @trial_status.message,
action_button_arguments: {
tag: :a,
href: request_resend_enterprise_trial_path,
data: { turbo_method: :post }
},
action_button_content: I18n.t("ee.trial.resend_action")
}
set_waiting_for_confirmation_flash
else
@trial_status.apply_flash_message!(flash)
end
end
def token_saved_flash
flash_op_modal(component: EnterpriseTrials::WelcomeDialogComponent)
end
def set_waiting_for_confirmation_flash
flash.now[:warning] = {
message: @trial_status.message,
action_button_arguments: {
tag: :a,
href: request_resend_enterprise_trial_path,
data: { turbo_method: :post }
},
action_button_content: I18n.t("ee.trial.resend_action")
}
end
end
@@ -31,6 +31,7 @@
module EnterpriseTrials
class AugurLoadTrialService
STATUS_WAITING_CONFIRMATION = :awaiting_confirmation
STATUS_TOKEN_SAVED = :token_saved
def initialize(trial_key)
@trial_key = trial_key
@@ -64,19 +65,17 @@ module EnterpriseTrials
end
def handle_successful_trial(trial_json)
if trial_json["token"]
token = EnterpriseToken.new(encoded_token: trial_json["token"])
if token.save
@trial_key.destroy
return ServiceResult.success(result: token, message: I18n.t("ee.trial.successfully_saved"))
else
return ServiceResult.failure(result: token,
message_type: :info,
message: I18n.t("ee.trial.successfully_saved"))
end
if trial_json["token"].nil?
return ServiceResult.success(result: nil, message: I18n.t("ee.trial.already_retrieved"))
end
ServiceResult.success(result: nil, message: I18n.t("ee.trial.already_retrieved"))
token = EnterpriseToken.new(encoded_token: trial_json["token"])
if token.save
@trial_key.destroy
ServiceResult.success(result: STATUS_TOKEN_SAVED, message: I18n.t("ee.trial.successfully_saved"))
else
ServiceResult.failure(result: token)
end
end
def augur_host
+2
View File
@@ -2195,6 +2195,8 @@ en:
successfully_saved: "Your trial enterprise token has been successfully retrieved."
start_over: "Start over trial request"
resend_action: "Resend confirmation email"
welcome_title: "Quick feature overview"
welcome_description: "Get a quick overview of project management and team collaboration with OpenProject Enterprise edition."
confirmation_info: >
We sent you an email on %{date} to %{email}.
Please check your inbox and click the confirmation link provided to start your 14 days trial.
+2
View File
@@ -121,6 +121,8 @@ webinar_videos:
href: https://www.youtube.com/watch?v=un6zCm8_FT4
get_started_videos:
href: https://www.youtube.com/playlist?list=PLGzJ4gG7hPb8WWOWmeXqlfMfhdXReu-RJ
enterprise_welcome_video:
href: https://www.youtube.com/embed/zLMSydhFSkw?autoplay=1'
openproject_docs:
href: https://www.openproject.org/docs/
contact_us:
@@ -33,6 +33,8 @@ require "spec_helper"
RSpec.describe "Enterprise trial management",
:js,
:webmock do
include Redmine::I18n
let(:admin) { create(:admin) }
let(:trial_id) { "1b6486b4-5a30-4042-8714-99d7c8e6b637" }
@@ -178,9 +180,11 @@ RSpec.describe "Enterprise trial management",
end
it "does not send a request when an internal validation fails" do
click_link_or_button("Start free trial")
fill_in "Company", with: "Foo Corp."
click_link_or_button("Continue")
# No stubbed request with webmock -> No allowed requests
click_link_or_button("Continue")
page.within("#enterprise-trial-dialog") do
expect(page).to have_text("First name can't be blank.")
@@ -231,7 +235,7 @@ RSpec.describe "Enterprise trial management",
context "with a waiting request pending" do
before do
stub_request(:post, "https://start.openproject-edge.com:443/public/v1/trials")
.to_return(status: 200, headers: { "Content-Type" => "application/json" }, body: created_body.to_json)
.to_return(status: 202, headers: { "Content-Type" => "application/json" }, body: created_body.to_json)
stub_request(:get, "https://start.openproject-edge.com:443/public/v1/trials/#{trial_id}")
.to_return(status: 422, headers: { "Content-Type" => "application/json" }, body: waiting_body.to_json)
@@ -246,22 +250,14 @@ RSpec.describe "Enterprise trial management",
end
it "can get the trial if reloading the page" do
# We need to go to another page to stop the request cycle
visit info_admin_index_path
# Stub with successful body
# Stub the proxy to a successful return
# which marks the user has confirmed the mail link
stub_request(:get, "https://start.openproject-edge.com:443/public/v1/trials/#{trial_id}")
.to_return(status: 200, headers: { "Content-Type" => "application/json" }, body: confirmed_body.to_json)
# Stub the details URL to still return 403
stub_request(:get, "https://start.openproject-edge.com:443/public/v1/trials/#{trial_id}/details")
.to_return(status: 403)
visit enterprise_tokens_path
expect_and_dismiss_flash(message: "Successful update.")
expect(page).to have_text("Enterprise Plan (Token Version 1)")
expect(page).to have_text("OpenProject Test")
expect(page).to have_text("5")
@@ -270,27 +266,14 @@ RSpec.describe "Enterprise trial management",
end
it "can confirm that trial regularly" do
find_test_selector("op-ee-trial-waiting-resend-link", text: "Resend").click
expect(page).to have_css(".op-toast", text: "Email has been resent.", wait: 20)
expect(page).to have_text "foo@foocorp.example"
expect(page).to have_text "email sent - waiting for confirmation"
expect(page).to have_text "We sent you an email on #{format_date(Date.current)} to foo@foocorp.example"
# Stub the proxy to a successful return
# which marks the user has confirmed the mail link
stub_request(:get, "https://start.openproject-edge.com:443/public/v1/trials/#{trial_id}")
.to_return(status: 200, headers: { "Content-Type" => "application/json" }, body: confirmed_body.to_json)
.to_return(status: 202, headers: { "Content-Type" => "application/json" }, body: confirmed_body.to_json)
# Wait until the next request
expect(page).to have_test_selector "op-ee-trial-waiting-status--confirmed", text: "confirmed", wait: 20
click_link_or_button("Resend confirmation email")
# advance to video
click_on "Continue"
# advance to close
click_on "Continue"
expect_and_dismiss_flash(message: "Successful update.")
expect(page).to have_text("Enterprise Plan (Token Version 1)")
expect(page).to have_text("OpenProject Test")
expect(page).to have_text("5")