Skip to content

Commit 56c2aac

Browse files
author
Guillaume Chau
committed
feat(ui): Prompts can now be shown and disabled
1 parent a1eaa2f commit 56c2aac

File tree

11 files changed

+62
-29
lines changed

11 files changed

+62
-29
lines changed

packages/@vue/cli-ui/src/components/PromptCheckbox.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<div class="prompt prompt-checkbox">
2+
<VueDisable
3+
:disabled="!prompt.enabled"
4+
class="prompt prompt-checkbox"
5+
>
36
<div class="prompt-content">
47
<ListItemInfo
58
:name="prompt.message"
@@ -20,7 +23,7 @@
2023
</div>
2124

2225
<PromptError :error="prompt.error"/>
23-
</div>
26+
</VueDisable>
2427
</template>
2528

2629
<script>

packages/@vue/cli-ui/src/components/PromptConfirm.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<div class="prompt prompt-confirm">
2+
<VueDisable
3+
:disabled="!prompt.enabled"
4+
class="prompt prompt-confirm"
5+
>
36
<VueSwitch
47
:value="value(prompt.value)"
58
class="extend-left"
@@ -13,7 +16,7 @@
1316
</VueSwitch>
1417

1518
<PromptError :error="prompt.error"/>
16-
</div>
19+
</VueDisable>
1720
</template>
1821

1922
<script>

packages/@vue/cli-ui/src/components/PromptInput.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<div class="prompt prompt-input">
2+
<VueDisable
3+
:disabled="!prompt.enabled"
4+
class="prompt prompt-input"
5+
>
36
<div class="prompt-content">
47
<ListItemInfo
58
:name="prompt.message"
@@ -17,7 +20,7 @@
1720
</div>
1821

1922
<PromptError :error="prompt.error"/>
20-
</div>
23+
</VueDisable>
2124
</template>
2225

2326
<script>

packages/@vue/cli-ui/src/components/PromptList.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<template>
2-
<div class="prompt prompt-list">
2+
<VueDisable
3+
:disabled="!prompt.enabled"
4+
class="prompt prompt-list"
5+
>
36
<div class="prompt-content">
47
<ListItemInfo
58
:name="prompt.message"
@@ -23,7 +26,7 @@
2326
</div>
2427

2528
<PromptError :error="prompt.error"/>
26-
</div>
29+
</VueDisable>
2730
</template>
2831

2932
<script>

packages/@vue/cli-ui/src/components/PromptsList.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<div class="content">
44
<component
55
v-for="prompt of prompts"
6-
v-if="prompt.enabled"
6+
v-if="prompt.visible"
77
:key="prompt.id"
88
:is="getModule(prompt)"
99
:prompt="prompt"

packages/@vue/cli-ui/src/graphql-api/connectors/prompts.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ function removeAnswer (id) {
138138
function generatePrompt (data) {
139139
return {
140140
id: data.name,
141-
enabled: true,
142141
type: data.type,
142+
visible: true,
143+
enabled: true,
143144
name: data.short || null,
144145
message: data.message,
145146
description: data.description || null,
@@ -154,15 +155,15 @@ function generatePrompt (data) {
154155

155156
function updatePrompts () {
156157
for (const prompt of prompts) {
157-
const oldEnabled = prompt.enabled
158-
prompt.enabled = getEnabled(prompt.raw.when)
158+
const oldVisible = prompt.visible
159+
prompt.visible = getEnabled(prompt.raw.when)
159160

160161
prompt.choices = getChoices(prompt)
161162

162-
if (oldEnabled !== prompt.enabled && !prompt.enabled) {
163+
if (oldVisible !== prompt.visible && !prompt.visible) {
163164
removeAnswer(prompt.id)
164165
prompt.valueChanged = false
165-
} else if (prompt.enabled && !prompt.valueChanged) {
166+
} else if (prompt.visible && !prompt.valueChanged) {
166167
let value = getDefaultValue(prompt)
167168
prompt.value = getDisplayedValue(prompt, value)
168169
setAnswer(prompt.id, getValue(prompt, value))

packages/@vue/cli-ui/src/graphql-api/type-defs.js

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ enum PackageManager {
2121
yarn
2222
}
2323
24+
interface DescribedEntity {
25+
name: String
26+
description: String
27+
link: String
28+
}
29+
2430
type Folder {
2531
name: String!
2632
path: String!
@@ -52,7 +58,7 @@ input ProjectImportInput {
5258
path: String!
5359
}
5460
55-
type Preset {
61+
type Preset implements DescribedEntity {
5662
id: ID!
5763
name: String
5864
description: String
@@ -94,9 +100,9 @@ type PluginInstallation {
94100
prompts: [Prompt]
95101
}
96102
97-
type Feature {
103+
type Feature implements DescribedEntity {
98104
id: ID!
99-
name: String!
105+
name: String
100106
description: String
101107
link: String
102108
enabled: Boolean!
@@ -125,10 +131,11 @@ type PromptError {
125131
link: String
126132
}
127133
128-
type Prompt {
134+
type Prompt implements DescribedEntity {
129135
id: ID!
130-
enabled: Boolean!
131136
type: PromptType!
137+
visible: Boolean!
138+
enabled: Boolean
132139
name: String
133140
message: String
134141
description: String
@@ -154,12 +161,13 @@ type Progress {
154161
args: [String]
155162
}
156163
157-
type Task {
164+
type Task implements DescribedEntity {
158165
id: ID!
159166
status: TaskStatus!
160-
name: String!
167+
name: String
161168
command: String!
162169
description: String
170+
link: String
163171
logs: [TaskLog]
164172
}
165173
@@ -182,6 +190,15 @@ enum TaskLogType {
182190
stderr
183191
}
184192
193+
type Configuration implements DescribedEntity {
194+
id: ID!
195+
name: String
196+
description: String
197+
link: String
198+
icon: String
199+
prompts: [Prompt]
200+
}
201+
185202
type Query {
186203
progress (id: ID!): Progress
187204
cwd: String!
@@ -196,6 +213,8 @@ type Query {
196213
plugin (id: ID!): Plugin
197214
tasks: [Task]
198215
task (id: ID!): Task
216+
configurations: [Configuration]
217+
configuration (id: ID!): Configuration
199218
}
200219
201220
type Mutation {

packages/@vue/cli-ui/src/graphql/promptFragment.gql

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
fragment prompt on Prompt {
55
id
6-
enabled
76
type
7+
visible
8+
enabled
89
name
910
message
1011
description

packages/@vue/cli-ui/src/mixins/Prompts.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ export default function ({
88
return {
99
computed: {
1010
configurationValid () {
11-
return this.enabledPrompts.filter(
11+
return this.visiblePrompts.filter(
1212
p =>
1313
p.error ||
1414
p.value === null ||
1515
JSON.parse(p.value) === ''
1616
).length === 0
1717
},
1818

19-
enabledPrompts () {
19+
visiblePrompts () {
2020
if (!this[field]) {
2121
return []
2222
}
2323
return this[field].prompts.filter(
24-
p => p.enabled
24+
p => p.visible
2525
)
2626
}
2727
},

packages/@vue/cli-ui/src/views/ProjectCreate.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@
201201
/>
202202

203203
<VueButton
204-
v-if="enabledPrompts.length"
204+
v-if="visiblePrompts.length"
205205
icon-right="arrow_forward"
206206
:label="$t('views.project-create.tabs.features.buttons.next')"
207207
class="big primary"
@@ -249,12 +249,12 @@
249249
id="config"
250250
:label="$t('views.project-create.tabs.configuration.title')"
251251
icon="settings_applications"
252-
:disabled="!detailsValid || !presetValid || !manual || !enabledPrompts.length"
252+
:disabled="!detailsValid || !presetValid || !manual || !visiblePrompts.length"
253253
lazy
254254
>
255255
<div class="content vue-ui-disable-scroll">
256256
<PromptsList
257-
:prompts="enabledPrompts"
257+
:prompts="visiblePrompts"
258258
@answer="answerPrompt"
259259
/>
260260
</div>

0 commit comments

Comments
 (0)