import { createCollectionFilesTree } from "~/models/collection-file";
import { Dispatch } from 'redux';
import { RootState } from '~/store/store';
+import { getUserUuid } from "~/common/getuser";
import { ServiceRepository } from '~/services/services';
import { FilterBuilder } from '~/services/api/filter-builder';
import { pipe, values } from 'lodash/fp';
export const initUserProject = (pickerId: string) =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
- const uuid = services.authService.getUuid();
+ const uuid = getUserUuid(getState());
if (uuid) {
dispatch(receiveTreePickerData({
id: '',
};
export const loadUserProject = (pickerId: string, includeCollections = false, includeFiles = false) =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
- const uuid = services.authService.getUuid();
+ const uuid = getUserUuid(getState());
if (uuid) {
dispatch(loadProject({ id: uuid, pickerId, includeCollections, includeFiles }));
}
export const loadFavoritesProject = (params: LoadFavoritesProjectParams) =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
const { pickerId, includeCollections = false, includeFiles = false } = params;
- const uuid = services.authService.getUuid();
+ const uuid = getUserUuid(getState());
if (uuid) {
-
const filters = pipe(
(fb: FilterBuilder) => includeCollections
- ? fb.addIsA('headUuid', [ResourceKind.PROJECT, ResourceKind.COLLECTION])
- : fb.addIsA('headUuid', [ResourceKind.PROJECT]),
+ ? fb.addIsA('head_uuid', [ResourceKind.PROJECT, ResourceKind.COLLECTION])
+ : fb.addIsA('head_uuid', [ResourceKind.PROJECT]),
fb => fb.getFilters(),
)(new FilterBuilder());
export const loadPublicFavoritesProject = (params: LoadFavoritesProjectParams) =>
async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
const { pickerId, includeCollections = false, includeFiles = false } = params;
- const uuidPrefix = getState().config.uuidPrefix;
+ const uuidPrefix = getState().auth.config.uuidPrefix;
const uuid = `${uuidPrefix}-j7d0g-fffffffffffffff`;
if (uuid) {
const filters = pipe(
(fb: FilterBuilder) => includeCollections
- ? fb.addIsA('headUuid', [ResourceKind.PROJECT, ResourceKind.COLLECTION])
- : fb.addIsA('headUuid', [ResourceKind.PROJECT]),
+ ? fb.addIsA('head_uuid', [ResourceKind.PROJECT, ResourceKind.COLLECTION])
+ : fb.addIsA('head_uuid', [ResourceKind.PROJECT]),
fb => fb
- .addEqual('linkClass', LinkClass.STAR)
- .addEqual('ownerUuid', uuid)
+ .addEqual('link_class', LinkClass.STAR)
+ .addEqual('owner_uuid', uuid)
.addLike('name', '')
.getFilters(),
)(new FilterBuilder());
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id, pickerId: TreePickerId.PROJECTS }));
- const ownerUuid = id.length === 0 ? services.authService.getUuid() || '' : id;
+
+ const ownerUuid = id.length === 0 ? getUserUuid(getState()) || '' : id;
const { items } = await services.projectService.list(buildParams(ownerUuid));
dispatch<any>(receiveTreePickerProjectsData(id, items, TreePickerId.PROJECTS));
export const loadFavoriteTreePickerProjects = (id: string) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const parentId = services.authService.getUuid() || '';
+ const parentId = getUserUuid(getState()) || '';
if (id === '') {
dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: parentId, pickerId: TreePickerId.FAVORITES }));
export const loadPublicFavoriteTreePickerProjects = (id: string) =>
async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
- const parentId = services.authService.getUuid() || '';
+ const parentId = getUserUuid(getState()) || '';
if (id === '') {
dispatch(treePickerActions.LOAD_TREE_PICKER_NODE({ id: parentId, pickerId: TreePickerId.PUBLIC_FAVORITES }));
const buildParams = (ownerUuid: string) => {
return {
filters: new FilterBuilder()
- .addEqual('ownerUuid', ownerUuid)
+ .addEqual('owner_uuid', ownerUuid)
.getFilters(),
order: new OrderBuilder<ProjectResource>()
.addAsc('name')
.getOrder()
};
-};
\ No newline at end of file
+};