debian-mirror-gitlab/app/assets/javascripts/environments/components/environments_app.vue

139 lines
4 KiB
Vue
Raw Normal View History

2018-03-17 18:26:18 +05:30
<script>
2020-03-09 13:42:32 +05:30
import { GlButton } from '@gitlab/ui';
2019-07-07 11:18:12 +05:30
import envrionmentsAppMixin from 'ee_else_ce/environments/mixins/environments_app_mixin';
2020-03-09 13:42:32 +05:30
import Flash from '~/flash';
import { s__ } from '~/locale';
2018-12-13 13:39:08 +05:30
import emptyState from './empty_state.vue';
import eventHub from '../event_hub';
import environmentsMixin from '../mixins/environments_mixin';
2020-03-09 13:42:32 +05:30
import CIPaginationMixin from '~/vue_shared/mixins/ci_pagination_api_mixin';
import EnableReviewAppButton from './enable_review_app_button.vue';
2018-12-13 13:39:08 +05:30
import StopEnvironmentModal from './stop_environment_modal.vue';
2019-07-07 11:18:12 +05:30
import ConfirmRollbackModal from './confirm_rollback_modal.vue';
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
export default {
components: {
2020-03-09 13:42:32 +05:30
ConfirmRollbackModal,
2018-12-13 13:39:08 +05:30
emptyState,
2020-03-09 13:42:32 +05:30
EnableReviewAppButton,
GlButton,
2018-12-13 13:39:08 +05:30
StopEnvironmentModal,
},
2018-03-17 18:26:18 +05:30
2019-07-07 11:18:12 +05:30
mixins: [CIPaginationMixin, environmentsMixin, envrionmentsAppMixin],
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
props: {
endpoint: {
type: String,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
canCreateEnvironment: {
type: Boolean,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
canReadEnvironment: {
type: Boolean,
required: true,
},
newEnvironmentPath: {
type: String,
required: true,
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
helpPagePath: {
type: String,
required: true,
},
2019-09-30 21:07:59 +05:30
deployBoardsHelpPath: {
type: String,
required: false,
default: '',
},
2018-12-13 13:39:08 +05:30
},
created() {
eventHub.$on('toggleFolder', this.toggleFolder);
},
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
beforeDestroy() {
eventHub.$off('toggleFolder');
},
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
methods: {
toggleFolder(folder) {
this.store.toggleFolder(folder);
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
if (!folder.isOpen) {
this.fetchChildEnvironments(folder, true);
}
},
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
fetchChildEnvironments(folder, showLoader = false) {
this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', showLoader);
this.service
.getFolderContent(folder.folder_path)
.then(response => this.store.setfolderContent(folder, response.data.environments))
.then(() => this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false))
.catch(() => {
Flash(s__('Environments|An error occurred while fetching the environments.'));
this.store.updateEnvironmentProp(folder, 'isLoadingFolderContent', false);
});
},
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
successCallback(resp) {
this.saveData(resp);
2018-03-17 18:26:18 +05:30
2018-12-13 13:39:08 +05:30
// We need to verify if any folder is open to also update it
const openFolders = this.store.getOpenFolders();
if (openFolders.length) {
openFolders.forEach(folder => this.fetchChildEnvironments(folder));
}
2018-03-17 18:26:18 +05:30
},
2018-12-13 13:39:08 +05:30
},
};
2018-03-17 18:26:18 +05:30
</script>
<template>
2020-01-01 13:55:28 +05:30
<div>
2018-11-18 11:00:15 +05:30
<stop-environment-modal :environment="environmentInStopModal" />
2019-07-07 11:18:12 +05:30
<confirm-rollback-modal :environment="environmentInRollbackModal" />
2018-11-18 11:00:15 +05:30
2018-03-17 18:26:18 +05:30
<div class="top-area">
2019-02-15 15:39:39 +05:30
<tabs :tabs="tabs" scope="environments" @onChangeTab="onChangeTab" />
2018-03-17 18:26:18 +05:30
2020-03-09 13:42:32 +05:30
<div class="nav-controls">
<enable-review-app-button v-if="state.reviewAppDetails.can_setup_review_app" class="mr-2" />
<gl-button
v-if="canCreateEnvironment && !isLoading"
:href="newEnvironmentPath"
category="primary"
variant="success"
>
2019-07-07 11:18:12 +05:30
{{ s__('Environments|New environment') }}
2020-03-09 13:42:32 +05:30
</gl-button>
2018-03-17 18:26:18 +05:30
</div>
</div>
<container
:is-loading="isLoading"
:environments="state.environments"
:pagination="state.paginationInformation"
:can-read-environment="canReadEnvironment"
2019-07-07 11:18:12 +05:30
:canary-deployment-feature-id="canaryDeploymentFeatureId"
:show-canary-deployment-callout="showCanaryDeploymentCallout"
:user-callouts-path="userCalloutsPath"
:lock-promotion-svg-path="lockPromotionSvgPath"
:help-canary-deployments-path="helpCanaryDeploymentsPath"
2019-09-30 21:07:59 +05:30
:deploy-boards-help-path="deployBoardsHelpPath"
2018-03-17 18:26:18 +05:30
@onChangePage="onChangePage"
>
<empty-state
v-if="!isLoading && state.environments.length === 0"
2018-11-08 19:23:39 +05:30
slot="emptyState"
2018-03-17 18:26:18 +05:30
:new-path="newEnvironmentPath"
:help-path="helpPagePath"
:can-create-environment="canCreateEnvironment"
/>
</container>
</div>
</template>