Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mod disable/uninstall status indicator #1182

Merged
merged 4 commits into from
Jan 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import { Component, Prop, Watch } from 'vue-property-decorator';

@Component
export default class Modal extends Vue {
/*
Prefer using the ModalCard component for future modals as it uses
the correct bulma classes for modal cards, which this one does not!
*/

@Prop({default: false, type: Boolean})
open!: boolean;
Expand Down
43 changes: 43 additions & 0 deletions src/components/ModalCard.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<template>
<div :class="['modal', {'is-active': isActive}]">
<div class="modal-background" @click="closeModal()"/>
<div class="modal-card py-4">
<header class="modal-card-head">
<slot name="header"/>
</header>
<section class="modal-card-body">
<slot name="body"/>
</section>
<footer class="modal-card-foot">
<slot name="footer"/>
</footer>
</div>
<button v-if="canClose" class="modal-close is-large" aria-label="close" @click="closeModal()"/>
</div>
</template>

<script lang="ts">
import Vue from 'vue';
import { Component, Prop } from 'vue-property-decorator';

@Component
export default class ModalCard extends Vue {

@Prop({default: false, type: Boolean})
isActive!: boolean;

@Prop({default: true, type: Boolean})
canClose!: boolean;

closeModal() {
if (this.canClose) {
this.$emit('close-modal');
}
}
}
</script>


<style scoped lang="scss">

</style>
4 changes: 3 additions & 1 deletion src/components/all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import Hero from './Hero.vue';
import Progress from './Progress.vue';
import ExpandableCard from './ExpandableCard.vue';
import Modal from './Modal.vue';
import ModalCard from './ModalCard.vue';
import Link from './Link.vue';

export {
Hero,
Progress,
Link,
ExpandableCard,
Modal
Modal,
ModalCard,
}
5 changes: 3 additions & 2 deletions src/components/views/LocalModList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,10 @@ import UninstallModModal from './LocalModList/UninstallModModal.vue';
const err: Error = e as Error;
this.$emit("error", err);
LoggerProvider.instance.Log(LogSeverity.ACTION_STOPPED, `${err.name}\n-> ${err.message}`);
} finally {
this.selectedManifestMod = null;
this.modBeingDisabled = null;
}
this.selectedManifestMod = null;
this.modBeingDisabled = null;
}

async performDisable(mods: ManifestV2[]): Promise<R2Error | void> {
Expand Down
10 changes: 5 additions & 5 deletions src/components/views/LocalModList/AssociatedModsModal.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
import { Modal } from '../../all';
import { ModalCard } from '../../all';
import ManifestV2 from '../../../model/ManifestV2';

@Component({
components: {Modal}
components: {ModalCard}
})
export default class AssociatedModsModal extends Vue {

Expand All @@ -22,8 +22,8 @@ export default class AssociatedModsModal extends Vue {
}
</script>
<template>
<Modal :open="true" @close-modal="onClose">
<template v-slot:title>
<ModalCard :is-active="true" @close-modal="onClose">
<template v-slot:header>
<p class='card-header-title'>
Mods associated with {{mod.getName()}}
</p>
Expand Down Expand Up @@ -54,7 +54,7 @@ export default class AssociatedModsModal extends Vue {
Done
</button>
</template>
</Modal>
</ModalCard>
</template>

<style scoped lang="scss">
Expand Down
60 changes: 33 additions & 27 deletions src/components/views/LocalModList/DisableModModal.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
import { Modal } from '../../all';
import { ModalCard } from '../../all';
import ManifestV2 from '../../../model/ManifestV2';

@Component({
components: {Modal}
components: {ModalCard}
})
export default class DisableModModal extends Vue {

Expand All @@ -28,48 +28,54 @@ export default class DisableModModal extends Vue {

@Prop({required: true, type: Function})
readonly onDisableExcludeDependents!: (mod: ManifestV2) => void;

get isLocked(): boolean {
return this.modBeingDisabled !== null;
}
}
</script>
<template>
<Modal :open="true" @close-modal="onClose">
<template v-slot:title>
<p class='card-header-title'>Disabling
{{mod.getName()}}
</p>
<ModalCard :is-active="true" :can-close="!isLocked" @close-modal="onClose">
<template v-slot:header>
<p class="modal-card-title">Disabling {{mod.getName()}}</p>
</template>
<template v-slot:body>
<div class='notification is-warning'>
<p>
Other mods depend on this mod. Select <strong>Disable all</strong>
to disable dependent mods, otherwise they may cause errors.
</p>
</div>
<p>Mods to be disabled:</p>
<br/>
<div>
<ul class="list">
<li class="list-item">{{mod.getName()}}</li>
<li class="list-item" v-for='(key, index) in dependantsList'
:key='`dependant-${index}`'>
{{key.getName()}}
</li>
</ul>
<div class="max-height-100 is-flex is-flex-direction-column">
<div class='notification is-warning'>
<p>
Other mods depend on this mod. Select <strong>Disable all</strong>
to disable dependent mods, otherwise they may cause errors.
</p>
</div>
<h3 class="subtitle mb-3">Mods to be disabled</h3>
<div class="is-flex-shrink-1 overflow-auto code-snippet">
<ul class="list">
<li class="list-item">{{mod.getName()}}</li>
<li class="list-item" v-for='(key, index) in dependantsList'
:key='`dependant-${index}`'>
{{key.getName()}}
</li>
</ul>
</div>
<div v-if="isLocked" class="mt-3">
<h3 class="subtitle mb-3">Disabling {{modBeingDisabled}}</h3>
<progress class="progress is-small is-info"/>
</div>
</div>
</template>
<template v-slot:footer>
<button class="button is-info"
:disabled="isLocked"
@click="onDisableIncludeDependents(mod)">
Disable all (recommended)
</button>
<button class="button"
:disabled="isLocked"
@click="onDisableExcludeDependents(mod)">
Disable {{mod.getName()}} only
</button>
<span v-if="modBeingDisabled" class="tag is-warning margin-top--1rem margin-left">
Disabling {{ modBeingDisabled }}
</span>
</template>
</Modal>
</ModalCard>
</template>

<style scoped lang="scss">
Expand Down
62 changes: 33 additions & 29 deletions src/components/views/LocalModList/UninstallModModal.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<script lang="ts">
import { Vue, Component, Prop } from 'vue-property-decorator';
import { Modal } from '../../all';
import { ModalCard } from '../../all';
import ManifestV2 from '../../../model/ManifestV2';

@Component({
components: {Modal}
components: {ModalCard}
})
export default class UninstallModModal extends Vue {

Expand All @@ -28,50 +28,54 @@ export default class UninstallModModal extends Vue {

@Prop({required: true, type: Function})
readonly onUninstallExcludeDependents!: (mod: ManifestV2) => void;

get isLocked(): boolean {
return this.modBeingUninstalled !== null;
}
}
</script>
<template>
<Modal :open="true" @close-modal="onClose">
<template v-slot:title>
<p class='card-header-title'>
Uninstalling {{mod.getName()}}
</p>
<ModalCard :is-active="true" :can-close="!isLocked" @close-modal="onClose">
<template v-slot:header>
<p class='modal-card-title'>Uninstalling {{mod.getName()}}</p>
</template>
<template v-slot:body>
<div class='notification is-warning'>
<p>
Other mods depend on this mod. Select <strong>Uninstall all</strong>
to uninstall dependent mods, otherwise they may cause errors.
</p>
</div>
<p>Mods to be uninstalled:</p>
<br/>
<div>
<ul class="list">
<li class="list-item">{{mod.getName()}}</li>
<li class="list-item" v-for='(key, index) in dependantsList'
:key='`dependant-${index}`'>
{{key.getName()}}
</li>
</ul>
<div class="max-height-100 is-flex is-flex-direction-column">
<div class='notification is-warning'>
<p>
Other mods depend on this mod. Select <strong>Uninstall all</strong>
to uninstall dependent mods, otherwise they may cause errors.
</p>
</div>
<h3 class="subtitle mb-3">Mods to be uninstalled</h3>
<div class="is-flex-shrink-1 overflow-auto code-snippet">
<ul class="list">
<li class="list-item">{{mod.getName()}}</li>
<li class="list-item" v-for='(key, index) in dependantsList'
:key='`dependant-${index}`'>
{{key.getName()}}
</li>
</ul>
</div>
<div v-if="isLocked" class="mt-3">
<h3 class="subtitle mb-3">Uninstalling {{modBeingUninstalled}}</h3>
<progress class="progress is-small is-info"/>
</div>
</div>
</template>
<template v-slot:footer>
<button class="button is-info"
:disabled="modBeingUninstalled !== null"
:disabled="isLocked"
@click="onUninstallIncludeDependents(mod)">
Uninstall all (recommended)
</button>
<button class="button"
:disabled="modBeingUninstalled !== null"
:disabled="isLocked"
@click="onUninstallExcludeDependents(mod)">
Uninstall {{mod.getName()}} only
</button>
<span v-if="modBeingUninstalled" class="tag is-warning margin-top--1rem margin-left">
Uninstalling {{ modBeingUninstalled }}
</span>
</template>
</Modal>
</ModalCard>
</template>

<style scoped lang="scss">
Expand Down
14 changes: 14 additions & 0 deletions src/css/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -467,3 +467,17 @@ code {
height: 40px;
align-items: center;
}

.max-height-100 {
max-height: 100%;
}

.overflow-auto {
overflow: auto;
}

.code-snippet {
padding: 4px 4px 4px 8px;
border-radius: 8px;
background-color: rgba(0, 0, 0, 0.15);
}
6 changes: 6 additions & 0 deletions src/css/scheme/light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ $card-header-color: var(--card-header-color, $scheme-text-strong);
$card-color: var(--card-color, $scheme-text);
$card-footer-border-top: 1px solid var(--card-footer-border-top, $scheme-border);

$modal-card-body-background-color: var(--modal-card-body-background-color, $scheme-background);
$modal-card-head-background-color: var(--modal-card-head-background-color, $scheme-background);
$modal-card-head-border-bottom: 1px solid var(--modal-card-head-border-bottom, $scheme-border);
$modal-card-foot-border-top: 1px solid var(--modal-card-foot-border-top, $scheme-border);
$modal-card-title-color: var(--modal-card-title-color, $scheme-text);

$menu-item-color: var(--menu-item-color, $scheme-text);
$menu-item-hover-background-color: var(--menu-item-hover-background-color, #f5f5f5);
$menu-item-hover-color: var(--menu-item-hover-color, $scheme-text-strong);
Expand Down