53
53
54
54
v-bind =" attrs"
55
55
v-on =" on"
56
- @click =" $emit('clicked', extension.identifier, selected_version, is_installed) "
56
+ @click =" performAction "
57
57
>
58
58
{{ is_installed ? 'Uninstall' : 'Install' }}
59
59
</v-btn >
115
115
v-model =" editing_permissions"
116
116
style =" width :100% ; height :100% "
117
117
@save =" onEditingPermissionsSave"
118
- />
118
+ >
119
+ <template
120
+ v-if =" is_reset_editing_permissions_visible "
121
+ #controls
122
+ >
123
+ <v-btn
124
+ v-tooltip =" 'Reset to default permissions'"
125
+ class =" editor-control"
126
+ icon
127
+ color =" white"
128
+ @click =" onResetToDefaultPermissions"
129
+ >
130
+ <v-icon >mdi-restore</v-icon >
131
+ </v-btn >
132
+ </template >
133
+ </json-editor >
119
134
</v-card >
120
135
</v-expansion-panel-content >
121
136
</v-expansion-panel >
@@ -162,6 +177,7 @@ export default Vue.extend({
162
177
return {
163
178
selected_version: ' ' as string | null | undefined ,
164
179
editing_permissions: ' ' as string | JSONValue ,
180
+ custom_permissions: {} as Record <string , JSONValue >,
165
181
}
166
182
},
167
183
computed: {
@@ -213,11 +229,19 @@ export default Vue.extend({
213
229
),
214
230
]
215
231
},
232
+ is_reset_editing_permissions_visible(): boolean {
233
+ if (! this .selected_version ) {
234
+ return false
235
+ }
236
+
237
+ return JSON .stringify (this .editing_permissions ) !== JSON .stringify (this .selected ?.permissions )
238
+ },
216
239
},
217
240
watch: {
218
241
extension() {
219
242
this .selected_version = this .getLatestTag ()
220
243
this .editing_permissions = this .getVersionPermissions ()
244
+ this .custom_permissions = {}
221
245
},
222
246
selected_version() {
223
247
this .editing_permissions = this .getVersionPermissions ()
@@ -238,15 +262,36 @@ export default Vue.extend({
238
262
return ' Select a version to view permissions'
239
263
}
240
264
241
- const versions = this .extension ?.versions
242
- if (versions && this .selected_version in versions ) {
243
- return versions [this .selected_version ].permissions
265
+ if (this .selected ) {
266
+ return this .custom_permissions [this .selected_version ] ?? this .selected .permissions
244
267
}
245
268
246
269
return ' No permissions required'
247
270
},
248
- onEditingPermissionsSave() {
249
- console .log (' Permissions saved' )
271
+ onEditingPermissionsSave(json : JSONValue ) {
272
+ if (this .selected_version ) {
273
+ this .editing_permissions = json
274
+ this .custom_permissions [this .selected_version ] = json
275
+ }
276
+ },
277
+ onResetToDefaultPermissions() {
278
+ if (this .selected_version ) {
279
+ delete this .custom_permissions [this .selected_version ]
280
+ this .editing_permissions = this .getVersionPermissions ()
281
+ }
282
+ },
283
+ performAction() {
284
+ if (! this .selected_version ) {
285
+ return
286
+ }
287
+
288
+ this .$emit (
289
+ ' clicked' ,
290
+ this .extension .identifier ,
291
+ this .selected_version ,
292
+ JSON .stringify (this .custom_permissions [this .selected_version ]),
293
+ this .is_installed ,
294
+ )
250
295
},
251
296
},
252
297
})
@@ -280,6 +325,11 @@ div.readme ul {
280
325
margin-left : 20px ;
281
326
}
282
327
328
+ .editor-control {
329
+ margin : 0 ;
330
+ opacity : 0.7 ;
331
+ }
332
+
283
333
.extension-creators {
284
334
flex-grow : 1 ;
285
335
margin-left : 10px ;
0 commit comments