Skip to content

Commit 2f4ad13

Browse files
authored
Merge pull request #6952 from FlowFuse/6942-pinia-task-13-account-team
[6942] Pinia Task 13 - account-team
2 parents a30c57f + 642e705 commit 2f4ad13

File tree

149 files changed

+1420
-626
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+1420
-626
lines changed

frontend/src/App.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export default {
104104
...mapState(useUxDrawersStore, ['hiddenLeftDrawer']),
105105
...mapState(useAccountAuthStore, ['user']),
106106
...mapState(useUxLoadingStore, ['appLoader', 'offline']),
107-
...mapVuexState('account', ['team', 'settings']),
107+
...mapVuexState('account', ['settings']),
108108
loginRequired () {
109109
return this.$route.meta.requiresLogin !== false
110110
},

frontend/src/components/DevicesBrowser.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ import { CogIcon, PlusSmIcon } from '@heroicons/vue/solid'
348348
349349
import { mapActions, mapState } from 'pinia'
350350
import { markRaw } from 'vue'
351-
import { mapGetters, mapState as mapVuexState } from 'vuex'
351+
import { mapGetters } from 'vuex'
352352
353353
import deviceApi from '../api/devices.js'
354354
import teamApi from '../api/team.js'
@@ -386,6 +386,7 @@ import DevicesStatusBar from './charts/DeviceStatusBar.vue'
386386
import AddDeviceToGroupDialog from './dialogs/device-group-management/AddDeviceToGroupDialog.vue'
387387
import RemoveDeviceFromGroupDialog from './dialogs/device-group-management/RemoveDeviceFromGroupDialog.vue'
388388
389+
import { useContextStore } from '@/stores/context.js'
389390
import { useUxDialogStore } from '@/stores/ux-dialog.js'
390391
import { useUxToursStore } from '@/stores/ux-tours.js'
391392
@@ -461,7 +462,7 @@ export default {
461462
}
462463
},
463464
computed: {
464-
...mapVuexState('account', ['team', 'teamMembership']),
465+
...mapState(useContextStore, ['team']),
465466
...mapGetters('account', ['featuresCheck']),
466467
...mapState(useUxDialogStore, ['dialog']),
467468
...mapState(useUxToursStore, ['tours']),
@@ -615,7 +616,7 @@ export default {
615616
if (this.deviceCountDeltaSincePageLoad !== 0) {
616617
// Trigger a refresh of team info to resync following device
617618
// changes
618-
await this.$store.dispatch('account/refreshTeam')
619+
await useContextStore().refreshTeam()
619620
}
620621
},
621622
methods: {

frontend/src/components/NotificationsButton.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,18 @@
1111
import { MailIcon } from '@heroicons/vue/outline'
1212
import { mapActions, mapState } from 'pinia'
1313
import { markRaw } from 'vue'
14-
import { mapGetters } from 'vuex'
1514
1615
import NotificationsDrawer from './drawers/notifications/NotificationsDrawer.vue'
1716
17+
import { useAccountStore } from '@/stores/account.js'
1818
import { useUxDrawersStore } from '@/stores/ux-drawers.js'
1919
2020
export default {
2121
name: 'NotificationsButton',
2222
components: { MailIcon },
2323
computed: {
2424
...mapState(useUxDrawersStore, ['rightDrawer']),
25-
...mapGetters('account', ['hasNotifications']),
26-
...mapGetters('account', ['unreadNotificationsCount']),
25+
...mapState(useAccountStore, ['hasNotifications', 'unreadNotificationsCount']),
2726
notificationsCount: function () {
2827
// Return null if count = 0 so we don't show a 0 in the pill
2928
if (!this.unreadNotificationsCount) {

frontend/src/components/PageHeader.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
import { AcademicCapIcon, AdjustmentsIcon, CogIcon, CursorClickIcon, LogoutIcon, MenuIcon, PlusIcon, QuestionMarkCircleIcon, XIcon } from '@heroicons/vue/solid'
105105
import { mapActions, mapState } from 'pinia'
106106
import { ref } from 'vue'
107-
import { mapGetters, mapState as mapVuexState } from 'vuex'
107+
import { mapGetters } from 'vuex'
108108
109109
import usePermissions from '../composables/Permissions.js'
110110
@@ -120,6 +120,8 @@ import TeamSelection from './TeamSelection.vue'
120120
import GlobalSearch from './global-search/GlobalSearch.vue'
121121
122122
import { useAccountAuthStore } from '@/stores/account-auth.js'
123+
import { useAccountStore } from '@/stores/account.js'
124+
import { useContextStore } from '@/stores/context.js'
123125
import { useUxDrawersStore } from '@/stores/ux-drawers.js'
124126
import { useUxToursStore } from '@/stores/ux-tours.js'
125127
@@ -132,8 +134,9 @@ export default {
132134
},
133135
...mapState(useUxDrawersStore, ['leftDrawer', 'hiddenLeftDrawer']),
134136
...mapState(useAccountAuthStore, ['user']),
135-
...mapVuexState('account', ['team', 'teams']),
136-
...mapGetters('account', ['notifications', 'hasAvailableTeams', 'defaultUserTeam', 'canCreateTeam', 'isTrialAccount', 'featuresCheck']),
137+
...mapState(useContextStore, ['team']),
138+
...mapState(useAccountStore, ['teams', 'notifications', 'hasAvailableTeams', 'defaultUserTeam']),
139+
...mapGetters('account', ['canCreateTeam', 'featuresCheck']),
137140
navigationOptions () {
138141
return [
139142
{

frontend/src/components/TeamSelection.vue

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,16 @@ import {
4242
ListboxOption
4343
} from '@headlessui/vue'
4444
import { PlusIcon, UserAddIcon } from '@heroicons/vue/solid'
45-
import { mapGetters, mapState } from 'vuex'
45+
import { mapState } from 'pinia'
46+
import { mapGetters, mapState as mapVuexState } from 'vuex'
4647
4748
import usePermissions from '../composables/Permissions.js'
4849
4950
import NavItem from './NavItem.vue'
5051
52+
import { useAccountStore } from '@/stores/account.js'
53+
import { useContextStore } from '@/stores/context.js'
54+
5155
export default {
5256
name: 'FFTeamSelection',
5357
emits: ['option-selected'],
@@ -61,8 +65,10 @@ export default {
6165
return { PlusIcon, UserAddIcon, hasPermission }
6266
},
6367
computed: {
64-
...mapState('account', ['team', 'teams', 'settings']),
65-
...mapGetters('account', ['hasAvailableTeams', 'canCreateTeam']),
68+
...mapState(useContextStore, ['team']),
69+
...mapState(useAccountStore, ['teams', 'hasAvailableTeams']),
70+
...mapVuexState('account', ['settings']),
71+
...mapGetters('account', ['canCreateTeam']),
6672
teamOptions () {
6773
return [
6874
...this.teams.map(team => {
@@ -101,7 +107,7 @@ export default {
101107
methods: {
102108
selectTeam (team) {
103109
if (team) {
104-
this.$store.dispatch('account/setTeam', team.slug)
110+
useAccountStore().setTeam(team.slug)
105111
.then(() => this.$router.push({
106112
name: 'Team',
107113
params: {

frontend/src/components/TeamTypeTile.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131

3232
<script>
3333
import { mapState } from 'pinia'
34-
import { mapState as mapVuexState } from 'vuex'
3534
3635
import { useHubspotHelper } from '../composables/Hubspot.js'
3736
3837
import { useAccountAuthStore } from '@/stores/account-auth.js'
38+
import { useAccountStore } from '@/stores/account.js'
3939
4040
export default {
4141
name: 'TeamTypeTile',
@@ -59,7 +59,7 @@ export default {
5959
return { talkToSalesCalendarModal }
6060
},
6161
computed: {
62-
...mapVuexState('account', ['teams']),
62+
...mapState(useAccountStore, ['teams']),
6363
...mapState(useAccountAuthStore, ['user']),
6464
pricing: function () {
6565
const billingDescriptionKey = this.billingInterval === 'year' ? 'yrDescription' : 'description'

frontend/src/components/banners/FeatureUnavailableToTeam.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@
2626
<script>
2727
import { SparklesIcon } from '@heroicons/vue/outline'
2828
29-
import { mapState } from 'vuex'
29+
import { mapState } from 'pinia'
30+
31+
import { useContextStore } from '@/stores/context.js'
3032
3133
export default {
3234
name: 'FeatureUnavailableToTeam',
@@ -49,7 +51,7 @@ export default {
4951
}
5052
},
5153
computed: {
52-
...mapState('account', ['team']),
54+
...mapState(useContextStore, ['team']),
5355
upgradePath () {
5456
return { name: 'TeamChangeType', params: { team_slug: this.team.slug } }
5557
}

frontend/src/components/banners/SubscriptionExpired.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@
2828

2929
<script>
3030
import { ChevronRightIcon, ExclamationCircleIcon } from '@heroicons/vue/outline'
31-
import { mapState } from 'vuex'
31+
import { mapState } from 'pinia'
3232
3333
import usePermissions from '../../composables/Permissions.js'
3434
35+
import { useContextStore } from '@/stores/context.js'
36+
3537
export default {
3638
name: 'SubscriptionExpired',
3739
components: {
@@ -44,7 +46,7 @@ export default {
4446
return { hasPermission }
4547
},
4648
computed: {
47-
...mapState('account', ['team']),
49+
...mapState(useContextStore, ['team']),
4850
billingPath () {
4951
return '/team/' + this.team.slug + '/billing'
5052
},

frontend/src/components/banners/TeamSuspended.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,17 @@
1313

1414
<script>
1515
import { ExclamationCircleIcon } from '@heroicons/vue/outline'
16-
import { mapState } from 'vuex'
16+
import { mapState } from 'pinia'
17+
18+
import { useContextStore } from '@/stores/context.js'
1719
1820
export default {
1921
name: 'TeamSuspended',
2022
components: {
2123
ExclamationCircleIcon
2224
},
2325
computed: {
24-
...mapState('account', ['team'])
26+
...mapState(useContextStore, ['team'])
2527
}
2628
}
2729
</script>

frontend/src/components/banners/TeamTrial.vue

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,12 @@
3838
<script>
3939
import { ChevronRightIcon, ExclamationCircleIcon } from '@heroicons/vue/outline'
4040
41-
import { mapState } from 'vuex'
41+
import { mapState } from 'pinia'
4242
4343
import usePermissions from '../../composables/Permissions.js'
4444
45+
import { useContextStore } from '@/stores/context.js'
46+
4547
export default {
4648
name: 'TeamTrialBanner',
4749
components: {
@@ -54,7 +56,7 @@ export default {
5456
return { hasPermission }
5557
},
5658
computed: {
57-
...mapState('account', ['team', 'teamMembership']),
59+
...mapState(useContextStore, ['team']),
5860
billingPath () {
5961
return '/team/' + this.team.slug + '/settings/change-type'
6062
},

0 commit comments

Comments
 (0)