Add support for user-mounted widgets

This commit is contained in:
Alicia Sykes 2022-06-24 21:45:15 +01:00
parent a3a26ce063
commit 51002b4033
1 changed files with 10 additions and 2 deletions

View File

@ -32,7 +32,6 @@
</template>
<script>
// Import form elements, icons and utils
import ErrorHandler from '@/utils/ErrorHandler';
import Button from '@/components/FormElements/Button';
import UpdateIcon from '@/assets/interface-icons/widget-update.svg';
@ -110,7 +109,6 @@ const COMPAT = {
export default {
name: 'Widget',
components: {
// Register form elements
Button,
UpdateIcon,
OpenIcon,
@ -156,6 +154,7 @@ export default {
return this.widget.hideControls;
},
component() {
this.appendUserCustomComponents();
const type = COMPAT[this.widgetType] || this.widget.type;
if (!type) {
ErrorHandler('Widget type was not found');
@ -184,6 +183,15 @@ export default {
setLoaderState(loading) {
this.loading = loading;
},
/* If user has specified custom widgets, append them to list */
appendUserCustomComponents() {
const customWidgets = this.appConfig?.customWidgets;
if (customWidgets && Array.isArray(customWidgets)) {
customWidgets.forEach((widget) => {
COMPAT[widget.identifier] = widget.component;
});
}
},
},
};
</script>