Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

refactor: re-implement issue store module with pinia (#1097)

Liu Ji41a6130cc474
diff --git a/frontend/src/components/CreateDatabasePrepForm.vue b/frontend/src/components/CreateDatabasePrepForm.vue
index e1a2725f70..cacfad94f0 100644
--- a/frontend/src/components/CreateDatabasePrepForm.vue
+++ b/frontend/src/components/CreateDatabasePrepForm.vue
@@ -212,7 +212,6 @@ import {
defineComponent,
ref,
} from "vue";
-import { useStore } from "vuex";
import { useRouter } from "vue-router";
import { isEmpty } from "lodash-es";
import { NTooltip } from "naive-ui";
@@ -250,6 +249,7 @@ import {
useCurrentUser,
useEnvironmentStore,
useInstanceStore,
+ useIssueStore,
useProjectStore,
} from "@/store";
@@ -297,7 +297,6 @@ export default defineComponent({
},
emits: ["dismiss"],
setup(props, { emit }) {
- const store = useStore();
const instanceStore = useInstanceStore();
const router = useRouter();
@@ -496,9 +495,13 @@ export default defineComponent({
// Do not submit non-selected optional labels
const labelList = state.labelList.filter((label) => !!label.value);
context.labels = JSON.stringify(labelList);
- store.dispatch("issue/createIssue", newIssue).then((createdIssue) => {
- router.push(`/issue/${issueSlug(createdIssue.name, createdIssue.id)}`);
- });
+ useIssueStore()
+ .createIssue(newIssue)
+ .then((createdIssue) => {
+ router.push(
+ `/issue/${issueSlug(createdIssue.name, createdIssue.id)}`
+ );
+ });
};
// update `state.labelList` when selected Environment changed
diff --git a/frontend/src/components/DataSourceMemberForm.vue b/frontend/src/components/DataSourceMemberForm.vue
index c08ea279b7..913318f948 100644
--- a/frontend/src/components/DataSourceMemberForm.vue
+++ b/frontend/src/components/DataSourceMemberForm.vue
@@ -186,7 +186,7 @@ import {
} from "../types";
import { issueSlug } from "../utils";
import { useI18n } from "vue-i18n";
-import { pushNotification, useDatabaseStore } from "@/store";
+import { pushNotification, useDatabaseStore, useIssueStore } from "@/store";
interface LocalState {
environmentId?: EnvironmentId;
@@ -331,10 +331,7 @@ export default defineComponent({
let linkedIssue: Issue | undefined = undefined;
if (state.issueId) {
try {
- linkedIssue = await store.dispatch(
- "issue/fetchIssueById",
- state.issueId
- );
+ linkedIssue = await useIssueStore().fetchIssueById(state.issueId);
} catch (err) {
console.warn(`Unable to fetch linked issue id ${state.issueId}`, err);
}
diff --git a/frontend/src/components/Issue/IssueDetailLayout.vue b/frontend/src/components/Issue/IssueDetailLayout.vue
index 1e81f392ce..597fc90dfd 100644
--- a/frontend/src/components/Issue/IssueDetailLayout.vue
+++ b/frontend/src/components/Issue/IssueDetailLayout.vue
@@ -279,6 +279,7 @@ import {
useCurrentUser,
useDatabaseStore,
useInstanceStore,
+ useIssueStore,
useIssueSubscriberStore,
useProjectStore,
} from "@/store";
@@ -316,6 +317,7 @@ export default defineComponent({
const store = useStore();
const router = useRouter();
const route = useRoute();
+ const issueStore = useIssueStore();
const issueSubscriberStore = useIssueSubscriberStore();
const currentUser = useCurrentUser();
@@ -508,7 +510,7 @@ export default defineComponent({
delete issue.pipeline;
issue.payload = {};
- store.dispatch("issue/createIssue", issue).then((createdIssue) => {
+ issueStore.createIssue(issue).then((createdIssue) => {
// Use replace to omit the new issue url in the navigation history.
router.replace(
`/issue/${issueSlug(createdIssue.name, createdIssue.id)}`
@@ -521,9 +523,8 @@ export default defineComponent({
status: newStatus,
comment: comment,
};
-
- store
- .dispatch("issue/updateIssueStatus", {
+ issueStore
+ .updateIssueStatus({
issueId: (props.issue as Issue).id,
issueStatusPatch,
})
@@ -578,8 +579,8 @@ export default defineComponent({
issuePatch: IssuePatch,
postUpdated?: (updatedIssue: Issue) => void
) => {
- store
- .dispatch("issue/patchIssue", {
+ issueStore
+ .patchIssue({
issueId: (props.issue as Issue).id,
issuePatch,
})
diff --git a/frontend/src/components/ProjectOverviewPanel.vue b/frontend/src/components/ProjectOverviewPanel.vue
index 6c34d91334..c646dc71dd 100644
--- a/frontend/src/components/ProjectOverviewPanel.vue
+++ b/frontend/src/components/ProjectOverviewPanel.vue
@@ -119,7 +119,6 @@ import {
computed,
defineComponent,
} from "vue";
-import { useStore } from "vuex";
import ActivityTable from "../components/ActivityTable.vue";
import DatabaseTable from "../components/DatabaseTable.vue";
import TenantDatabaseTable, { YAxisRadioGroup } from "./TenantDatabaseTable";
@@ -134,7 +133,7 @@ import {
} from "../types";
import { findDefaultGroupByLabel } from "../utils";
import { NSpin } from "naive-ui";
-import { useActivityStore, useLabelStore } from "@/store";
+import { useActivityStore, useIssueStore, useLabelStore } from "@/store";
import { storeToRefs } from "pinia";
// Show at most 5 activity
@@ -170,7 +169,6 @@ export default defineComponent({
},
},
setup(props) {
- const store = useStore();
const labelStore = useLabelStore();
const state = reactive<LocalState>({
@@ -194,8 +192,8 @@ export default defineComponent({
};
const prepareIssueList = () => {
- store
- .dispatch("issue/fetchIssueList", {
+ useIssueStore()
+ .fetchIssueList({
projectId: props.project.id,
})
.then((issueList: Issue[]) => {
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 6ca6b69bcf..4f00e38c52 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -18,6 +18,7 @@ import {
useDatabaseStore,
useEnvironmentStore,
useInstanceStore,
+ useIssueStore,
usePrincipalStore,
useRouterStore,
} from "../store";
@@ -752,7 +753,8 @@ const routes: Array<RouteRecordRaw> = [
if (slug.toLowerCase() == "new") {
return t("common.new");
}
- return store.getters["issue/issueById"](idFromSlug(slug)).name;
+ const issue = useIssueStore().getIssueById(idFromSlug(slug));
+ return issue.name;
},
allowBookmark: true,
},
@@ -816,6 +818,7 @@ router.beforeEach((to, from, next) => {
const databaseStore = useDatabaseStore();
const environmentStore = useEnvironmentStore();
const instanceStore = useInstanceStore();
+ const issueStore = useIssueStore();
const tabStore = useTabStore();
const routerStore = useRouterStore();
const projectWebhookStore = useProjectWebhookStore();
@@ -1044,8 +1047,8 @@ router.beforeEach((to, from, next) => {
});
return;
}
- store
- .dispatch("issue/fetchIssueById", idFromSlug(issueSlug))
+ issueStore
+ .fetchIssueById(idFromSlug(issueSlug))
.then(() => {
next();
})
diff --git a/frontend/src/store/modules/issue.ts b/frontend/src/store/modules/issue.ts
deleted file mode 100644
index 0b88ac6885..0000000000
--- a/frontend/src/store/modules/issue.ts
+++ /dev/null
@@ -1,308 +0,0 @@
-import axios from "axios";
-import {
- empty,
- EMPTY_ID,
- Issue,
- IssueCreate,
- IssueId,
- IssuePatch,
- IssueState,
- IssueStatus,
- IssueStatusPatch,
- Pipeline,
- Principal,
- PrincipalId,
- Project,
- ProjectId,
- ResourceIdentifier,
- ResourceObject,
- unknown,
-} from "../../types";
-import {
- getPrincipalFromIncludedList,
- useActivityStore,
- useDatabaseStore,
- useInstanceStore,
- useProjectStore,
-} from "../pinia-modules";
-
-function convert(
- issue: ResourceObject,
- includedList: ResourceObject[],
- rootGetters: any
-): Issue {
- const projectId = (issue.relationships!.project.data as ResourceIdentifier)
- .id;
- let project: Project = unknown("PROJECT") as Project;
- project.id = parseInt(projectId);
-
- const pipelineId = (issue.relationships!.pipeline.data as ResourceIdentifier)
- .id;
- let pipeline = unknown("PIPELINE") as Pipeline;
- pipeline.id = parseInt(pipelineId);
-
- for (const item of includedList || []) {
- if (
- item.type == "project" &&
- (issue.relationships!.project.data as ResourceIdentifier).id == item.id
- ) {
- project = useProjectStore().convert(item, includedList || []);
- }
-
- if (
- item.type == "pipeline" &&
- issue.relationships!.pipeline.data &&
- (issue.relationships!.pipeline.data as ResourceIdentifier).id == item.id
- ) {
- pipeline = rootGetters["pipeline/convert"](item, includedList);
- }
- }
-
- const subscriberList = [] as Principal[];
- if (issue.relationships!.subscriberList.data) {
- for (const subscriberData of issue.relationships!.subscriberList
- .data as ResourceIdentifier[]) {
- subscriberList.push(
- getPrincipalFromIncludedList(subscriberData, includedList)
- );
- }
- }
-
- return {
- ...(issue.attributes as Omit<
- Issue,
- "id" | "project" | "creator" | "updater" | "assignee" | "subscriberList"
- >),
- id: parseInt(issue.id),
- creator: getPrincipalFromIncludedList(
- issue.relationships!.creator.data,
- includedList
- ),
- updater: getPrincipalFromIncludedList(
- issue.relationships!.updater.data,
- includedList
- ),
- assignee: getPrincipalFromIncludedList(
- issue.relationships!.assignee.data,
- includedList
- ),
- project,
- pipeline,
- subscriberList: subscriberList,
- };
-}
-
-const state: () => IssueState = () => ({
- issueById: new Map(),
-});
-
-const getters = {
- issueById:
- (state: IssueState) =>
- (issueId: IssueId): Issue => {
- if (issueId == EMPTY_ID) {
- return empty("ISSUE") as Issue;
- }
-
- return state.issueById.get(issueId) || (unknown("ISSUE") as Issue);
- },
-};
-
-const actions = {
- async fetchIssueList(
- { rootGetters }: any,
- {
- issueStatusList,
- userId,
- projectId,
- limit,
- }: {
- issueStatusList?: IssueStatus[];
- userId?: PrincipalId;
- projectId?: ProjectId;
- limit?: number;
- }
- ) {
- const queryList = [];
- if (issueStatusList) {
- queryList.push(`status=${issueStatusList.join(",")}`);
- }
- if (userId) {
- queryList.push(`user=${userId}`);
- }
- if (projectId) {
- queryList.push(`project=${projectId}`);
- }
- if (limit) {
- queryList.push(`limit=${limit}`);
- }
- let url = "/api/issue";
- if (queryList.length > 0) {
- url += `?${queryList.join("&")}`;
- }
- const data = (await axios.get(url)).data;
- const issueList = data.data.map((issue: ResourceObject) => {
- return convert(issue, data.included, rootGetters);
- });
-
- // The caller consumes directly, so we don't store it.
- return issueList;
- },
-
- async fetchIssueById({ commit, rootGetters }: any, issueId: IssueId) {
- const data = (await axios.get(`/api/issue/${issueId}`)).data;
- const issue = convert(data.data, data.included, rootGetters);
- commit("setIssueById", {
- issueId,
- issue,
- });
-
- // It might be the first time the particular instance/database objects are returned,
- // so that we should also update instance/database store, otherwise, we may get
- // unknown instance/database when navigating to other UI from the issue detail page
- // since other UIs are getting instance/database by id from the store.
- const instanceStore = useInstanceStore();
- const databaseStore = useDatabaseStore();
- for (const stage of issue.pipeline.stageList) {
- for (const task of stage.taskList) {
- instanceStore.setInstanceById({
- instanceId: task.instance.id,
- instance: task.instance,
- });
-
- if (task.database) {
- databaseStore.upsertDatabaseList({
- databaseList: [task.database],
- });
- }
- }
- }
- return issue;
- },
-
- async createIssue({ commit, rootGetters }: any, newIssue: IssueCreate) {
- const data = (
- await axios.post(`/api/issue`, {
- data: {
- type: "IssueCreate",
- attributes: {
- ...newIssue,
- // Server expects payload as string, so we stringify first.
- createContext: JSON.stringify(newIssue.createContext),
- payload: JSON.stringify(newIssue.payload),
- },
- },
- })
- ).data;
- const createdIssue = convert(data.data, data.included, rootGetters);
-
- commit("setIssueById", {
- issueId: createdIssue.id,
- issue: createdIssue,
- });
-
- return createdIssue;
- },
-
- async validateIssue({ commit, rootGetters }: any, newIssue: IssueCreate) {
- const data = (
- await axios.post(`/api/issue`, {
- data: {
- type: "IssueCreate",
- attributes: {
- ...newIssue,
- // Server expects payload as string, so we stringify first.
- createContext: JSON.stringify(newIssue.createContext),
- payload: JSON.stringify(newIssue.payload),
- validateOnly: true,
- },
- },
- })
- ).data;
- const createdIssue = convert(data.data, data.included, rootGetters);
- return createdIssue;
- },
-
- async patchIssue(
- { commit, dispatch, rootGetters }: any,
- {
- issueId,
- issuePatch,
- }: {
- issueId: IssueId;
- issuePatch: IssuePatch;
- }
- ) {
- const data = (
- await axios.patch(`/api/issue/${issueId}`, {
- data: {
- type: "issuePatch",
- attributes: issuePatch,
- },
- })
- ).data;
- const updatedIssue = convert(data.data, data.included, rootGetters);
-
- commit("setIssueById", {
- issueId: issueId,
- issue: updatedIssue,
- });
-
- useActivityStore().fetchActivityListForIssue(issueId);
-
- return updatedIssue;
- },
-
- async updateIssueStatus(
- { commit, dispatch, rootGetters }: any,
- {
- issueId,
- issueStatusPatch,
- }: {
- issueId: IssueId;
- issueStatusPatch: IssueStatusPatch;
- }
- ) {
- const data = (
- await axios.patch(`/api/issue/${issueId}/status`, {
- data: {
- type: "issueStatusPatch",
- attributes: issueStatusPatch,
- },
- })
- ).data;
- const updatedIssue = convert(data.data, data.included, rootGetters);
-
- commit("setIssueById", {
- issueId: issueId,
- issue: updatedIssue,
- });
-
- useActivityStore().fetchActivityListForIssue(issueId);
-
- return updatedIssue;
- },
-};
-
-const mutations = {
- setIssueById(
- state: IssueState,
- {
- issueId,
- issue,
- }: {
- issueId: IssueId;
- issue: Issue;
- }
- ) {
- state.issueById.set(issueId, issue);
- },
-};
-
-export default {
- namespaced: true,
- state,
- getters,
- actions,
- mutations,
-};
diff --git a/frontend/src/store/pinia-modules/index.ts b/frontend/src/store/pinia-modules/index.ts
index a67d590c1a..89d108a27f 100644
--- a/frontend/src/store/pinia-modules/index.ts
+++ b/frontend/src/store/pinia-modules/index.ts
@@ -11,6 +11,7 @@ export * from "./debug";
export * from "./deployment";
export * from "./environment";
export * from "./gitlab";
+export * from "./issue";
export * from "./issueSubscriber";
export * from "./inbox";
export * from "./instance";
diff --git a/frontend/src/store/pinia-modules/issue.ts b/frontend/src/store/pinia-modules/issue.ts
new file mode 100644
index 0000000000..fda0120838
--- /dev/null
+++ b/frontend/src/store/pinia-modules/issue.ts
@@ -0,0 +1,267 @@
+import axios from "axios";
+import {
+ empty,
+ EMPTY_ID,
+ Issue,
+ IssueCreate,
+ IssueId,
+ IssuePatch,
+ IssueState,
+ IssueStatus,
+ IssueStatusPatch,
+ Pipeline,
+ Principal,
+ PrincipalId,
+ Project,
+ ProjectId,
+ ResourceIdentifier,
+ ResourceObject,
+ unknown,
+} from "@/types";
+import { getPrincipalFromIncludedList } from "./principal";
+import { useActivityStore } from "./activity";
+import { useDatabaseStore } from "./database";
+import { useInstanceStore } from "./instance";
+import { useProjectStore } from "./project";
+import { store } from "../index";
+import { defineStore } from "pinia";
+
+function convert(issue: ResourceObject, includedList: ResourceObject[]): Issue {
+ const projectId = (issue.relationships!.project.data as ResourceIdentifier)
+ .id;
+ let project: Project = unknown("PROJECT") as Project;
+ project.id = parseInt(projectId);
+
+ const pipelineId = (issue.relationships!.pipeline.data as ResourceIdentifier)
+ .id;
+ let pipeline = unknown("PIPELINE") as Pipeline;
+ pipeline.id = parseInt(pipelineId);
+
+ const projectStore = useProjectStore();
+ for (const item of includedList || []) {
+ if (
+ item.type == "project" &&
+ (issue.relationships!.project.data as ResourceIdentifier).id == item.id
+ ) {
+ project = projectStore.convert(item, includedList || []);
+ }
+
+ if (
+ item.type == "pipeline" &&
+ issue.relationships!.pipeline.data &&
+ (issue.relationships!.pipeline.data as ResourceIdentifier).id == item.id
+ ) {
+ pipeline = store.getters["pipeline/convert"](item, includedList);
+ }
+ }
+
+ const subscriberList = [] as Principal[];
+ if (issue.relationships!.subscriberList.data) {
+ for (const subscriberData of issue.relationships!.subscriberList
+ .data as ResourceIdentifier[]) {
+ subscriberList.push(
+ getPrincipalFromIncludedList(subscriberData, includedList)
+ );
+ }
+ }
+
+ return {
+ ...(issue.attributes as Omit<
+ Issue,
+ "id" | "project" | "creator" | "updater" | "assignee" | "subscriberList"
+ >),
+ id: parseInt(issue.id),
+ creator: getPrincipalFromIncludedList(
+ issue.relationships!.creator.data,
+ includedList
+ ),
+ updater: getPrincipalFromIncludedList(
+ issue.relationships!.updater.data,
+ includedList
+ ),
+ assignee: getPrincipalFromIncludedList(
+ issue.relationships!.assignee.data,
+ includedList
+ ),
+ project,
+ pipeline,
+ subscriberList: subscriberList,
+ };
+}
+
+export const useIssueStore = defineStore("issue", {
+ state: (): IssueState => ({
+ issueById: new Map(),
+ }),
+ actions: {
+ getIssueById(issueId: IssueId): Issue {
+ if (issueId == EMPTY_ID) {
+ return empty("ISSUE") as Issue;
+ }
+
+ return this.issueById.get(issueId) || (unknown("ISSUE") as Issue);
+ },
+ setIssueById({ issueId, issue }: { issueId: IssueId; issue: Issue }) {
+ this.issueById.set(issueId, issue);
+ },
+ async fetchIssueList({
+ issueStatusList,
+ userId,
+ projectId,
+ limit,
+ }: {
+ issueStatusList?: IssueStatus[];
+ userId?: PrincipalId;
+ projectId?: ProjectId;
+ limit?: number;
+ }) {
+ const queryList = [];
+ if (issueStatusList) {
+ queryList.push(`status=${issueStatusList.join(",")}`);
+ }
+ if (userId) {
+ queryList.push(`user=${userId}`);
+ }
+ if (projectId) {
+ queryList.push(`project=${projectId}`);
+ }
+ if (limit) {
+ queryList.push(`limit=${limit}`);
+ }
+ let url = "/api/issue";
+ if (queryList.length > 0) {
+ url += `?${queryList.join("&")}`;
+ }
+ const data = (await axios.get(url)).data;
+ const issueList: Issue[] = data.data.map((issue: ResourceObject) => {
+ return convert(issue, data.included);
+ });
+
+ // The caller consumes directly, so we don't store it.
+ return issueList;
+ },
+ async fetchIssueById(issueId: IssueId) {
+ const data = (await axios.get(`/api/issue/${issueId}`)).data;
+ const issue = convert(data.data, data.included);
+ this.setIssueById({
+ issueId,
+ issue,
+ });
+
+ // It might be the first time the particular instance/database objects are returned,
+ // so that we should also update instance/database store, otherwise, we may get
+ // unknown instance/database when navigating to other UI from the issue detail page
+ // since other UIs are getting instance/database by id from the store.
+ const instanceStore = useInstanceStore();
+ const databaseStore = useDatabaseStore();
+ for (const stage of issue.pipeline.stageList) {
+ for (const task of stage.taskList) {
+ instanceStore.setInstanceById({
+ instanceId: task.instance.id,
+ instance: task.instance,
+ });
+
+ if (task.database) {
+ databaseStore.upsertDatabaseList({
+ databaseList: [task.database],
+ });
+ }
+ }
+ }
+ return issue;
+ },
+ async createIssue(newIssue: IssueCreate) {
+ const data = (
+ await axios.post(`/api/issue`, {
+ data: {
+ type: "IssueCreate",
+ attributes: {
+ ...newIssue,
+ // Server expects payload as string, so we stringify first.
+ createContext: JSON.stringify(newIssue.createContext),
+ payload: JSON.stringify(newIssue.payload),
+ },
+ },
+ })
+ ).data;
+ const createdIssue = convert(data.data, data.included);
+
+ this.setIssueById({
+ issueId: createdIssue.id,
+ issue: createdIssue,
+ });
+
+ return createdIssue;
+ },
+ async validateIssue(newIssue: IssueCreate) {
+ const data = (
+ await axios.post(`/api/issue`, {
+ data: {
+ type: "IssueCreate",
+ attributes: {
+ ...newIssue,
+ // Server expects payload as string, so we stringify first.
+ createContext: JSON.stringify(newIssue.createContext),
+ payload: JSON.stringify(newIssue.payload),
+ validateOnly: true,
+ },
+ },
+ })
+ ).data;
+ const createdIssue = convert(data.data, data.included);
+ return createdIssue;
+ },
+ async patchIssue({
+ issueId,
+ issuePatch,
+ }: {
+ issueId: IssueId;
+ issuePatch: IssuePatch;
+ }) {
+ const data = (
+ await axios.patch(`/api/issue/${issueId}`, {
+ data: {
+ type: "issuePatch",
+ attributes: issuePatch,
+ },
+ })
+ ).data;
+ const updatedIssue = convert(data.data, data.included);
+
+ this.setIssueById({
+ issueId: issueId,
+ issue: updatedIssue,
+ });
+
+ useActivityStore().fetchActivityListForIssue(issueId);
+
+ return updatedIssue;
+ },
+ async updateIssueStatus({
+ issueId,
+ issueStatusPatch,
+ }: {
+ issueId: IssueId;
+ issueStatusPatch: IssueStatusPatch;
+ }) {
+ const data = (
+ await axios.patch(`/api/issue/${issueId}/status`, {
+ data: {
+ type: "issueStatusPatch",
+ attributes: issueStatusPatch,
+ },
+ })
+ ).data;
+ const updatedIssue = convert(data.data, data.included);
+
+ this.setIssueById({
+ issueId: issueId,
+ issue: updatedIssue,
+ });
+
+ useActivityStore().fetchActivityListForIssue(issueId);
+
+ return updatedIssue;
+ },
+ },
+});
diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue
index 94b9e03cca..803b2f8340 100644
--- a/frontend/src/views/Home.vue
+++ b/frontend/src/views/Home.vue
@@ -49,13 +49,12 @@
<script lang="ts">
import { watchEffect, onMounted, reactive, ref, defineComponent } from "vue";
-import { useStore } from "vuex";
import { useRouter } from "vue-router";
import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";
import { IssueTable } from "../components/Issue";
import { activeEnvironment, activeTask } from "../utils";
import { Environment, Issue, TaskStatus, UNKNOWN_ID } from "../types";
-import { useCurrentUser, useEnvironmentStore } from "@/store";
+import { useCurrentUser, useEnvironmentStore, useIssueStore } from "@/store";
// Show at most 10 recently closed issues
const MAX_CLOSED_ISSUE_COUNT = 10;
@@ -78,7 +77,7 @@ export default defineComponent({
setup() {
const searchField = ref();
- const store = useStore();
+ const issueStore = useIssueStore();
const router = useRouter();
const state = reactive<LocalState>({
@@ -104,8 +103,8 @@ export default defineComponent({
const prepareIssueList = () => {
// It will also be called when user logout
if (currentUser.value.id != UNKNOWN_ID) {
- store
- .dispatch("issue/fetchIssueList", {
+ issueStore
+ .fetchIssueList({
issueStatusList: ["OPEN"],
userId: currentUser.value.id,
})
@@ -129,8 +128,8 @@ export default defineComponent({
}
});
- store
- .dispatch("issue/fetchIssueList", {
+ issueStore
+ .fetchIssueList({
issueStatusList: ["DONE", "CANCELED"],
userId: currentUser.value.id,
limit: MAX_CLOSED_ISSUE_COUNT,
diff --git a/frontend/src/views/IssueDashboard.vue b/frontend/src/views/IssueDashboard.vue
index 344996daa1..63418f7fa4 100644
--- a/frontend/src/views/IssueDashboard.vue
+++ b/frontend/src/views/IssueDashboard.vue
@@ -41,7 +41,6 @@
<script lang="ts">
import { useRouter } from "vue-router";
-import { useStore } from "vuex";
import EnvironmentTabFilter from "../components/EnvironmentTabFilter.vue";
import { IssueTable } from "../components/Issue";
import MemberSelect from "../components/MemberSelect.vue";
@@ -57,7 +56,12 @@ import {
import { activeEnvironment, projectSlug } from "../utils";
import { BBTableSectionDataSource } from "../bbkit/types";
import { useI18n } from "vue-i18n";
-import { useCurrentUser, useEnvironmentStore, useProjectStore } from "@/store";
+import {
+ useCurrentUser,
+ useEnvironmentStore,
+ useIssueStore,
+ useProjectStore,
+} from "@/store";
interface LocalState {
showOpen: boolean;
@@ -77,7 +81,7 @@ export default defineComponent({
const { t } = useI18n();
const searchField = ref();
- const store = useStore();
+ const issueStore = useIssueStore();
const router = useRouter();
const currentUser = useCurrentUser();
@@ -130,8 +134,8 @@ export default defineComponent({
// We call open and close separately because normally the number of open issues is limited
// while the closed issues could be a lot.
if (state.showOpen) {
- store
- .dispatch("issue/fetchIssueList", {
+ issueStore
+ .fetchIssueList({
issueStatusList: ["OPEN"],
userId: scopeByPrincipal ? state.selectedPrincipalId : undefined,
projectId: state.selectedProjectId,
@@ -142,8 +146,8 @@ export default defineComponent({
}
if (state.showClosed) {
- store
- .dispatch("issue/fetchIssueList", {
+ issueStore
+ .fetchIssueList({
issueStatusList: ["DONE", "CANCELED"],
userId: scopeByPrincipal ? state.selectedPrincipalId : undefined,
projectId: state.selectedProjectId,
diff --git a/frontend/src/views/IssueDetail.vue b/frontend/src/views/IssueDetail.vue
index c4de920976..95d11013d2 100644
--- a/frontend/src/views/IssueDetail.vue
+++ b/frontend/src/views/IssueDetail.vue
@@ -27,7 +27,6 @@ import {
defineComponent,
Ref,
} from "vue";
-import { Store, useStore } from "vuex";
import { useRoute, _RouteLocationBase } from "vue-router";
import { idFromSlug } from "../utils";
import { IssueDetailLayout } from "../components/Issue";
@@ -60,6 +59,7 @@ import {
useActuatorStore,
useCurrentUser,
useDatabaseStore,
+ useIssueStore,
useProjectStore,
} from "@/store";
@@ -93,10 +93,10 @@ export default defineComponent({
},
setup(props) {
- const store = useStore();
const route = useRoute();
const currentUser = useCurrentUser();
+ const issueStore = useIssueStore();
const projectStore = useProjectStore();
let newIssueTemplate = ref<IssueTemplate>(defaultTemplate());
@@ -141,8 +141,8 @@ export default defineComponent({
const issue = computed((): Issue | IssueCreate => {
return state.create
- ? state.newIssue
- : store.getters["issue/issueById"](idFromSlug(props.issueSlug));
+ ? state.newIssue!
+ : issueStore.getIssueById(idFromSlug(props.issueSlug));
});
const findProject = async (): Promise<Project> => {
@@ -161,7 +161,7 @@ export default defineComponent({
const helper = new IssueCreateHelper({
template: newIssueTemplate,
currentUser,
- store,
+ issueStore,
route,
});
await helper.prepare();
@@ -196,7 +196,7 @@ export default defineComponent({
const helper = new IssueCreateHelper({
template: newIssueTemplate,
currentUser,
- store,
+ issueStore,
route,
});
await helper.prepare();
@@ -294,7 +294,7 @@ export default defineComponent({
}
state.pollIssueTimer = setTimeout(() => {
- store.dispatch("issue/fetchIssueById", idFromSlug(props.issueSlug));
+ issueStore.fetchIssueById(idFromSlug(props.issueSlug));
pollIssue(Math.min(interval * 2, NORMAL_POLL_INTERVAL));
}, Math.max(1000, Math.min(interval, NORMAL_POLL_INTERVAL) + (Math.random() * 2 - 1) * POLL_JITTER));
};
@@ -374,7 +374,7 @@ export default defineComponent({
type IssueCreateHelperContext = {
template: Ref<IssueTemplate>;
currentUser: Ref<Principal>;
- store: Store<any>;
+ issueStore: ReturnType<typeof useIssueStore>;
route: _RouteLocationBase;
};
@@ -436,11 +436,8 @@ class IssueCreateHelper {
}
async validate(): Promise<[IssueCreate, Issue]> {
- const { store } = this.context;
- const issue: Issue = await store.dispatch(
- "issue/validateIssue",
- this.issueCreate
- );
+ const { issueStore } = this.context;
+ const issue = await issueStore.validateIssue(this.issueCreate!);
this.issue = issue;