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: add user session check in task management template initialization and remove reactive from getters of plugin, role reference store #5270

Merged
merged 1 commit into from
Dec 19, 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
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { pinia } from '@/store/pinia';
import { useUserStore } from '@/store/user/user-store';

import {
useTaskManagementTemplateStore,
} from '@/services/ops-flow/task-management-templates/stores/use-task-management-template-store';

export const initTaskManagementTemplate = async () => {
const userStore = useUserStore(pinia);
if (userStore.state.isSessionExpired) return;

const taskManagementTemplateStore = useTaskManagementTemplateStore(pinia);
await Promise.allSettled([
taskManagementTemplateStore.setInitialTemplateId(),
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/store/reference/all-reference-store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { computed, reactive } from 'vue';
import { computed } from 'vue';

import { defineStore } from 'pinia';

Expand Down Expand Up @@ -94,7 +94,7 @@ export const useAllReferenceStore = defineStore('all-reference-store', () => {
const workspaceGroupReferenceStore = useWorkspaceGroupReferenceStore();
const roleReferenceStore = useRoleReferenceStore();

const getters = reactive({
const getters = {
// REFACTOR: unify into one case (serviceAccount or service_account)
cloudServiceType: computed<CloudServiceTypeReferenceMap>(() => cloudServiceTypeReferenceStore.getters.cloudServiceTypeItems),
cloud_service_type: computed<CloudServiceTypeReferenceMap>(() => cloudServiceTypeReferenceStore.getters.cloudServiceTypeItems),
Expand Down Expand Up @@ -129,7 +129,7 @@ export const useAllReferenceStore = defineStore('all-reference-store', () => {
namespace: computed(() => namespaceReferenceStore.getters.namespaceItems),
metric: computed<MetricReferenceMap>(() => metricReferenceStore.getters.metricItems),
role: computed(() => roleReferenceStore.getters.roleItems),
});
};

const actions = {
async sync(type: PiniaStoreReferenceType, data?: any) {
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/store/reference/plugin-reference-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const usePluginReferenceStore = defineStore('reference-plugin', () => {
items: null as PluginReferenceMap | null,
});

const getters = reactive({
const getters = {
pluginItems: asyncComputed<PluginReferenceMap>(async () => {
if (state.items === null) await load();
return state.items ?? {};
Expand All @@ -38,9 +38,9 @@ export const usePluginReferenceStore = defineStore('reference-plugin', () => {
type: 'plugin',
key: 'plugin_id',
name: 'name',
referenceMap: getters.pluginItems,
referenceMap: getters.pluginItems.value,
})),
});
};

const load = async (options?: ReferenceLoadOptions) => {
const currentTime = new Date().getTime();
Expand Down
6 changes: 3 additions & 3 deletions apps/web/src/store/reference/role-reference-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const useRoleReferenceStore = defineStore('reference-role', () => {
items: null as RoleReferenceMap | null,
});

const getters = reactive({
const getters = {
roleItems: asyncComputed<RoleReferenceMap>(async () => {
if (state.items === null) await load();
return state.items ?? {};
Expand All @@ -41,9 +41,9 @@ export const useRoleReferenceStore = defineStore('reference-role', () => {
type: MANAGED_VARIABLE_MODELS.role.meta.key,
key: MANAGED_VARIABLE_MODELS.role.meta.idKey,
name: MANAGED_VARIABLE_MODELS.role.meta.name,
referenceMap: getters.roleItems,
referenceMap: getters.roleItems.value,
})),
});
};

const load = async (options?: ReferenceLoadOptions) => {
const currentTime = new Date().getTime();
Expand Down
Loading