diff --git a/GITALY_SERVER_VERSION b/GITALY_SERVER_VERSION index 522c3806095..ff24873ca4c 100644 --- a/GITALY_SERVER_VERSION +++ b/GITALY_SERVER_VERSION @@ -1 +1 @@ -40fae4205d3ad62ca9341620146486bee8d31b28 +d924490032231edb9452acdaca7d8e4747cf6ab4 diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js index 84a5d5ae4b3..01e463c1965 100644 --- a/app/assets/javascripts/api.js +++ b/app/assets/javascripts/api.js @@ -870,6 +870,14 @@ const Api = { return axios.put(url, freezePeriod); }, + deleteFreezePeriod(id, freezePeriodId) { + const url = Api.buildUrl(this.freezePeriodPath) + .replace(':id', encodeURIComponent(id)) + .replace(':freeze_period_id', encodeURIComponent(freezePeriodId)); + + return axios.delete(url); + }, + trackRedisCounterEvent(event) { if (!gon.features?.usageDataApi) { return null; diff --git a/app/assets/javascripts/deploy_freeze/components/deploy_freeze_table.vue b/app/assets/javascripts/deploy_freeze/components/deploy_freeze_table.vue index 8282f1d910a..77767456f76 100644 --- a/app/assets/javascripts/deploy_freeze/components/deploy_freeze_table.vue +++ b/app/assets/javascripts/deploy_freeze/components/deploy_freeze_table.vue @@ -1,5 +1,5 @@ @@ -72,6 +100,18 @@ export default { @click="setFreezePeriod(item)" /> + diff --git a/app/assets/javascripts/deploy_freeze/store/actions.js b/app/assets/javascripts/deploy_freeze/store/actions.js index fed80b46eda..a2056165cb2 100644 --- a/app/assets/javascripts/deploy_freeze/store/actions.js +++ b/app/assets/javascripts/deploy_freeze/store/actions.js @@ -52,6 +52,22 @@ export const updateFreezePeriod = (store) => }), ); +export const deleteFreezePeriod = ({ state, commit }, { id }) => { + commit(types.REQUEST_DELETE_FREEZE_PERIOD, id); + + return Api.deleteFreezePeriod(state.projectId, id) + .then(() => commit(types.RECEIVE_DELETE_FREEZE_PERIOD_SUCCESS, id)) + .catch((e) => { + createFlash({ + message: __('Error: Unable to delete deploy freeze'), + }); + commit(types.RECEIVE_DELETE_FREEZE_PERIOD_ERROR, id); + + // eslint-disable-next-line no-console + console.error('[gitlab] Unable to delete deploy freeze:', e); + }); +}; + export const fetchFreezePeriods = ({ commit, state }) => { commit(types.REQUEST_FREEZE_PERIODS); diff --git a/app/assets/javascripts/deploy_freeze/store/mutation_types.js b/app/assets/javascripts/deploy_freeze/store/mutation_types.js index 8e6fdfd4443..0fec96e2e4c 100644 --- a/app/assets/javascripts/deploy_freeze/store/mutation_types.js +++ b/app/assets/javascripts/deploy_freeze/store/mutation_types.js @@ -10,4 +10,8 @@ export const SET_SELECTED_ID = 'SET_SELECTED_ID'; export const SET_FREEZE_START_CRON = 'SET_FREEZE_START_CRON'; export const SET_FREEZE_END_CRON = 'SET_FREEZE_END_CRON'; +export const REQUEST_DELETE_FREEZE_PERIOD = 'REQUEST_DELETE_FREEZE_PERIOD'; +export const RECEIVE_DELETE_FREEZE_PERIOD_SUCCESS = 'RECEIVE_DELETE_FREEZE_PERIOD_SUCCESS'; +export const RECEIVE_DELETE_FREEZE_PERIOD_ERROR = 'RECEIVE_DELETE_FREEZE_PERIOD_ERROR'; + export const RESET_MODAL = 'RESET_MODAL'; diff --git a/app/assets/javascripts/deploy_freeze/store/mutations.js b/app/assets/javascripts/deploy_freeze/store/mutations.js index fdd1ea6e32e..151f7f39f5a 100644 --- a/app/assets/javascripts/deploy_freeze/store/mutations.js +++ b/app/assets/javascripts/deploy_freeze/store/mutations.js @@ -1,15 +1,28 @@ +import Vue from 'vue'; import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils'; +import { secondsToHours } from '~/lib/utils/datetime_utility'; import * as types from './mutation_types'; -const formatTimezoneName = (freezePeriod, timezoneList) => - convertObjectPropsToCamelCase({ +const formatTimezoneName = (freezePeriod, timezoneList) => { + const tz = timezoneList.find((timezone) => timezone.identifier === freezePeriod.cron_timezone); + return convertObjectPropsToCamelCase({ ...freezePeriod, cron_timezone: { - formattedTimezone: timezoneList.find((tz) => tz.identifier === freezePeriod.cron_timezone) - ?.name, + formattedTimezone: tz && `[UTC ${secondsToHours(tz.offset)}] ${tz.name}`, identifier: freezePeriod.cron_timezone, }, }); +}; + +const setFreezePeriodIsDeleting = (state, id, isDeleting) => { + const freezePeriod = state.freezePeriods.find((f) => f.id === id); + + if (!freezePeriod) { + return; + } + + Vue.set(freezePeriod, 'isDeleting', isDeleting); +}; export default { [types.REQUEST_FREEZE_PERIODS](state) { @@ -53,6 +66,18 @@ export default { state.selectedId = id; }, + [types.REQUEST_DELETE_FREEZE_PERIOD](state, id) { + setFreezePeriodIsDeleting(state, id, true); + }, + + [types.RECEIVE_DELETE_FREEZE_PERIOD_SUCCESS](state, id) { + state.freezePeriods = state.freezePeriods.filter((f) => f.id !== id); + }, + + [types.RECEIVE_DELETE_FREEZE_PERIOD_ERROR](state, id) { + setFreezePeriodIsDeleting(state, id, false); + }, + [types.RESET_MODAL](state) { state.freezeStartCron = ''; state.freezeEndCron = ''; diff --git a/app/assets/javascripts/environments/components/container.vue b/app/assets/javascripts/environments/components/container.vue index 9e058af56c4..cec53869aa8 100644 --- a/app/assets/javascripts/environments/components/container.vue +++ b/app/assets/javascripts/environments/components/container.vue @@ -22,10 +22,6 @@ export default { type: Object, required: true, }, - canReadEnvironment: { - type: Boolean, - required: true, - }, }, methods: { onChangePage(page) { @@ -42,7 +38,7 @@ export default {
- +