From 8df3997a92bffa2d29f3c559933a336b837cdb93 Mon Sep 17 00:00:00 2001 From: Zeger-Jan van de Weg Date: Sun, 7 May 2017 22:35:56 +0000 Subject: Add Pipeline Schedules that supersedes experimental Trigger Schedule --- .../projects/pipeline_schedules/_form.html.haml | 32 ++++++++++++++++++++ .../_pipeline_schedule.html.haml | 35 ++++++++++++++++++++++ .../projects/pipeline_schedules/_table.html.haml | 12 ++++++++ .../projects/pipeline_schedules/_tabs.html.haml | 18 +++++++++++ .../projects/pipeline_schedules/edit.html.haml | 7 +++++ .../projects/pipeline_schedules/index.html.haml | 24 +++++++++++++++ .../projects/pipeline_schedules/new.html.haml | 7 +++++ app/views/projects/pipelines/_head.html.haml | 6 ++++ app/views/projects/triggers/_form.html.haml | 22 -------------- app/views/projects/triggers/_index.html.haml | 2 -- app/views/projects/triggers/_trigger.html.haml | 6 ---- 11 files changed, 141 insertions(+), 30 deletions(-) create mode 100644 app/views/projects/pipeline_schedules/_form.html.haml create mode 100644 app/views/projects/pipeline_schedules/_pipeline_schedule.html.haml create mode 100644 app/views/projects/pipeline_schedules/_table.html.haml create mode 100644 app/views/projects/pipeline_schedules/_tabs.html.haml create mode 100644 app/views/projects/pipeline_schedules/edit.html.haml create mode 100644 app/views/projects/pipeline_schedules/index.html.haml create mode 100644 app/views/projects/pipeline_schedules/new.html.haml (limited to 'app/views/projects') diff --git a/app/views/projects/pipeline_schedules/_form.html.haml b/app/views/projects/pipeline_schedules/_form.html.haml new file mode 100644 index 00000000000..4a21cce024e --- /dev/null +++ b/app/views/projects/pipeline_schedules/_form.html.haml @@ -0,0 +1,32 @@ +- content_for :page_specific_javascripts do + = page_specific_javascript_bundle_tag('schedule_form') + += form_for [@project.namespace.becomes(Namespace), @project, @schedule], as: :schedule, html: { id: "new-pipeline-schedule-form", class: "form-horizontal js-pipeline-schedule-form" } do |f| + = form_errors(@schedule) + .form-group + .col-md-6 + = f.label :description, 'Description', class: 'label-light' + = f.text_field :description, class: 'form-control', required: true, autofocus: true, placeholder: 'Provide a short description for this pipeline' + .form-group + .col-md-12 + = f.label :cron, 'Interval Pattern', class: 'label-light' + #interval-pattern-input{ data: { initial_interval: @schedule.cron } } + .form-group + .col-md-6 + = f.label :cron_timezone, 'Cron Timezone', class: 'label-light' + = dropdown_tag("Select a timezone", options: { toggle_class: 'btn js-timezone-dropdown', title: "Select a timezone", filter: true, placeholder: "Filter", data: { data: timezone_data } } ) + = f.text_field :cron_timezone, value: @schedule.cron_timezone, id: 'schedule_cron_timezone', class: 'hidden', name: 'schedule[cron_timezone]', required: true + .form-group + .col-md-6 + = f.label :ref, 'Target Branch', class: 'label-light' + = dropdown_tag("Select target branch", options: { toggle_class: 'btn js-target-branch-dropdown', title: "Select target branch", filter: true, placeholder: "Filter", data: { data: @project.repository.branch_names } } ) + = f.text_field :ref, value: @schedule.ref, id: 'schedule_ref', class: 'hidden', name: 'schedule[ref]', required: true + .form-group + .col-md-6 + = f.label :active, 'Activated', class: 'label-light' + %div + = f.check_box :active, required: false, value: @schedule.active? + active + .footer-block.row-content-block + = f.submit 'Save pipeline schedule', class: 'btn btn-create', tabindex: 3 + = link_to 'Cancel', pipeline_schedules_path(@project), class: 'btn btn-cancel' diff --git a/app/views/projects/pipeline_schedules/_pipeline_schedule.html.haml b/app/views/projects/pipeline_schedules/_pipeline_schedule.html.haml new file mode 100644 index 00000000000..1406868488f --- /dev/null +++ b/app/views/projects/pipeline_schedules/_pipeline_schedule.html.haml @@ -0,0 +1,35 @@ +- if pipeline_schedule + %tr.pipeline-schedule-table-row + %td + = pipeline_schedule.description + %td.branch-name-cell + = icon('code-fork') + = link_to pipeline_schedule.ref, namespace_project_commits_path(@project.namespace, @project, pipeline_schedule.ref), class: "branch-name" + %td + - if pipeline_schedule.last_pipeline + .status-icon-container{ class: "ci-status-icon-#{pipeline_schedule.last_pipeline.status}" } + = link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline_schedule.last_pipeline.id) do + = ci_icon_for_status(pipeline_schedule.last_pipeline.status) + - else + None + %td.next-run-cell + - if pipeline_schedule.active? + = time_ago_with_tooltip(pipeline_schedule.next_run_at) + - else + Inactive + %td + - if pipeline_schedule.owner + = image_tag avatar_icon(pipeline_schedule.owner, 20), class: "avatar s20" + = link_to user_path(pipeline_schedule.owner) do + = pipeline_schedule.owner&.name + %td + .pull-right.btn-group + - if can?(current_user, :update_pipeline_schedule, @project) && !pipeline_schedule.owned_by?(current_user) + = link_to take_ownership_pipeline_schedule_path(pipeline_schedule), method: :post, title: 'Take Ownership', class: 'btn' do + Take ownership + - if can?(current_user, :update_pipeline_schedule, pipeline_schedule) + = link_to edit_pipeline_schedule_path(pipeline_schedule), title: 'Edit', class: 'btn' do + = icon('pencil') + - if can?(current_user, :admin_pipeline_schedule, pipeline_schedule) + = link_to pipeline_schedule_path(pipeline_schedule), title: 'Delete', method: :delete, class: 'btn btn-remove', data: { confirm: "Are you sure you want to cancel this pipeline?" } do + = icon('trash') diff --git a/app/views/projects/pipeline_schedules/_table.html.haml b/app/views/projects/pipeline_schedules/_table.html.haml new file mode 100644 index 00000000000..25c7604eb24 --- /dev/null +++ b/app/views/projects/pipeline_schedules/_table.html.haml @@ -0,0 +1,12 @@ +.table-holder + %table.table.ci-table + %thead + %tr + %th Description + %th Target + %th Last Pipeline + %th Next Run + %th Owner + %th + + = render partial: "pipeline_schedule", collection: @schedules diff --git a/app/views/projects/pipeline_schedules/_tabs.html.haml b/app/views/projects/pipeline_schedules/_tabs.html.haml new file mode 100644 index 00000000000..2a1fb16876a --- /dev/null +++ b/app/views/projects/pipeline_schedules/_tabs.html.haml @@ -0,0 +1,18 @@ +%ul.nav-links + %li{ class: active_when(scope.nil?) }> + = link_to schedule_path_proc.call(nil) do + All + %span.badge.js-totalbuilds-count + = number_with_delimiter(all_schedules.count(:id)) + + %li{ class: active_when(scope == 'active') }> + = link_to schedule_path_proc.call('active') do + Active + %span.badge + = number_with_delimiter(all_schedules.active.count(:id)) + + %li{ class: active_when(scope == 'inactive') }> + = link_to schedule_path_proc.call('inactive') do + Inactive + %span.badge + = number_with_delimiter(all_schedules.inactive.count(:id)) diff --git a/app/views/projects/pipeline_schedules/edit.html.haml b/app/views/projects/pipeline_schedules/edit.html.haml new file mode 100644 index 00000000000..e16fe0b7a98 --- /dev/null +++ b/app/views/projects/pipeline_schedules/edit.html.haml @@ -0,0 +1,7 @@ +- page_title "Edit", @schedule.description, "Pipeline Schedule" + +%h3.page-title + Edit Pipeline Schedule #{@schedule.id} +%hr + += render "form" diff --git a/app/views/projects/pipeline_schedules/index.html.haml b/app/views/projects/pipeline_schedules/index.html.haml new file mode 100644 index 00000000000..dd35c3055f2 --- /dev/null +++ b/app/views/projects/pipeline_schedules/index.html.haml @@ -0,0 +1,24 @@ +- content_for :page_specific_javascripts do + = page_specific_javascript_bundle_tag('schedules_index') + +- @no_container = true +- page_title "Pipeline Schedules" += render "projects/pipelines/head" + +%div{ class: container_class } + #scheduling-pipelines-callout + .top-area + - schedule_path_proc = ->(scope) { pipeline_schedules_path(@project, scope: scope) } + = render "tabs", schedule_path_proc: schedule_path_proc, all_schedules: @all_schedules, scope: @scope + + .nav-controls + = link_to new_namespace_project_pipeline_schedule_path(@project.namespace, @project), class: 'btn btn-create' do + %span New Schedule + + - if @schedules.present? + %ul.content-list + = render partial: "table" + - else + .light-well + .nothing-here-block No schedules + diff --git a/app/views/projects/pipeline_schedules/new.html.haml b/app/views/projects/pipeline_schedules/new.html.haml new file mode 100644 index 00000000000..b89e170ad3c --- /dev/null +++ b/app/views/projects/pipeline_schedules/new.html.haml @@ -0,0 +1,7 @@ +- page_title "New Pipeline Schedule" + +%h3.page-title + Schedule a new pipeline +%hr + += render "form" diff --git a/app/views/projects/pipelines/_head.html.haml b/app/views/projects/pipelines/_head.html.haml index b0dac9de1c6..db9d77dba16 100644 --- a/app/views/projects/pipelines/_head.html.haml +++ b/app/views/projects/pipelines/_head.html.haml @@ -15,6 +15,12 @@ %span Jobs + - if project_nav_tab? :pipelines + = nav_link(controller: :pipeline_schedules) do + = link_to pipeline_schedules_path(@project), title: 'Schedules', class: 'shortcuts-builds' do + %span + Schedules + - if project_nav_tab? :environments = nav_link(controller: :environments) do = link_to project_environments_path(@project), title: 'Environments', class: 'shortcuts-environments' do diff --git a/app/views/projects/triggers/_form.html.haml b/app/views/projects/triggers/_form.html.haml index 70d654fa9a0..5f708b3a2ed 100644 --- a/app/views/projects/triggers/_form.html.haml +++ b/app/views/projects/triggers/_form.html.haml @@ -8,26 +8,4 @@ .form-group = f.label :key, "Description", class: "label-light" = f.text_field :description, class: "form-control", required: true, title: 'Trigger description is required.', placeholder: "Trigger description" - - if @trigger.persisted? - %hr - = f.fields_for :trigger_schedule do |schedule_fields| - = schedule_fields.hidden_field :id - .form-group - .checkbox - = schedule_fields.label :active do - = schedule_fields.check_box :active - %strong Schedule trigger (experimental) - .help-block - If checked, this trigger will be executed periodically according to cron and timezone. - = link_to icon('question-circle'), help_page_path('ci/triggers/README', anchor: 'using-scheduled-triggers') - .form-group - = schedule_fields.label :cron, "Cron", class: "label-light" - = schedule_fields.text_field :cron, class: "form-control", title: 'Cron specification is required.', placeholder: "0 1 * * *" - .form-group - = schedule_fields.label :cron, "Timezone", class: "label-light" - = schedule_fields.text_field :cron_timezone, class: "form-control", title: 'Timezone is required.', placeholder: "UTC" - .form-group - = schedule_fields.label :ref, "Branch or tag", class: "label-light" - = schedule_fields.text_field :ref, class: "form-control", title: 'Branch or tag is required.', placeholder: "master" - .help-block Existing branch name, tag = f.submit btn_text, class: "btn btn-save" diff --git a/app/views/projects/triggers/_index.html.haml b/app/views/projects/triggers/_index.html.haml index 84e945ee0df..cc74e50a5e3 100644 --- a/app/views/projects/triggers/_index.html.haml +++ b/app/views/projects/triggers/_index.html.haml @@ -22,8 +22,6 @@ %th %strong Last used %th - %strong Next run at - %th = render partial: 'projects/triggers/trigger', collection: @triggers, as: :trigger - else %p.settings-message.text-center.append-bottom-default diff --git a/app/views/projects/triggers/_trigger.html.haml b/app/views/projects/triggers/_trigger.html.haml index ebd91a8e2af..9b5f63ae81a 100644 --- a/app/views/projects/triggers/_trigger.html.haml +++ b/app/views/projects/triggers/_trigger.html.haml @@ -29,12 +29,6 @@ - else Never - %td - - if trigger.trigger_schedule&.active? - = trigger.trigger_schedule.real_next_run - - else - Never - %td.text-right.trigger-actions - take_ownership_confirmation = "By taking ownership you will bind this trigger to your user account. With this the trigger will have access to all your projects as if it was you. Are you sure?" - revoke_trigger_confirmation = "By revoking a trigger you will break any processes making use of it. Are you sure?" -- cgit v1.2.1