Commit d7401cd6 authored by Shinya Maeda's avatar Shinya Maeda
Browse files

Decouple FE

parent f2876839
app/assets/images/ci_favicons/canary/favicon_status_scheduled.ico

5.3 KB

app/assets/images/ci_favicons/favicon_status_scheduled.png

1.05 KB

......@@ -370,23 +370,3 @@ window.gl.utils = {
getTimeago,
localTimeAgo,
};
/**
* Formats milliseconds as timestamp (e.g. 01:02:03).
*
* @param milliseconds
* @returns {string}
*/
export const formatTime = milliseconds => {
const remainingSeconds = Math.floor(milliseconds / 1000) % 60;
const remainingMinutes = Math.floor(milliseconds / 1000 / 60) % 60;
const remainingHours = Math.floor(milliseconds / 1000 / 60 / 60);
let formattedTime = '';
if (remainingHours < 10) formattedTime += '0';
formattedTime += `${remainingHours}:`;
if (remainingMinutes < 10) formattedTime += '0';
formattedTime += `${remainingMinutes}:`;
if (remainingSeconds < 10) formattedTime += '0';
formattedTime += remainingSeconds;
return formattedTime;
};
<script>
import { s__, sprintf } from '~/locale';
import { formatTime } from '~/lib/utils/datetime_utility';
import eventHub from '../event_hub';
import icon from '../../vue_shared/components/icon.vue';
import tooltip from '../../vue_shared/directives/tooltip';
......@@ -24,17 +22,10 @@ export default {
};
},
methods: {
onClickAction(action) {
const confirmationMessage = sprintf(s__("DelayedJobs|Are you sure you want to run %{jobName} immediately? This job will run automatically after it's timer finishes."), { jobName: action.name });
// https://gitlab.com/gitlab-org/gitlab-ce/issues/52099
// eslint-disable-next-line no-alert
if (!window.confirm(confirmationMessage)) {
return;
}
onClickAction(endpoint) {
this.isLoading = true;
eventHub.$emit('postAction', action.path);
eventHub.$emit('postAction', endpoint);
},
isActionDisabled(action) {
......@@ -44,11 +35,6 @@ export default {
return !action.playable;
},
remainingTime(action) {
const remainingMilliseconds = new Date(action.scheduled_at).getTime() - Date.now();
return formatTime(remainingMilliseconds);
},
},
};
</script>
......@@ -77,24 +63,17 @@ export default {
<ul class="dropdown-menu dropdown-menu-right">
<li
v-for="action in actions"
:key="action.path"
v-for="(action, i) in actions"
:key="i"
>
<button
:class="{ disabled: isActionDisabled(action) }"
:disabled="isActionDisabled(action)"
type="button"
class="js-pipeline-action-link no-btn btn"
@click="onClickAction(action)"
@click="onClickAction(action.path)"
>
{{ action.name }}
<span
v-if="action.scheduled_at"
class="pull-right"
>
<icon name="clock" />
{{ remainingTime(action) }}
</span>
</button>
</li>
</ul>
......
......@@ -59,9 +59,6 @@ export default {
};
},
computed: {
actions() {
return [...this.pipeline.details.manual_actions, ...this.pipeline.details.scheduled_actions];
},
/**
* If provided, returns the commit tag.
* Needed to render the commit component column.
......@@ -324,8 +321,8 @@ export default {
>
<div class="btn-group table-action-buttons">
<pipelines-actions-component
v-if="actions.length > 0"
:actions="actions"
v-if="pipeline.details.manual_actions.length"
:actions="pipeline.details.manual_actions"
/>
<pipelines-artifacts-component
......
......@@ -360,10 +360,6 @@
i {
color: $gl-text-color-secondary;
}
svg {
fill: $gl-text-color-secondary;
}
}
.clone-dropdown-btn a {
......
......@@ -64,7 +64,6 @@
}
}
.ci-status-icon-scheduled,
.ci-status-icon-manual {
svg {
fill: $gl-text-color;
......
......@@ -760,7 +760,6 @@
}
&.ci-status-icon-canceled,
&.ci-status-icon-scheduled,
&.ci-status-icon-disabled,
&.ci-status-icon-not-found,
&.ci-status-icon-manual {
......
......@@ -27,7 +27,6 @@
&.ci-canceled,
&.ci-disabled,
&.ci-scheduled,
&.ci-manual {
color: $gl-text-color;
border-color: $gl-text-color;
......
......@@ -110,13 +110,6 @@ class Projects::JobsController < Projects::ApplicationController
redirect_to build_path(@build)
end
def unschedule
return respond_422 unless @build.scheduled?
@build.unschedule!
redirect_to build_path(@build)
end
def status
render json: BuildSerializer
.new(project: @project, current_user: @current_user)
......
......@@ -20,8 +20,6 @@ module CiStatusHelper
'passed with warnings'
when 'manual'
'waiting for manual action'
when 'scheduled'
'waiting for delayed job'
else
status
end
......@@ -41,8 +39,6 @@ module CiStatusHelper
s_('CiStatusText|passed')
when 'manual'
s_('CiStatusText|blocked')
when 'scheduled'
s_('CiStatusText|scheduled')
else
# All states are already being translated inside the detailed statuses:
# :running => Gitlab::Ci::Status::Running
......@@ -87,8 +83,6 @@ module CiStatusHelper
'status_skipped'
when 'manual'
'status_manual'
when 'scheduled'
'status_scheduled'
else
'status_canceled'
end
......
......@@ -21,17 +21,9 @@ module TimeHelper
"#{from.to_s(:short)} - #{to.to_s(:short)}"
end
def duration_in_numbers(duration_in_seconds, allow_overflow = false)
if allow_overflow
seconds = duration_in_seconds % 1.minute
minutes = (duration_in_seconds / 1.minute) % (1.hour / 1.minute)
hours = duration_in_seconds / 1.hour
def duration_in_numbers(duration)
time_format = duration < 1.hour ? "%M:%S" : "%H:%M:%S"
"%02d:%02d:%02d" % [hours, minutes, seconds]
else
time_format = duration_in_seconds < 1.hour ? "%M:%S" : "%H:%M:%S"
Time.at(duration_in_seconds).utc.strftime(time_format)
end
Time.at(duration).utc.strftime(time_format)
end
end
......@@ -35,10 +35,6 @@ module Ci
"#{subject.name} - #{detailed_status.status_tooltip}"
end
def execute_in
scheduled? && scheduled_at && [0, scheduled_at - Time.now].max
end
private
def tooltip_for_badge
......
......@@ -8,8 +8,7 @@ class CommitStatusPresenter < Gitlab::View::Presenter::Delegated
stuck_or_timeout_failure: 'There has been a timeout failure or the job got stuck. Check your timeout limits or try again',
runner_system_failure: 'There has been a runner system failure, please try again',
missing_dependency_failure: 'There has been a missing dependency failure',
runner_unsupported: 'Your runner is outdated, please upgrade your runner',
stale_schedule: 'Delayed job could not be executed by some reason, please try again'
runner_unsupported: 'Your runner is outdated, please upgrade your runner'
}.freeze
private_constant :CALLOUT_FAILURE_MESSAGES
......
......@@ -12,11 +12,6 @@ class BuildActionEntity < Grape::Entity
end
expose :playable?, as: :playable
expose :scheduled_at, if: -> (build) { build.scheduled? }
expose :unschedule_path, if: -> (build) { build.scheduled? } do |build|
unschedule_project_job_path(build.project, build)
end
private
......
......@@ -25,7 +25,6 @@ class JobEntity < Grape::Entity
end
expose :playable?, as: :playable
expose :scheduled_at
expose :created_at
expose :updated_at
expose :detailed_status, as: :status, with: DetailedStatusEntity
......
......@@ -5,6 +5,5 @@ class PipelineDetailsEntity < PipelineEntity
expose :ordered_stages, as: :stages, using: StageEntity
expose :artifacts, using: BuildArtifactEntity
expose :manual_actions, using: BuildActionEntity
expose :scheduled_actions, using: BuildActionEntity
end
end
......@@ -13,7 +13,6 @@ class PipelineSerializer < BaseSerializer
:cancelable_statuses,
:trigger_requests,
:manual_actions,
:scheduled_actions,
:artifacts,
{
pending_builds: :project,
......
......@@ -47,9 +47,7 @@
%span.badge.badge-info triggered
- if job.try(:allow_failure)
%span.badge.badge-danger allowed to fail
- if job.schedulable?
%span.badge.badge-info= s_('DelayedJobs|scheduled')
- elsif job.action?
- if job.action?
%span.badge.badge-info manual
- if pipeline_link
......@@ -103,24 +101,6 @@
- if job.active?
= link_to cancel_project_job_path(job.project, job, return_to: request.original_url), method: :post, title: 'Cancel', class: 'btn btn-build' do
= icon('remove', class: 'cred')
- elsif job.scheduled?
.btn-group
.btn.btn-default.has-tooltip{ disabled: true,
title: job.scheduled_at }
= sprite_icon('planning')
= duration_in_numbers(job.execute_in, true)
- confirmation_message = s_("DelayedJobs|Are you sure you want to run %{job_name} immediately? This job will run automatically after it's timer finishes.") % { job_name: job.name }
= link_to play_project_job_path(job.project, job, return_to: request.original_url),
method: :post,
title: s_('DelayedJobs|Start now'),
class: 'btn btn-default btn-build has-tooltip',
data: { confirm: confirmation_message } do
= sprite_icon('play')
= link_to unschedule_project_job_path(job.project, job, return_to: request.original_url),
method: :post,
title: s_('DelayedJobs|Unschedule'),
class: 'btn btn-default btn-build has-tooltip' do
= sprite_icon('time-out')
- elsif allow_retry
- if job.playable? && !admin && can?(current_user, :update_build, job)
= link_to play_project_job_path(job.project, job, return_to: request.original_url), method: :post, title: 'Play', class: 'btn btn-build' do
......
<svg width="14" height="14" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg"><circle cx="7" cy="7" r="7"/><circle fill="#FFF" cx="7" cy="7" r="6"/><g transform="translate(2.75 2.75)" fill-rule="nonzero"><path d="M4.165 7.81a3.644 3.644 0 1 1 0-7.29 3.644 3.644 0 0 1 0 7.29zm0-1.042a2.603 2.603 0 1 0 0-5.206 2.603 2.603 0 0 0 0 5.206z"/><rect x="3.644" y="2.083" width="1.041" height="2.603" rx=".488"/><rect x="3.644" y="3.644" width="2.083" height="1.041" rx=".488"/></g></svg>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment