Skip to content
7 changes: 4 additions & 3 deletions frontend/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
</template>

<script>
import { mapState } from 'pinia'
import { mapActions, mapState as mapVuexState } from 'vuex'
import { mapActions, mapState } from 'pinia'
import { mapState as mapVuexState } from 'vuex'

import Loading from './components/Loading.vue'
import Offline from './components/Offline.vue'
Expand All @@ -78,6 +78,7 @@ import PasswordExpired from './pages/PasswordExpired.vue'
import TermsAndConditions from './pages/TermsAndConditions.vue'
import UnverifiedEmail from './pages/UnverifiedEmail.vue'

import { useContextStore } from '@/stores/context.js'
import { useUxDrawersStore } from '@/stores/ux-drawers.js'

export default {
Expand Down Expand Up @@ -144,7 +145,7 @@ export default {
this.$store.dispatch('product/checkFlags')
},
methods: {
...mapActions('context', ['updateRoute'])
...mapActions(useContextStore, ['updateRoute'])
}
}
</script>
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/pages/device/Editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@
<script>

import { CogIcon, HomeIcon, XIcon } from '@heroicons/vue/solid/index.js'
import { mapActions, mapGetters, mapState } from 'vuex'

import { mapActions } from 'pinia'
import { mapGetters, mapState } from 'vuex'

import DropdownMenu from '../../../components/DropdownMenu.vue'
import ResizeBar from '../../../components/ResizeBar.vue'
Expand All @@ -81,6 +83,8 @@ import usePermissions from '../../../composables/Permissions.js'
import { useResizingHelper } from '../../../composables/ResizingHelper.js'
import Alerts from '../../../services/alerts.js'

import { useContextStore } from '@/stores/context.js'

const DRAWER_DEFAULT_WIDTH = 550 // Default drawer width in pixels
const DRAWER_MAX_VIEWPORT_MARGIN = 200 // Space to preserve when drawer is at max width
const DRAWER_MAX_WIDTH_RATIO = 0.9 // Maximum drawer width as percentage of viewport (desktop)
Expand Down Expand Up @@ -312,7 +316,7 @@ export default {
this.stopPolling()
},
methods: {
...mapActions('context', { setContextDevice: 'setDevice' }),
...mapActions(useContextStore, { setContextDevice: 'setDevice' }),
loadDevice: async function () {
let tries = 0
let device = await this.fetchDevice(this.$route.params.id, false)
Expand Down
8 changes: 6 additions & 2 deletions frontend/src/pages/instance/Editor/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@

<script>
import { HomeIcon, XIcon } from '@heroicons/vue/solid'
import { mapActions, mapGetters } from 'vuex'

import { mapActions } from 'pinia'
import { mapGetters } from 'vuex'

import InstanceStatusPolling from '../../../components/InstanceStatusPolling.vue'
import ResizeBar from '../../../components/ResizeBar.vue'
Expand All @@ -89,6 +91,8 @@ import { Roles } from '../../../utils/roles.js'
import ConfirmInstanceDeleteDialog from '../Settings/dialogs/ConfirmInstanceDeleteDialog.vue'
import DashboardLink from '../components/DashboardLink.vue'

import { useContextStore } from '@/stores/context.js'

// Drawer size constraints
const DRAWER_MIN_WIDTH = 310 // Minimum drawer width in pixels
const DRAWER_DEFAULT_WIDTH = 550 // Default drawer width in pixels
Expand Down Expand Up @@ -246,7 +250,7 @@ export default {
this.clearInstance()
},
methods: {
...mapActions('context', ['setInstance', 'clearInstance'])
...mapActions(useContextStore, ['setInstance', 'clearInstance'])
}
}
</script>
2 changes: 0 additions & 2 deletions frontend/src/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@ import { createStore } from 'vuex'
import commonActions from './common/actions.js'
import commonMutations from './common/mutations.js'
import account from './modules/account/index.js'
import context from './modules/context/index.js'
import product from './modules/product/index.js'
import storagePlugin from './plugins/storage.plugin.js'

export default createStore({
modules: {
account,
context,
product
},
actions: {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/store/modules/account/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { getActivePinia } from 'pinia'
import { nextTick } from 'vue'

import flowBlueprintsApi from '../../../api/flowBlueprints.js'

import settingsApi from '../../../api/settings.js'
import teamApi from '../../../api/team.js'
import userApi from '../../../api/user.js'
import { getTeamProperty } from '../../../composables/TeamProperties.js'
import router from '../../../routes.js'
import product from '../../../services/product.js'

import { useContextStore } from '@/stores/context.js'
import { useUxDialogStore } from '@/stores/ux-dialog.js'
import { useUxDrawersStore } from '@/stores/ux-drawers.js'
import { useUxNavigationStore } from '@/stores/ux-navigation.js'
Expand Down Expand Up @@ -523,7 +523,7 @@ const actions = {
useUxNavigationStore().$reset()
useUxDrawersStore().$reset()
useUxStore().$reset()
// Task 5: useContextStore().$reset()
useContextStore().$reset()
// Task 6: useProductTablesStore().$reset()
// Task 7: useProductBrokersStore().$reset()
// Task 8: useProductAssistantStore().$reset()
Expand Down
111 changes: 0 additions & 111 deletions frontend/src/store/modules/context/index.js

This file was deleted.

10 changes: 6 additions & 4 deletions frontend/src/store/modules/product/assistant/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import SemVer from 'semver'

import messagingService from '../../../../services/messaging.service.js'

import { useContextStore } from '@/stores/context.js'

const MAX_DEBUG_LOG_ENTRIES = 100 // maximum number of debug log entries to keep

const eventsRegistry = {
Expand Down Expand Up @@ -159,11 +161,11 @@ const meta = {
const state = initialState()

const getters = {
immersiveInstance: (state, getters, rootState) => {
return rootState.context.instance
immersiveInstance: () => {
return useContextStore().instance
},
immersiveDevice: (state, getters, rootState) => {
return rootState.context.device
immersiveDevice: () => {
return useContextStore().device
},
hasUserSelection: (state) => {
return state.selectedNodes.length
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/store/modules/product/expert/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import { useUxDrawersStore } from '../../../../stores/ux-drawers.js'
import { FF_AGENT, OPERATOR_AGENT } from './agents.js'

import FFAgent from './ff-agent/index.js'

import OperatorAgent from './operator-agent/index.js'

import { useContextStore } from '@/stores/context.js'

const initialState = () => ({
shouldWakeUpAssistant: false,
agentMode: FF_AGENT, // ff-agent or operator-agent
Expand Down Expand Up @@ -331,11 +334,11 @@ const actions = {
commit('SET_ABORT_CONTROLLER', controller)
},

sendQuery ({ commit, state, getters, rootGetters, rootState }, { query }) {
sendQuery ({ commit, state, getters, rootState }, { query }) {
const payload = {
query,
context: {
...rootGetters['context/expert'],
...useContextStore().expert,
agent: state.agentMode
},
sessionId: state[state.agentMode].sessionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@
export function useAccountBridge () {
Comment thread
n-lark marked this conversation as resolved.
// Use require() instead of a top-level import to avoid a circular module dependency.
// Static imports of store/index.js here would create a cycle:
// ux-drawers.js → ux-navigation.js → _account-bridge.js → store/index.js → account/index.js → ux-navigation.js
// ux-drawers.js → ux-navigation.js → _account_bridge.js → store/index.js → account/index.js → ux-navigation.js
// By requiring lazily inside the function body, the Vuex store is fully initialized before this runs.
const store = require('../store/index.js').default
const user = store.state.account.user
const team = store.state.account.team
return {
team: store.state.account.team,
user,
userId: user?.id || null,
team,
teamId: team?.id || null,
teamSlug: team?.slug || null,
features: store.state.account.features,
teamMembership: store.getters['account/teamMembership'] ?? { role: 0 },
featuresCheck: store.getters['account/featuresCheck'],
requiresBilling: store.getters['account/requiresBilling'],
isTrialAccount: store.getters['account/isTrialAccount'] || false,
isTrialAccountExpired: store.getters['account/isTrialAccountExpired']
}
}
Loading
Loading