diff options
author | Rémy Raes <contact@remyraes.com> | 2023-04-10 14:25:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-10 14:25:32 +0200 |
commit | 6d58e6793d40df4fec518f37351868803a02a033 (patch) | |
tree | 8ba8b1fdf503579314e9475bee409e0ba549e7ad /src-vue/src/views/DeveloperView.vue | |
parent | 0d4744ad1f05ea6410b4cbe4e1e0270e67055ce6 (diff) | |
download | FlightCore-6d58e6793d40df4fec518f37351868803a02a033.tar.gz FlightCore-6d58e6793d40df4fec518f37351868803a02a033.zip |
refactor: Notifications (#259)
* feat: wrap ElNotification class in a showNotification method
* refactor: replace notification invocations in mod views
* feat: add 'info' type to showNotification method
* refactor: replace notification invocations in repair view
* refactor: replace notification invocations in settings view
* refactor: replace notification invocations in developer view
* feat: showNotification method now returns a NotificationHandle
* feat: showNotification has a duration argument
* refactor: replace notification invocations in pull requests module
* refactor: replace notification invocation in repair view
* refactor: replace notification invocations in UI store
* refactor: remove unused import from play view
* refactor: use showErrorNotification method to wrap up error display
* fix: add missing showErrorNotification imports
* style: format code
* style: format ThunderstoreModCard.vue
* style: format pull_requests.ts
* style: format SettingsView.vue
* style: format RepairView.vue
* style: format DeveloperView.vue
* refactor: remove useless import
* refactor: add missing showErrorNotification invocation
* feat: showErrorNotification has an optional title argument
* style: format LocalModsView.vue
Diffstat (limited to 'src-vue/src/views/DeveloperView.vue')
-rw-r--r-- | src-vue/src/views/DeveloperView.vue | 81 |
1 files changed, 13 insertions, 68 deletions
diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue index 7712756c..d9e268e3 100644 --- a/src-vue/src/views/DeveloperView.vue +++ b/src-vue/src/views/DeveloperView.vue @@ -87,10 +87,10 @@ <script lang="ts"> import { defineComponent } from "vue"; import { invoke } from "@tauri-apps/api"; -import { ElNotification } from "element-plus"; import { GameInstall } from "../utils/GameInstall"; import { TagWrapper } from "../../../src-tauri/bindings/TagWrapper"; import PullRequestsSelector from "../components/PullRequestsSelector.vue"; +import { showErrorNotification, showNotification } from "../utils/ui"; export default defineComponent({ name: "DeveloperView", @@ -130,30 +130,15 @@ export default defineComponent({ }, async crashApplication() { await invoke("force_panic"); - ElNotification({ - title: 'Error', - message: "Never should have been able to get here!", - type: 'error', - position: 'bottom-right' - }); + showErrorNotification("Never should have been able to get here!"); }, async checkLinuxCompatibility() { await invoke("linux_checks") .then(() => { - ElNotification({ - title: 'Linux compatible', - message: 'All checks passed', - type: 'success', - position: 'bottom-right' - }); + showNotification('Linux compatible', 'All checks passed'); }) .catch((error) => { - ElNotification({ - title: 'Not linux compatible', - message: error, - type: 'error', - position: 'bottom-right' - }); + showNotification('Not Linux compatible', error, 'error'); console.error(error); }); }, @@ -174,20 +159,10 @@ export default defineComponent({ console.log(message); // Just a visual indicator that it worked - ElNotification({ - title: 'Success', - message: "Success", - type: 'success', - position: 'bottom-right' - }); + showNotification('Success'); }) .catch((error) => { - ElNotification({ - title: 'Error', - message: error, - type: 'error', - position: 'bottom-right' - }); + showErrorNotification(error); }); }, async installMod() { @@ -196,62 +171,32 @@ export default defineComponent({ install_type: this.$store.state.install_type } as GameInstall; let mod_to_install = this.mod_to_install_field_string; - await invoke("install_mod_caller", { gameInstall: game_install, thunderstoreModString: mod_to_install }).then((message) => { + await invoke<string>("install_mod_caller", { gameInstall: game_install, thunderstoreModString: mod_to_install }).then((message) => { // Show user notification if mod install completed. - ElNotification({ - title: `Installed ${mod_to_install}`, - message: message as string, - type: 'success', - position: 'bottom-right' - }); + showNotification(`Installed ${mod_to_install}`, message); }) .catch((error) => { - ElNotification({ - title: 'Error', - message: error, - type: 'error', - position: 'bottom-right' - }); + showErrorNotification(error); }); }, async getTags() { await invoke<TagWrapper[]>("get_list_of_tags") .then((message) => { this.ns_release_tags = message; - ElNotification({ - title: "Done", - message: "Fetched tags", - type: 'success', - position: 'bottom-right' - }); + showNotification("Done", "Fetched tags"); }) .catch((error) => { - ElNotification({ - title: 'Error', - message: error, - type: 'error', - position: 'bottom-right' - }); + showErrorNotification(error); }); }, async compareTags() { await invoke<string>("compare_tags", {firstTag: this.firstTag.value, secondTag: this.secondTag.value}) .then((message) => { this.release_notes_text = message; - ElNotification({ - title: "Done", - message: "Generated release notes", - type: 'success', - position: 'bottom-right' - }); + showNotification("Done", "Generated release notes"); }) .catch((error) => { - ElNotification({ - title: 'Error', - message: error, - type: 'error', - position: 'bottom-right' - }); + showErrorNotification(error); }); }, } |