fix(editor): Prevent keyboard shortcuts to edit workflows in readonly mode (#6613)

This commit is contained in:
Csaba Tuncsik
2023-07-06 16:01:52 +02:00
committed by GitHub
parent 7515f7d52a
commit 7383e7fd48
4 changed files with 41 additions and 38 deletions

View File

@@ -1,8 +1,9 @@
import { defineComponent } from 'vue';
import { mapStores } from 'pinia';
import dateformat from 'dateformat';
import { VIEWS } from '@/constants';
import { useToast } from '@/composables';
import { useSourceControlStore } from '@/stores';
export const genericHelpers = defineComponent({
setup() {
@@ -17,11 +18,15 @@ export const genericHelpers = defineComponent({
};
},
computed: {
...mapStores(useSourceControlStore),
isReadOnlyRoute(): boolean {
return ![VIEWS.WORKFLOW, VIEWS.NEW_WORKFLOW, VIEWS.LOG_STREAMING_SETTINGS].includes(
this.$route.name as VIEWS,
);
},
readOnlyEnv(): boolean {
return this.sourceControlStore.preferences.branchReadOnly;
},
},
methods: {
displayTimer(msPassed: number, showMs = false): string {
@@ -49,21 +54,6 @@ export const genericHelpers = defineComponent({
const [date, time] = formattedDate.split('#');
return { date, time };
},
editAllowedCheck(): boolean {
if (this.isReadOnlyRoute) {
this.showMessage({
// title: 'Workflow can not be changed!',
title: this.$locale.baseText('genericHelpers.showMessage.title'),
message: this.$locale.baseText('genericHelpers.showMessage.message'),
type: 'info',
duration: 0,
dangerouslyUseHTMLString: true,
});
return false;
}
return true;
},
/**
* @note Loading helpers extracted as composable in useLoadingService