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
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ class InfoListBoxComponent < Primer::Component

attr_reader :title, :list, :system_arguments

def initialize(title:, list:, **system_arguments)
def initialize(title:, list:, show_icon: true, **system_arguments)
super()
@title = title
@list = list
@show_icon = show_icon
@system_arguments = system_arguments
end

Expand All @@ -57,14 +58,16 @@ def call
end

def render_item(item)
concat(render(
Primer::Beta::Octicon.new(
icon: item[:checked] ? :"check-circle" : :"x-circle",
color: item[:checked] ? :success : :danger
)
))
if @show_icon
concat(render(
Primer::Beta::Octicon.new(
icon: item[:checked] ? :"check-circle" : :"x-circle",
color: item[:checked] ? :success : :danger
)
))
end
if item[:url].present?
concat(render(Primer::Beta::Link.new(href: item[:url], ml: 1)) { item[:label] })
concat(render(Primer::Beta::Link.new(href: item[:url], ml: 1, target: "_blank")) { item[:label] })
else
concat(render(Primer::Beta::Text.new(ml: 1)) { item[:label] })
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,7 @@ See COPYRIGHT and LICENSE files for more details.
component.with_row do
render(Admin::Import::Jira::ImportRuns::WizardStepFetchDataComponent.new(model))
end
component.with_row(scheme: :neutral, color: :muted, align_items: :center) do
render(Primer::Beta::Text.new(font_weight: :semibold)) {
I18n.t(:"admin.jira.run.wizard.groups.groups_and_users.title")
}
end
component.with_row do
render(Admin::Import::Jira::ImportRuns::WizardStepGroupsAndUsersComponent.new(model))
end

component.with_row(scheme: :neutral, color: :muted, align_items: :center) do
render(Primer::Beta::Text.new(font_weight: :semibold)) {
I18n.t(:"admin.jira.run.wizard.groups.configuration.title")
Expand All @@ -57,6 +50,7 @@ See COPYRIGHT and LICENSE files for more details.
component.with_row do
render(Admin::Import::Jira::ImportRuns::WizardStepImportScopeComponent.new(model))
end

component.with_row(scheme: :neutral, color: :muted, align_items: :center) do
render(Primer::Beta::Text.new(font_weight: :semibold)) {
I18n.t(:"admin.jira.run.wizard.groups.confirming.title")
Expand All @@ -65,6 +59,7 @@ See COPYRIGHT and LICENSE files for more details.
component.with_row do
render(Admin::Import::Jira::ImportRuns::WizardStepConfirmImportComponent.new(model))
end

component.with_row(scheme: :neutral, color: :muted, align_items: :center) do
render(Primer::Beta::Text.new(font_weight: :semibold)) {
I18n.t(:"admin.jira.run.wizard.groups.review.title")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ See COPYRIGHT and LICENSE files for more details.
box.with_row(mb: 3) do
render(Admin::Import::Jira::ImportRuns::InfoListBoxComponent.new(
title: I18n.t(:"admin.jira.run.wizard.sections.confirm_import.label_available_data"),
list: import_selection
list: import_selection,
show_icon: false
))
end
if model.in_state?(:projects_meta_done)
Expand Down Expand Up @@ -80,7 +81,8 @@ See COPYRIGHT and LICENSE files for more details.
box.with_row(mb: 3) do
render(Admin::Import::Jira::ImportRuns::InfoListBoxComponent.new(
title: I18n.t(:"admin.jira.run.wizard.sections.confirm_import.label_import_data"),
list: import_selection
list: import_selection,
show_icon: false
))
end
end
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ See COPYRIGHT and LICENSE files for more details.
})
end
end
if model.in_state?(:import_scope)
if model.in_state?(:instance_meta_done)
box.with_row(mb: 3, mt: 3) do
render(Primer::Alpha::Banner.new(scheme: :warning, icon: :alert)) {
I18n.t(:"admin.jira.run.wizard.sections.import_scope.label_info")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def import_stats_available
issues_label(available_issues_count),
statuses_label(available_statuses_count),
types_label(available_types_count),
I18n.t(:"admin.jira.run.wizard.sections.import_scope.elements.users")
users_label(available_users_count)
].map { |label| { label:, checked: true } }
end

Expand Down Expand Up @@ -83,5 +83,9 @@ def available_statuses_count
def available_types_count
model.available["total_issue_types"]
end

def available_users_count
model.available["total_users"]
end
end
end
20 changes: 0 additions & 20 deletions app/controllers/admin/import/jira/import_runs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ class ImportRunsController < ApplicationController
layout "admin"

VALID_STEPS = %i[
init
fetch_instance_meta
fetch_groups_and_users
import_groups_and_users
fetch_projects_meta
import_scope
configure
import
revert
Expand Down Expand Up @@ -111,10 +107,6 @@ def handle_error(error)
end
end

def init
@jira_import.transition_to!(:initial)
end

def fetch_instance_meta
@jira_import.transition_to!(:instance_meta_fetching)
end
Expand Down Expand Up @@ -145,22 +137,10 @@ def blocking_run
.first
end

def import_scope
@jira_import.transition_to!(:import_scope)
end

def configure
@jira_import.transition_to!(:configuring)
end

def fetch_groups_and_users
@jira_import.transition_to!(:groups_and_users_fetching)
end

def import_groups_and_users
@jira_import.transition_to!(:groups_and_users_importing)
end

def revert
@jira_import.transition_to!(:reverting)
end
Expand Down
46 changes: 1 addition & 45 deletions app/models/import/jira_import_state_machine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,6 @@ class JiraImportStateMachine
state :instance_meta_error
state :instance_meta_done

state :groups_and_users_init

state :groups_and_users_fetching
state :groups_and_users_fetching_cancelling
state :groups_and_users_fetching_cancelled
state :groups_and_users_fetching_error
state :groups_and_users_fetching_done

state :groups_and_users_importing
state :groups_and_users_importing_cancelling
state :groups_and_users_importing_cancelled
state :groups_and_users_importing_error
state :groups_and_users_importing_done

state :import_scope
state :configuring
state :projects_meta_fetching
Expand All @@ -73,19 +59,7 @@ class JiraImportStateMachine
transition from: INITIAL, to: [INSTANCE_META_FETCHING]
transition from: INSTANCE_META_FETCHING, to: [INSTANCE_META_DONE, INSTANCE_META_ERROR]
transition from: INSTANCE_META_ERROR, to: [INSTANCE_META_FETCHING]
transition from: INSTANCE_META_DONE, to: [GROUPS_AND_USERS_INIT]
transition from: GROUPS_AND_USERS_INIT, to: [GROUPS_AND_USERS_FETCHING]
transition from: GROUPS_AND_USERS_FETCHING, to: [GROUPS_AND_USERS_FETCHING_ERROR,
GROUPS_AND_USERS_FETCHING_CANCELLING,
GROUPS_AND_USERS_FETCHING_DONE]
transition from: GROUPS_AND_USERS_FETCHING_CANCELLING, to: [GROUPS_AND_USERS_FETCHING_CANCELLED]
transition from: GROUPS_AND_USERS_FETCHING_ERROR, to: [GROUPS_AND_USERS_FETCHING]
transition from: GROUPS_AND_USERS_FETCHING_DONE, to: [GROUPS_AND_USERS_IMPORTING]
transition from: GROUPS_AND_USERS_IMPORTING, to: [GROUPS_AND_USERS_IMPORTING_ERROR,
GROUPS_AND_USERS_IMPORTING_DONE]
transition from: GROUPS_AND_USERS_IMPORTING_ERROR, to: [GROUPS_AND_USERS_IMPORTING]
transition from: GROUPS_AND_USERS_IMPORTING_DONE, to: [IMPORT_SCOPE]
transition from: IMPORT_SCOPE, to: [CONFIGURING]
transition from: INSTANCE_META_DONE, to: [CONFIGURING, INSTANCE_META_FETCHING]
transition from: CONFIGURING, to: [PROJECTS_META_FETCHING]
transition from: PROJECTS_META_FETCHING, to: [PROJECTS_META_DONE, PROJECTS_META_ERROR]
transition from: PROJECTS_META_ERROR, to: [PROJECTS_META_FETCHING]
Expand All @@ -98,22 +72,6 @@ class JiraImportStateMachine
transition from: REVERT_CANCELLED, to: [REVERTING]
transition from: REVERT_ERROR, to: [REVERTING]

after_transition(to: :groups_and_users_fetching) do |jira_import, _transition|
Import::JiraFetchGroupsAndUsersJob.perform_later(jira_import.id)
end

after_transition(to: :groups_and_users_importing) do |jira_import, _transition|
Import::JiraImportGroupsAndUsersJob.perform_later(jira_import.id)
end

after_transition(to: :groups_and_users_fetching_done) do |jira_import, _transition|
jira_import.update_column(:cursor, nil)
end

after_transition(to: :groups_and_users_importing_done) do |jira_import, _transition|
jira_import.update_column(:cursor, nil)
end

after_transition(to: :reverted) do |jira_import, _transition|
jira_import.update_column(:cursor, nil)
end
Expand All @@ -140,8 +98,6 @@ def status_running?
[
INSTANCE_META_FETCHING,
PROJECTS_META_FETCHING,
GROUPS_AND_USERS_FETCHING,
GROUPS_AND_USERS_IMPORTING,
IMPORTING,
REVERTING
].include?(current_state)
Expand Down
Loading
Loading