Commit 6ae76738 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'environments-vue-5' into 'master'

Use vue files for vue components.

See merge request !10882
parents ba215788 54933058
<script>
/* eslint-disable no-new */ /* eslint-disable no-new */
/* global Flash */ /* global Flash */
import Vue from 'vue';
import EnvironmentsService from '../services/environments_service'; import EnvironmentsService from '../services/environments_service';
import EnvironmentTable from './environments_table.vue'; import EnvironmentTable from './environments_table.vue';
import EnvironmentsStore from '../stores/environments_store'; import EnvironmentsStore from '../stores/environments_store';
...@@ -8,7 +9,7 @@ import TablePaginationComponent from '../../vue_shared/components/table_paginati ...@@ -8,7 +9,7 @@ import TablePaginationComponent from '../../vue_shared/components/table_paginati
import '../../lib/utils/common_utils'; import '../../lib/utils/common_utils';
import eventHub from '../event_hub'; import eventHub from '../event_hub';
export default Vue.component('environment-component', { export default {
components: { components: {
'environment-table': EnvironmentTable, 'environment-table': EnvironmentTable,
...@@ -140,12 +141,15 @@ export default Vue.component('environment-component', { ...@@ -140,12 +141,15 @@ export default Vue.component('environment-component', {
}); });
}, },
}, },
};
template: ` </script>
<template>
<div :class="cssContainerClass"> <div :class="cssContainerClass">
<div class="top-area"> <div class="top-area">
<ul v-if="!isLoading" class="nav-links"> <ul
<li v-bind:class="{ 'active': scope === null || scope === 'available' }"> v-if="!isLoading"
class="nav-links">
<li :class="{ active: scope === null || scope === 'available' }">
<a :href="projectEnvironmentsPath"> <a :href="projectEnvironmentsPath">
Available Available
<span class="badge js-available-environments-count"> <span class="badge js-available-environments-count">
...@@ -153,7 +157,7 @@ export default Vue.component('environment-component', { ...@@ -153,7 +157,7 @@ export default Vue.component('environment-component', {
</span> </span>
</a> </a>
</li> </li>
<li v-bind:class="{ 'active' : scope === 'stopped' }"> <li :class="{ active : scope === 'stopped' }">
<a :href="projectStoppedEnvironmentsPath"> <a :href="projectStoppedEnvironmentsPath">
Stopped Stopped
<span class="badge js-stopped-environments-count"> <span class="badge js-stopped-environments-count">
...@@ -162,19 +166,29 @@ export default Vue.component('environment-component', { ...@@ -162,19 +166,29 @@ export default Vue.component('environment-component', {
</a> </a>
</li> </li>
</ul> </ul>
<div v-if="canCreateEnvironmentParsed && !isLoading" class="nav-controls"> <div
<a :href="newEnvironmentPath" class="btn btn-create"> v-if="canCreateEnvironmentParsed && !isLoading"
class="nav-controls">
<a
:href="newEnvironmentPath"
class="btn btn-create">
New environment New environment
</a> </a>
</div> </div>
</div> </div>
<div class="content-list environments-container"> <div class="content-list environments-container">
<div class="environments-list-loading text-center" v-if="isLoading"> <div
<i class="fa fa-spinner fa-spin" aria-hidden="true"></i> class="environments-list-loading text-center"
v-if="isLoading">
<i
class="fa fa-spinner fa-spin"
aria-hidden="true" />
</div> </div>
<div class="blank-state blank-state-no-icon" <div
class="blank-state blank-state-no-icon"
v-if="!isLoading && state.environments.length === 0"> v-if="!isLoading && state.environments.length === 0">
<h2 class="blank-state-title js-blank-state-title"> <h2 class="blank-state-title js-blank-state-title">
You don't have any environments right now. You don't have any environments right now.
...@@ -187,14 +201,16 @@ export default Vue.component('environment-component', { ...@@ -187,14 +201,16 @@ export default Vue.component('environment-component', {
</a> </a>
</p> </p>
<a v-if="canCreateEnvironmentParsed" <a
v-if="canCreateEnvironmentParsed"
:href="newEnvironmentPath" :href="newEnvironmentPath"
class="btn btn-create js-new-environment-button"> class="btn btn-create js-new-environment-button">
New Environment New Environment
</a> </a>
</div> </div>
<div class="table-holder" <div
class="table-holder"
v-if="!isLoading && state.environments.length > 0"> v-if="!isLoading && state.environments.length > 0">
<environment-table <environment-table
...@@ -205,11 +221,10 @@ export default Vue.component('environment-component', { ...@@ -205,11 +221,10 @@ export default Vue.component('environment-component', {
:is-loading-folder-content="isLoadingFolderContent" /> :is-loading-folder-content="isLoadingFolderContent" />
</div> </div>
<table-pagination v-if="state.paginationInformation && state.paginationInformation.totalPages > 1" <table-pagination
v-if="state.paginationInformation && state.paginationInformation.totalPages > 1"
:change="changePage" :change="changePage"
:pageInfo="state.paginationInformation"> :pageInfo="state.paginationInformation" />
</table-pagination>
</div> </div>
</div> </div>
`, </template>
});
import EnvironmentsComponent from './components/environment'; import Vue from 'vue';
import EnvironmentsComponent from './components/environment.vue';
$(() => { document.addEventListener('DOMContentLoaded', () => new Vue({
window.gl = window.gl || {}; el: '#environments-list-view',
components: {
if (gl.EnvironmentsListApp) { 'environments-table-app': EnvironmentsComponent,
gl.EnvironmentsListApp.$destroy(true); },
} render: createElement => createElement('environments-table-app'),
}));
gl.EnvironmentsListApp = new EnvironmentsComponent({
el: document.querySelector('#environments-list-view'),
});
});
import EnvironmentsFolderComponent from './environments_folder_view'; import Vue from 'vue';
import EnvironmentsFolderComponent from './environments_folder_view.vue';
$(() => { document.addEventListener('DOMContentLoaded', () => new Vue({
window.gl = window.gl || {}; el: '#environments-folder-list-view',
components: {
if (gl.EnvironmentsListFolderApp) { 'environments-folder-app': EnvironmentsFolderComponent,
gl.EnvironmentsListFolderApp.$destroy(true); },
} render: createElement => createElement('environments-folder-app'),
}));
gl.EnvironmentsListFolderApp = new EnvironmentsFolderComponent({
el: document.querySelector('#environments-folder-list-view'),
});
});
<script>
/* eslint-disable no-new */ /* eslint-disable no-new */
/* global Flash */ /* global Flash */
import Vue from 'vue';
import EnvironmentsService from '../services/environments_service'; import EnvironmentsService from '../services/environments_service';
import EnvironmentTable from '../components/environments_table.vue'; import EnvironmentTable from '../components/environments_table.vue';
import EnvironmentsStore from '../stores/environments_store'; import EnvironmentsStore from '../stores/environments_store';
...@@ -8,7 +8,7 @@ import TablePaginationComponent from '../../vue_shared/components/table_paginati ...@@ -8,7 +8,7 @@ import TablePaginationComponent from '../../vue_shared/components/table_paginati
import '../../lib/utils/common_utils'; import '../../lib/utils/common_utils';
import '../../vue_shared/vue_resource_interceptor'; import '../../vue_shared/vue_resource_interceptor';
export default Vue.component('environment-folder-view', { export default {
components: { components: {
'environment-table': EnvironmentTable, 'environment-table': EnvironmentTable,
'table-pagination': TablePaginationComponent, 'table-pagination': TablePaginationComponent,
...@@ -116,26 +116,33 @@ export default Vue.component('environment-folder-view', { ...@@ -116,26 +116,33 @@ export default Vue.component('environment-folder-view', {
return param; return param;
}, },
}, },
};
template: ` </script>
<template>
<div :class="cssContainerClass"> <div :class="cssContainerClass">
<div class="top-area" v-if="!isLoading"> <div
class="top-area"
v-if="!isLoading">
<h4 class="js-folder-name environments-folder-name"> <h4 class="js-folder-name environments-folder-name">
Environments / <b>{{folderName}}</b> Environments / <b>{{folderName}}</b>
</h4> </h4>
<ul class="nav-links"> <ul class="nav-links">
<li v-bind:class="{ 'active': scope === null || scope === 'available' }"> <li :class="{ active: scope === null || scope === 'available' }">
<a :href="availablePath" class="js-available-environments-folder-tab"> <a
:href="availablePath"
class="js-available-environments-folder-tab">
Available Available
<span class="badge js-available-environments-count"> <span class="badge js-available-environments-count">
{{state.availableCounter}} {{state.availableCounter}}
</span> </span>
</a> </a>
</li> </li>
<li v-bind:class="{ 'active' : scope === 'stopped' }"> <li :class="{ active : scope === 'stopped' }">
<a :href="stoppedPath" class="js-stopped-environments-folder-tab"> <a
:href="stoppedPath"
class="js-stopped-environments-folder-tab">
Stopped Stopped
<span class="badge js-stopped-environments-count"> <span class="badge js-stopped-environments-count">
{{state.stoppedCounter}} {{state.stoppedCounter}}
...@@ -146,11 +153,16 @@ export default Vue.component('environment-folder-view', { ...@@ -146,11 +153,16 @@ export default Vue.component('environment-folder-view', {
</div> </div>
<div class="environments-container"> <div class="environments-container">
<div class="environments-list-loading text-center" v-if="isLoading"> <div
<i class="fa fa-spinner fa-spin"></i> class="environments-list-loading text-center"
v-if="isLoading">
<i
class="fa fa-spinner fa-spin"
aria-hidden="true"/>
</div> </div>
<div class="table-holder" <div
class="table-holder"
v-if="!isLoading && state.environments.length > 0"> v-if="!isLoading && state.environments.length > 0">
<environment-table <environment-table
...@@ -159,11 +171,11 @@ export default Vue.component('environment-folder-view', { ...@@ -159,11 +171,11 @@ export default Vue.component('environment-folder-view', {
:can-read-environment="canReadEnvironmentParsed" :can-read-environment="canReadEnvironmentParsed"
:service="service"/> :service="service"/>
<table-pagination v-if="state.paginationInformation && state.paginationInformation.totalPages > 1" <table-pagination
v-if="state.paginationInformation && state.paginationInformation.totalPages > 1"
:change="changePage" :change="changePage"
:pageInfo="state.paginationInformation"/> :pageInfo="state.paginationInformation"/>
</div> </div>
</div> </div>
</div> </div>
`, </template>
});
import Vue from 'vue'; import Vue from 'vue';
import '~/flash'; import '~/flash';
import EnvironmentsComponent from '~/environments/components/environment'; import environmentsComponent from '~/environments/components/environment.vue';
import { environment, folder } from './mock_data'; import { environment, folder } from './mock_data';
describe('Environment', () => { describe('Environment', () => {
preloadFixtures('static/environments/environments.html.raw'); preloadFixtures('static/environments/environments.html.raw');
let EnvironmentsComponent;
let component; let component;
beforeEach(() => { beforeEach(() => {
loadFixtures('static/environments/environments.html.raw'); loadFixtures('static/environments/environments.html.raw');
EnvironmentsComponent = Vue.extend(environmentsComponent);
}); });
describe('successfull request', () => { describe('successfull request', () => {
......
import Vue from 'vue'; import Vue from 'vue';
import '~/flash'; import '~/flash';
import EnvironmentsFolderViewComponent from '~/environments/folder/environments_folder_view'; import environmentsFolderViewComponent from '~/environments/folder/environments_folder_view.vue';
import { environmentsList } from '../mock_data'; import { environmentsList } from '../mock_data';
describe('Environments Folder View', () => { describe('Environments Folder View', () => {
preloadFixtures('static/environments/environments_folder_view.html.raw'); preloadFixtures('static/environments/environments_folder_view.html.raw');
let EnvironmentsFolderViewComponent;
beforeEach(() => { beforeEach(() => {
loadFixtures('static/environments/environments_folder_view.html.raw'); loadFixtures('static/environments/environments_folder_view.html.raw');
EnvironmentsFolderViewComponent = Vue.extend(environmentsFolderViewComponent);
window.history.pushState({}, null, 'environments/folders/build'); window.history.pushState({}, null, 'environments/folders/build');
}); });
......
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