From 92f65b38ad00c23411734f71a7eb444e6455d81a Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Mon, 11 Mar 2024 15:31:29 +0100 Subject: [PATCH] MOBILE-4268 core: Remove storybook --- .storybook/main.js | 11 -- .storybook/preview.js | 11 -- .storybook/styles.scss | 7 - .storybook/tsconfig.json | 11 -- package.json | 1 - src/assets/storybook/courses.json | 1 - src/assets/storybook/geopattern.svg | 2 - src/assets/storybook/sites/companylisa.ts | 32 ---- src/assets/storybook/sites/schoolbarbara.ts | 32 ---- src/assets/storybook/sites/schooljeffery.ts | 32 ---- .../stories/components/components.module.ts | 43 ------ .../course-image-cards-page.html | 22 --- .../course-image-cards-page.scss | 16 -- .../course-image-cards-page.ts | 28 ---- .../course-image-list-page.html | 19 --- .../course-image-list-page.ts | 27 ---- .../empty-box-page/empty-box-page.html | 15 -- .../empty-box-page/empty-box-page.ts | 27 ---- .../empty-box-wrapper/empty-box-wrapper.html | 3 - .../empty-box-wrapper/empty-box-wrapper.ts | 38 ----- .../sites-list-wrapper.html | 23 --- .../sites-list-wrapper/sites-list-wrapper.ts | 60 -------- .../stories/course-image.stories.ts | 104 ------------- .../components/stories/empty-box.stories.ts | 79 ---------- .../components/stories/error-info.stories.ts | 50 ------- .../components/stories/sites-list.stories.ts | 78 ---------- .../components/stories/user-avatar.stories.ts | 37 ----- .../stories/components/components.module.ts | 37 ----- .../global-search-results-page.html | 18 --- .../global-search-results-page.ts | 141 ------------------ .../stories/global-search-result.stories.ts | 136 ----------------- src/storybook/storybook.module.ts | 78 ---------- src/storybook/stubs/classes/site.ts | 59 -------- src/storybook/stubs/classes/sqlitedb.ts | 32 ---- src/storybook/stubs/services/db.ts | 35 ----- src/storybook/stubs/services/filepool.ts | 32 ---- src/storybook/stubs/services/http.ts | 38 ----- .../stubs/services/pushnotifications.ts | 32 ---- src/storybook/stubs/services/sites.ts | 86 ----------- src/storybook/utils/helpers.ts | 30 ---- tsconfig.app.json | 1 - 41 files changed, 1564 deletions(-) delete mode 100644 .storybook/main.js delete mode 100644 .storybook/preview.js delete mode 100644 .storybook/styles.scss delete mode 100644 .storybook/tsconfig.json delete mode 100644 src/assets/storybook/courses.json delete mode 100644 src/assets/storybook/geopattern.svg delete mode 100644 src/assets/storybook/sites/companylisa.ts delete mode 100644 src/assets/storybook/sites/schoolbarbara.ts delete mode 100644 src/assets/storybook/sites/schooljeffery.ts delete mode 100644 src/core/components/stories/components/components.module.ts delete mode 100644 src/core/components/stories/components/course-image-cards-page/course-image-cards-page.html delete mode 100644 src/core/components/stories/components/course-image-cards-page/course-image-cards-page.scss delete mode 100644 src/core/components/stories/components/course-image-cards-page/course-image-cards-page.ts delete mode 100644 src/core/components/stories/components/course-image-list-page/course-image-list-page.html delete mode 100644 src/core/components/stories/components/course-image-list-page/course-image-list-page.ts delete mode 100644 src/core/components/stories/components/empty-box-page/empty-box-page.html delete mode 100644 src/core/components/stories/components/empty-box-page/empty-box-page.ts delete mode 100644 src/core/components/stories/components/empty-box-wrapper/empty-box-wrapper.html delete mode 100644 src/core/components/stories/components/empty-box-wrapper/empty-box-wrapper.ts delete mode 100644 src/core/components/stories/components/sites-list-wrapper/sites-list-wrapper.html delete mode 100644 src/core/components/stories/components/sites-list-wrapper/sites-list-wrapper.ts delete mode 100644 src/core/components/stories/course-image.stories.ts delete mode 100644 src/core/components/stories/empty-box.stories.ts delete mode 100644 src/core/components/stories/error-info.stories.ts delete mode 100644 src/core/components/stories/sites-list.stories.ts delete mode 100644 src/core/components/stories/user-avatar.stories.ts delete mode 100644 src/core/features/search/stories/components/components.module.ts delete mode 100644 src/core/features/search/stories/components/global-search-results-page/global-search-results-page.html delete mode 100644 src/core/features/search/stories/components/global-search-results-page/global-search-results-page.ts delete mode 100644 src/core/features/search/stories/global-search-result.stories.ts delete mode 100644 src/storybook/storybook.module.ts delete mode 100644 src/storybook/stubs/classes/site.ts delete mode 100644 src/storybook/stubs/classes/sqlitedb.ts delete mode 100644 src/storybook/stubs/services/db.ts delete mode 100644 src/storybook/stubs/services/filepool.ts delete mode 100644 src/storybook/stubs/services/http.ts delete mode 100644 src/storybook/stubs/services/pushnotifications.ts delete mode 100644 src/storybook/stubs/services/sites.ts delete mode 100644 src/storybook/utils/helpers.ts diff --git a/.storybook/main.js b/.storybook/main.js deleted file mode 100644 index 6d3a8b83b..000000000 --- a/.storybook/main.js +++ /dev/null @@ -1,11 +0,0 @@ -module.exports = { - framework: '@storybook/angular', - addons: [ - '@storybook/addon-controls', - '@storybook/addon-viewport', - 'storybook-addon-designs', - 'storybook-addon-rtl-direction', - 'storybook-dark-mode', - ], - stories: ['../src/**/*.stories.ts'], -} diff --git a/.storybook/preview.js b/.storybook/preview.js deleted file mode 100644 index c3b705822..000000000 --- a/.storybook/preview.js +++ /dev/null @@ -1,11 +0,0 @@ -import '!style-loader!css-loader!sass-loader!../src/theme/theme.design-system.scss'; -import '!style-loader!css-loader!sass-loader!./styles.scss'; - -export const parameters = { - layout: 'centered', - darkMode: { - darkClass: 'dark', - classTarget: 'html', - stylePreview: true, - }, -}; diff --git a/.storybook/styles.scss b/.storybook/styles.scss deleted file mode 100644 index 8be75bade..000000000 --- a/.storybook/styles.scss +++ /dev/null @@ -1,7 +0,0 @@ -storybook-dynamic-app-root { - color: var(--ion-text-color); -} - -.core-error-info { - max-width: 300px; -} diff --git a/.storybook/tsconfig.json b/.storybook/tsconfig.json deleted file mode 100644 index a8a27caf8..000000000 --- a/.storybook/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "extends": "../tsconfig.json", - "include": [ - "../src/**/*" - ], - "exclude": [ - "../src/**/tests/**", - "../src/testing/**", - "../src/**/*.test.ts" - ] -} diff --git a/package.json b/package.json index 6de706636..2032c4f3f 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,6 @@ "dev:ios": "ionic cordova run ios", "prod:android": "npm run prod --prefix cordova-plugin-moodleapp && NODE_ENV=production ionic cordova run android --prod", "prod:ios": "NODE_ENV=production ionic cordova run ios --prod", - "storybook": "start-storybook -p 6006", "test": "NODE_ENV=testing gulp && jest --verbose", "test:ci": "NODE_ENV=testing gulp && jest -ci --runInBand --verbose", "test:watch": "NODE_ENV=testing gulp watch & jest --watch", diff --git a/src/assets/storybook/courses.json b/src/assets/storybook/courses.json deleted file mode 100644 index 81b9390e0..000000000 --- a/src/assets/storybook/courses.json +++ /dev/null @@ -1 +0,0 @@ -[{"id":1,"courseimage":"https://picsum.photos/500/500","shortname":"Moodle and Mountaineering","summary":"This course will introduce you to the basics of Alpine Mountaineering, while at the same time highlighting some of the great features of Moodle."},{"id":2,"courseimage":"assets/storybook/geopattern.svg","shortname":"Digital Literacy","summary":"This course explores Digital Literacy and its importance for teachers and students. The course is optimised for the Moodle App. Please try it out!"},{"id":3,"shortname":"Class and Conflict in World Cinema","summary":"In this module we will analyse two very significant films - City of God and La Haine, both of which depict violent lives in poor conditions, the former in the favelas of Brazil and the latter in a Parisian banlieue. We will look at how conflict and class are portrayed, focusing particularly on the use of mise en scène."}] diff --git a/src/assets/storybook/geopattern.svg b/src/assets/storybook/geopattern.svg deleted file mode 100644 index 60e7e8a9d..000000000 --- a/src/assets/storybook/geopattern.svg +++ /dev/null @@ -1,2 +0,0 @@ - - \ No newline at end of file diff --git a/src/assets/storybook/sites/companylisa.ts b/src/assets/storybook/sites/companylisa.ts deleted file mode 100644 index 3689523d7..000000000 --- a/src/assets/storybook/sites/companylisa.ts +++ /dev/null @@ -1,32 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { CoreSiteFixture } from '@/storybook/stubs/classes/site'; - -export const companyLisaSite: CoreSiteFixture = { - id: 'companylisasite', - info: { - version: '2022041900', - sitename: 'Company', - username: 'lisa', - firstname: 'Lisa', - lastname: 'Díaz', - fullname: 'Lisa Díaz', - lang: 'en', - userid: 1, - siteurl: 'https://company.example.edu', - userpictureurl: 'https://i.pravatar.cc/300?user=companylisa', - functions: [], - }, -}; diff --git a/src/assets/storybook/sites/schoolbarbara.ts b/src/assets/storybook/sites/schoolbarbara.ts deleted file mode 100644 index c4fa3eda3..000000000 --- a/src/assets/storybook/sites/schoolbarbara.ts +++ /dev/null @@ -1,32 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { CoreSiteFixture } from '@/storybook/stubs/classes/site'; - -export const schoolBarbaraSite: CoreSiteFixture = { - id: 'schoolbarbarasite', - info: { - version: '2022041900', - sitename: 'School', - username: 'barbara', - firstname: 'Barbara', - lastname: 'Gardner', - fullname: 'Barbara Gardner', - lang: 'en', - userid: 1, - siteurl: 'https://campus.example.edu', - userpictureurl: 'https://i.pravatar.cc/300?user=schoolbarbara', - functions: [], - }, -}; diff --git a/src/assets/storybook/sites/schooljeffery.ts b/src/assets/storybook/sites/schooljeffery.ts deleted file mode 100644 index c7823f2b0..000000000 --- a/src/assets/storybook/sites/schooljeffery.ts +++ /dev/null @@ -1,32 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { CoreSiteFixture } from '@/storybook/stubs/classes/site'; - -export const schoolJefferySite: CoreSiteFixture = { - id: 'schooljefferysite', - info: { - version: '2022041900', - sitename: 'School', - username: 'jeffery', - firstname: 'Jeffery', - lastname: 'Sanders', - fullname: 'Jeffery Sanders', - lang: 'en', - userid: 2, - siteurl: 'https://campus.example.edu', - userpictureurl: 'https://i.pravatar.cc/300?user=schooljeffery', - functions: [], - }, -}; diff --git a/src/core/components/stories/components/components.module.ts b/src/core/components/stories/components/components.module.ts deleted file mode 100644 index d0648467e..000000000 --- a/src/core/components/stories/components/components.module.ts +++ /dev/null @@ -1,43 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { CoreEmptyBoxPageComponent } from './empty-box-page/empty-box-page'; -import { CoreEmptyBoxWrapperComponent } from './empty-box-wrapper/empty-box-wrapper'; -import { StorybookModule } from '@/storybook/storybook.module'; -import { CoreSearchComponentsModule } from '@features/search/components/components.module'; -import { CoreComponentsModule } from '@components/components.module'; -import { CommonModule } from '@angular/common'; -import { CoreCourseImageCardsPageComponent } from '@components/stories/components/course-image-cards-page/course-image-cards-page'; -import { CoreCourseImageListPageComponent } from '@components/stories/components/course-image-list-page/course-image-list-page'; -import { CoreSitesListWrapperComponent } from './sites-list-wrapper/sites-list-wrapper'; -import { CoreDirectivesModule } from '@directives/directives.module'; - -@NgModule({ - declarations: [ - CoreCourseImageCardsPageComponent, - CoreCourseImageListPageComponent, - CoreEmptyBoxPageComponent, - CoreEmptyBoxWrapperComponent, - CoreSitesListWrapperComponent, - ], - imports: [ - CommonModule, - StorybookModule, - CoreDirectivesModule, - CoreComponentsModule, - CoreSearchComponentsModule, - ], -}) -export class CoreComponentsStorybookModule {} diff --git a/src/core/components/stories/components/course-image-cards-page/course-image-cards-page.html b/src/core/components/stories/components/course-image-cards-page/course-image-cards-page.html deleted file mode 100644 index f1ad00bca..000000000 --- a/src/core/components/stories/components/course-image-cards-page/course-image-cards-page.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - -

Course Cards

-
-
-
- - -
- -
- - {{ course.shortname }} - - - {{ course.summary }} - -
-
-
diff --git a/src/core/components/stories/components/course-image-cards-page/course-image-cards-page.scss b/src/core/components/stories/components/course-image-cards-page/course-image-cards-page.scss deleted file mode 100644 index 23f07c6fd..000000000 --- a/src/core/components/stories/components/course-image-cards-page/course-image-cards-page.scss +++ /dev/null @@ -1,16 +0,0 @@ -:host { - - ion-card { - max-width: 350px; - margin-right: auto; - margin-left: auto; - } - - .course-image-wrapper { - width: 100%; - height: 0; - padding-top: 40%; - position: relative; - } - -} diff --git a/src/core/components/stories/components/course-image-cards-page/course-image-cards-page.ts b/src/core/components/stories/components/course-image-cards-page/course-image-cards-page.ts deleted file mode 100644 index f2b6b0323..000000000 --- a/src/core/components/stories/components/course-image-cards-page/course-image-cards-page.ts +++ /dev/null @@ -1,28 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component } from '@angular/core'; -import { CoreCourseListItem } from '@features/courses/services/courses'; -import courses from '@/assets/storybook/courses.json'; - -@Component({ - selector: 'core-course-image-cards-page', - templateUrl: 'course-image-cards-page.html', - styleUrls: ['./course-image-cards-page.scss'], -}) -export class CoreCourseImageCardsPageComponent { - - courses: Partial[] = courses; - -} diff --git a/src/core/components/stories/components/course-image-list-page/course-image-list-page.html b/src/core/components/stories/components/course-image-list-page/course-image-list-page.html deleted file mode 100644 index f9638bea7..000000000 --- a/src/core/components/stories/components/course-image-list-page/course-image-list-page.html +++ /dev/null @@ -1,19 +0,0 @@ - - - - -

Courses List

-
-
-
- - - - - - {{ course.shortname }} - - - - -
diff --git a/src/core/components/stories/components/course-image-list-page/course-image-list-page.ts b/src/core/components/stories/components/course-image-list-page/course-image-list-page.ts deleted file mode 100644 index cf66b61f0..000000000 --- a/src/core/components/stories/components/course-image-list-page/course-image-list-page.ts +++ /dev/null @@ -1,27 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component } from '@angular/core'; -import { CoreCourseListItem } from '@features/courses/services/courses'; -import courses from '@/assets/storybook/courses.json'; - -@Component({ - selector: 'core-course-image-list-page', - templateUrl: 'course-image-list-page.html', -}) -export class CoreCourseImageListPageComponent { - - courses: Partial[] = courses; - -} diff --git a/src/core/components/stories/components/empty-box-page/empty-box-page.html b/src/core/components/stories/components/empty-box-page/empty-box-page.html deleted file mode 100644 index 0bd2c567a..000000000 --- a/src/core/components/stories/components/empty-box-page/empty-box-page.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - -

Search

-
-
-
- -
- - -
-
-
diff --git a/src/core/components/stories/components/empty-box-page/empty-box-page.ts b/src/core/components/stories/components/empty-box-page/empty-box-page.ts deleted file mode 100644 index a290850b8..000000000 --- a/src/core/components/stories/components/empty-box-page/empty-box-page.ts +++ /dev/null @@ -1,27 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component, Input } from '@angular/core'; - -@Component({ - selector: 'core-empty-box-page', - templateUrl: 'empty-box-page.html', -}) -export class CoreEmptyBoxPageComponent { - - @Input() icon!: string; - @Input() content!: string; - @Input() dimmed!: boolean; - -} diff --git a/src/core/components/stories/components/empty-box-wrapper/empty-box-wrapper.html b/src/core/components/stories/components/empty-box-wrapper/empty-box-wrapper.html deleted file mode 100644 index 10dc9fa5f..000000000 --- a/src/core/components/stories/components/empty-box-wrapper/empty-box-wrapper.html +++ /dev/null @@ -1,3 +0,0 @@ - -
-
diff --git a/src/core/components/stories/components/empty-box-wrapper/empty-box-wrapper.ts b/src/core/components/stories/components/empty-box-wrapper/empty-box-wrapper.ts deleted file mode 100644 index 6b99f2a47..000000000 --- a/src/core/components/stories/components/empty-box-wrapper/empty-box-wrapper.ts +++ /dev/null @@ -1,38 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component, Input, OnChanges } from '@angular/core'; -import { DomSanitizer } from '@singletons'; -import { SafeHtml } from '@angular/platform-browser'; - -@Component({ - selector: 'core-empty-box-wrapper', - templateUrl: 'empty-box-wrapper.html', -}) -export class CoreEmptyBoxWrapperComponent implements OnChanges { - - @Input() icon!: string; - @Input() content!: string; - @Input() dimmed!: boolean; - - html?: SafeHtml; - - /** - * @inheritdoc - */ - ngOnChanges(): void { - this.html = DomSanitizer.bypassSecurityTrustHtml(this.content); - } - -} diff --git a/src/core/components/stories/components/sites-list-wrapper/sites-list-wrapper.html b/src/core/components/stories/components/sites-list-wrapper/sites-list-wrapper.html deleted file mode 100644 index a7b72397b..000000000 --- a/src/core/components/stories/components/sites-list-wrapper/sites-list-wrapper.html +++ /dev/null @@ -1,23 +0,0 @@ - - - - - -

Extra text for user {{ site.fullname }}

- {{ site.badge }} MB -
- - - - - - - - {{site.badge}} - - - -
-
-
diff --git a/src/core/components/stories/components/sites-list-wrapper/sites-list-wrapper.ts b/src/core/components/stories/components/sites-list-wrapper/sites-list-wrapper.ts deleted file mode 100644 index 06dc02b22..000000000 --- a/src/core/components/stories/components/sites-list-wrapper/sites-list-wrapper.ts +++ /dev/null @@ -1,60 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component, Input, OnChanges, OnInit, SimpleChanges } from '@angular/core'; -import { CoreAccountsList, CoreLoginHelper } from '@features/login/services/login-helper'; -import { CoreSiteBasicInfo } from '@services/sites'; - -@Component({ - selector: 'core-sites-list-wrapper', - templateUrl: 'sites-list-wrapper.html', -}) -export class CoreSitesListWrapperComponent implements OnInit, OnChanges { - - @Input() sitesClickable = false; - @Input() currentSiteClickableSelect = 'undefined'; - @Input() extraText: 'text' | 'badge' | 'none' = 'none'; - @Input() extraDetails: 'delete-button' | 'badge' | 'none' = 'none'; - - accountsList?: CoreAccountsList; - currentSiteClickable?: boolean; - - /** - * @inheritdoc - */ - async ngOnInit(): Promise { - this.accountsList = await CoreLoginHelper.getAccountsList(); - } - - /** - * @inheritdoc - */ - async ngOnChanges(changes: SimpleChanges): Promise { - if (changes.currentSiteClickableSelect) { - this.currentSiteClickable = this.currentSiteClickableSelect === 'undefined' ? - undefined : - this.currentSiteClickableSelect === 'true'; - } - } - - /** - * Site clicked. - * - * @param site Site. - */ - siteClicked(site: CoreSiteBasicInfo): void { - alert(`clicked on ${site.id} - ${site.fullname}`); - } - -} diff --git a/src/core/components/stories/course-image.stories.ts b/src/core/components/stories/course-image.stories.ts deleted file mode 100644 index cd919a6fe..000000000 --- a/src/core/components/stories/course-image.stories.ts +++ /dev/null @@ -1,104 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Meta, moduleMetadata } from '@storybook/angular'; - -import { story } from '@/storybook/utils/helpers'; - -import { CoreCourseImageComponent } from '@components/course-image/course-image'; -import { APP_INITIALIZER } from '@angular/core'; -import { CoreSitesStub } from '@/storybook/stubs/services/sites'; -import { CoreCourseImageListPageComponent } from '@components/stories/components/course-image-list-page/course-image-list-page'; -import { CoreComponentsStorybookModule } from '@components/stories/components/components.module'; -import { CoreCourseImageCardsPageComponent } from '@components/stories/components/course-image-cards-page/course-image-cards-page'; - -interface Args { - type: 'image' | 'geopattern' | 'color'; - fill: boolean; -} - -export default { - title: 'Core/Course Image', - component: CoreCourseImageComponent, - decorators: [ - moduleMetadata({ - imports: [CoreComponentsStorybookModule], - providers: [ - { - provide: APP_INITIALIZER, - multi: true, - useValue: () => { - const site = CoreSitesStub.getRequiredCurrentSite(); - - site.stubWSResponse('tool_mobile_get_config', { - settings: [ - { name: 'core_admin_coursecolor1', value: '#F9B000' }, - { name: 'core_admin_coursecolor2', value: '#EF4B00' }, - { name: 'core_admin_coursecolor3', value: '#4338FB' }, - { name: 'core_admin_coursecolor4', value: '#E142FB' }, - { name: 'core_admin_coursecolor5', value: '#FF0064' }, - { name: 'core_admin_coursecolor6', value: '#FF0F18' }, - { name: 'core_admin_coursecolor7', value: '#039B06' }, - { name: 'core_admin_coursecolor8', value: '#039B88' }, - { name: 'core_admin_coursecolor9', value: '#EF009B' }, - { name: 'core_admin_coursecolor10', value: '#020B6E' }, - ], - warnings: [], - }); - }, - }, - ], - }), - ], - argTypes: { - type: { - control: { - type: 'select', - options: ['image', 'geopattern', 'color'], - }, - }, - }, - args: { - type: 'image', - fill: false, - }, -}; - -const Template = story(({ type, ...args }) => { - const getImageSource = () => { - switch (type) { - case 'image': - return 'https://picsum.photos/500/500'; - case 'geopattern': - return 'assets/storybook/geopattern.svg'; - case 'color': - return undefined; - } - }; - - return { - component: CoreCourseImageComponent, - props: { - ...args, - course: { - id: 1, - courseimage: getImageSource(), - }, - }, - }; -}); - -export const Primary = story(Template); -export const ListPage = story(() => ({ component: CoreCourseImageListPageComponent })); -export const CardsPage = story(() => ({ component: CoreCourseImageCardsPageComponent })); diff --git a/src/core/components/stories/empty-box.stories.ts b/src/core/components/stories/empty-box.stories.ts deleted file mode 100644 index 8b2922fa6..000000000 --- a/src/core/components/stories/empty-box.stories.ts +++ /dev/null @@ -1,79 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Meta, moduleMetadata } from '@storybook/angular'; -import { marked } from 'marked'; - -import { story } from '@/storybook/utils/helpers'; - -import { CoreEmptyBoxComponent } from '@components/empty-box/empty-box'; -import { CoreEmptyBoxWrapperComponent } from './components/empty-box-wrapper/empty-box-wrapper'; -import { CoreEmptyBoxPageComponent } from './components/empty-box-page/empty-box-page'; -import { CoreComponentsStorybookModule } from './components/components.module'; - -interface Args { - icon: string; - content: string; - dimmed: boolean; -} - -export default > { - title: 'Core/Empty Box', - component: CoreEmptyBoxComponent, - decorators: [ - moduleMetadata({ imports: [CoreComponentsStorybookModule] }), - ], - argTypes: { - icon: { - control: { - type: 'select', - options: ['fas-magnifying-glass', 'fas-user', 'fas-check'], - }, - }, - }, - args: { - icon: 'fas-user', - content: 'No users', - dimmed: false, - }, -}; - -const WrapperTemplate = story((args) => ({ - component: CoreEmptyBoxWrapperComponent, - props: { - ...args, - content: marked(args.content), - }, -})); - -const PageTemplate = story((args) => ({ - component: CoreEmptyBoxPageComponent, - props: { - ...args, - content: marked(args.content), - }, -})); - -export const Primary = story(WrapperTemplate); - -export const Example = story(PageTemplate, { - icon: 'fas-magnifying-glass', - content: '**No results for "Test Search"**\n\nCheck for typos or try using different keywords', -}); - -export const DimmedExample = story(PageTemplate, { - icon: 'fas-magnifying-glass', - content: 'What are you searching for?', - dimmed: true, -}); diff --git a/src/core/components/stories/error-info.stories.ts b/src/core/components/stories/error-info.stories.ts deleted file mode 100644 index 9c67a6d13..000000000 --- a/src/core/components/stories/error-info.stories.ts +++ /dev/null @@ -1,50 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Meta, moduleMetadata, Story } from '@storybook/angular'; - -import { story } from '@/storybook/utils/helpers'; -import { StorybookModule } from '@/storybook/storybook.module'; - -import { CoreErrorInfoComponent } from '@components/error-info/error-info'; - -interface Args { - errorCode: string; - errorDetails: string; -} - -export default > { - title: 'Core/Error Info', - component: CoreErrorInfoComponent, - decorators: [ - moduleMetadata({ - declarations: [CoreErrorInfoComponent], - imports: [StorybookModule], - }), - ], - args: { - errorCode: '', - errorDetails: - 'AJAX endpoint not found. ' + - 'This can happen if the Moodle site is too old or it blocks access to this endpoint. ' + - 'The Moodle app only supports Moodle systems 3.5 onwards.', - }, -}; - -const Template: Story = (args) => ({ - component: CoreErrorInfoComponent, - props: args, -}); - -export const Primary = story(Template); diff --git a/src/core/components/stories/sites-list.stories.ts b/src/core/components/stories/sites-list.stories.ts deleted file mode 100644 index 0fa75f7e5..000000000 --- a/src/core/components/stories/sites-list.stories.ts +++ /dev/null @@ -1,78 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Meta, moduleMetadata } from '@storybook/angular'; - -import { story } from '@/storybook/utils/helpers'; -import { CoreSitesListComponent } from '@components/sites-list/sites-list'; -import { CoreSitesListWrapperComponent } from './components/sites-list-wrapper/sites-list-wrapper'; -import { CoreComponentsStorybookModule } from './components/components.module'; - -interface Args { - sitesClickable: boolean; - currentSiteClickable: 'true' | 'false' | 'undefined'; - extraText: 'text' | 'badge' | 'none'; - extraDetails: 'delete-button' | 'badge' | 'none'; -} - -export default > { - title: 'Core/Sites List', - component: CoreSitesListComponent, - decorators: [ - moduleMetadata({ imports: [CoreComponentsStorybookModule] }), - ], - argTypes: { - sitesClickable: { - control: { - type: 'boolean', - }, - }, - currentSiteClickable: { - control: { - type: 'select', - options: ['true', 'false', 'undefined'], - }, - }, - extraText: { - control: { - type: 'select', - options: ['text', 'badge', 'none'], - }, - }, - extraDetails: { - control: { - type: 'select', - options: ['delete-button', 'badge', 'none'], - }, - }, - }, - args: { - sitesClickable: false, - currentSiteClickable: 'undefined', - extraText: 'none', - extraDetails: 'none', - }, -}; - -const Template = story(({ sitesClickable, currentSiteClickable, extraText, extraDetails }) => ({ - component: CoreSitesListWrapperComponent, - props: { - sitesClickable, - currentSiteClickableSelect: currentSiteClickable, - extraText, - extraDetails, - }, -})); - -export const Primary = story(Template); diff --git a/src/core/components/stories/user-avatar.stories.ts b/src/core/components/stories/user-avatar.stories.ts deleted file mode 100644 index 64303d414..000000000 --- a/src/core/components/stories/user-avatar.stories.ts +++ /dev/null @@ -1,37 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Meta, moduleMetadata, Story } from '@storybook/angular'; - -import { story } from '@/storybook/utils/helpers'; -import { StorybookModule } from '@/storybook/storybook.module'; - -import { CoreUserAvatarComponent } from '@components/user-avatar/user-avatar'; - -export default { - title: 'Core/User Avatar', - component: CoreUserAvatarComponent, - decorators: [ - moduleMetadata({ - declarations: [CoreUserAvatarComponent], - imports: [StorybookModule], - }), - ], -}; - -const Template: Story = () => ({ - component: CoreUserAvatarComponent, -}); - -export const Primary = story(Template); diff --git a/src/core/features/search/stories/components/components.module.ts b/src/core/features/search/stories/components/components.module.ts deleted file mode 100644 index 1e59da784..000000000 --- a/src/core/features/search/stories/components/components.module.ts +++ /dev/null @@ -1,37 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { NgModule } from '@angular/core'; -import { StorybookModule } from '@/storybook/storybook.module'; -import { CoreSearchComponentsModule } from '@features/search/components/components.module'; -import { CoreComponentsModule } from '@components/components.module'; -import { CommonModule } from '@angular/common'; -import { - CoreSearchGlobalSearchResultsPageComponent, -} from '@features/search/stories/components/global-search-results-page/global-search-results-page'; -import { CoreSharedModule } from '@/core/shared.module'; - -@NgModule({ - declarations: [ - CoreSearchGlobalSearchResultsPageComponent, - ], - imports: [ - CoreSharedModule, - CommonModule, - StorybookModule, - CoreComponentsModule, - CoreSearchComponentsModule, - ], -}) -export class CoreSearchComponentsStorybookModule {} diff --git a/src/core/features/search/stories/components/global-search-results-page/global-search-results-page.html b/src/core/features/search/stories/components/global-search-results-page/global-search-results-page.html deleted file mode 100644 index eeb81da2c..000000000 --- a/src/core/features/search/stories/components/global-search-results-page/global-search-results-page.html +++ /dev/null @@ -1,18 +0,0 @@ - - - - -

Search Results

-
-
-
- -
- - - - -
-
-
diff --git a/src/core/features/search/stories/components/global-search-results-page/global-search-results-page.ts b/src/core/features/search/stories/components/global-search-results-page/global-search-results-page.ts deleted file mode 100644 index 6154c5d22..000000000 --- a/src/core/features/search/stories/components/global-search-results-page/global-search-results-page.ts +++ /dev/null @@ -1,141 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Component } from '@angular/core'; -import { CoreCourseListItem } from '@features/courses/services/courses'; -import { CoreUserWithAvatar } from '@components/user-avatar/user-avatar'; -import { CoreSearchGlobalSearchResult } from '@features/search/services/global-search'; -import courses from '@/assets/storybook/courses.json'; - -@Component({ - selector: 'core-search-global-search-results-page', - templateUrl: 'global-search-results-page.html', -}) -export class CoreSearchGlobalSearchResultsPageComponent { - - results: CoreSearchGlobalSearchResult[] = [ - { - id: 1, - url: '', - title: 'Activity forum test', - content: 'this is a content test for a forum to see in the search result.', - context: { - courseName: 'Course 102', - userName: 'Stephania Krovalenko', - }, - module: { - name: 'forum', - iconurl: 'assets/img/mod/forum.svg', - area: 'activity', - }, - }, - { - id: 2, - url: '', - title: 'Activity assignment test', - content: 'this is a content test for a forum to see in the search result.', - context: { - courseName: 'Course 102', - }, - module: { - name: 'assign', - iconurl: 'assets/img/mod/assign.svg', - area: '', - }, - }, - { - id: 3, - url: '', - title: 'Course 101', - course: courses[0] as CoreCourseListItem, - }, - { - id: 4, - url: '', - title: 'John the Tester', - user: { - fullname: 'John Doe', - profileimageurl: 'https://placekitten.com/300/300', - } as CoreUserWithAvatar, - }, - { - id: 5, - url: '', - title: 'Search result title', - content: 'this is a content test for a forum to see in the search result.', - context: { - userName: 'Stephania Krovalenko', - }, - module: { - name: 'forum', - iconurl: 'assets/img/mod/forum.svg', - area: 'post', - }, - }, - { - id: 6, - url: '', - title: 'Side block', - context: { - courseName: 'Moodle Site', - }, - component: { - name: 'block_html', - iconurl: 'https://master.mm.moodledemo.net/theme/image.php?theme=boost&component=core&image=e%2Fanchor', - }, - }, - { - id: 7, - url: '', - title: 'Course section', - context: { - courseName: 'Course 101', - }, - component: { - name: 'core_course', - iconurl: 'https://master.mm.moodledemo.net/theme/image.php?theme=boost&component=core&image=i%2Fsection', - }, - }, - { - id: 8, - url: '', - title: 'This item has long text everywhere, so make sure that it looks good anyways. ' + - 'Even if the screen you\'re using is also big, this should still be a problem because this text is *really* long.', - content: 'You would normally see lorem ipsum here, but we decided to just write some gibberish here to make it more ' + - 'real. We all know that lorem ipsum is fabricated text, and even though it serves its purpose, it isn\'t as ' + - 'engaging as some real, hand-crafted text (not sure why this should be engaging, anyways).', - context: { - courseName: 'And it\'s not just the title, either. Other things like the Course title also take more than ' + - 'you would expect in a normal site (or even not so normal).', - userName: 'To top it off, it has a user name as well! What is this madness? Well, at some point you just have to ' + - 'get creative. Honestly, I\'m surprised if you\'re even reading this. Kudos to you for being thorough.', - }, - module: { - name: 'book', - iconurl: 'assets/img/mod/book.svg', - area: '', - }, - }, - ]; - - /** - * Result clicked. - * - * @param title Result title. - */ - resultClicked(title: string): void { - alert(`clicked on ${title}`); - } - -} diff --git a/src/core/features/search/stories/global-search-result.stories.ts b/src/core/features/search/stories/global-search-result.stories.ts deleted file mode 100644 index 8bc43c2bd..000000000 --- a/src/core/features/search/stories/global-search-result.stories.ts +++ /dev/null @@ -1,136 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Meta, moduleMetadata } from '@storybook/angular'; - -import { story } from '@/storybook/utils/helpers'; - -import { CoreSearchGlobalSearchResultComponent } from '@features/search/components/global-search-result/global-search-result'; -import { CoreSearchComponentsStorybookModule } from '@features/search/stories/components/components.module'; -import { - CoreSearchGlobalSearchResultsPageComponent, -} from '@features/search/stories/components/global-search-results-page/global-search-results-page'; -import { APP_INITIALIZER } from '@angular/core'; -import { CoreCourseModuleDelegate } from '@features/course/services/module-delegate'; -import { AddonModForumModuleHandler } from '@addons/mod/forum/services/handlers/module'; -import { AddonModAssignModuleHandler } from '@addons/mod/assign/services/handlers/module'; -import { CoreSearchGlobalSearchResult } from '@features/search/services/global-search'; -import { CoreUserWithAvatar } from '@components/user-avatar/user-avatar'; -import { CoreCourseListItem } from '@features/courses/services/courses'; -import courses from '@/assets/storybook/courses.json'; - -interface Args { - title: string; - content: string; - image: 'course' | 'user' | 'none'; - module: 'forum-activity' | 'forum-post' | 'assign' | 'none'; - courseContext: boolean; - userContext: boolean; - showCourse: boolean; -} - -export default > { - title: 'Core/Search/Global Search Result', - component: CoreSearchGlobalSearchResultComponent, - decorators: [ - moduleMetadata({ - imports: [CoreSearchComponentsStorybookModule], - providers: [ - { - provide: APP_INITIALIZER, - multi: true, - useValue() { - CoreCourseModuleDelegate.registerHandler(AddonModForumModuleHandler.instance); - CoreCourseModuleDelegate.registerHandler(AddonModAssignModuleHandler.instance); - CoreCourseModuleDelegate.updateHandlers(); - }, - }, - ], - }), - ], - argTypes: { - image: { - control: { - type: 'select', - options: ['course', 'user', 'none'], - }, - }, - module: { - control: { - type: 'select', - options: ['forum-activity', 'forum-post', 'assign', 'none'], - }, - }, - }, - args: { - title: 'Result #1', - content: 'This item seems really interesting, maybe you should click through', - image: 'none', - module: 'none', - courseContext: false, - userContext: false, - showCourse: true, - }, - parameters: { - design: { - type: 'figma', - url: 'https://www.figma.com/file/h3E7pkfgyImJPaYmTfnwuF/Global-Search?node-id=118%3A4610', - }, - }, -}; - -const Template = story(({ image, courseContext, userContext, module, showCourse, ...args }) => { - const result: CoreSearchGlobalSearchResult = { - ...args, - id: 1, - url: '', - }; - - if (courseContext || userContext) { - result.context = { - courseName: courseContext ? 'Course 101' : undefined, - userName: userContext ? 'John Doe' : undefined, - }; - } - - if (module !== 'none') { - const name = module.startsWith('forum') ? 'forum' : module; - - result.module = { - name, - iconurl: `assets/img/mod/${name}.svg`, - area: module.startsWith('forum') ? module.substring(6) : '', - }; - } - - switch (image) { - case 'course': - result.course = courses[0] as CoreCourseListItem; - break; - case 'user': - result.user = { - fullname: 'John Doe', - profileimageurl: 'https://placekitten.com/300/300', - } as CoreUserWithAvatar; - break; - } - - return { - component: CoreSearchGlobalSearchResultComponent, - props: { result, showCourse }, - }; -}); - -export const Primary = story(Template); -export const ResultsPage = story(() => ({ component: CoreSearchGlobalSearchResultsPageComponent })); diff --git a/src/storybook/storybook.module.ts b/src/storybook/storybook.module.ts deleted file mode 100644 index b8aa614d7..000000000 --- a/src/storybook/storybook.module.ts +++ /dev/null @@ -1,78 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { IonicModule } from '@ionic/angular'; -import { NgModule, ApplicationInitStatus, APP_INITIALIZER } from '@angular/core'; -import { Observable, of } from 'rxjs'; -import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; - -import englishTranslations from '@/assets/lang/en.json'; -import { CoreApplicationInitStatus } from '@classes/application-init-status'; -import { Translate } from '@singletons'; -import { CoreSitesProviderStub, CoreSitesStub } from '@/storybook/stubs/services/sites'; -import { CoreSitesProvider } from '@services/sites'; -import { CoreDbProviderStub } from '@/storybook/stubs/services/db'; -import { CoreDbProvider } from '@services/db'; -import { CoreFilepoolProviderStub } from '@/storybook/stubs/services/filepool'; -import { CoreFilepoolProvider } from '@services/filepool'; -import { HttpClientStub } from '@/storybook/stubs/services/http'; -import { HttpClient } from '@angular/common/http'; -import { CorePushNotificationsProvider } from '@features/pushnotifications/services/pushnotifications'; -import { CorePushNotificationsProviderStub } from './stubs/services/pushnotifications'; - -// For translate loader. AoT requires an exported function for factories. -export class StaticTranslateLoader extends TranslateLoader { - - getTranslation(): Observable { - return of(englishTranslations); - } - -} - -/** - * Module declaring dependencies for Storybook components. - */ -@NgModule({ - imports: [ - IonicModule.forRoot(), - TranslateModule.forRoot({ - loader: { - provide: TranslateLoader, - useClass: StaticTranslateLoader, - }, - }), - ], - providers: [ - { provide: ApplicationInitStatus, useClass: CoreApplicationInitStatus }, - { provide: CoreSitesProvider, useClass: CoreSitesProviderStub }, - { provide: CoreDbProvider, useClass: CoreDbProviderStub }, - { provide: CoreFilepoolProvider, useClass: CoreFilepoolProviderStub }, - { provide: CorePushNotificationsProvider, useClass: CorePushNotificationsProviderStub }, - { provide: HttpClient, useClass: HttpClientStub }, - { - provide: APP_INITIALIZER, - multi: true, - useValue: () => { - Translate.setDefaultLang('en'); - Translate.use('en'); - CoreSitesStub.stubCurrentSite(); - }, - }, - ], - exports: [ - IonicModule, - TranslateModule, - ], -}) -export class StorybookModule {} diff --git a/src/storybook/stubs/classes/site.ts b/src/storybook/stubs/classes/site.ts deleted file mode 100644 index 4d266913b..000000000 --- a/src/storybook/stubs/classes/site.ts +++ /dev/null @@ -1,59 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { CoreSiteWSPreSets, WSObservable } from '@classes/sites/authenticated-site'; -import { CoreSite, CoreSiteConfigResponse } from '@classes/sites/site'; -import { CoreSiteInfo } from '@classes/sites/unauthenticated-site'; -import { of } from 'rxjs'; - -export interface CoreSiteFixture { - id: string; - info: CoreSiteInfo; -} - -export class CoreSiteStub extends CoreSite { - - protected wsStubs: Record = {}; - - constructor (fixture: CoreSiteFixture) { - super(fixture.id, fixture.info.siteurl, '', { info: fixture.info }); - - this.stubWSResponse('tool_mobile_get_config', { - settings: [], - warnings: [], - }); - } - - /** - * @inheritdoc - */ - readObservable(wsFunction: string, data: unknown, preSets?: CoreSiteWSPreSets): WSObservable { - if (wsFunction in this.wsStubs) { - return of(this.wsStubs[wsFunction] as T); - } - - return super.readObservable(wsFunction, data, preSets); - } - - /** - * Prepare as stubbed response for a given WS. - * - * @param wsFunction WS function. - * @param response Response. - */ - stubWSResponse(wsFunction: string, response: T): void { - this.wsStubs[wsFunction] = response; - } - -} diff --git a/src/storybook/stubs/classes/sqlitedb.ts b/src/storybook/stubs/classes/sqlitedb.ts deleted file mode 100644 index f35345951..000000000 --- a/src/storybook/stubs/classes/sqlitedb.ts +++ /dev/null @@ -1,32 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { SQLiteDB } from '@classes/sqlitedb'; -import { SQLiteObject } from '@awesome-cordova-plugins/sqlite/ngx'; - -/** - * SQlite database stub. - */ -export class SQLiteDBStub extends SQLiteDB { - - /** - * @inheritdoc - */ - async createDatabase(): Promise { - return new Proxy({ - executeSql: () => Promise.resolve({ insertId: Math.random().toString() }), - }, {}) as unknown as SQLiteObject; - } - -} diff --git a/src/storybook/stubs/services/db.ts b/src/storybook/stubs/services/db.ts deleted file mode 100644 index e74c90bb2..000000000 --- a/src/storybook/stubs/services/db.ts +++ /dev/null @@ -1,35 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { SQLiteDBStub } from '@/storybook/stubs/classes/sqlitedb'; -import { SQLiteDB } from '@classes/sqlitedb'; -import { CoreDbProvider } from '@services/db'; - -/** - * Database provider stub. - */ -export class CoreDbProviderStub extends CoreDbProvider { - - /** - * @inheritdoc - */ - getDB(name: string, forceNew?: boolean): SQLiteDB { - if (this.dbInstances[name] === undefined || forceNew) { - this.dbInstances[name] = new SQLiteDBStub(name); - } - - return this.dbInstances[name]; - } - -} diff --git a/src/storybook/stubs/services/filepool.ts b/src/storybook/stubs/services/filepool.ts deleted file mode 100644 index d5c604aad..000000000 --- a/src/storybook/stubs/services/filepool.ts +++ /dev/null @@ -1,32 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { makeSingleton } from '@singletons'; -import { CoreFilepoolProvider } from '@services/filepool'; - -/** - * Filepool provider stub. - */ -export class CoreFilepoolProviderStub extends CoreFilepoolProvider { - - /** - * @inheritdoc - */ - async getSrcByUrl(siteId: string, fileUrl: string): Promise { - return fileUrl; - } - -} - -export const CoreFilepoolStub = makeSingleton(CoreFilepoolProvider); diff --git a/src/storybook/stubs/services/http.ts b/src/storybook/stubs/services/http.ts deleted file mode 100644 index 55e397d72..000000000 --- a/src/storybook/stubs/services/http.ts +++ /dev/null @@ -1,38 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { makeSingleton } from '@singletons'; -import { HttpClient, HttpHandler } from '@angular/common/http'; -import { from, Observable } from 'rxjs'; - -/** - * Http service stub. - */ -export class HttpClientStub extends HttpClient { - - constructor() { - super(null as unknown as HttpHandler); - } - - /** - * @inheritdoc - */ - // eslint-disable-next-line @typescript-eslint/no-explicit-any - get(url: string): Observable { - return from(fetch(url).then(response => response.text())); - } - -} - -export const HttpStub = makeSingleton(HttpClient); diff --git a/src/storybook/stubs/services/pushnotifications.ts b/src/storybook/stubs/services/pushnotifications.ts deleted file mode 100644 index 9d380c32c..000000000 --- a/src/storybook/stubs/services/pushnotifications.ts +++ /dev/null @@ -1,32 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { CorePushNotificationsProvider } from '@features/pushnotifications/services/pushnotifications'; -import { makeSingleton } from '@singletons'; - -/** - * Sites provider stub. - */ -export class CorePushNotificationsProviderStub extends CorePushNotificationsProvider { - - /** - * @inheritdoc - */ - async getSiteCounter(): Promise { - return Math.round(Math.random() * 100); - } - -} - -export const CorePushNotificationsStub = makeSingleton(CorePushNotificationsProvider); diff --git a/src/storybook/stubs/services/sites.ts b/src/storybook/stubs/services/sites.ts deleted file mode 100644 index 52a60f351..000000000 --- a/src/storybook/stubs/services/sites.ts +++ /dev/null @@ -1,86 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { companyLisaSite } from '@/assets/storybook/sites/companylisa'; -import { schoolBarbaraSite } from '@/assets/storybook/sites/schoolbarbara'; -import { schoolJefferySite } from '@/assets/storybook/sites/schooljeffery'; -import { CoreSiteFixture, CoreSiteStub } from '@/storybook/stubs/classes/site'; -import { CoreError } from '@classes/errors/error'; -import { CoreSite } from '@classes/sites/site'; -import { SiteDBEntry } from '@services/database/sites'; -import { CoreSiteBasicInfo, CoreSitesProvider } from '@services/sites'; -import { makeSingleton } from '@singletons'; - -/** - * Sites provider stub. - */ -export class CoreSitesProviderStub extends CoreSitesProvider { - - protected static readonly SITES_FIXTURES = [schoolBarbaraSite, schoolJefferySite, companyLisaSite]; - - /** - * @inheritdoc - */ - getRequiredCurrentSite!: () => CoreSiteStub; - - /** - * @inheritdoc - */ - async getSites(ids?: string[]): Promise { - const sites = CoreSitesProviderStub.SITES_FIXTURES.map(site => ( { - id: site.id, - siteUrl: site.info.siteurl, - info: JSON.stringify(site.info), - token: '', - privateToken: '', - loggedOut: 0, - })); - - return this.siteDBRecordsToBasicInfo(sites, ids); - } - - /** - * @inheritdoc - */ - async getSite(siteId?: string): Promise { - if (!siteId) { - if (this.currentSite) { - return this.currentSite; - } - - throw new CoreError('No current site found.'); - } - - const siteFixture = CoreSitesProviderStub.SITES_FIXTURES.find(site => site.id === siteId); - if (!siteFixture) { - throw new CoreError('SiteId not found.'); - } - - return new CoreSiteStub(siteFixture); - } - - /** - * @inheritdoc - */ - stubCurrentSite(fixture?: CoreSiteFixture): CoreSiteStub { - if (!this.currentSite) { - this.currentSite = new CoreSiteStub(fixture ?? schoolBarbaraSite); - } - - return this.getRequiredCurrentSite(); - } - -} - -export const CoreSitesStub = makeSingleton(CoreSitesProvider); diff --git a/src/storybook/utils/helpers.ts b/src/storybook/utils/helpers.ts deleted file mode 100644 index 5ed8ae7b9..000000000 --- a/src/storybook/utils/helpers.ts +++ /dev/null @@ -1,30 +0,0 @@ -// (C) Copyright 2015 Moodle Pty Ltd. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -import { Story } from '@storybook/angular'; - -/** - * Define story. - * - * @param template Story template. - * @param defaultArgs Default arguments. - * @returns Story. - */ -export function story(template: Story, defaultArgs: Partial = {}): Story { - const story = template.bind({}); - - story.args = defaultArgs; - - return story; -} diff --git a/tsconfig.app.json b/tsconfig.app.json index addf75e8c..411dc5e5b 100644 --- a/tsconfig.app.json +++ b/tsconfig.app.json @@ -25,7 +25,6 @@ "src/**/tests/**", "src/**/stories/**", "src/testing/**", - "src/storybook/**", "src/**/*.test.ts", "src/**/*.stories.*" ]