rudeshark.net/packages/client/src/widgets/notifications.vue
Andreas Nedbal 708fba989a
feat(tests): add e2e tests for widgets (#8735)
* test(e2e): add baseline for widget tests

* chore(repo): enable test running in branch

* fix(e2e): set viewport for widget tests

* fix(client): add widget identifier classes to widgets

* test(e2e): add memo widget test

* fix(tests): force select value

* fix(tests): force button press for widget addition

* fix(tests): invoke select value differently

* fix(tests): adjust widget submit

* fix(tests): don't explicitly navigate for widget test

* fix(tests): click label to hide select popup

* fix(tests): just click modal background

* fix(tests): adjust modal background selector

* fix(tests): click all modal backgrounds

* feat(e2e): add test for adding timeline widget

* fix(client): add more widget identifier classes

* feat(tests): add method abstraction for test cases

* fix(tests): force-click overlays

* fix(tests): force widget button press

* fix(tests): remove timeout from final widget check

* feat(tests): add widget removal test case

* fix(client): use mk instead of msky as class prefix

* fix(tests): check widgets for existence rather than visibility

* chore(meta): don't run tests for specific feature branch
2022-05-28 14:28:12 +09:00

70 lines
2.0 KiB
Vue

<template>
<MkContainer :style="`height: ${widgetProps.height}px;`" :show-header="widgetProps.showHeader" :scrollable="true" class="mkw-notifications">
<template #header><i class="fas fa-bell"></i>{{ $ts.notifications }}</template>
<template #func><button class="_button" @click="configureNotification()"><i class="fas fa-cog"></i></button></template>
<div>
<XNotifications :include-types="widgetProps.includingTypes"/>
</div>
</MkContainer>
</template>
<script lang="ts" setup>
import { GetFormResultType } from '@/scripts/form';
import { useWidgetPropsManager, Widget, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget';
import MkContainer from '@/components/ui/container.vue';
import XNotifications from '@/components/notifications.vue';
import * as os from '@/os';
import { defineAsyncComponent } from 'vue';
const name = 'notifications';
const widgetPropsDef = {
showHeader: {
type: 'boolean' as const,
default: true,
},
height: {
type: 'number' as const,
default: 300,
},
includingTypes: {
type: 'array' as const,
hidden: true,
default: null,
},
};
type WidgetProps = GetFormResultType<typeof widgetPropsDef>;
// 現時点ではvueの制限によりimportしたtypeをジェネリックに渡せない
//const props = defineProps<WidgetComponentProps<WidgetProps>>();
//const emit = defineEmits<WidgetComponentEmits<WidgetProps>>();
const props = defineProps<{ widget?: Widget<WidgetProps>; }>();
const emit = defineEmits<{ (ev: 'updateProps', props: WidgetProps); }>();
const { widgetProps, configure, save } = useWidgetPropsManager(name,
widgetPropsDef,
props,
emit,
);
const configureNotification = () => {
os.popup(defineAsyncComponent(() => import('@/components/notification-setting-window.vue')), {
includingTypes: widgetProps.includingTypes,
}, {
done: async (res) => {
const { includingTypes } = res;
widgetProps.includingTypes = includingTypes;
save();
}
}, 'closed');
};
defineExpose<WidgetComponentExpose>({
name,
configure,
id: props.widget ? props.widget.id : null,
});
</script>