From f3c7413f529be4a00dba7b0ab23904b48ea13a35 Mon Sep 17 00:00:00 2001 From: undergroundwires Date: Sun, 7 Mar 2021 19:33:05 +0100 Subject: [PATCH] restructure presentation layer - Move most GUI related code to /presentation - Move components to /components (separate from bootstrap and style) - Move shared components helpers to /components/shared - Rename Bootstrapping to bootstrapping to enforce same naming convention in /presentation --- docs/presentation.md | 20 ++++++++++++++++--- src/{ => presentation}/background.ts | 4 ++++ .../ApplicationBootstrapper.ts | 0 .../IVueBootstrapper.ts | 0 .../Modules/IconBootstrapper.ts | 0 .../Modules/TooltipBootstrapper.ts | 0 .../Modules/TreeBootstrapper.ts | 0 .../Modules/VModalBootstrapper.ts | 0 .../Modules/VueBootstrapper.ts | 0 src/{ => presentation/components}/App.vue | 10 +++++----- .../Code/CodeButtons/Code.vue | 0 .../Code/CodeButtons/IconButton.vue | 0 .../Code/CodeButtons/MacOsInstructions.vue | 0 .../Code/CodeButtons/TheCodeButtons.vue | 2 +- .../{ => components}/Code/TheCodeArea.vue | 4 ++-- .../Scripts/Cards/CardList.vue | 4 ++-- .../Scripts/Cards/CardListItem.vue | 4 ++-- .../Scripts/Cards/NonCollapsingDirective.ts | 0 .../Scripts/Menu/Grouping/Grouping.ts | 0 .../Scripts/Menu/Grouping/TheGrouper.vue | 0 .../Menu/Selector/SelectableOption.vue | 2 +- .../Scripts/Menu/Selector/TheSelector.vue | 2 +- .../Scripts/Menu/TheOsChanger.vue | 2 +- .../Scripts/Menu/TheScriptsMenu.vue | 2 +- .../Scripts/ScriptsTree/ScriptNodeParser.ts | 0 .../Scripts/ScriptsTree/ScriptsTree.vue | 2 +- .../SelectableTree/INodeSelectedEvent.ts | 0 .../SelectableTree/LiquorTree/LiquorTree.d.ts | 0 .../LiquorTree/LiquorTreeOptions.ts | 0 .../NodeWrapper/NodePredicateFilter.ts | 0 .../NodeWrapper/NodeStateUpdater.ts | 0 .../LiquorTree/NodeWrapper/NodeTranslator.ts | 0 .../SelectableTree/Node/DocumentationUrls.vue | 0 .../ScriptsTree/SelectableTree/Node/INode.ts | 0 .../ScriptsTree/SelectableTree/Node/Node.vue | 0 .../SelectableTree/Node/RevertToggle.vue | 2 +- .../Node/Reverter/CategoryReverter.ts | 0 .../SelectableTree/Node/Reverter/IReverter.ts | 0 .../Node/Reverter/ReverterFactory.ts | 0 .../Node/Reverter/ScriptReverter.ts | 0 .../SelectableTree/SelectableTree.vue | 0 .../Scripts/Slider/Handle.vue | 0 .../Scripts/Slider/HorizontalResizeSlider.vue | 0 .../Scripts/TheScriptArea.vue | 10 +++++----- .../Scripts/TheScriptsList.vue | 10 +++++----- .../{ => components/Shared}/Responsive.vue | 0 .../{ => components/Shared}/StatefulVue.ts | 2 +- .../{ => components/Shared}/Throttle.ts | 0 .../TheFooter/DownloadUrlList.vue | 0 .../TheFooter/DownloadUrlListItem.vue | 0 .../TheFooter/PrivacyPolicy.vue | 0 .../{ => components}/TheFooter/TheFooter.vue | 0 .../{ => components}/TheHeader.vue | 0 .../{ => components}/TheSearchBar.vue | 4 ++-- src/{ => presentation}/main.ts | 4 ++-- src/{ => presentation}/shims-tsx.d.ts | 0 src/{ => presentation}/shims-vue.d.ts | 0 .../Cards/NonCollapsingDirective.spec.ts | 4 ++-- .../ScriptsTree/ScriptNodeParser.spec.ts | 13 ++++++------ .../NodeWrapper/NodePredicateFilter.spec.ts | 4 ++-- .../NodeWrapper/NodeStateUpdater.spec.ts | 4 ++-- .../NodeWrapper/NodeTranslator.spec.ts | 4 ++-- .../Node/Reverter/CategoryReverter.spec.ts | 10 +++++----- .../Node/Reverter/ReverterFactory.spec.ts | 17 ++++++++-------- .../Node/Reverter/ScriptReverter.spec.ts | 12 +++++------ .../{ => components/Shared}/Throttle.spec.ts | 2 +- vue.config.js | 11 +++++++++- 67 files changed, 100 insertions(+), 71 deletions(-) rename src/{ => presentation}/background.ts (94%) rename src/presentation/{Bootstrapping => bootstrapping}/ApplicationBootstrapper.ts (100%) rename src/presentation/{Bootstrapping => bootstrapping}/IVueBootstrapper.ts (100%) rename src/presentation/{Bootstrapping => bootstrapping}/Modules/IconBootstrapper.ts (100%) rename src/presentation/{Bootstrapping => bootstrapping}/Modules/TooltipBootstrapper.ts (100%) rename src/presentation/{Bootstrapping => bootstrapping}/Modules/TreeBootstrapper.ts (100%) rename src/presentation/{Bootstrapping => bootstrapping}/Modules/VModalBootstrapper.ts (100%) rename src/presentation/{Bootstrapping => bootstrapping}/Modules/VueBootstrapper.ts (100%) rename src/{ => presentation/components}/App.vue (76%) rename src/presentation/{ => components}/Code/CodeButtons/Code.vue (100%) rename src/presentation/{ => components}/Code/CodeButtons/IconButton.vue (100%) rename src/presentation/{ => components}/Code/CodeButtons/MacOsInstructions.vue (100%) rename src/presentation/{ => components}/Code/CodeButtons/TheCodeButtons.vue (98%) rename src/presentation/{ => components}/Code/TheCodeArea.vue (97%) rename src/presentation/{ => components}/Scripts/Cards/CardList.vue (95%) rename src/presentation/{ => components}/Scripts/Cards/CardListItem.vue (97%) rename src/presentation/{ => components}/Scripts/Cards/NonCollapsingDirective.ts (100%) rename src/presentation/{ => components}/Scripts/Menu/Grouping/Grouping.ts (100%) rename src/presentation/{ => components}/Scripts/Menu/Grouping/TheGrouper.vue (100%) rename src/presentation/{ => components}/Scripts/Menu/Selector/SelectableOption.vue (88%) rename src/presentation/{ => components}/Scripts/Menu/Selector/TheSelector.vue (98%) rename src/presentation/{ => components}/Scripts/Menu/TheOsChanger.vue (96%) rename src/presentation/{ => components}/Scripts/Menu/TheScriptsMenu.vue (96%) rename src/presentation/{ => components}/Scripts/ScriptsTree/ScriptNodeParser.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/ScriptsTree.vue (98%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/INodeSelectedEvent.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/LiquorTree/LiquorTree.d.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/LiquorTree/LiquorTreeOptions.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodePredicateFilter.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodeStateUpdater.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodeTranslator.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/DocumentationUrls.vue (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/INode.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/Node.vue (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/RevertToggle.vue (98%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/Reverter/CategoryReverter.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/Reverter/IReverter.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ReverterFactory.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter.ts (100%) rename src/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/SelectableTree.vue (100%) rename src/presentation/{ => components}/Scripts/Slider/Handle.vue (100%) rename src/presentation/{ => components}/Scripts/Slider/HorizontalResizeSlider.vue (100%) rename src/presentation/{ => components}/Scripts/TheScriptArea.vue (67%) rename src/presentation/{ => components}/Scripts/TheScriptsList.vue (91%) rename src/presentation/{ => components/Shared}/Responsive.vue (100%) rename src/presentation/{ => components/Shared}/StatefulVue.ts (94%) rename src/presentation/{ => components/Shared}/Throttle.ts (100%) rename src/presentation/{ => components}/TheFooter/DownloadUrlList.vue (100%) rename src/presentation/{ => components}/TheFooter/DownloadUrlListItem.vue (100%) rename src/presentation/{ => components}/TheFooter/PrivacyPolicy.vue (100%) rename src/presentation/{ => components}/TheFooter/TheFooter.vue (100%) rename src/presentation/{ => components}/TheHeader.vue (100%) rename src/presentation/{ => components}/TheSearchBar.vue (93%) rename src/{ => presentation}/main.ts (51%) rename src/{ => presentation}/shims-tsx.d.ts (100%) rename src/{ => presentation}/shims-vue.d.ts (100%) rename tests/unit/presentation/{ => components}/Scripts/Cards/NonCollapsingDirective.spec.ts (90%) rename tests/unit/presentation/{ => components}/Scripts/ScriptsTree/ScriptNodeParser.spec.ts (91%) rename tests/unit/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodePredicateFilter.spec.ts (88%) rename tests/unit/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodeStateUpdater.spec.ts (97%) rename tests/unit/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/LiquorTree/NodeWrapper/NodeTranslator.spec.ts (95%) rename tests/unit/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/Reverter/CategoryReverter.spec.ts (90%) rename tests/unit/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ReverterFactory.spec.ts (66%) rename tests/unit/presentation/{ => components}/Scripts/ScriptsTree/SelectableTree/Node/Reverter/ScriptReverter.spec.ts (87%) rename tests/unit/presentation/{ => components/Shared}/Throttle.spec.ts (96%) diff --git a/docs/presentation.md b/docs/presentation.md index 9c984b63..8b023696 100644 --- a/docs/presentation.md +++ b/docs/presentation.md @@ -4,6 +4,20 @@ - Desktop application is created using [Electron](https://www.electronjs.org/). - Event driven as in components simply listens to events from the state and act accordingly. +## Structure + +- [`/src/` **`presentation/`**](./../src/presentation/): Contains all presentation related code including Vue and Electron configurations + - [**`bootstrapping/`**](./../src/presentation/bootstrapping/): Registers Vue global objects including components and plugins. + - [**`components/`**](./../src/presentation/components/): Contains all Vue components and their helper classes. + - [**`Shared/`**](./../src/presentation/components/Shared): Contains Vue components and component helpers that are shared across other components. + - [**`styles/`**](./../src/presentation/styles/): Contains shared styles used throughout different components. + - [**`main.ts`**](./../src/presentation/main.ts): Application entry point that mounts and starts Vue application. + - [**`background.ts`**](./../src/presentation/background.ts): Main process of Electron, started as first thing when app starts. +- [**`/public/`**](./../public/): Contains static assets that will simply be copied and not go through webpack. +- [**`/vue.config.js`**](./../vue.config.js): Global Vue CLI configurations loaded by `@vue/cli-service` +- [**`/postcss.config.js`**](./../postcss.config.js): PostCSS configurations that are used by Vue CLI internally +- [**`/babel.config.js`**](./../babel.config.js): Babel configurations for polyfills used by `@vue/cli-plugin-babel` + ## Application data - Components and should use [ApplicationFactory](./../src/application/ApplicationFactory.ts) singleton to reach the application domain. @@ -16,9 +30,9 @@ - Stateful components mutate or/and react to state changes in [ApplicationContext](./../src/application/Context/ApplicationContext.ts). - Stateless components that does not handle state extends `Vue` -- Stateful components that depends on the collection state such as user selection, search queries and more extends [`StatefulVue`](./../src/presentation/StatefulVue.ts) -- The single source of truth is a singleton of the state created and made available to presentation layer by [`StatefulVue`](./../src/presentation/StatefulVue.ts) +- Stateful components that depends on the collection state such as user selection, search queries and more extends [`StatefulVue`](./../src/presentation/components/Shared/StatefulVue.ts) +- The single source of truth is a singleton of the state created and made available to presentation layer by [`StatefulVue`](./../src/presentation/components/Shared/StatefulVue.ts) - `StatefulVue` includes abstract `handleCollectionState` that is fired once the component is loaded and also each time [collection](./collection-files.md) is changed. - Do not forget to subscribe from events when component is destroyed or if needed [collection](./collection-files.md) is changed. - - 💡 `events` in base class [`StatefulVue`](./../src/presentation/StatefulVue.ts) makes lifecycling easier + - 💡 `events` in base class [`StatefulVue`](./../src/presentation/components/Shared/StatefulVue.ts) makes lifecycling easier - 📖 See [Application state | Application layer](./presentation.md#application-state) where the state is implemented using using state pattern. diff --git a/src/background.ts b/src/presentation/background.ts similarity index 94% rename from src/background.ts rename to src/presentation/background.ts index cb542cfc..3625bdfa 100644 --- a/src/background.ts +++ b/src/presentation/background.ts @@ -1,5 +1,9 @@ 'use strict'; +// This is main process of Electron, started as first thing when app starts. +// This script is running through entire life of the application. +// It doesn't have any windows which you can see on screen, opens the main window from here. + import { app, protocol, BrowserWindow, shell } from 'electron'; import { createProtocol } from 'vue-cli-plugin-electron-builder/lib'; import installExtension, { VUEJS_DEVTOOLS } from 'electron-devtools-installer'; diff --git a/src/presentation/Bootstrapping/ApplicationBootstrapper.ts b/src/presentation/bootstrapping/ApplicationBootstrapper.ts similarity index 100% rename from src/presentation/Bootstrapping/ApplicationBootstrapper.ts rename to src/presentation/bootstrapping/ApplicationBootstrapper.ts diff --git a/src/presentation/Bootstrapping/IVueBootstrapper.ts b/src/presentation/bootstrapping/IVueBootstrapper.ts similarity index 100% rename from src/presentation/Bootstrapping/IVueBootstrapper.ts rename to src/presentation/bootstrapping/IVueBootstrapper.ts diff --git a/src/presentation/Bootstrapping/Modules/IconBootstrapper.ts b/src/presentation/bootstrapping/Modules/IconBootstrapper.ts similarity index 100% rename from src/presentation/Bootstrapping/Modules/IconBootstrapper.ts rename to src/presentation/bootstrapping/Modules/IconBootstrapper.ts diff --git a/src/presentation/Bootstrapping/Modules/TooltipBootstrapper.ts b/src/presentation/bootstrapping/Modules/TooltipBootstrapper.ts similarity index 100% rename from src/presentation/Bootstrapping/Modules/TooltipBootstrapper.ts rename to src/presentation/bootstrapping/Modules/TooltipBootstrapper.ts diff --git a/src/presentation/Bootstrapping/Modules/TreeBootstrapper.ts b/src/presentation/bootstrapping/Modules/TreeBootstrapper.ts similarity index 100% rename from src/presentation/Bootstrapping/Modules/TreeBootstrapper.ts rename to src/presentation/bootstrapping/Modules/TreeBootstrapper.ts diff --git a/src/presentation/Bootstrapping/Modules/VModalBootstrapper.ts b/src/presentation/bootstrapping/Modules/VModalBootstrapper.ts similarity index 100% rename from src/presentation/Bootstrapping/Modules/VModalBootstrapper.ts rename to src/presentation/bootstrapping/Modules/VModalBootstrapper.ts diff --git a/src/presentation/Bootstrapping/Modules/VueBootstrapper.ts b/src/presentation/bootstrapping/Modules/VueBootstrapper.ts similarity index 100% rename from src/presentation/Bootstrapping/Modules/VueBootstrapper.ts rename to src/presentation/bootstrapping/Modules/VueBootstrapper.ts diff --git a/src/App.vue b/src/presentation/components/App.vue similarity index 76% rename from src/App.vue rename to src/presentation/components/App.vue index 7a923939..a0cd601a 100644 --- a/src/App.vue +++ b/src/presentation/components/App.vue @@ -12,11 +12,11 @@