Skip to content

Commit c211626

Browse files
authored
Remove Vuetify from 'Request more space' form error banner
1 parent 96272ce commit c211626

3 files changed

Lines changed: 94 additions & 7 deletions

File tree

contentcuration/contentcuration/frontend/settings/pages/Storage/RequestForm.vue

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44
ref="form"
55
@submit.prevent="submit"
66
>
7-
<Banner
8-
:value="Boolean(errorCount())"
7+
<StudioBanner
8+
v-if="Boolean(errorCount())"
99
error
10-
:text="errorText()"
11-
class="my-2"
12-
/>
10+
class="studio-banner"
11+
>
12+
{{ errorText() }}
13+
</StudioBanner>
1314

1415
<!-- Nature of content -->
1516
<h3>{{ $tr('natureOfYourContentLabel') }}</h3>
@@ -264,11 +265,12 @@
264265
265266
import sortBy from 'lodash/sortBy';
266267
import { mapActions, mapState } from 'vuex';
268+
import useKLiveRegion from 'kolibri-design-system/lib/composables/useKLiveRegion';
267269
import { generateFormMixin, constantsTranslationMixin } from 'shared/mixins';
268270
import { LicensesList } from 'shared/leUtils/Licenses';
269271
import CountryField from 'shared/views/form/CountryField';
270272
import MultiSelect from 'shared/views/form/MultiSelect';
271-
import Banner from 'shared/views/Banner';
273+
import StudioBanner from 'shared/views/StudioBanner';
272274
import InfoModal from 'shared/views/InfoModal';
273275
274276
const formMixin = generateFormMixin({
@@ -320,10 +322,14 @@
320322
components: {
321323
CountryField,
322324
MultiSelect,
323-
Banner,
325+
StudioBanner,
324326
InfoModal,
325327
},
326328
mixins: [constantsTranslationMixin, formMixin],
329+
setup() {
330+
const { sendPoliteMessage } = useKLiveRegion();
331+
return { sendPoliteMessage };
332+
},
327333
computed: {
328334
...mapState('settings', ['channels']),
329335
orgSelected() {
@@ -392,6 +398,7 @@
392398
if (this.$refs.form.scrollIntoView) {
393399
this.$refs.form.scrollIntoView({ behavior: 'smooth' });
394400
}
401+
this.sendPoliteMessage(this.errorText());
395402
},
396403
397404
// eslint-disable-next-line kolibri/vue-no-unused-methods, vue/no-unused-properties
@@ -524,4 +531,9 @@
524531
line-height: 1.5;
525532
}
526533
534+
.studio-banner {
535+
margin-top: 8px;
536+
margin-bottom: 8px;
537+
}
538+
527539
</style>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<template>
2+
3+
<div
4+
class="banner"
5+
data-testid="studio-banner"
6+
:style="{ backgroundColor: error ? $themePalette.red.v_100 : '' }"
7+
>
8+
<slot>
9+
{{ text }}
10+
</slot>
11+
</div>
12+
13+
</template>
14+
15+
16+
<script>
17+
18+
export default {
19+
name: 'StudioBanner',
20+
props: {
21+
error: {
22+
type: Boolean,
23+
default: false,
24+
},
25+
},
26+
};
27+
28+
</script>
29+
30+
31+
<style lang="scss" scoped>
32+
33+
.banner {
34+
padding: 16px;
35+
}
36+
37+
</style>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { render, screen } from '@testing-library/vue';
2+
import VueRouter from 'vue-router';
3+
import StudioBanner from '../StudioBanner.vue';
4+
5+
const sampleErrorMessage = 'This is an error message';
6+
7+
describe('StudioBanner', () => {
8+
test('render with defaults values', () => {
9+
render(StudioBanner, {
10+
props: {
11+
error: false,
12+
},
13+
routes: new VueRouter(),
14+
slots: {
15+
default: 'normal text',
16+
},
17+
});
18+
const banner = screen.getByTestId('studio-banner');
19+
expect(banner).toBeInTheDocument();
20+
});
21+
22+
test('render with error true', () => {
23+
render(StudioBanner, {
24+
props: {
25+
error: true,
26+
},
27+
routes: new VueRouter(),
28+
slots: {
29+
default: sampleErrorMessage,
30+
},
31+
});
32+
33+
const banner = screen.getByTestId('studio-banner');
34+
expect(banner).toBeInTheDocument();
35+
expect(banner).toHaveStyle('background-color: rgb(255, 217, 211)');
36+
expect(screen.getByText(sampleErrorMessage)).toBeInTheDocument();
37+
});
38+
});

0 commit comments

Comments
 (0)