Skip to content

Commit 5a271a5

Browse files
committed
Configure frozen fields post-action in web UI
This change is part of story #12189 We had to bump the version of `vue-test-utils` and `vue` due to a bug with the `mount()` methods and nested components. You can find the reference here on GitHub at vuejs/vue-test-utils#1054. Change-Id: I8bd0538ebf7e0f434e8fa2554ec202ac3ede1376
1 parent 1e695c7 commit 5a271a5

File tree

14 files changed

+538
-103
lines changed

14 files changed

+538
-103
lines changed

plugins/tracker/www/scripts/package-lock.json

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/tracker/www/scripts/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@
2626
"pump": "^3.0.0",
2727
"readable-stream": "^2.3.6",
2828
"sprintf-js": "^1.1.1",
29-
"vue": "^2.5.17",
29+
"vue": "^2.5.18",
3030
"vue-gettext": "^2.1.0",
3131
"vuex": "^3.0.1"
3232
},
3333
"devDependencies": {
34-
"@vue/test-utils": "^1.0.0-beta.27",
34+
"@vue/test-utils": "^1.0.0-beta.29",
3535
"angular-mocks": "^1.7.4",
3636
"gulp": "^3.9.1",
3737
"gulp-angular-gettext": "^2.2.0",

plugins/tracker/www/scripts/workflow-transitions/po/fr.po

+33-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ msgstr "Ajouter une action"
2525
msgid "Add another action"
2626
msgstr "Ajouter une nouvelle action"
2727

28+
msgid "Advanced configuration is incompatible with this post-action"
29+
msgstr "La configuration avancée est incompatible avec cette post-action"
30+
2831
msgid "An error occurred"
2932
msgstr "Une erreur est survenue"
3033

@@ -74,6 +77,9 @@ msgstr "Modifier ou supprimer le champ"
7477
msgid "Change the value of a field"
7578
msgstr "Modifier la valeur d'un champ"
7679

80+
msgid "Change the value of a field (incompatible)"
81+
msgstr "Modifier la valeur d'un champ (incompatible)"
82+
7783
msgid "Choose a field"
7884
msgstr "Choisissez un champ"
7985

@@ -128,9 +134,21 @@ msgstr "Champ"
128134
msgid "Field(s) that must not be empty"
129135
msgstr "Le(s) champs suivant(s) doivent obligatoirement avoir une valeur"
130136

137+
msgid "Fields that will be set as read-only"
138+
msgstr "Champs qui seront passés en lecture seule"
139+
131140
msgid "Floats"
132141
msgstr "Flottants"
133142

143+
msgid "Freeze fields"
144+
msgstr "Figer des champs"
145+
146+
msgid "Freeze fields (already used)"
147+
msgstr "Figer des champs (déjà utilisé)"
148+
149+
msgid "Freeze fields (incompatible)"
150+
msgstr "Figer des champs (incompatible)"
151+
134152
msgid "Fully deactivate the workflow"
135153
msgstr "Désactiver complètement le workflow"
136154

@@ -139,7 +157,9 @@ msgstr "Groupes autorisés à effectuer la transition"
139157

140158
msgid ""
141159
"If you have any post actions of type \"Frozen Fields\", they will be deleted."
142-
msgstr "Si vous avez configuré des post-actions de type \"Champs Figés\", elles seront supprimées."
160+
msgstr ""
161+
"Si vous avez configuré des post-actions de type \"Champs Figés\", elles "
162+
"seront supprimées."
143163

144164
msgid ""
145165
"In order to configure transitions rules on this tracker, your first need to "
@@ -168,6 +188,9 @@ msgstr "Nouvelle valeur"
168188
msgid "No action is currently defined."
169189
msgstr "Aucune action n'est encore définie."
170190

191+
msgid "Other actions"
192+
msgstr "Autres actions"
193+
171194
msgid "Please choose"
172195
msgstr "Veuillez choisir"
173196

@@ -237,6 +260,9 @@ msgid "Tuleap will automatically pass the following parameters to the job:"
237260
msgstr ""
238261
"Tuleap va automatiquement transmettre les paramètres suivants à la tâche :"
239262

263+
msgid "Unique actions"
264+
msgstr "Actions uniques"
265+
240266
msgid "Use advanced configuration"
241267
msgstr "Utiliser la configuration avancée"
242268

@@ -250,6 +276,9 @@ msgstr ""
250276
msgid "Wait a minute..."
251277
msgstr "Attendez une minute..."
252278

279+
msgid "You can only have this post-action once."
280+
msgstr "Vous ne pouvez avoir cette post-action qu'une seule fois."
281+
253282
msgid ""
254283
"You're about to switch to advanced configuration mode.\n"
255284
" Each transition will be configurable independently.\n"
@@ -271,6 +300,9 @@ msgstr ""
271300
"Merci de bien vouloir vérifier les configurations mises en place pour chaque "
272301
"état."
273302

303+
msgid "Your tracker doesn't seem to have available writable fields"
304+
msgstr "Votre tracker ne semble pas avoir de champs inscriptibles disponibles."
305+
274306
msgid "Your tracker doesn't seem to have integer, float or date fields."
275307
msgstr "Votre tracker ne semble pas avoir de champs entier, flottant ou date."
276308

plugins/tracker/www/scripts/workflow-transitions/src/app.spec.js

+2
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ import "./components/TransitionMatrixContent.spec.js";
3131
import "./components/TransitionRulesEnforcementWarning.spec.js";
3232
import "./components/BaseTrackerWorkflowTransitions.spec.js";
3333
import "./components/TransitionDeleter.spec.js";
34+
import "./components/TransitionModal/PostAction/PostAction.spec.js";
3435
import "./components/TransitionModal/PostAction/RunJobAction.spec.js";
3536
import "./components/TransitionModal/PostAction/IntInput.spec.js";
3637
import "./components/TransitionModal/PostAction/DateInput.spec.js";
3738
import "./components/TransitionModal/PostAction/SetValueAction.spec.js";
3839
import "./components/TransitionModal/PostAction/FloatInput.spec.js";
40+
import "./components/TransitionModal/PostAction/FrozenFieldsAction.spec.js";
3941
import "./components/TransitionModal/FilledPreConditionsSection.spec.js";
4042
import "./components/TransitionModal/PostActionsSection.spec.js";
4143
import "./components/FirstConfiguration/FirstConfigurationSections.spec.js";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*
2+
* Copyright (c) Enalean, 2019 - Present. All Rights Reserved.
3+
*
4+
* This file is a part of Tuleap.
5+
*
6+
* Tuleap is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* Tuleap is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
18+
*/
19+
20+
import { mount } from "@vue/test-utils";
21+
22+
import FrozenFieldsAction from "./FrozenFieldsAction.vue";
23+
import localVue from "../../../support/local-vue.js";
24+
import { createStoreMock } from "../../../support/store-wrapper.spec-helper.js";
25+
import { create } from "../../../support/factories.js";
26+
27+
describe("FrozenFieldsAction", () => {
28+
let store;
29+
const date_field_id = 43;
30+
const date_field = create("field", { field_id: date_field_id, type: "date" });
31+
const int_field_id = 44;
32+
const int_field = create("field", { field_id: int_field_id, type: "int" });
33+
const float_field_id = 45;
34+
const float_field = create("field", { field_id: float_field_id, type: "float" });
35+
const status_field_id = 46;
36+
const status_field = create("field", { field_id: status_field_id, type: "sb" });
37+
let wrapper;
38+
39+
beforeEach(() => {
40+
const current_tracker = {
41+
fields: [date_field, int_field, float_field, status_field]
42+
};
43+
44+
const store_options = {
45+
state: {
46+
transitionModal: {
47+
current_transition: create("transition"),
48+
is_modal_save_running: false
49+
},
50+
current_tracker: current_tracker
51+
},
52+
getters: {
53+
"transitionModal/set_value_action_fields": [date_field, int_field, float_field],
54+
"transitionModal/post_actions": [],
55+
current_workflow_field: status_field,
56+
is_workflow_advanced: false
57+
}
58+
};
59+
60+
store = createStoreMock(store_options);
61+
62+
wrapper = mount(FrozenFieldsAction, {
63+
stubs: ["multi-select"],
64+
mocks: { $store: store },
65+
propsData: { post_action: create("post_action", "presented") },
66+
localVue
67+
});
68+
});
69+
70+
afterEach(() => store.reset());
71+
72+
it("disables the option when no fields are available", () => {
73+
store.state.current_tracker = null;
74+
75+
expect(wrapper.find("[data-test=freeze_fields]").attributes().disabled).toBeTruthy();
76+
});
77+
78+
it("disables the option when post-action is already used", () => {
79+
store.getters["transitionModal/post_actions"] = [
80+
create("post_action", { type: "frozen_fields" })
81+
];
82+
83+
expect(wrapper.find("[data-test=freeze_fields").attributes().disabled).toBeTruthy();
84+
});
85+
86+
it("should not show the status field as available", () => {
87+
expect(wrapper.find(`[data-test=field_${status_field_id}]`).exists()).toBeFalsy();
88+
});
89+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<!--
2+
- Copyright (c) Enalean, 2019 - Present. All Rights Reserved.
3+
-
4+
- This file is a part of Tuleap.
5+
-
6+
- Tuleap is free software; you can redistribute it and/or modify
7+
- it under the terms of the GNU General Public License as published by
8+
- the Free Software Foundation; either version 2 of the License, or
9+
- (at your option) any later version.
10+
-
11+
- Tuleap is distributed in the hope that it will be useful,
12+
- but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
- GNU General Public License for more details.
15+
-
16+
- You should have received a copy of the GNU General Public License
17+
- along with Tuleap. If not, see <http://www.gnu.org/licenses/>.
18+
-
19+
-->
20+
21+
<template>
22+
<post-action v-bind:post_action="post_action">
23+
<div class="tracker-workflow-transition-modal-action-details-element tlp-form-element">
24+
<label for="workflow-transition-modal-frozen-fields" class="tlp-label">
25+
<translate>Fields that will be set as read-only</translate> <i class="fa fa-asterisk"></i>
26+
</label>
27+
<multi-select
28+
id="workflow-transition-modal-frozen-fields"
29+
class="tlp-select"
30+
required
31+
v-bind:configuration="{
32+
width: '100%',
33+
placeholder: frozen_field_select_placeholder
34+
}"
35+
v-model="frozen_field_ids"
36+
v-bind:disabled="is_modal_save_running"
37+
>
38+
<option
39+
v-for="field in writable_fields"
40+
v-bind:key="field.field_id"
41+
v-bind:value="field.field_id"
42+
v-bind:data-test="`field_${field.field_id}`"
43+
>
44+
{{ field.label }}
45+
</option>
46+
</multi-select>
47+
</div>
48+
</post-action>
49+
</template>
50+
<script>
51+
import PostAction from "./PostAction.vue";
52+
import { mapState, mapGetters } from "vuex";
53+
import MultiSelect from "../MultiSelect.vue";
54+
import { READ_ONLY_FIELDS, STRUCTURAL_FIELDS } from "../../../../../constants/fields-constants.js";
55+
import { compare } from "../../../support/string.js";
56+
57+
const fields_blacklist = [...STRUCTURAL_FIELDS, ...READ_ONLY_FIELDS];
58+
59+
export default {
60+
name: "FrozenFieldsAction",
61+
components: { PostAction, MultiSelect },
62+
props: {
63+
post_action: {
64+
type: Object,
65+
mandatory: true
66+
}
67+
},
68+
computed: {
69+
...mapState(["current_tracker"]),
70+
...mapState("transitionModal", ["current_transition", "is_modal_save_running"]),
71+
...mapGetters(["current_workflow_field"]),
72+
...mapState({
73+
writable_fields(state) {
74+
if (state.current_tracker === null) {
75+
return [];
76+
}
77+
return state.current_tracker.fields
78+
.filter(field => !fields_blacklist.includes(field.type))
79+
.filter(field => !(field.field_id === this.current_workflow_field.field_id))
80+
.sort((field1, field2) => compare(field1.label, field2.label));
81+
}
82+
}),
83+
frozen_field_select_placeholder() {
84+
return this.$gettext("Choose a field");
85+
},
86+
frozen_field_ids: {
87+
get() {
88+
return this.post_action.field_ids;
89+
},
90+
set(field_ids) {
91+
this.$store.commit("transitionModal/updateFrozenFieldsPostActionFieldIds", {
92+
post_action: this.post_action,
93+
field_ids
94+
});
95+
}
96+
}
97+
}
98+
};
99+
</script>

0 commit comments

Comments
 (0)