//
// SPDX-License-Identifier: AGPL-3.0
-import { unionize, ofType, UnionOf } from "unionize";
-import { CommonResourceService } from "../../common/api/common-resource-service";
-import { Dispatch } from "redux";
-import { apiClient } from "../../common/api/server-api";
-import { Resource, ResourceKind } from "../../models/resource";
+import { unionize, ofType, UnionOf } from '~/common/unionize';
export const detailsPanelActions = unionize({
TOGGLE_DETAILS_PANEL: ofType<{}>(),
- LOAD_DETAILS: ofType<{ uuid: string, kind: ResourceKind }>(),
- LOAD_DETAILS_SUCCESS: ofType<{ item: Resource }>(),
-}, { tag: 'type', value: 'payload' });
+ LOAD_DETAILS_PANEL: ofType<string>()
+});
export type DetailsPanelAction = UnionOf<typeof detailsPanelActions>;
-export const loadDetails = (uuid: string, kind: ResourceKind) =>
- (dispatch: Dispatch) => {
- dispatch(detailsPanelActions.LOAD_DETAILS({ uuid, kind }));
- getService(kind)
- .get(uuid)
- .then(project => {
- dispatch(detailsPanelActions.LOAD_DETAILS_SUCCESS({ item: project }));
- });
- };
-
-const getService = (kind: ResourceKind) => {
- switch (kind) {
- case ResourceKind.PROJECT:
- return new CommonResourceService(apiClient, "groups");
- case ResourceKind.COLLECTION:
- return new CommonResourceService(apiClient, "collections");
- default:
- return new CommonResourceService(apiClient, "");
- }
-};
+export const loadDetailsPanel = (uuid: string) => detailsPanelActions.LOAD_DETAILS_PANEL(uuid);
+