Skip to content

Commit 76f44bd

Browse files
committed
Update automations limitation
1 parent 7b165c0 commit 76f44bd

File tree

2 files changed

+28
-27
lines changed

2 files changed

+28
-27
lines changed

frontend/src/modules/automation/components/automation-toggle.vue

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
:model-value="props.automation.state === 'active'"
55
class="!grow-0 !ml-0"
66
:disabled="!canEnable"
7+
:before-change="beforeChange"
78
@change="handleChange"
89
/>
910
<span class="ml-2 text-gray-900 text-sm">
@@ -16,6 +17,9 @@
1617
import { computed, defineProps } from 'vue';
1718
import { useAutomationStore } from '@/modules/automation/store';
1819
import { useStore } from 'vuex';
20+
import { getWorkflowMax, showWorkflowLimitDialog } from '@/modules/automation/automation-limit';
21+
import { mapGetters } from '@/shared/vuex/vuex.helpers';
22+
import { FeatureFlag } from '@/utils/featureFlag';
1923
import { automationTypes } from '../config/automation-types';
2024
2125
const props = defineProps({
@@ -29,14 +33,38 @@ const store = useStore();
2933
3034
const { changePublishState } = useAutomationStore();
3135
36+
const { currentTenant } = mapGetters('auth');
37+
3238
const canEnable = computed(() => {
3339
const { type } = props.automation;
40+
3441
if (automationTypes[type]?.enableGuard) {
3542
return props.automation.state === 'active' || automationTypes[type]?.enableGuard(props.automation, store);
3643
}
44+
3745
return true;
3846
});
3947
48+
const beforeChange = () => {
49+
if (props.automation.state === 'active') {
50+
return true;
51+
}
52+
53+
const isFeatureEnabled = FeatureFlag.isFlagEnabled(
54+
FeatureFlag.flags.automations,
55+
);
56+
57+
if (!isFeatureEnabled) {
58+
const planWorkflowCountMax = getWorkflowMax(
59+
currentTenant.value.plan,
60+
);
61+
62+
showWorkflowLimitDialog({ planWorkflowCountMax });
63+
}
64+
65+
return isFeatureEnabled;
66+
};
67+
4068
const handleChange = (value) => {
4169
changePublishState(props.automation.id, value);
4270
};

frontend/src/modules/automation/pages/automation-list-page.vue

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -128,10 +128,8 @@ import { storeToRefs } from 'pinia';
128128
import pluralize from 'pluralize';
129129
import AppAutomationForm from '@/modules/automation/components/automation-form.vue';
130130
import AppAutomationListTable from '@/modules/automation/components/list/automation-list-table.vue';
131-
import { mapGetters } from '@/shared/vuex/vuex.helpers';
132131
import AppAutomationExecutions from '@/modules/automation/components/automation-executions.vue';
133132
import { FeatureFlag } from '@/utils/featureFlag';
134-
import { getWorkflowMax, showWorkflowLimitDialog } from '@/modules/automation/automation-limit';
135133
136134
import { useStore } from 'vuex';
137135
import config from '@/config';
@@ -158,40 +156,15 @@ const {
158156
} = storeToRefs(automationStore);
159157
const { getAutomations, changeAutomationFilter } = automationStore;
160158
161-
const { currentTenant } = mapGetters('auth');
162-
163159
const store = useStore();
164160
const fetchIntegrations = () => store.dispatch('integration/doFetch');
165161
166-
/**
167-
* Check if tenant has feature flag enabled
168-
*/
169-
const canAddAutomation = () => {
170-
const isFeatureEnabled = FeatureFlag.isFlagEnabled(
171-
FeatureFlag.flags.automations,
172-
);
173-
174-
if (!isFeatureEnabled) {
175-
const planWorkflowCountMax = getWorkflowMax(
176-
currentTenant.value.plan,
177-
);
178-
179-
showWorkflowLimitDialog({ planWorkflowCountMax });
180-
}
181-
182-
return isFeatureEnabled;
183-
};
184-
185162
// Executions drawer
186163
const createAutomation = (type) => {
187164
if (!automationTypes[type].canCreate(store)) {
188165
return;
189166
}
190167
191-
if (!canAddAutomation()) {
192-
return;
193-
}
194-
195168
openAutomationForm.value = true;
196169
editAutomation.value = null;
197170
automationFormType.value = type;

0 commit comments

Comments
 (0)