Merge pull request #14474 from ElectronicBlueberry/admin-tool-install

Hide Disabled Installation Actions for Tool Installations
This commit is contained in:
Dannon
2022-08-19 09:10:27 -04:00
committed by GitHub
3 changed files with 47 additions and 116 deletions
@@ -28,6 +28,15 @@
<span v-if="!data.value" :class="repoChecked" />
<span v-else :class="repoUnchecked" />
</template>
<template v-slot:cell(status)="row">
<span v-if="row.item.status">
<span
v-if="!['Error', 'Installed', 'Uninstalled'].includes(row.item.status)"
class="fa fa-spinner fa-spin" />
{{ row.item.status }}
</span>
<span v-else> - </span>
</template>
<template v-slot:cell(actions)="row">
<InstallationActions
:status="row.item.status"
@@ -96,6 +105,7 @@ export default {
{ key: "tools", label: "Tools and Versions" },
{ key: "profile", label: "Requires" },
{ key: "missing_test_components", label: "Tests" },
{ key: "status" },
{ key: "actions", label: "", class: "toolshed-repo-actions" },
],
showSettings: false,
@@ -199,7 +209,7 @@ export default {
<style lang="scss">
// make actions take up less space
.toolshed-repo-actions {
width: 15%;
min-width: 280px;
width: 10%;
min-width: 120px;
}
</style>
@@ -1,36 +0,0 @@
import { mount, createLocalVue } from "@vue/test-utils";
import InstallationActions from "./InstallationActions";
import { localizationPlugin } from "components/plugins";
const localVue = createLocalVue();
localVue.use(localizationPlugin);
describe("InstallationActions", () => {
it("test installed repository revision", () => {
const wrapper = mount(InstallationActions, {
propsData: {
installed: true,
status: "Installed",
},
localVue,
});
const $el = wrapper.find("button:nth-of-type(2)");
expect($el.classes()).toEqual(expect.arrayContaining(["btn-danger"]));
$el.trigger("click");
expect(wrapper.emitted().onUninstall).toBeDefined();
});
it("test uninstalled repository revision", () => {
const wrapper = mount(InstallationActions, {
propsData: {
installed: false,
status: "Uninstalled",
},
localVue,
});
const $el = wrapper.find("button:nth-of-type(1)");
expect($el.classes()).toEqual(expect.arrayContaining(["btn-primary"]));
$el.trigger("click");
expect(wrapper.emitted().onInstall).toBeDefined();
});
});
@@ -1,86 +1,43 @@
<template>
<div>
<span class="d-inline-block status">
<span v-if="installingState" class="fa fa-spinner fa-spin" />
{{ status }}
</span>
<div class="d-inline-block">
<b-button
:disabled="!installState"
:class="buttonClass"
:variant="installState ? 'primary' : ''"
@click="onInstall">
Install
</b-button>
<b-button
:disabled="!uninstallState"
:class="buttonClass"
:variant="uninstallState ? 'danger' : ''"
@click="onUninstall">
Uninstall
</b-button>
<b-button
:disabled="!resetState"
:class="buttonClass"
:title="l('Reset Broken or Stuck Installation')"
:variant="resetState ? 'warning' : ''"
@click="onCancel">
Reset
</b-button>
</div>
</div>
</template>
<script>
import Vue from "vue";
import BootstrapVue from "bootstrap-vue";
<script setup>
import { computed } from "vue";
Vue.use(BootstrapVue);
const props = defineProps({
status: String,
});
export default {
props: {
status: {
type: String,
default: "Uninstalled",
},
},
data() {
return {
buttonClass: "btn-sm text-nowrap",
};
},
computed: {
installState() {
return !this.status || this.status === "Uninstalled";
},
uninstallState() {
return this.status === "Installed";
},
resetState() {
return !this.installState && !this.uninstallState;
},
installingState() {
return this.status !== "Error" && this.resetState;
},
},
methods: {
onInstall() {
this.$emit("onInstall");
},
onUninstall() {
this.$emit("onUninstall");
},
onCancel() {
if (window.confirm(`Do you want to reset this repository?`)) {
this.$emit("onUninstall");
}
},
},
};
const installState = computed(() => !props.status || props.status === "Uninstalled");
const uninstallState = computed(() => props.status === "Installed");
const emit = defineEmits(["onInstall", "onUninstall"]);
function onCancel() {
if (window.confirm(`Do you want to reset this repository?`)) {
emit("onUninstall");
}
}
</script>
<template>
<div>
<b-button v-if="installState" variant="primary" class="btn-sm" @click="() => emit('onInstall')">
Install
</b-button>
<b-button v-else-if="uninstallState" variant="danger" class="btn-sm" @click="() => emit('onUninstall')">
Uninstall
</b-button>
<b-button
v-else
variant="warning"
class="btn-sm"
:title="l('Reset Broken or Stuck Installation')"
@click="onCancel">
Reset
</b-button>
</div>
</template>
<style lang="scss" scoped>
.status {
display: inline-block;
button {
min-width: 80px;
}
</style>