Welcome to mirror list, hosted at ThFree Co, Russian Federation.

App.vue « src - github.com/nextcloud/issuetemplate.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 2509d77f82e568de256efa586dce4c2fb4fce48c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<template>
	<div id="issuetemplate" class="section">
	<h2 class="inlineblock">{{ t('issuetemplate', 'Issue reporting') }}</h2>

	<p>
		For reporting potential security issues please see
		<a href="https://nextcloud.com/security/">https://nextcloud.com/security/</a>
	</p>

	<div>

		<form-wizard @on-complete="onComplete"
					 shape="tab"
					 color="#0082c9"
					 error-color="#a94442"
					 ref="wizard">
			<div slot="title"></div>


			<tab-content title="Affected component" icon="icon-category-customization icon-invert" :before-change="validateAppSelect">
				<app-selector v-on:select="selectComponent"></app-selector>
			</tab-content>

			<tab-content title="Issue description" icon="icon-user icon-invert" :before-change="validateIssueDescription">
				<vue-form-generator :model="model" :schema="firstTabSchema" :options="formOptions" ref="firstTabForm"></vue-form-generator>
			</tab-content>

			<tab-content v-for="tab in tabs" v-if="model.component" :key="tab.identifier" :title="tab.title" icon="icon-settings icon-invert" :before-change="()=>validateDetails(tab)">
				<detail-section :app="getAppId()" :section="tab.identifier" :ref="tab.identifier" :model="model"></detail-section>
			</tab-content>

			<tab-content title="Check issue report" icon="icon-checkmark icon-invert" v-if="tabs.length">
				<h4>Check your bug report before submitting it</h4>
				<div class="panel-body">
					<p>
						<strong>Please always check if the automatically filled out information is correct and there is nothing important missing, before reporting the issue.</strong>
					</p>

					<p>
						<strong>This report will be submitted to nextcloud/server</strong>
					</p>

					<div id="preview" v-html="preview.rendered">

					</div>
					<textarea id="preview" v-model="preview.markdown">

						</textarea>
				</div>
			</tab-content>

			<template slot="footer" slot-scope="props">
				<div class="wizard-footer-left">
					<button v-if="props.activeTabIndex > 0 && !props.isLastStep" @click="props.prevTab()">Previous</button>
				</div>
				<div class="wizard-footer-right">
					<button v-if="!props.isLastStep" @click="props.nextTab()" class="primary">Next</button>
					<button v-if="props.isLastStep" v-clipboard:copy="preview.markdown" class="">Copy issue text</button>
					<button v-if="props.isLastStep && preview.markdown && preview.markdown.length<4096" @click="openIssue()"  class="">Open a new issue</button>
				</div>
			</template>

		</form-wizard>


	</div>
	</div>
</template>
<script>
	import AppSelector from './components/appselector.vue';
	import DetailSection from './components/detailsection.vue';
	import VueFormGenerator from 'vue-form-generator';

	export default {
		name: 'App',
		components: {
			'app-selector': AppSelector,
			'detail-section': DetailSection,
		},
		mounted: function () {
			this.resetWizard();
		},
		data() {
			return {
				color: '#aaaaaa',
				tabs: [],
				model: {},
				preview: {},
				formOptions: {
					validationErrorClass: "has-error",
					validationSuccessClass: "has-success",
					validateAfterChanged: true
				},
				firstTabSchema: {
					fields: [
						{
							type: "input",
							inputType: "text",
							label: "Issue title",
							model: "title",
							//required: true,
							validator: VueFormGenerator.validators.string,
							styleClasses: 'col-sm-12'
						},
						{
							type: "textArea",
							inputType: "text",
							label: "Steps to reproduce",
							model: "stepsToReproduce",
							required: true,
							validator: VueFormGenerator.validators.string,
							styleClasses: 'col-sm-12'
						},
						{
							type: "textArea",
							inputType: "text",
							label: "Expected behaviour",
							model: "expectedBehaviour",
							required: true,
							validator: VueFormGenerator.validators.string,
							styleClasses: 'col-sm-6'
						},
						{
							type: "textArea",
							inputType: "text",
							label: "Actual behaviour",
							model: "actualBehaviour",
							required: true,
							validator: VueFormGenerator.validators.string,
							styleClasses: 'col-sm-6'
						}
					]
				}
			}
		},
		methods: {
			updateSections: function () {
				var self = this;
				self.tabs = [];
				$.ajax({
					url: OC.generateUrl('/apps/issuetemplate/sections/' + this.getAppId()),
					method: 'GET',
					success: function (data) {
						self.tabs = data;
					},
					error: function (error) {
						self.tabs = [];
					}
				});
			},
			getAppId: function () {
				if (this.model.component !== null) {
					return this.model.component.id;
				}
				return null;
			},
			selectComponent: function (component) {
				this.model.component = component;
				this.updateSections();
				this.$refs.wizard.nextTab();
			},
			onComplete: function(){
				this.resetWizard();
			},
			resetWizard: function() {
				this.model = {
					component: null,
					title: '',
					stepsToReproduce: '',
					expectedBehaviour: '',
					actualBehaviour: '',
					details: {}
				};
			},
			validateAppSelect: function() {
				return this.getAppId() !== null;
			},
			validateIssueDescription: function(){
				return this.$refs.firstTabForm.validate();
			},
			validateDetails: function(tab){
				var self = this;
				var updates = this.$refs[tab.identifier][0].fetchUpdates();
				if (updates === false) {
					return false;
				}
				this.model.details[tab.identifier] = updates[tab.identifier];
				$.ajax({
					url: OC.generateUrl('/apps/issuetemplate/render'),
					data: this.model,
					method: 'POST',
					success: function (data) {
						self.preview = data;
					}
				});
				return true;
			},
			openIssue: function() {
				var urlComplete = this.model.component.bugs + "/new/?title=" + encodeURIComponent(this.model.title) + "&body=" + encodeURIComponent(this.preview.markdown);
				window.open(urlComplete);
			}
		}
	}
</script>