Skip to content

Commit edfe7d7

Browse files
slusarzcmouse
authored andcommitted
doveadm: CLI usage information should be displayed the same as HTTP API
Namely, hide under a clickable element, so user only sees the doveadm mode they need after clicking.
1 parent 9f5c1b5 commit edfe7d7

File tree

2 files changed

+50
-35
lines changed

2 files changed

+50
-35
lines changed

components/DoveadmCliComponent.vue

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<script setup>
2+
/* Properties for this component:
3+
* 'data' (object): The command argument data.
4+
*/
5+
const props = defineProps(['data'])
6+
const d = props.data
7+
</script>
8+
9+
<template>
10+
<div>
11+
<ul>
12+
<li>Usage: <code>doveadm {{ d.usage }}</code></li>
13+
</ul>
14+
15+
<table v-if="d.args">
16+
<thead>
17+
<tr>
18+
<th>Argument(s)</th>
19+
<th>Type</th>
20+
<th>Description</th>
21+
<th>Example</th>
22+
</tr>
23+
</thead>
24+
<tbody>
25+
<template v-for="elem in d.args">
26+
<tr>
27+
<td><code>{{ elem.flag }}</code></td>
28+
<td>{{ elem.type }}</td>
29+
<td v-html="elem.text" />
30+
<td><code v-if="elem.example !== undefined">{{ JSON.stringify(elem.example) }}</code></td>
31+
</tr>
32+
</template>
33+
</tbody>
34+
</table>
35+
</div>
36+
</template>

components/DoveadmComponent.vue

Lines changed: 14 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,14 @@ const d = Object.fromEntries(Object.entries(data.doveadm).filter(([k, v]) =>
1818
(v.tags.includes(props.tag))))
1919
).sort())
2020
21-
let apiComponent = ref({})
22-
function httpApiClick(k) {
23-
apiComponent.value[k] = 'DoveadmHttpApiComponent'
21+
const cliComponent = ref({})
22+
function cliClick(k) {
23+
cliComponent.value[k] = 'DoveadmCliComponent'
24+
}
25+
26+
const httpComponent = ref({})
27+
function httpClick(k) {
28+
httpComponent.value[k] = 'DoveadmHttpApiComponent'
2429
}
2530
</script>
2631

@@ -99,41 +104,15 @@ function httpApiClick(k) {
99104

100105
<div v-if="v.text" v-html="v.text" />
101106

102-
<div class="info custom-block">
103-
<p class="custom-block-title">CLI</p>
104-
<div>
105-
<ul>
106-
<li>Usage: <code>doveadm {{ v.usage }}</code></li>
107-
</ul>
108-
109-
<table v-if="v.args">
110-
<thead>
111-
<tr>
112-
<th>Argument(s)</th>
113-
<th>Type</th>
114-
<th>Description</th>
115-
<th>Example</th>
116-
</tr>
117-
</thead>
118-
<tbody>
119-
<template v-for="elem in v.args">
120-
<tr>
121-
<td><code>{{ elem.flag }}</code></td>
122-
<td>{{ elem.type }}</td>
123-
<td v-html="elem.text" />
124-
<td><code v-if="elem.example !== undefined">{{ JSON.stringify(elem.example) }}</code></td>
125-
</tr>
126-
</template>
127-
</tbody>
128-
</table>
129-
</div>
130-
</div>
107+
<details @click.capture.once="cliClick(k)" class="details custom-block">
108+
<summary>CLI</summary>
109+
<component v-if="cliComponent[k]" :is="cliComponent[k]" :data="v" />
110+
</details>
131111

132-
<details v-if="v.args" @click.capture.once="httpApiClick(k)" class="details custom-block">
112+
<details v-if="v.args" @click.capture.once="httpClick(k)" class="details custom-block">
133113
<summary v-html="data.http_api_link" />
134-
<component v-if="apiComponent[k]" :is="apiComponent[k]" :data="v" />
114+
<component v-if="httpComponent[k]" :is="httpComponent[k]" :data="v" />
135115
</details>
136-
137116
</article>
138117
</section>
139118
</template>

0 commit comments

Comments
 (0)