foreman_patch 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +619 -0
- data/README.md +38 -0
- data/Rakefile +53 -0
- data/app/assets/javascript/foreman_patch/plan_edit_windows.js +9 -0
- data/app/assets/stylesheets/foreman_patch/cycle_plans.scss +6 -0
- data/app/assets/stylesheets/foreman_patch/foreman_patch.css +4 -0
- data/app/controllers/concerns/foreman_patch/parameters/ticket_field.rb +26 -0
- data/app/controllers/foreman_patch/api/v2/base_controller.rb +12 -0
- data/app/controllers/foreman_patch/api/v2/cycles_controller.rb +78 -0
- data/app/controllers/foreman_patch/api/v2/groups_controller.rb +70 -0
- data/app/controllers/foreman_patch/api/v2/host_groups_controller.rb +13 -0
- data/app/controllers/foreman_patch/api/v2/invocations_controller.rb +70 -0
- data/app/controllers/foreman_patch/api/v2/plans_controller.rb +79 -0
- data/app/controllers/foreman_patch/api/v2/rounds_controller.rb +77 -0
- data/app/controllers/foreman_patch/api/v2/window_plans_controller.rb +73 -0
- data/app/controllers/foreman_patch/api/v2/windows_controller.rb +85 -0
- data/app/controllers/foreman_patch/concerns/api/v2/hosts_controller_extensions.rb +21 -0
- data/app/controllers/foreman_patch/concerns/hosts_controller_extensions.rb +61 -0
- data/app/controllers/foreman_patch/cycles_controller.rb +34 -0
- data/app/controllers/foreman_patch/groups_controller.rb +68 -0
- data/app/controllers/foreman_patch/invocations_controller.rb +51 -0
- data/app/controllers/foreman_patch/plans_controller.rb +59 -0
- data/app/controllers/foreman_patch/rounds_controller.rb +18 -0
- data/app/controllers/foreman_patch/ticket_fields_controller.rb +37 -0
- data/app/controllers/foreman_patch/window_plans_controller.rb +60 -0
- data/app/controllers/foreman_patch/windows_controller.rb +58 -0
- data/app/helpers/concerns/foreman_patch/hosts_helper_extensions.rb +13 -0
- data/app/helpers/foreman_patch/cycles_helper.rb +19 -0
- data/app/helpers/foreman_patch/hosts_helper.rb +52 -0
- data/app/helpers/foreman_patch/patching_helper.rb +116 -0
- data/app/helpers/foreman_patch/plans_helper.rb +45 -0
- data/app/helpers/foreman_patch/ticket_helper.rb +11 -0
- data/app/helpers/foreman_patch/window_patching_helper.rb +20 -0
- data/app/helpers/foreman_patch/window_plans_helper.rb +13 -0
- data/app/helpers/foreman_patch/windows_helper.rb +17 -0
- data/app/lib/actions/foreman_patch/cycle/complete.rb +41 -0
- data/app/lib/actions/foreman_patch/cycle/create.rb +69 -0
- data/app/lib/actions/foreman_patch/cycle/initiate.rb +68 -0
- data/app/lib/actions/foreman_patch/cycle/plan.rb +73 -0
- data/app/lib/actions/foreman_patch/cycle/prepare_content.rb +123 -0
- data/app/lib/actions/foreman_patch/host/reschedule.rb +32 -0
- data/app/lib/actions/foreman_patch/invocation/action.rb +135 -0
- data/app/lib/actions/foreman_patch/invocation/ensure_services.rb +47 -0
- data/app/lib/actions/foreman_patch/invocation/patch.rb +93 -0
- data/app/lib/actions/foreman_patch/invocation/reschedule.rb +21 -0
- data/app/lib/actions/foreman_patch/invocation/restart.rb +101 -0
- data/app/lib/actions/foreman_patch/invocation/update_packages.rb +52 -0
- data/app/lib/actions/foreman_patch/invocation/wait_for_host.rb +103 -0
- data/app/lib/actions/foreman_patch/round/add_missing_hosts.rb +21 -0
- data/app/lib/actions/foreman_patch/round/create.rb +37 -0
- data/app/lib/actions/foreman_patch/round/patch.rb +81 -0
- data/app/lib/actions/foreman_patch/round/plan.rb +33 -0
- data/app/lib/actions/foreman_patch/round/resolve_hosts.rb +45 -0
- data/app/lib/actions/foreman_patch/window/create.rb +41 -0
- data/app/lib/actions/foreman_patch/window/patch.rb +72 -0
- data/app/lib/actions/foreman_patch/window/plan.rb +43 -0
- data/app/lib/actions/foreman_patch/window/publish.rb +32 -0
- data/app/lib/actions/foreman_patch/window/resolve_hosts.rb +31 -0
- data/app/lib/actions/helpers/failure_notification.rb +20 -0
- data/app/lib/actions/helpers/with_feature_action.rb +102 -0
- data/app/lib/actions/middleware/check_exit_status.rb +31 -0
- data/app/mailers/foreman_patch/cycle_mailer.rb +17 -0
- data/app/mailers/foreman_patch/group_mailer.rb +41 -0
- data/app/mailers/foreman_patch/invocation_mailer.rb +19 -0
- data/app/models/foreman_patch/concerns/group_facet_host_extensions.rb +35 -0
- data/app/models/foreman_patch/concerns/host_managed_extensions.rb +17 -0
- data/app/models/foreman_patch/cycle.rb +49 -0
- data/app/models/foreman_patch/group.rb +43 -0
- data/app/models/foreman_patch/host/group_facet.rb +13 -0
- data/app/models/foreman_patch/invocation.rb +60 -0
- data/app/models/foreman_patch/plan.rb +110 -0
- data/app/models/foreman_patch/plan_task_group.rb +11 -0
- data/app/models/foreman_patch/round.rb +68 -0
- data/app/models/foreman_patch/ticket_field.rb +23 -0
- data/app/models/foreman_patch/window.rb +123 -0
- data/app/models/foreman_patch/window_plan.rb +77 -0
- data/app/models/foreman_patch/window_task_group.rb +11 -0
- data/app/models/setting/patching.rb +57 -0
- data/app/services/foreman_patch/cycle_name_generator.rb +38 -0
- data/app/services/foreman_patch/ticket/affected_items.rb +110 -0
- data/app/services/foreman_patch/ticket/api.rb +68 -0
- data/app/services/foreman_patch/ticket/change_request.rb +92 -0
- data/app/services/foreman_patch/ticket/field_render.rb +21 -0
- data/app/services/foreman_patch/ticket/payload.rb +136 -0
- data/app/services/foreman_patch/ticket.rb +14 -0
- data/app/views/dashboard/_foreman_patch_widget.html.erb +2 -0
- data/app/views/foreman_patch/api/v2/cycles/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/cycles/create.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/cycles/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/cycles/show.json.rabl +9 -0
- data/app/views/foreman_patch/api/v2/cycles/update.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/group_facet/base.json.rabl +7 -0
- data/app/views/foreman_patch/api/v2/group_facet/base_with_root.json.rabl +4 -0
- data/app/views/foreman_patch/api/v2/group_facet/show.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/groups/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/groups/create.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/groups/index.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/groups/show.json.rabl +14 -0
- data/app/views/foreman_patch/api/v2/groups/update.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/invocations/base.json.rabl +6 -0
- data/app/views/foreman_patch/api/v2/invocations/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/invocations/phase.json.rabl +7 -0
- data/app/views/foreman_patch/api/v2/invocations/show.json.rabl +7 -0
- data/app/views/foreman_patch/api/v2/plans/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/plans/create.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/plans/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/plans/show.json.rabl +9 -0
- data/app/views/foreman_patch/api/v2/plans/update.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/rounds/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/rounds/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/rounds/show.json.rabl +17 -0
- data/app/views/foreman_patch/api/v2/rounds/status.json.rabl +11 -0
- data/app/views/foreman_patch/api/v2/window_plans/base.json.rabl +4 -0
- data/app/views/foreman_patch/api/v2/window_plans/create.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/window_plans/index.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/window_plans/show.json.rabl +14 -0
- data/app/views/foreman_patch/api/v2/window_plans/update.json.rabl +2 -0
- data/app/views/foreman_patch/api/v2/windows/base.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/windows/index.json.rabl +3 -0
- data/app/views/foreman_patch/api/v2/windows/schedule.json.rabl +13 -0
- data/app/views/foreman_patch/api/v2/windows/show.json.rabl +13 -0
- data/app/views/foreman_patch/api/v2/windows/update.json.rabl +3 -0
- data/app/views/foreman_patch/cycle_mailer/_details.html.erb +4 -0
- data/app/views/foreman_patch/cycle_mailer/_round.html.erb +12 -0
- data/app/views/foreman_patch/cycle_mailer/_summary.html.erb +6 -0
- data/app/views/foreman_patch/cycle_mailer/_window.html.erb +4 -0
- data/app/views/foreman_patch/cycle_mailer/planned.html.erb +7 -0
- data/app/views/foreman_patch/cycles/_form.html.erb +9 -0
- data/app/views/foreman_patch/cycles/edit.html.erb +41 -0
- data/app/views/foreman_patch/cycles/index.html.erb +45 -0
- data/app/views/foreman_patch/cycles/show.html.erb +26 -0
- data/app/views/foreman_patch/group_mailer/_dashboard.html.erb +31 -0
- data/app/views/foreman_patch/group_mailer/_list.html.erb +17 -0
- data/app/views/foreman_patch/group_mailer/completed.html.erb +16 -0
- data/app/views/foreman_patch/group_mailer/initiated.html.erb +4 -0
- data/app/views/foreman_patch/groups/_form.html.erb +9 -0
- data/app/views/foreman_patch/groups/edit.html.erb +3 -0
- data/app/views/foreman_patch/groups/index.html.erb +40 -0
- data/app/views/foreman_patch/groups/new.html.erb +3 -0
- data/app/views/foreman_patch/hosts/hosts/new_action.html.erb +1 -0
- data/app/views/foreman_patch/hosts/new_action.html.erb +1 -0
- data/app/views/foreman_patch/invocation_mailer/_output_line_set.html.erb +6 -0
- data/app/views/foreman_patch/invocation_mailer/_output_line_set.text.erb +3 -0
- data/app/views/foreman_patch/invocation_mailer/failure.html.erb +50 -0
- data/app/views/foreman_patch/invocation_mailer/failure.text.erb +10 -0
- data/app/views/foreman_patch/invocations/_output_line_set.html.erb +8 -0
- data/app/views/foreman_patch/invocations/_phase.html.erb +17 -0
- data/app/views/foreman_patch/invocations/_primary.html.erb +1 -0
- data/app/views/foreman_patch/invocations/_refresh.js.erb +7 -0
- data/app/views/foreman_patch/invocations/show.html.erb +44 -0
- data/app/views/foreman_patch/invocations/show.js.erb +17 -0
- data/app/views/foreman_patch/layouts/react.html.erb +17 -0
- data/app/views/foreman_patch/plans/_form.html.erb +12 -0
- data/app/views/foreman_patch/plans/edit.html.erb +6 -0
- data/app/views/foreman_patch/plans/index.html.erb +32 -0
- data/app/views/foreman_patch/plans/new.html.erb +3 -0
- data/app/views/foreman_patch/plans/show.html.erb +19 -0
- data/app/views/foreman_patch/rounds/show.html.erb +54 -0
- data/app/views/foreman_patch/ticket_fields/_fields.html.erb +66 -0
- data/app/views/foreman_patch/ticket_fields/edit.html.erb +6 -0
- data/app/views/foreman_patch/ticket_fields/index.html.erb +26 -0
- data/app/views/foreman_patch/ticket_fields/new.html.erb +6 -0
- data/app/views/foreman_patch/window_plans/_form.html.erb +11 -0
- data/app/views/foreman_patch/window_plans/_hidden_layout.html.erb +7 -0
- data/app/views/foreman_patch/window_plans/edit.html.erb +3 -0
- data/app/views/foreman_patch/window_plans/new.html.erb +3 -0
- data/app/views/foreman_patch/windows/_form.html.erb +21 -0
- data/app/views/foreman_patch/windows/_groups.html.erb +2 -0
- data/app/views/foreman_patch/windows/_rounds.html.erb +24 -0
- data/app/views/foreman_patch/windows/_schedule.html.erb +16 -0
- data/app/views/foreman_patch/windows/_ticket.html.erb +12 -0
- data/app/views/foreman_patch/windows/edit.html.erb +3 -0
- data/app/views/foreman_patch/windows/new.html.erb +3 -0
- data/app/views/foreman_patch/windows/show.html.erb +27 -0
- data/app/views/foreman_patch/windows/show.json.erb +4 -0
- data/app/views/hosts/select_multiple_patch_group.html.erb +12 -0
- data/app/views/overrides/patch_groups/_host_patch_group_select.html.erb +9 -0
- data/app/views/templates/ensure_services.erb +28 -0
- data/config/api_routes.rb +37 -0
- data/config/initializers/pagelets.rb +6 -0
- data/config/initializers/safemode_jail.rb +4 -0
- data/config/routes/mount_engine.rb +3 -0
- data/config/routes/overrides.rb +10 -0
- data/config/routes.rb +47 -0
- data/db/migrate/20210202161304_create_foreman_patch_plans.rb +32 -0
- data/db/migrate/20210202163323_create_foreman_patch_cycles.rb +38 -0
- data/db/migrate/20210202164301_create_foreman_patch_groups.rb +37 -0
- data/db/migrate/20210226134103_add_name_to_cycles.rb +31 -0
- data/db/migrate/20210226162824_rename_default_window.rb +5 -0
- data/db/migrate/20210302165058_add_task_to_window_groups.rb +7 -0
- data/db/migrate/20210304141111_create_invocation.rb +16 -0
- data/db/migrate/20210519163923_add_cycle_end_date.rb +29 -0
- data/db/migrate/20210525154113_expand_window_groups.rb +27 -0
- data/db/migrate/20210723160142_add_cycle_plan_task_group.rb +7 -0
- data/db/migrate/20210831160044_cycle_plan_start_correction.rb +5 -0
- data/db/migrate/20210907104645_rename_group_priority.rb +5 -0
- data/db/migrate/20210909130118_remove_old_references.rb +14 -0
- data/db/migrate/20210910141428_rename_round.rb +7 -0
- data/db/migrate/20210910163542_rename_plan.rb +8 -0
- data/db/migrate/20211014212415_round_group_reference.rb +9 -0
- data/db/migrate/20220105224803_add_group_label.rb +25 -0
- data/db/migrate/20220114153808_plan_add_name_generator.rb +5 -0
- data/db/migrate/20220117103808_remove_cycle_description.rb +5 -0
- data/db/migrate/20220406110705_add_window_state.rb +37 -0
- data/db/migrate/20220407161120_add_round_status.rb +9 -0
- data/db/migrate/20220902134800_add_invocation_status.rb +28 -0
- data/db/seeds.d/100-assign_features_with_templates.rb +16 -0
- data/db/seeds.d/160-mail_notifications.rb +38 -0
- data/db/seeds.d/75-job_templates.rb +16 -0
- data/lib/foreman_patch/engine.rb +87 -0
- data/lib/foreman_patch/plugin.rb +47 -0
- data/lib/foreman_patch/version.rb +3 -0
- data/lib/foreman_patch.rb +4 -0
- data/lib/tasks/foreman_patch_tasks.rake +47 -0
- data/locale/Makefile +60 -0
- data/locale/en/foreman_patch.po +19 -0
- data/locale/foreman_patch.pot +19 -0
- data/locale/gemspec.rb +2 -0
- data/package.json +35 -0
- data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss +6 -0
- data/public/assets/foreman_patch/cycle_plans-e5667e178ba389908f5c815b24ec0ea77c340849d56bc39c5ce72bb626bd446a.scss.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css +1 -0
- data/public/assets/foreman_patch/foreman_patch-ce5805a60c0d5f896f557ff5246e5a09172043004c850b39bea54e618df1c485.css.gz +0 -0
- data/public/assets/foreman_patch/foreman_patch.json +1 -0
- data/public/assets/foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js +1 -0
- data/public/assets/foreman_patch/plan_edit_windows-e656ba411642a7f983b51958ab30ac49c056322d19295a603cff4d5e6c71c8ed.js.gz +0 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.css +1 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.css.gz +0 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.js +6 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.js.gz +0 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.js.map +1 -0
- data/public/webpack/foreman_patch/bundle-200e97f4e2ad9ed413ea.js.map.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.css +1 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.css.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.js +6 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.js.gz +0 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.js.map +1 -0
- data/public/webpack/foreman_patch/foreman_patch-1e4f2d5e6f040a27aa7a.js.map.gz +0 -0
- data/public/webpack/foreman_patch/manifest.json +26 -0
- data/public/webpack/foreman_patch/manifest.json.gz +0 -0
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js +2 -0
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.gz +0 -0
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.map +1 -0
- data/public/webpack/foreman_patch/vendor-4b77c91f1e9103179596.js.map.gz +0 -0
- data/test/factories/foreman_patch_factories.rb +5 -0
- data/test/test_plugin_helper.rb +6 -0
- data/test/unit/foreman_patch_test.rb +11 -0
- data/webpack/components/Cycle/Cycle.js +57 -0
- data/webpack/components/Cycle/CycleActions.js +21 -0
- data/webpack/components/Cycle/CycleConstants.js +2 -0
- data/webpack/components/Cycle/CycleHelpers.js +3 -0
- data/webpack/components/Cycle/CycleSelectors.js +10 -0
- data/webpack/components/Cycle/Window.js +32 -0
- data/webpack/components/Cycle/index.js +41 -0
- data/webpack/components/Groups/Group.js +20 -0
- data/webpack/components/Groups/Groups.js +46 -0
- data/webpack/components/Groups/GroupsHelpers.js +11 -0
- data/webpack/components/Groups/Priority.js +51 -0
- data/webpack/components/Invocation/Invocation.js +47 -0
- data/webpack/components/Invocation/InvocationActions.js +8 -0
- data/webpack/components/Invocation/InvocationConsts.js +1 -0
- data/webpack/components/Invocation/InvocationSelectors.js +14 -0
- data/webpack/components/Invocation/index.js +36 -0
- data/webpack/components/Invocations/Invocations.js +55 -0
- data/webpack/components/Invocations/InvocationsConstants.js +1 -0
- data/webpack/components/Invocations/InvocationsHelpers.js +11 -0
- data/webpack/components/Invocations/InvocationsPage.js +66 -0
- data/webpack/components/Invocations/InvocationsPage.scss +3 -0
- data/webpack/components/Invocations/InvocationsSelectors.js +21 -0
- data/webpack/components/Invocations/components/InvocationItem.js +66 -0
- data/webpack/components/Invocations/components/InvocationStatus.js +51 -0
- data/webpack/components/Invocations/index.js +99 -0
- data/webpack/components/Plan/Plan.js +90 -0
- data/webpack/components/Plan/PlanActions.js +12 -0
- data/webpack/components/Plan/PlanConstants.js +1 -0
- data/webpack/components/Plan/PlanSelectors.js +9 -0
- data/webpack/components/Plan/Window.js +33 -0
- data/webpack/components/Plan/index.js +36 -0
- data/webpack/components/PlanWindow/PlanWindow.js +55 -0
- data/webpack/components/PlanWindow/index.js +32 -0
- data/webpack/components/RoundProgress/AggregateStatus.js +58 -0
- data/webpack/components/RoundProgress/RoundProgress.js +48 -0
- data/webpack/components/RoundProgress/RoundProgressActions.js +9 -0
- data/webpack/components/RoundProgress/RoundProgressConstants.js +1 -0
- data/webpack/components/RoundProgress/RoundProgressSelectors.js +24 -0
- data/webpack/components/RoundProgress/index.js +44 -0
- data/webpack/components/Rounds/Rounds.js +57 -0
- data/webpack/components/Rounds/RoundsActions.js +8 -0
- data/webpack/components/Rounds/RoundsConsts.js +1 -0
- data/webpack/components/Rounds/RoundsSelectors.js +14 -0
- data/webpack/components/Rounds/components/RoundItem.js +52 -0
- data/webpack/components/Rounds/components/RoundStatus.js +40 -0
- data/webpack/components/Rounds/index.js +37 -0
- data/webpack/components/common/Calendar/Calendar.js +86 -0
- data/webpack/components/common/Calendar/Calendar.scss +76 -0
- data/webpack/components/common/Calendar/CalendarConstants.js +1 -0
- data/webpack/components/common/Calendar/CalendarHelpers.js +77 -0
- data/webpack/components/common/Calendar/Day/index.js +9 -0
- data/webpack/components/common/Calendar/Event.js +25 -0
- data/webpack/components/common/Calendar/Month/Day.js +51 -0
- data/webpack/components/common/Calendar/Month/Header.js +77 -0
- data/webpack/components/common/Calendar/Month/Month.js +47 -0
- data/webpack/components/common/Calendar/Month/index.js +1 -0
- data/webpack/components/common/Calendar/View.js +20 -0
- data/webpack/components/common/Calendar/Week/index.js +13 -0
- data/webpack/components/common/Calendar/index.js +2 -0
- data/webpack/components/common/Terminal/OutputLine.js +26 -0
- data/webpack/components/common/Terminal/Terminal.js +115 -0
- data/webpack/components/common/Terminal/Terminal.scss +47 -0
- data/webpack/index.js +20 -0
- metadata +438 -0
Binary file
|
@@ -0,0 +1,57 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { LoadingState, Alert } from 'patternfly-react';
|
4
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
5
|
+
import { STATUS } from 'foremanReact/constants';
|
6
|
+
|
7
|
+
import Calendar from '../common/Calendar';
|
8
|
+
import Window from './Window';
|
9
|
+
|
10
|
+
const Cycle = ({ id, name, description, start_date, end_date, windows, moveWindow, status}) => {
|
11
|
+
if (status === STATUS.ERROR) {
|
12
|
+
return (
|
13
|
+
<Alert type="error">
|
14
|
+
{__(
|
15
|
+
'There was an error while loading the cycle, try refreshing the page.'
|
16
|
+
)}
|
17
|
+
</Alert>
|
18
|
+
);
|
19
|
+
}
|
20
|
+
|
21
|
+
const start = new Date(start_date + 'T00:00:00.000');
|
22
|
+
const end = new Date(end_date + 'T23:59:59.999');
|
23
|
+
|
24
|
+
const events = windows.map(window => {
|
25
|
+
const start = new Date(window.start_at);
|
26
|
+
const end = new Date(window.end_by);
|
27
|
+
|
28
|
+
return {
|
29
|
+
id: window.id,
|
30
|
+
start: new Date(window.start_at),
|
31
|
+
end: new Date(window.end_by),
|
32
|
+
title: <Window {...window} start={start} end={end} />,
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
return (
|
37
|
+
<LoadingState loading={status === STATUS.PENDING}>
|
38
|
+
<Calendar start={start} end={end} events={events} onEventMoved={moveWindow} />
|
39
|
+
</LoadingState>
|
40
|
+
);
|
41
|
+
};
|
42
|
+
|
43
|
+
Cycle.propTypes = {
|
44
|
+
id: PropTypes.number,
|
45
|
+
name: PropTypes.string,
|
46
|
+
start_date: PropTypes.string,
|
47
|
+
end_date: PropTypes.string,
|
48
|
+
windows: PropTypes.array,
|
49
|
+
moveWindow: PropTypes.func,
|
50
|
+
status: PropTypes.string,
|
51
|
+
};
|
52
|
+
|
53
|
+
Cycle.defaultProps = {
|
54
|
+
windows: [],
|
55
|
+
};
|
56
|
+
|
57
|
+
export default Cycle;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { APIActions } from 'foremanReact/redux/API/APIActions';
|
2
|
+
//import { withInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
|
3
|
+
import { CYCLE, WINDOW } from './CycleConstants';
|
4
|
+
|
5
|
+
const getCycleUrl = (id) => `/foreman_patch/api/cycles/${id}`;
|
6
|
+
const getWindowUrl = (id) => `/foreman_patch/api/windows/${id}`;
|
7
|
+
|
8
|
+
export const getCycle = (id) => APIActions.get({ key: CYCLE, url: getCycleUrl(id) });
|
9
|
+
|
10
|
+
export const deleteWindow = (id) => APIActions.delete({ key: WINDOW, url: getWindowUrl(id)});
|
11
|
+
|
12
|
+
export const moveWindow = (object) => APIActions.put({
|
13
|
+
key: WINDOW,
|
14
|
+
url: getWindowUrl(object.id),
|
15
|
+
params: {
|
16
|
+
window: {
|
17
|
+
start_at: object.start.toISOString(),
|
18
|
+
end_by: object.end.toISOString(),
|
19
|
+
}
|
20
|
+
}
|
21
|
+
});
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import {
|
2
|
+
selectAPIStatus,
|
3
|
+
selectAPIResponse,
|
4
|
+
} from 'foremanReact/redux/API/APISelectors';
|
5
|
+
import { CYCLE } from './CycleConstants';
|
6
|
+
|
7
|
+
export const selectCycle = state => (selectAPIResponse(state, CYCLE) || {});
|
8
|
+
|
9
|
+
export const selectStatus = state => selectAPIStatus(state, CYCLE);
|
10
|
+
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
|
4
|
+
const Window = ({id, name, description, start, end, locale, hour12}) => {
|
5
|
+
const time = Intl.DateTimeFormat(locale, {
|
6
|
+
hour: 'numeric', minute: 'numeric', hour12: hour12
|
7
|
+
}).format(start);
|
8
|
+
|
9
|
+
return (
|
10
|
+
<div className="ellipsis">
|
11
|
+
<a href={`/foreman_patch/windows/${id}`}>{time} {name}</a>
|
12
|
+
</div>
|
13
|
+
);
|
14
|
+
};
|
15
|
+
|
16
|
+
Window.propTypes = {
|
17
|
+
id: PropTypes.number.isRequired,
|
18
|
+
name: PropTypes.string.isRequired,
|
19
|
+
description: PropTypes.string,
|
20
|
+
start: PropTypes.instanceOf(Date).isRequired,
|
21
|
+
end: PropTypes.instanceOf(Date).isRequired,
|
22
|
+
locale: PropTypes.string,
|
23
|
+
hour12: PropTypes.bool,
|
24
|
+
};
|
25
|
+
|
26
|
+
Window.defaultProps = {
|
27
|
+
description: null,
|
28
|
+
locale: 'en-US',
|
29
|
+
hour12: true,
|
30
|
+
};
|
31
|
+
|
32
|
+
export default Window;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
import React, { useEffect } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { useSelector, useDispatch } from 'react-redux';
|
4
|
+
|
5
|
+
import Cycle from './Cycle';
|
6
|
+
import {
|
7
|
+
selectCycle,
|
8
|
+
selectStatus,
|
9
|
+
} from './CycleSelectors';
|
10
|
+
import {
|
11
|
+
getCycle,
|
12
|
+
moveWindow,
|
13
|
+
} from './CycleActions';
|
14
|
+
|
15
|
+
const WrappedCycle = ({ id }) => {
|
16
|
+
const dispatch = useDispatch();
|
17
|
+
|
18
|
+
const cycle = useSelector(selectCycle);
|
19
|
+
const status = useSelector(selectStatus);
|
20
|
+
|
21
|
+
const updateWindow = (window) => {
|
22
|
+
dispatch(moveWindow(window));
|
23
|
+
};
|
24
|
+
|
25
|
+
useEffect(() => {
|
26
|
+
dispatch(getCycle(id));
|
27
|
+
}, [dispatch]);
|
28
|
+
|
29
|
+
return (<Cycle {...cycle} moveWindow={updateWindow} status={status} />);
|
30
|
+
};
|
31
|
+
|
32
|
+
WrappedCycle.propTypes = {
|
33
|
+
id: PropTypes.number.isRequired,
|
34
|
+
locale: PropTypes.string,
|
35
|
+
};
|
36
|
+
|
37
|
+
WrappedCycle.defaultProps = {
|
38
|
+
locale: 'en-US',
|
39
|
+
};
|
40
|
+
|
41
|
+
export default WrappedCycle;
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import React from 'react'
|
2
|
+
import PropTypes from 'prop-types'
|
3
|
+
import { useDrag } from 'react-dnd'
|
4
|
+
|
5
|
+
import { GROUP } from './GroupsConstants'
|
6
|
+
|
7
|
+
const Group = (props) => {
|
8
|
+
const [, drag] = useDrag({
|
9
|
+
type: GROUP,
|
10
|
+
item: {
|
11
|
+
...props
|
12
|
+
},
|
13
|
+
});
|
14
|
+
|
15
|
+
return (
|
16
|
+
<span ref={drag}></span>
|
17
|
+
);
|
18
|
+
};
|
19
|
+
|
20
|
+
export default Group;
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { DndProvider } from 'react-dnd';
|
4
|
+
import HTML5Backend from 'react-dnd-html5-backend';
|
5
|
+
|
6
|
+
import Priority from './Priority';
|
7
|
+
import { prioritizeGroups } from './GroupsHelpers';
|
8
|
+
|
9
|
+
const Groups = ({groups}) => {
|
10
|
+
const [priorities, setPriorities] = useState(prioritizeGroups(groups));
|
11
|
+
|
12
|
+
const moveGroup = (group, source, target, insert) => {
|
13
|
+
const result = priorities;
|
14
|
+
|
15
|
+
// insert the group into the correct priority
|
16
|
+
if (insert) {
|
17
|
+
// insert a new priority with the group
|
18
|
+
result.splice(target, 0, [ group ]);
|
19
|
+
} else {
|
20
|
+
// add group to existing priority
|
21
|
+
result[target].push(group);
|
22
|
+
}
|
23
|
+
|
24
|
+
// remove group from source priority
|
25
|
+
result[source] = result[source].filter(e => (e !== group));
|
26
|
+
|
27
|
+
// remove priority if it is empty
|
28
|
+
if (result[source].length === 0) {
|
29
|
+
result.splice(group.priority, 1);
|
30
|
+
}
|
31
|
+
|
32
|
+
setPriorities(result);
|
33
|
+
};
|
34
|
+
|
35
|
+
return (
|
36
|
+
<DndProvider backend={HTML5Backend}>
|
37
|
+
<div className="group-list">
|
38
|
+
{priorities.map(groups, index => (
|
39
|
+
<Priority priority={index} groups={groups} />
|
40
|
+
))}
|
41
|
+
</div>
|
42
|
+
</DndProvider>
|
43
|
+
);
|
44
|
+
};
|
45
|
+
|
46
|
+
export default Groups;
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { useDrop } from 'react-dnd';
|
4
|
+
|
5
|
+
import { GROUP } from './GroupConstants';
|
6
|
+
|
7
|
+
const Priority = ({priority, groups}) => {
|
8
|
+
const [, drop] = useDrop({
|
9
|
+
accept: GROUP,
|
10
|
+
hover(item, monitor) {
|
11
|
+
const sourcePriority = item.priority
|
12
|
+
const targetPriority = priority
|
13
|
+
|
14
|
+
if (groups.length === 1 && sourcePriority === targetPriority) {
|
15
|
+
return
|
16
|
+
}
|
17
|
+
|
18
|
+
// Determine rectangle on screen
|
19
|
+
const hoverBoundingRect = ref.current?.getBoundingClientRect()
|
20
|
+
|
21
|
+
// Three vertical zones
|
22
|
+
// 1: top 25% - insert above
|
23
|
+
// 2: middle 50% - drop into
|
24
|
+
// 3: bottom 25% - insert below
|
25
|
+
// This results in 2 Y boundaries
|
26
|
+
const hoverAboveY = (hoverBoundingRect.bottom - hoverBoundingRect.top) * 0.25
|
27
|
+
const hoverBelowY = (hoverBoundingRect.bottom - hoverBoundingRect.top) * 0.75
|
28
|
+
|
29
|
+
// Determine mouse position
|
30
|
+
const clientOffset = monitor.getClientOffset()
|
31
|
+
|
32
|
+
// Get pixes from the top
|
33
|
+
const hoverClientY = clientOffset.y - hoverBoundingRect.top
|
34
|
+
|
35
|
+
const targetPriority = hoverPriority
|
36
|
+
|
37
|
+
moveGroup(group, targetPriority, insert)
|
38
|
+
group.priority = hoverPriority
|
39
|
+
}
|
40
|
+
});
|
41
|
+
|
42
|
+
return (
|
43
|
+
<div ref={drop}>
|
44
|
+
{groups.map(group => (
|
45
|
+
<Group priority={priority} group={group} />
|
46
|
+
))}
|
47
|
+
</div>
|
48
|
+
);
|
49
|
+
};
|
50
|
+
|
51
|
+
export default Priority;
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import React, { useState } from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
4
|
+
import { Tabs, Tab, TabTitleText, LoadingState } from 'patternfly-react';
|
5
|
+
import { STATUS } from 'foremanReact/constants';
|
6
|
+
|
7
|
+
import Terminal from '../common/Terminal/Terminal';
|
8
|
+
|
9
|
+
const Invocation = ({ invocation, status }) => {
|
10
|
+
if (status === STATUS.ERROR) {
|
11
|
+
return (
|
12
|
+
<Alert type="error">
|
13
|
+
{__(
|
14
|
+
'There was an error loading the invocation, try refreshing the page.'
|
15
|
+
)}
|
16
|
+
</Alert>
|
17
|
+
);
|
18
|
+
}
|
19
|
+
|
20
|
+
const [activeTabKey, setActiveTabKey] = useState(0);
|
21
|
+
|
22
|
+
const handleTabClick = (event, tabIndex) => {
|
23
|
+
setActiveTabKey(tabIndex);
|
24
|
+
};
|
25
|
+
|
26
|
+
return (
|
27
|
+
<LoadingState loading={status == STATUS.PENDING}>
|
28
|
+
<Tabs activeKey={activeTabKey} onSelect={handleTabClick}>
|
29
|
+
<Tab eventKey={0} title={<TabTitleText>Overview</TabTitleText>}>
|
30
|
+
TODO: status
|
31
|
+
</Tab>
|
32
|
+
{invocation.phases.map((phase, index) => (
|
33
|
+
<Tab event={index + 1} title={<TabTitleText>{phase.humanized_name}</TabTitleText>}>
|
34
|
+
<Terminal key={phase.label} linesets={phase.live_output}/>
|
35
|
+
</Tab>
|
36
|
+
))}
|
37
|
+
</Tabs>
|
38
|
+
</LoadingState>
|
39
|
+
);
|
40
|
+
};
|
41
|
+
|
42
|
+
Invocation.propTypes = {
|
43
|
+
status: PropTypes.string.isRequired,
|
44
|
+
invocation: PropTypes.object.isRequired,
|
45
|
+
};
|
46
|
+
|
47
|
+
export default Invocation;
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { getURL } from 'foremanReact/common/urlHelpers';
|
2
|
+
import { get } from 'foremanReact/redux/API';
|
3
|
+
import { withInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
|
4
|
+
import { INVOCATION } from './InvocationConsts';
|
5
|
+
|
6
|
+
const url = getURI().addQuery('format', 'json');
|
7
|
+
export const getData = () =>
|
8
|
+
withInterval(get({ key: INVOCATION, url }), 1000);
|
@@ -0,0 +1 @@
|
|
1
|
+
export const INVOCATION = 'INVOCATION';
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import {
|
2
|
+
selectAPIStatus,
|
3
|
+
selectAPIResponse,
|
4
|
+
} from 'foremanReact/redux/API/APISelectors';
|
5
|
+
import { INVOCATION } from './InvocationConsts';
|
6
|
+
|
7
|
+
export const selectInvocation = state =>
|
8
|
+
selectAPIResponse(state, INVOCATION) || {};
|
9
|
+
|
10
|
+
export const selectState = state =>
|
11
|
+
selectAPIResponse(state, INVOCATION).state;
|
12
|
+
|
13
|
+
export const selectStatus = state =>
|
14
|
+
selectAPIStatus(state, INVOCATION);
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import React { useEffect, useState } from 'react';
|
2
|
+
import { useSelector, useDispatch } from 'react-redux';
|
3
|
+
import { stopInterval } from 'foremanReact/redux/middlewares/IntervalMiddleware';
|
4
|
+
import Invocation from './Invocation';
|
5
|
+
import {
|
6
|
+
selectInvocation,
|
7
|
+
selectState,
|
8
|
+
selectStatus,
|
9
|
+
} from './InvocationSelectors';
|
10
|
+
import { getData } from './InvocationActions';
|
11
|
+
import { INVOCATION } from './InvocationsConsts';
|
12
|
+
|
13
|
+
const WrappedInvocation = () => {
|
14
|
+
const dispatch = useDispatch();
|
15
|
+
const state = useSelector(selectState);
|
16
|
+
const invocation = useSelector(selectInvocation);
|
17
|
+
const status = useSelector(selectStatus);
|
18
|
+
|
19
|
+
useEffect(() => {
|
20
|
+
dispatch(getData());
|
21
|
+
|
22
|
+
return () => {
|
23
|
+
dispatch(stopInterval(INVOCATION));
|
24
|
+
};
|
25
|
+
}, [dispatch]);
|
26
|
+
|
27
|
+
useEffect(() => {
|
28
|
+
if (state === 'stopped') {
|
29
|
+
dispatch(stopInterval(INVOCATION));
|
30
|
+
}
|
31
|
+
}, [state, dispatch]);
|
32
|
+
|
33
|
+
return <Invocation invocation={invocation} status={status}/>
|
34
|
+
};
|
35
|
+
|
36
|
+
export default WrappedInvocation;
|
@@ -0,0 +1,55 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
4
|
+
import { LoadingState, Alert } from 'patternfly-react';
|
5
|
+
import { STATUS } from 'foremanReact/constants';
|
6
|
+
|
7
|
+
import InvocationItem from './components/InvocationItem';
|
8
|
+
|
9
|
+
const Invocations = ({ status, items }) => {
|
10
|
+
if (status === STATUS.ERROR) {
|
11
|
+
return (
|
12
|
+
<Alert type="error">
|
13
|
+
{__(
|
14
|
+
'There was an error while updating the status, try refreshing the page.'
|
15
|
+
)}
|
16
|
+
</Alert>
|
17
|
+
);
|
18
|
+
}
|
19
|
+
|
20
|
+
const rows = items.length ? (
|
21
|
+
items.map(item => (<InvocationItem {...item} />))
|
22
|
+
) : (
|
23
|
+
<tr>
|
24
|
+
<td colSpan="3">{__('No hosts found.')}</td>
|
25
|
+
</tr>
|
26
|
+
);
|
27
|
+
|
28
|
+
return (
|
29
|
+
<LoadingState loading={!items.length && status === STATUS.PENDING}>
|
30
|
+
<div>
|
31
|
+
<table className="table table-bordered table-striped table-hover">
|
32
|
+
<thead>
|
33
|
+
<tr>
|
34
|
+
<th>{__('Host')}</th>
|
35
|
+
<th className="col-md-2">{__('Status')}</th>
|
36
|
+
<th className="col-md-1">{__('Actions')}</th>
|
37
|
+
</tr>
|
38
|
+
</thead>
|
39
|
+
<tbody>{rows}</tbody>
|
40
|
+
</table>
|
41
|
+
</div>
|
42
|
+
</LoadingState>
|
43
|
+
);
|
44
|
+
};
|
45
|
+
|
46
|
+
Invocations.propTypes = {
|
47
|
+
status: PropTypes.string,
|
48
|
+
items: PropTypes.array.isRequired,
|
49
|
+
};
|
50
|
+
|
51
|
+
Invocations.defaultProps = {
|
52
|
+
status: null,
|
53
|
+
};
|
54
|
+
|
55
|
+
export default Invocations;
|
@@ -0,0 +1 @@
|
|
1
|
+
export const INVOCATIONS = 'INVOCATIONS';
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import { getURI } from 'foremanReact/common/urlHelpers';
|
2
|
+
|
3
|
+
export const getUrl = (round, searchQuery, pagination) => {
|
4
|
+
const baseUrl = getURI()
|
5
|
+
.path(`/foreman_patch/api/rounds/${round}/invocations`)
|
6
|
+
.search('')
|
7
|
+
.addQuery('page', pagination.page)
|
8
|
+
.addQuery('per_page', pagination.perPage);
|
9
|
+
|
10
|
+
return searchQuery ? baseUrl.addQuery('search', searchQuery) : baseUrl;
|
11
|
+
};
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types'
|
3
|
+
import { Grid } from 'patternfly-react';
|
4
|
+
|
5
|
+
import SearchBar from 'foremanReact/components/SearchBar';
|
6
|
+
import Pagination from 'foremanReact/components/Pagination/PaginationWrapper';
|
7
|
+
import { getControllerSearchProps } from 'foremanReact/constants';
|
8
|
+
|
9
|
+
import Invocations from './Invocations';
|
10
|
+
import './InvocationsPage.scss';
|
11
|
+
|
12
|
+
const InvocationsPage = ({
|
13
|
+
status,
|
14
|
+
items,
|
15
|
+
total,
|
16
|
+
searchQuery,
|
17
|
+
pagination,
|
18
|
+
handleSearch,
|
19
|
+
handlePagination,
|
20
|
+
}) => (
|
21
|
+
<div id="patch_invocations">
|
22
|
+
<Grid.Row>
|
23
|
+
<Grid.Col md={6} className="title_filter">
|
24
|
+
<SearchBar
|
25
|
+
onSearch={handleSearch}
|
26
|
+
data={{
|
27
|
+
...getControllerSearchProps('foreman_patch/invocations'),
|
28
|
+
autocomplete: {
|
29
|
+
id: 'invocations_search',
|
30
|
+
searchQuery,
|
31
|
+
url: '/foreman_patch/invocations/auto_complete_search',
|
32
|
+
useKeyShortcuts: true,
|
33
|
+
},
|
34
|
+
bookmarks: {},
|
35
|
+
}}
|
36
|
+
/>
|
37
|
+
</Grid.Col>
|
38
|
+
</Grid.Row>
|
39
|
+
<br />
|
40
|
+
<Invocations status={status} items={items} />
|
41
|
+
<Pagination
|
42
|
+
viewType="table"
|
43
|
+
itemCount={total}
|
44
|
+
pagination={pagination}
|
45
|
+
onChange={handlePagination}
|
46
|
+
dropdownButtonId="invocations-pagination-dropdown"
|
47
|
+
className="invocations-pagination"
|
48
|
+
/>
|
49
|
+
</div>
|
50
|
+
);
|
51
|
+
|
52
|
+
InvocationsPage.propTypes = {
|
53
|
+
status: PropTypes.string,
|
54
|
+
items: PropTypes.array.isRequired,
|
55
|
+
total: PropTypes.number.isRequired,
|
56
|
+
searchQuery: PropTypes.string.isRequired,
|
57
|
+
pagination: PropTypes.object.isRequired,
|
58
|
+
handleSearch: PropTypes.func.isRequired,
|
59
|
+
handlePagination: PropTypes.func.isRequired,
|
60
|
+
};
|
61
|
+
|
62
|
+
InvocationsPage.defaultProps = {
|
63
|
+
status: null,
|
64
|
+
};
|
65
|
+
|
66
|
+
export default InvocationsPage;
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import {
|
2
|
+
selectAPIStatus,
|
3
|
+
selectAPIResponse,
|
4
|
+
} from 'foremanReact/redux/API/APISelectors';
|
5
|
+
import { selectDoesIntervalExist } from 'foremanReact/redux/middlewares/IntervalMiddleware/IntervalSelectors';
|
6
|
+
|
7
|
+
import { INVOCATIONS } from './InvocationsConstants';
|
8
|
+
|
9
|
+
export const selectItems = state =>
|
10
|
+
selectAPIResponse(state, INVOCATIONS).results || [];
|
11
|
+
export const selectTotal = state =>
|
12
|
+
selectAPIResponse(state, INVOCATIONS).total || 0;
|
13
|
+
|
14
|
+
export const selectAutoRefresh = state =>
|
15
|
+
selectItems(state).some(item => (item.result === 'pending'));
|
16
|
+
|
17
|
+
export const selectStatus = state => selectAPIStatus(state, INVOCATIONS);
|
18
|
+
|
19
|
+
export const selectIntervalExists = state =>
|
20
|
+
selectDoesIntervalExist(state, INVOCATIONS);
|
21
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
import React from 'react';
|
2
|
+
import PropTypes from 'prop-types';
|
3
|
+
import { ActionButtons } from 'foremanReact/components/common/ActionButtons/ActionButtons';
|
4
|
+
import { translate as __ } from 'foremanReact/common/I18n';
|
5
|
+
|
6
|
+
import InvocationStatus from './InvocationStatus';
|
7
|
+
|
8
|
+
const InvocationItem = ({ id, name, status, task_id, host_id }) => {
|
9
|
+
|
10
|
+
const actions = [
|
11
|
+
{
|
12
|
+
title: __('Host Detail'),
|
13
|
+
action: {
|
14
|
+
href: `/hosts/${name}`,
|
15
|
+
'data-method': 'get',
|
16
|
+
id: `${name}-actions-host`,
|
17
|
+
}
|
18
|
+
},
|
19
|
+
];
|
20
|
+
|
21
|
+
if (task_id) {
|
22
|
+
actions.push({
|
23
|
+
title: __('Task Detail'),
|
24
|
+
action: {
|
25
|
+
href: `/foreman_tasks/tasks/${task_id}`,
|
26
|
+
'data-method': 'get',
|
27
|
+
id: `${name}-actions-task`,
|
28
|
+
},
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
if (status == 'pending') {
|
33
|
+
actions.push({
|
34
|
+
title: __('Cancel'),
|
35
|
+
action: {
|
36
|
+
href: `/foreman_patch/invocations/${id}`,
|
37
|
+
'data-method': 'delete',
|
38
|
+
id: `${name}-actions-cancel`,
|
39
|
+
}
|
40
|
+
});
|
41
|
+
}
|
42
|
+
|
43
|
+
return (
|
44
|
+
<tr id={`invocation-${id}`}>
|
45
|
+
<td className="invocation_name">
|
46
|
+
<a href={`/foreman_patch/invocations/${id}`}>{name}</a>
|
47
|
+
</td>
|
48
|
+
<td className="invocation_status">
|
49
|
+
<InvocationStatus status={status} />
|
50
|
+
</td>
|
51
|
+
<td className="invocation_actions">
|
52
|
+
<ActionButtons buttons={[...actions]} />
|
53
|
+
</td>
|
54
|
+
</tr>
|
55
|
+
);
|
56
|
+
};
|
57
|
+
|
58
|
+
InvocationItem.propTypes = {
|
59
|
+
id: PropTypes.number.isRequired,
|
60
|
+
name: PropTypes.string.isRequired,
|
61
|
+
status: PropTypes.string.isRequired,
|
62
|
+
host_id: PropTypes.number.isRequired,
|
63
|
+
task_id: PropTypes.number.isRequired,
|
64
|
+
};
|
65
|
+
|
66
|
+
export default InvocationItem;
|