Skip to content

Commit

Permalink
fix(ui): graciously handle situation with no tutorial flows loaded (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosPaunovic authored and brian-mulier-p committed Aug 8, 2024
1 parent ae15cef commit d57d9dd
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
3 changes: 2 additions & 1 deletion ui/src/components/layout/TopNavBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,15 @@
},
computed: {
...mapState("api", ["version"]),
...mapState("core", ["tutorialFlows"]),
...mapGetters("core", ["guidedProperties"]),
...mapGetters("auth", ["user"]),
displayNavBar() {
return this.$route?.name !== "welcome";
},
tourEnabled(){
// Temporary solution to not showing the tour menu item for EE
return !Object.keys(this.user).length
return this.tutorialFlows?.length && !Object.keys(this.user).length
}
},
methods: {
Expand Down
23 changes: 12 additions & 11 deletions ui/src/components/onboarding/VueTour.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
<div
v-if="currentStep(tour).title"
class="title"
:class="{dark: currentStep(tour).keepDark}"
:class="{dark: currentStep(tour).keepDark, empty: !flows.length}"
>
<div v-if="currentStep(tour).icon">
<img
:src="currentStep(tour).icon"
:class="{jump: currentStep(tour).jump}"
>
</div>
<span v-html="currentStep(tour).title" />
<span v-html="tour.currentStep === 1 && !flows.length ? t('onboarding.no_flows') : currentStep(tour).title" />
</div>
</template>
<template #content>
Expand Down Expand Up @@ -99,6 +99,7 @@
![0, 1].includes(tour.currentStep) ||
!tour.isLast
"
:disabled="tour.currentStep === 1 && !flows.length"
@click="
tour.isLast
? finishTour(tour.currentStep)
Expand Down Expand Up @@ -147,7 +148,6 @@
import Finish from "./components/buttons/Finish.vue";
import {apiUrl} from "override/utils/route";
import {pageFromRoute} from "../../utils/eventsRouter";
import TaskIcon from "@kestra-io/ui-libs/src/components/misc/TaskIcon.vue";
Expand Down Expand Up @@ -208,7 +208,7 @@
};
const activeFlow = ref(0);
const flows = ref([]);
const flows = computed(() => store.state.core.tutorialFlows);
const allTasks = (tasks) => {
const uniqueTypes = new Set();
Expand Down Expand Up @@ -300,7 +300,7 @@
name: "flows/update",
params: {
namespace: "tutorial",
id: flows.value[activeFlow.value].id,
id: flows.value[activeFlow.value]?.id,
tab: "editor",
},
});
Expand All @@ -312,7 +312,7 @@
store.commit("editor/updateOnboarding"),
store.commit("core/setGuidedProperties", {
tourStarted: true,
template: flows.value[activeFlow.value].id,
template: flows.value[activeFlow.value]?.id,
});
wait(1);
Expand Down Expand Up @@ -422,11 +422,7 @@
};
onMounted(() => {
const HTTP = getCurrentInstance()?.appContext.config.globalProperties.$http;
HTTP.get(`${apiUrl(this)}/flows/tutorial`).then(
(response) => (flows.value = response.data),
);
store.dispatch("core/readTutorialFlows");
});
</script>

Expand Down Expand Up @@ -530,6 +526,11 @@ $flow-image-size-container: 36px;
font-weight: 500;
color: $color;
&.empty {
font-size: 1.2rem;
margin-bottom: 0;
}
& div {
height: 2rem;
margin-bottom: 1rem;
Expand Down
15 changes: 12 additions & 3 deletions ui/src/stores/core.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import {apiUrl} from "override/utils/route";

export default {
namespaced: true,
state: {
Expand All @@ -10,7 +12,8 @@ export default {
template: undefined,
},
monacoYamlConfigured: false,
autocompletionSource: undefined
autocompletionSource: undefined,
tutorialFlows: []
},
actions: {
showMessage({commit}, message) {
Expand All @@ -21,7 +24,10 @@ export default {
},
isUnsaved({commit}, unsavedChange) {
commit("setUnsavedChange", unsavedChange)
}
},
readTutorialFlows({commit}) {
return this.$http.get(`${apiUrl(this)}/flows/tutorial`).then((response) => commit("setTutorialFlows", response.data))
},
},
mutations: {
setMessage(state, message) {
Expand All @@ -41,7 +47,10 @@ export default {
},
setAutocompletionSource(state, autocompletionSource) {
state.autocompletionSource = autocompletionSource
}
},
setTutorialFlows(state, flows) {
state.tutorialFlows = flows
},
},
getters: {
unsavedChange(state) {
Expand Down
1 change: 1 addition & 0 deletions ui/src/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,7 @@
"previous": "Previous",
"finish": "Finish",
"skip": "Skip Tutorial",
"no_flows": "No flows available under tutorial namespace.",
"steps": {
"0": {
"title": "Welcome to Kestra!",
Expand Down
1 change: 1 addition & 0 deletions ui/src/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@
"previous": "Précédent",
"finish": "Finir",
"skip": "Passer le tutoriel",
"no_flows": "Aucun flux disponible dans l'espace de noms du tutoriel.",
"steps": {
"0": {
"title": "Bienvenue chez Kestra!",
Expand Down

0 comments on commit d57d9dd

Please sign in to comment.