5454 </div >
5555</template >
5656
57- <script lang="ts">
57+ <script lang="ts" setup >
5858import AppTemplate from ' ../components/AppTemplate.vue'
5959import ContextActions from ' ../components/Groups/ContextActions.vue'
6060import DetailsPanel from ' ../components/Groups/SideBar/DetailsPanel.vue'
@@ -72,135 +72,106 @@ import {
7272 useSideBar
7373} from ' @ownclouders/web-pkg'
7474import { Group } from ' @ownclouders/web-client/graph/generated'
75- import { computed , defineComponent , ref , unref , onBeforeUnmount , onMounted } from ' vue'
75+ import { computed , provide , ref , unref , onBeforeUnmount , onMounted } from ' vue'
7676import { useTask } from ' vue-concurrency'
7777import { useGettext } from ' vue3-gettext'
7878import { storeToRefs } from ' pinia'
7979import { call } from ' @ownclouders/web-client'
8080
81- export default defineComponent ({
82- components: {
83- AppLoadingSpinner ,
84- AppTemplate ,
85- GroupsList ,
86- NoContentMessage ,
87- ContextActions
88- },
89- provide() {
90- return {
91- group: computed (() => this .selectedGroups [0 ])
92- }
93- },
94- setup() {
95- const template = ref ()
96- const groupSettingsStore = useGroupSettingsStore ()
97- const { selectedGroups, groups } = storeToRefs (groupSettingsStore )
98- const clientService = useClientService ()
99- const { $gettext } = useGettext ()
100-
101- const { actions : createGroupActions } = useGroupActionsCreateGroup ()
102- const createGroupAction = computed (() => unref (createGroupActions )[0 ])
81+ const template = ref ()
82+ const groupSettingsStore = useGroupSettingsStore ()
83+ const { selectedGroups, groups } = storeToRefs (groupSettingsStore )
84+ const clientService = useClientService ()
85+ const { $gettext } = useGettext ()
86+ const { sideBarActivePanel, isSideBarOpen } = useSideBar ()
10387
104- const loadResourcesTask = useTask (function * (signal ) {
105- const loadedGroups = yield * call (
106- clientService .graphAuthenticated .groups .listGroups (
107- {
108- orderBy: [' displayName' ],
109- expand: [' members' ]
110- },
111- { signal }
112- )
113- )
114- groupSettingsStore .setGroups (loadedGroups || [])
115- }).restartable ()
88+ provide (' group' , selectedGroups [0 ])
11689
117- const { actions : deleteActions } = useGroupActionsDelete ()
118- const batchActions = computed (() => {
119- return [... unref (deleteActions )].filter ((item ) =>
120- item .isVisible ({ resources: unref (selectedGroups ) })
121- )
122- })
123-
124- const isLoading = computed (() => {
125- return loadResourcesTask .isRunning || ! loadResourcesTask .last
126- })
127-
128- const sideBarPanelContext = computed <SideBarPanelContext <unknown , unknown , Group >>(() => {
129- return {
130- parent: null ,
131- items: unref (selectedGroups )
132- }
133- })
90+ const { actions : createGroupActions } = useGroupActionsCreateGroup ()
91+ const createGroupAction = computed (() => unref (createGroupActions )[0 ])
13492
135- const sideBarAvailablePanels = [
136- {
137- name: ' DetailsPanel' ,
138- icon: ' group-2' ,
139- title : () => $gettext (' Details' ),
140- component: DetailsPanel ,
141- componentAttrs : () => ({ groups: unref (selectedGroups ) }),
142- isRoot : () => true ,
143- isVisible : () => true
144- },
93+ const loadResourcesTask = useTask (function * (signal ) {
94+ const loadedGroups = yield * call (
95+ clientService .graphAuthenticated .groups .listGroups (
14596 {
146- name: ' EditPanel' ,
147- icon: ' pencil' ,
148- title : () => $gettext (' Edit group' ),
149- component: EditPanel ,
150- componentAttrs : ({ items }) => {
151- return {
152- group: items .length === 1 ? items [0 ] : null
153- }
154- },
155- isVisible : ({ items }) => {
156- return items .length === 1 && ! items [0 ].groupTypes ?.includes (' ReadOnly' )
157- }
97+ orderBy: [' displayName' ],
98+ expand: [' members' ]
15899 },
159- {
160- name: ' GroupMembers' ,
161- icon: ' group' ,
162- title : () => $gettext (' Members' ),
163- component: MembersPanel ,
164- isVisible : ({ items }) => items .length === 1
165- }
166- ] satisfies SideBarPanel <unknown , unknown , Group >[]
100+ { signal }
101+ )
102+ )
103+ groupSettingsStore .setGroups (loadedGroups || [])
104+ }).restartable ()
105+
106+ const { actions : deleteActions } = useGroupActionsDelete ()
107+ const batchActions = computed (() => {
108+ return [... unref (deleteActions )].filter ((item ) =>
109+ item .isVisible ({ resources: unref (selectedGroups ) })
110+ )
111+ })
167112
168- onMounted ( async () => {
169- await loadResourcesTask .perform ()
170- })
113+ const isLoading = computed ( () => {
114+ return loadResourcesTask . isRunning || ! loadResourcesTask .last
115+ })
171116
172- onBeforeUnmount (() => {
173- groupSettingsStore .reset ()
174- })
117+ const sideBarPanelContext = computed <SideBarPanelContext <unknown , unknown , Group >>(() => {
118+ return {
119+ parent: null ,
120+ items: unref (selectedGroups )
121+ }
122+ })
175123
176- return {
177- ... useSideBar (),
178- groups ,
179- selectedGroups ,
180- template ,
181- loadResourcesTask ,
182- clientService ,
183- batchActions ,
184- sideBarAvailablePanels ,
185- sideBarPanelContext ,
186- createGroupAction ,
187- groupSettingsStore ,
188- isLoading
189- }
124+ const sideBarAvailablePanels = [
125+ {
126+ name: ' DetailsPanel' ,
127+ icon: ' group-2' ,
128+ title : () => $gettext (' Details' ),
129+ component: DetailsPanel ,
130+ componentAttrs : () => ({ groups: unref (selectedGroups ) }),
131+ isRoot : () => true ,
132+ isVisible : () => true
190133 },
191- computed: {
192- breadcrumbs() {
193- return [
194- { text: this . $gettext (' Administration Settings ' ), to: { path: ' /admin-settings ' } } ,
195- {
196- text: this . $gettext ( ' Groups ' ),
197- onClick : () => {
198- this . groupSettingsStore . setSelectedGroups ([])
199- this . loadResourcesTask . perform ()
200- }
201- }
202- ]
134+ {
135+ name: ' EditPanel ' ,
136+ icon: ' pencil ' ,
137+ title : () => $gettext (' Edit group ' ) ,
138+ component: EditPanel ,
139+ componentAttrs : ({ items }) => {
140+ return {
141+ group: items . length === 1 ? items [ 0 ] : null
142+ }
143+ },
144+ isVisible : ({ items }) => {
145+ return items . length === 1 && ! items [ 0 ]. groupTypes ?. includes ( ' ReadOnly ' )
203146 }
147+ },
148+ {
149+ name: ' GroupMembers' ,
150+ icon: ' group' ,
151+ title : () => $gettext (' Members' ),
152+ component: MembersPanel ,
153+ isVisible : ({ items }) => items .length === 1
204154 }
155+ ] satisfies SideBarPanel <unknown , unknown , Group >[]
156+
157+ onMounted (async () => {
158+ await loadResourcesTask .perform ()
159+ })
160+
161+ onBeforeUnmount (() => {
162+ groupSettingsStore .reset ()
163+ })
164+
165+ const breadcrumbs = computed (() => {
166+ return [
167+ { text: $gettext (' Administration Settings' ), to: { path: ' /admin-settings' } },
168+ {
169+ text: $gettext (' Groups' ),
170+ onClick : () => {
171+ groupSettingsStore .setSelectedGroups ([])
172+ loadResourcesTask .perform ()
173+ }
174+ }
175+ ]
205176})
206177 </script >
0 commit comments