diff --git a/examples/sn-dms-demo/package.json b/examples/sn-dms-demo/package.json index da312345d..25c0b3484 100644 --- a/examples/sn-dms-demo/package.json +++ b/examples/sn-dms-demo/package.json @@ -71,7 +71,7 @@ "react-responsive": "^6.0.1", "react-router-dom": "^4.3.1", "redux": "^4.0.1", - "redux-di-middleware": "^3.0.0", + "redux-di-middleware": "^2.0.2", "reflect-metadata": "^0.1.12", "ts-keycode-enum": "^1.0.6", "typeface-roboto": "^0.0.54", diff --git a/examples/sn-dms-demo/src/Actions.ts b/examples/sn-dms-demo/src/Actions.ts index fee800fc9..2bbb69daa 100644 --- a/examples/sn-dms-demo/src/Actions.ts +++ b/examples/sn-dms-demo/src/Actions.ts @@ -8,8 +8,8 @@ import { import { debounce, ObservableValue, usingAsync } from '@sensenet/client-utils' import { File as SnFile, GenericContent } from '@sensenet/default-content-types' import { ActionModel } from '@sensenet/default-content-types/dist/ActionModel' -import { Dispatch } from 'redux' -import { IInjectableActionCallbackParams } from 'redux-di-middleware' +import { Action, AnyAction, Dispatch } from 'redux' +import { InjectableAction } from 'redux-di-middleware' import { updateChildrenOptions } from './store/documentlibrary/actions' import { rootStateType } from './store/rootReducer' @@ -78,24 +78,25 @@ export const setEditedFirst = (edited: boolean) => ({ edited, }) -export const getListActions = (idOrPath: number | string, scenario?: string, customActions?: ActionModel[]) => ({ - type: 'GET_LIST_ACTIONS', - async inject(options: IInjectableActionCallbackParams) { - const actionsState = options.getState().dms.toolbar - if (!actionsState.isLoading && (actionsState.idOrPath !== idOrPath || actionsState.scenario !== scenario)) { - options.dispatch(loadListActions(idOrPath, scenario)) - const repository = options.getInjectable(Repository) - const data: { d: { Actions: ActionModel[] } } = (await repository.getActions({ idOrPath, scenario })) as any - const actions = customActions ? [...data.d.Actions, ...customActions] : data.d.Actions - const ordered = actions.sort((a, b) => { - const x = a.Index - const y = b.Index - return x < y ? -1 : x > y ? 1 : 0 - }) - options.dispatch(setListActions(ordered)) - } - }, -}) +export const getListActions = (idOrPath: number | string, scenario?: string, customActions?: ActionModel[]) => + ({ + type: 'GET_LIST_ACTIONS', + async inject(options) { + const actionsState = options.getState().dms.toolbar + if (!actionsState.isLoading && (actionsState.idOrPath !== idOrPath || actionsState.scenario !== scenario)) { + options.dispatch(loadListActions(idOrPath, scenario)) + const repository = options.getInjectable(Repository) + const data: { d: { Actions: ActionModel[] } } = (await repository.getActions({ idOrPath, scenario })) as any + const actions = customActions ? [...data.d.Actions, ...customActions] : data.d.Actions + const ordered = actions.sort((a, b) => { + const x = a.Index + const y = b.Index + return x < y ? -1 : x > y ? 1 : 0 + }) + options.dispatch(setListActions(ordered)) + } + }, + } as InjectableAction) export const loadListActions = (idOrPath: number | string, scenario?: string) => ({ type: 'LOAD_LIST_ACTIONS', @@ -174,11 +175,13 @@ export const trackUploadProgress = async ( } } -export const uploadFileList = ( +export const uploadFileList: ( + uploadOptions: Pick, Exclude, 'repository'>>, +) => InjectableAction = ( uploadOptions: Pick, Exclude, 'repository'>>, ) => ({ type: 'DMS_UPLOAD_FILE_LIST_INJECTABLE_ACTION', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const api = options.getInjectable(Repository) await usingAsync(new ObservableValue(), async progress => { progress.subscribe(async currentValue => @@ -200,11 +203,13 @@ export const uploadFileList = ( }, }) -export const uploadDataTransfer = ( +export const uploadDataTransfer: ( + options: Pick, Exclude, 'repository'>>, +) => InjectableAction = ( uploadOptions: Pick, Exclude, 'repository'>>, ) => ({ type: 'DMS_UPLOAD_DATA_TRANSFER_INJECTABLE_ACTION', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const api = options.getInjectable(Repository) await usingAsync(new ObservableValue(), async progress => { progress.subscribe(async currentValue => @@ -323,20 +328,21 @@ export const handleDrawerMenu = (open: boolean) => ({ open, }) -export const loadBreadcrumbActions = (idOrPath: number | string) => ({ - type: 'LOAD_BREADCRUMB_ACTIONS', - inject: async (options: IInjectableActionCallbackParams) => { - if (idOrPath === options.getState().dms.actionmenu.breadcrumb.idOrPath) { - return - } - const repository = options.getInjectable(Repository) - const actions: { d: { Actions: ActionModel[] } } = (await repository.getActions({ - idOrPath, - scenario: 'DMSBreadcrumb', - })) as any - options.dispatch({ - type: 'LOAD_BREADCRUMB_ACTIONS_SUCCESS', - result: { idOrPath, actions: actions.d.Actions }, - }) - }, -}) +export const loadBreadcrumbActions = (idOrPath: number | string) => + ({ + type: 'LOAD_BREADCRUMB_ACTIONS', + inject: async options => { + if (idOrPath === options.getState().dms.actionmenu.breadcrumb.idOrPath) { + return + } + const repository = options.getInjectable(Repository) + const actions: { d: { Actions: ActionModel[] } } = (await repository.getActions({ + idOrPath, + scenario: 'DMSBreadcrumb', + })) as any + options.dispatch({ + type: 'LOAD_BREADCRUMB_ACTIONS_SUCCESS', + result: { idOrPath, actions: actions.d.Actions }, + }) + }, + } as InjectableAction) diff --git a/examples/sn-dms-demo/src/components/ContentList/CellTemplates/DisplayNameCell.tsx b/examples/sn-dms-demo/src/components/ContentList/CellTemplates/DisplayNameCell.tsx index 551b707fb..a276e9d84 100644 --- a/examples/sn-dms-demo/src/components/ContentList/CellTemplates/DisplayNameCell.tsx +++ b/examples/sn-dms-demo/src/components/ContentList/CellTemplates/DisplayNameCell.tsx @@ -1,4 +1,4 @@ -import TableCell from '@material-ui/core/TableCell' +import { TableCell } from '@material-ui/core' import { GenericContent } from '@sensenet/default-content-types' import { Icon, iconType } from '@sensenet/icons-react' import * as React from 'react' diff --git a/examples/sn-dms-demo/src/components/Upload/UploadButton.tsx b/examples/sn-dms-demo/src/components/Upload/UploadButton.tsx index 2993e558b..cdec29453 100644 --- a/examples/sn-dms-demo/src/components/Upload/UploadButton.tsx +++ b/examples/sn-dms-demo/src/components/Upload/UploadButton.tsx @@ -1,5 +1,5 @@ +import { ClickAwayListener } from '@material-ui/core' import Button from '@material-ui/core/Button' -import ClickAwayListener from '@material-ui/core/ClickAwayListener' import ListItemIcon from '@material-ui/core/ListItemIcon' import ListItemText from '@material-ui/core/ListItemText' import Menu from '@material-ui/core/Menu' diff --git a/examples/sn-dms-demo/src/components/UsersAndGroups/DeleteUserFromGroup.tsx b/examples/sn-dms-demo/src/components/UsersAndGroups/DeleteUserFromGroup.tsx index 397aabf3d..4ebb01b67 100644 --- a/examples/sn-dms-demo/src/components/UsersAndGroups/DeleteUserFromGroup.tsx +++ b/examples/sn-dms-demo/src/components/UsersAndGroups/DeleteUserFromGroup.tsx @@ -1,5 +1,4 @@ -import Button from '@material-ui/core/Button' -import TableCell from '@material-ui/core/TableCell' +import { Button, TableCell } from '@material-ui/core' import { Group, User } from '@sensenet/default-content-types' import { Icon } from '@sensenet/icons-react' import * as React from 'react' diff --git a/examples/sn-dms-demo/src/components/UsersAndGroups/GroupSelector/GroupSearch.tsx b/examples/sn-dms-demo/src/components/UsersAndGroups/GroupSelector/GroupSearch.tsx index fbc40b0ce..90b1c648d 100644 --- a/examples/sn-dms-demo/src/components/UsersAndGroups/GroupSelector/GroupSearch.tsx +++ b/examples/sn-dms-demo/src/components/UsersAndGroups/GroupSelector/GroupSearch.tsx @@ -1,6 +1,6 @@ +import { Theme } from '@material-ui/core' import FormControl from '@material-ui/core/FormControl' import InputAdornment from '@material-ui/core/InputAdornment' -import { Theme } from '@material-ui/core/styles/createMuiTheme' import withStyles, { WithStyles } from '@material-ui/core/styles/withStyles' import TextField from '@material-ui/core/TextField' import { Icon, iconType } from '@sensenet/icons-react' diff --git a/examples/sn-dms-demo/src/components/UsersAndGroups/UserInfo.tsx b/examples/sn-dms-demo/src/components/UsersAndGroups/UserInfo.tsx index f8a773e7d..7dbf359ba 100644 --- a/examples/sn-dms-demo/src/components/UsersAndGroups/UserInfo.tsx +++ b/examples/sn-dms-demo/src/components/UsersAndGroups/UserInfo.tsx @@ -1,3 +1,4 @@ +import { Typography } from '@material-ui/core' import Avatar from '@material-ui/core/Avatar' import Paper from '@material-ui/core/Paper' import { Icon } from '@sensenet/icons-react' @@ -7,7 +8,6 @@ import * as DMSActions from '../../Actions' import { rootStateType } from '../../store/rootReducer' import EditPropertiesDialog from '../Dialogs/EditPropertiesDialog' -import Typography from '@material-ui/core/Typography' import { resources } from '../../assets/resources' // tslint:disable-next-line:no-var-requires diff --git a/examples/sn-dms-demo/src/components/WorkspaceSelector/WorkspaceSearch.tsx b/examples/sn-dms-demo/src/components/WorkspaceSelector/WorkspaceSearch.tsx index 3c7a61708..3f7b20f8f 100644 --- a/examples/sn-dms-demo/src/components/WorkspaceSelector/WorkspaceSearch.tsx +++ b/examples/sn-dms-demo/src/components/WorkspaceSelector/WorkspaceSearch.tsx @@ -1,6 +1,6 @@ +import { Theme } from '@material-ui/core' import FormControl from '@material-ui/core/FormControl' import InputAdornment from '@material-ui/core/InputAdornment' -import { Theme } from '@material-ui/core/styles/createMuiTheme' import withStyles, { WithStyles } from '@material-ui/core/styles/withStyles' import TextField from '@material-ui/core/TextField' import { Icon, iconType } from '@sensenet/icons-react' diff --git a/examples/sn-dms-demo/src/store/actionlog/actions.ts b/examples/sn-dms-demo/src/store/actionlog/actions.ts index 7fc65ea68..9dd8bd0ca 100644 --- a/examples/sn-dms-demo/src/store/actionlog/actions.ts +++ b/examples/sn-dms-demo/src/store/actionlog/actions.ts @@ -1,7 +1,7 @@ import { Repository } from '@sensenet/client-core' import { isExtendedError } from '@sensenet/client-core/dist/Repository/Repository' import { EventHub } from '@sensenet/repository-events' -import { IInjectableActionCallbackParams } from 'redux-di-middleware' +import { InjectableAction } from 'redux-di-middleware' import { resources } from '../../assets/resources' import { rootStateType } from '../../store/rootReducer' @@ -34,9 +34,9 @@ export const readLogEntries = (entries: LogEntry[]) => ({ entries, }) -export const initLog = () => ({ +export const initLog: () => InjectableAction> = () => ({ type: 'SN_DMS_INIT_LOG', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const repository = options.getInjectable(Repository) const eventHub = new EventHub(repository) eventHub.onContentCreated.subscribe(ev => { diff --git a/examples/sn-dms-demo/src/store/documentlibrary/actions.ts b/examples/sn-dms-demo/src/store/documentlibrary/actions.ts index 00075e471..ead5bd906 100644 --- a/examples/sn-dms-demo/src/store/documentlibrary/actions.ts +++ b/examples/sn-dms-demo/src/store/documentlibrary/actions.ts @@ -2,7 +2,8 @@ import { ODataCollectionResponse, ODataParams, Repository } from '@sensenet/clie import { ValueObserver } from '@sensenet/client-utils' import { GenericContent } from '@sensenet/default-content-types' import { EventHub } from '@sensenet/repository-events' -import { IInjectableActionCallbackParams } from 'redux-di-middleware' +import { Action } from 'redux' +import { InjectableAction } from 'redux-di-middleware' import { changedContent, debounceReloadOnProgress } from '../../Actions' import { rootStateType } from '../../store/rootReducer' import { DocumentLibraryState, loadChunkSize } from './reducers' @@ -26,12 +27,15 @@ export const startLoadingChildren = (idOrPath: number | string) => ({ export const finishLoadingChildren = () => ({ type: 'DMS_DOCLIB_FINISH_LOADING_CHILDREN', }) -export const loadParent = ( +export const loadParent: ( + idOrPath: string | number, + loadParentOptions?: ODataParams, +) => InjectableAction = ( idOrPath: number | string, loadParentOptions?: ODataParams, ) => ({ type: 'DMS_DOCLIB_LOAD_PARENT', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const prevState = options.getState().dms.documentLibrary if (prevState.parentIdOrPath === idOrPath) { return @@ -117,9 +121,11 @@ export const loadParent = ( }, }) -export const loadMore = (count: number = loadChunkSize) => ({ +export const loadMore: (count?: number) => InjectableAction = ( + count: number = loadChunkSize, +) => ({ type: 'DMS_DOCLIB_LOAD_MORE', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const currentDocLibState = options.getState().dms.documentLibrary if ( @@ -152,7 +158,9 @@ export const loadMore = (count: number = loadChunkSize) => ({ }, }) -export const setParent = (content: T) => ({ +export const setParent: (content: T) => Action & { content: T } = ( + content: T, +) => ({ type: 'DMS_DOCLIB_SET_PARENT', content, }) @@ -162,7 +170,9 @@ export const setAncestors = (ancestors: T[]) => ({ ancestors, }) -export const setItems = (items: ODataCollectionResponse) => ({ +export const setItems: ( + items: ODataCollectionResponse, +) => Action & { items: ODataCollectionResponse } = (items: ODataCollectionResponse) => ({ type: 'DMS_DOCLIB_SET_ITEMS', items, }) @@ -182,36 +192,37 @@ export const setActive = (active?: T) => ({ active, }) -export const updateChildrenOptions = (odataOptions: ODataParams) => ({ - type: 'DMS_DOCLIB_UPDATE_CHILDREN_OPTIONS', - odataOptions, - inject: async (options: IInjectableActionCallbackParams) => { - const currentState = options.getState() - const parentPath = currentState.dms.documentLibrary.parent ? currentState.dms.documentLibrary.parent.Path : '' - const repository = options.getInjectable(Repository) - options.dispatch( - startLoadingChildren( - currentState.dms.documentLibrary.parentIdOrPath ? currentState.dms.documentLibrary.parentIdOrPath : '', - ), - ) - try { - const items = await repository.loadCollection({ - path: parentPath, - oDataOptions: { - ...options.getState().dms.documentLibrary.childrenOptions, - ...odataOptions, - }, - }) - options.dispatch(setItems(items)) - } catch (error) { - options.dispatch(setError(error)) - } finally { - options.dispatch(finishLoadingChildren()) - options.dispatch(setChildrenOptions(odataOptions)) - } +export const updateChildrenOptions = (odataOptions: ODataParams) => + ({ + type: 'DMS_DOCLIB_UPDATE_CHILDREN_OPTIONS', + inject: async options => { + const currentState = options.getState() + const parentPath = currentState.dms.documentLibrary.parent ? currentState.dms.documentLibrary.parent.Path : '' + const repository = options.getInjectable(Repository) + options.dispatch( + startLoadingChildren( + currentState.dms.documentLibrary.parentIdOrPath ? currentState.dms.documentLibrary.parentIdOrPath : '', + ), + ) + try { + const items = await repository.loadCollection({ + path: parentPath, + oDataOptions: { + ...options.getState().dms.documentLibrary.childrenOptions, + ...odataOptions, + }, + }) + options.dispatch(setItems(items)) + } catch (error) { + options.dispatch(setError(error)) + } finally { + options.dispatch(finishLoadingChildren()) + options.dispatch(setChildrenOptions(odataOptions)) + } - }, -}) + /** */ + }, + } as InjectableAction & { odataOptions: ODataParams }) export const updateSearchValues = (value: Partial) => ({ type: 'DMS_DOCLIB_UPDATE_SEARCH_STATE', diff --git a/examples/sn-dms-demo/src/store/queries.ts b/examples/sn-dms-demo/src/store/queries.ts index 41fd50582..1a836b569 100644 --- a/examples/sn-dms-demo/src/store/queries.ts +++ b/examples/sn-dms-demo/src/store/queries.ts @@ -2,14 +2,24 @@ import { ODataBatchResponse, ODataParams, Repository } from '@sensenet/client-co import { Query } from '@sensenet/default-content-types' import { deleteContent, PromiseReturns, updateContent } from '@sensenet/redux/dist/Actions' import { AnyAction, Reducer } from 'redux' -import { IInjectableActionCallbackParams } from 'redux-di-middleware' +import { InjectableAction } from 'redux-di-middleware' import { rootStateType } from './rootReducer' export type QueryType = 'Private' | 'Public' | 'NonDefined' -export const saveQuery = (idOrPath: string | number, query: string, displayName: string, queryType = 'Private') => ({ +export const saveQuery: ( + idOrPath: string | number, + query: string, + displayName: string, + queryType: QueryType, +) => InjectableAction = ( + idOrPath: string | number, + query: string, + displayName: string, + queryType = 'Private', +) => ({ type: 'SN_DMS_SAVE_QUERY', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const repo = options.getInjectable(Repository) await repo.executeAction({ idOrPath, @@ -25,9 +35,17 @@ export const saveQuery = (idOrPath: string | number, query: string, displayName: }, }) -export const getQueries = (idOrPath: string | number, queryType = 'Private', force: boolean = false) => ({ +export const getQueries: ( + idOrPath: string | number, + queryType: QueryType, + force?: boolean, +) => InjectableAction = ( + idOrPath: string | number, + queryType = 'Private', + force: boolean = false, +) => ({ type: 'SN_DMS_GET_QUERIES', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const state = options.getState() if (force === false && state.dms.queries.idOrPath === idOrPath && state.dms.queries.queryType === queryType) { return @@ -70,7 +88,7 @@ export const setActive = (active?: T) => ({ active, }) -export interface QueriesType { +interface QueriesType { idOrPath: number | string queryType: QueryType queries: Query[] diff --git a/examples/sn-dms-demo/src/store/usersandgroups/actions.ts b/examples/sn-dms-demo/src/store/usersandgroups/actions.ts index c3bb253ad..2428d0bbf 100644 --- a/examples/sn-dms-demo/src/store/usersandgroups/actions.ts +++ b/examples/sn-dms-demo/src/store/usersandgroups/actions.ts @@ -2,8 +2,8 @@ import { ODataCollectionResponse, ODataParams, Repository } from '@sensenet/clie import { ValueObserver } from '@sensenet/client-utils' import { ActionModel, GenericContent, Group, User } from '@sensenet/default-content-types' import { EventHub } from '@sensenet/repository-events' -import { Action } from 'redux' -import { IInjectableActionCallbackParams } from 'redux-di-middleware' +import { Action, AnyAction } from 'redux' +import { InjectableAction } from 'redux-di-middleware' import { changedContent } from '../../Actions' import { arrayComparer } from '../../assets/helpers' import { rootStateType } from '../../store/rootReducer' @@ -15,9 +15,15 @@ export const startLoading = (idOrPath: number | string) => ({ idOrPath, }) -export const loadUser = (idOrPath: number | string, userOptions?: ODataParams) => ({ +export const loadUser: ( + idOrPath: string | number, + userOptions?: ODataParams, +) => InjectableAction = ( + idOrPath: number | string, + userOptions?: ODataParams, +) => ({ type: 'DMS_USERSANDGROUPS_LOAD_USER', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const prevState = options.getState().dms.usersAndGroups if (prevState.user.currentUser && prevState.user.currentUser.Id.toString() === idOrPath) { return @@ -113,22 +119,23 @@ export const setGroupOptions = (odataOptions: ODataPar odataOptions, }) -export const userIsAdmin = (userPath: string) => ({ - type: 'DMS_USER_ISADMIN', - inject: async (options: IInjectableActionCallbackParams) => { - const repository = options.getInjectable(Repository) - const payload = await repository.security.getParentGroups({ - contentIdOrPath: userPath, - directOnly: false, - oDataOptions: { - select: 'Name', - }, - }) - const groups = payload.d.results as Group[] - const admin = groups.find(group => group.Name === 'DMSAdmins') - options.dispatch(isAdmin(admin ? true : false)) - }, -}) +export const userIsAdmin = (userPath: string) => + ({ + type: 'DMS_USER_ISADMIN', + inject: async options => { + const repository = options.getInjectable(Repository) + const payload = await repository.security.getParentGroups({ + contentIdOrPath: userPath, + directOnly: false, + oDataOptions: { + select: 'Name', + }, + }) + const groups = payload.d.results as Group[] + const admin = groups.find(group => group.Name === 'DMSAdmins') + options.dispatch(isAdmin(admin ? true : false)) + }, + } as InjectableAction) export const isAdmin = (admin: boolean = false) => ({ type: 'DMS_USER_ISADMIN', @@ -140,73 +147,76 @@ export const setActive = (active?: T) => ({ active, }) -export const updateChildrenOptions = (o: ODataParams) => ({ - type: 'DMS_USERSANDGROUPS_UPDATE_CHILDREN_OPTIONS', - inject: async (options: IInjectableActionCallbackParams) => { - const currentState = options.getState() - const repository = options.getInjectable(Repository) - options.dispatch( - startLoading( - currentState.dms.usersAndGroups.user.currentUser ? currentState.dms.usersAndGroups.user.currentUser.Id : '', - ), - ) - try { - const items = await repository.security.getParentGroups({ - contentIdOrPath: currentState.dms.usersAndGroups.user.currentUser - ? currentState.dms.usersAndGroups.user.currentUser.Id - : 0, - directOnly: false, - oDataOptions: { - ...{ - select: ['Workspace', 'DisplayName', 'Type', 'Id', 'Path', 'Actions', 'Icon', 'Members'], - expand: ['Workspace', 'Actions', 'Members'], - filter: `isOf('Group')`, +export const updateChildrenOptions = (o: ODataParams) => + ({ + type: 'DMS_USERSANDGROUPS_UPDATE_CHILDREN_OPTIONS', + inject: async options => { + const currentState = options.getState() + const repository = options.getInjectable(Repository) + options.dispatch( + startLoading( + currentState.dms.usersAndGroups.user.currentUser ? currentState.dms.usersAndGroups.user.currentUser.Id : '', + ), + ) + try { + const items = await repository.security.getParentGroups({ + contentIdOrPath: currentState.dms.usersAndGroups.user.currentUser + ? currentState.dms.usersAndGroups.user.currentUser.Id + : 0, + directOnly: false, + oDataOptions: { + ...{ + select: ['Workspace', 'DisplayName', 'Type', 'Id', 'Path', 'Actions', 'Icon', 'Members'], + expand: ['Workspace', 'Actions', 'Members'], + filter: `isOf('Group')`, + }, + ...(o as any), }, - ...(o as any), - }, - }) - options.dispatch(setMemberships(items)) - } catch (error) { - options.dispatch(setError(error)) - } finally { - options.dispatch(finishLoading()) - options.dispatch(setChildrenOptions(o)) - } + }) + options.dispatch(setMemberships(items)) + } catch (error) { + options.dispatch(setError(error)) + } finally { + options.dispatch(finishLoading()) + options.dispatch(setChildrenOptions(o)) + } - }, -}) + /** */ + }, + } as InjectableAction & { odataOptions: ODataParams }) export const setChildrenOptions = (odataOptions: ODataParams) => ({ type: 'DMS_USERSANDGROUPS_SET_CHILDREN_OPTIONS', odataOptions, }) -export const removeMemberFromGroups = (contentIds: number[], groups: Group[]) => ({ - type: 'DMS_USERSANDGROUPS_REMOVE_MEMBER', - inject: async (options: IInjectableActionCallbackParams) => { - const currentState = options.getState() - const repository = options.getInjectable(Repository) - options.dispatch( - startLoading( - currentState.dms.usersAndGroups.user.currentUser ? currentState.dms.usersAndGroups.user.currentUser.Id : '', - ), - ) - try { - const remove = groups.map(async group => { - return await repository.security.removeMembers(group.Id, contentIds) - }) - await Promise.all(remove) - } catch (error) { - options.dispatch(setError(error)) - } finally { - const comparedList: Group[] = arrayComparer(groups, currentState.dms.usersAndGroups.user.memberships.d.results) - options.dispatch(updateGroupList({ d: { __count: comparedList.length, results: comparedList } })) - options.dispatch(loadUser(contentIds[0])) - options.dispatch(finishLoading()) - options.dispatch(getGroups(currentState.dms.usersAndGroups.user.memberships)) - } - }, -}) +export const removeMemberFromGroups = (contentIds: number[], groups: Group[]) => + ({ + type: 'DMS_USERSANDGROUPS_REMOVE_MEMBER', + inject: async options => { + const currentState = options.getState() + const repository = options.getInjectable(Repository) + options.dispatch( + startLoading( + currentState.dms.usersAndGroups.user.currentUser ? currentState.dms.usersAndGroups.user.currentUser.Id : '', + ), + ) + try { + const remove = groups.map(async group => { + return await repository.security.removeMembers(group.Id, contentIds) + }) + await Promise.all(remove) + } catch (error) { + options.dispatch(setError(error)) + } finally { + const comparedList: Group[] = arrayComparer(groups, currentState.dms.usersAndGroups.user.memberships.d.results) + options.dispatch(updateGroupList({ d: { __count: comparedList.length, results: comparedList } })) + options.dispatch(loadUser(contentIds[0])) + options.dispatch(finishLoading()) + options.dispatch(getGroups(currentState.dms.usersAndGroups.user.memberships)) + } + }, + } as InjectableAction & { odataOptions: ODataParams }) export const selectGroup = (groups: GenericContent[] | GenericContent) => { return { @@ -220,43 +230,45 @@ export const deselectGroup = (id: number) => ({ id, }) -export const getGroups = (memberships: ODataCollectionResponse) => ({ - type: 'DMS_USERSANDGROUPS_GET_GROUPS', - inject: async (options: IInjectableActionCallbackParams) => { - const currentState = options.getState() - const repository = options.getInjectable(Repository) - options.dispatch( - startLoading( - currentState.dms.usersAndGroups.user.currentUser ? currentState.dms.usersAndGroups.user.currentUser.Id : '', - ), - ) - try { - const groups = await repository.loadCollection({ - path: '/Root', - oDataOptions: { - query: '+TypeIs:Group', - select: ['DisplayName', 'Path', 'Actions'] as any, - expand: ['Actions'] as any, - }, - }) - const comparedList: Group[] = arrayComparer(groups.d.results, memberships.d.results) - const newGroups = { - d: { - __count: comparedList.length, - results: comparedList.filter((group: Group) => { - const actions = group.Actions as ActionModel[] - return actions ? actions.find((action: ActionModel) => action.Name === 'Edit') : [] - }), - }, +export const getGroups = (memberships: ODataCollectionResponse) => + ({ + type: 'DMS_USERSANDGROUPS_GET_GROUPS', + inject: async options => { + const currentState = options.getState() + const repository = options.getInjectable(Repository) + options.dispatch( + startLoading( + currentState.dms.usersAndGroups.user.currentUser ? currentState.dms.usersAndGroups.user.currentUser.Id : '', + ), + ) + try { + const groups = await repository.loadCollection({ + path: '/Root', + oDataOptions: { + query: '+TypeIs:Group', + select: ['DisplayName', 'Path', 'Actions'] as any, + expand: ['Actions'] as any, + }, + }) + const comparedList: Group[] = arrayComparer(groups.d.results, memberships.d.results) + const newGroups = { + d: { + __count: comparedList.length, + results: comparedList.filter((group: Group) => { + const actions = group.Actions as ActionModel[] + return actions ? actions.find((action: ActionModel) => action.Name === 'Edit') : [] + }), + }, + } + options.dispatch(setGroups(newGroups)) + } catch (error) { + options.dispatch(setError(error)) + } finally { + options.dispatch(finishLoading()) } - options.dispatch(setGroups(newGroups)) - } catch (error) { - options.dispatch(setError(error)) - } finally { - options.dispatch(finishLoading()) - } - }, -}) + }, + } as InjectableAction & { odataOptions: ODataParams }) + export const setGroups = (groups: ODataCollectionResponse) => ({ type: 'DMS_USERSANDGROUPS_SET_GROUPS', groups, @@ -271,31 +283,32 @@ export const clearSelection = () => ({ type: 'DMS_USERSANDGROUPS_CLEAR_SELECTION', }) -export const addUserToGroups = (user: User, groups: Group[]) => ({ - type: 'DMS_USERSANDGROUPS_ADD_USER_TO_GROUPS', - inject: async (options: IInjectableActionCallbackParams) => { - const currentState = options.getState() - const repository = options.getInjectable(Repository) as Repository - options.dispatch( - startLoading( - currentState.dms.usersAndGroups.user.currentUser ? currentState.dms.usersAndGroups.user.currentUser.Id : '', - ), - ) - try { - const add = groups.map(async group => { - return await repository.security.addMembers(group.Id, [user.Id]) - }) - await Promise.all(add) - } catch (error) { - options.dispatch(setError(error)) - } finally { - options.dispatch(finishLoading()) - options.dispatch(loadUser(user.Id)) - const comparedList: Group[] = arrayComparer(groups, currentState.dms.usersAndGroups.user.memberships.d.results) - options.dispatch(updateGroupList({ d: { __count: comparedList.length, results: comparedList } })) - } - }, -}) +export const addUserToGroups = (user: User, groups: Group[]) => + ({ + type: 'DMS_USERSANDGROUPS_ADD_USER_TO_GROUPS', + inject: async options => { + const currentState = options.getState() + const repository = options.getInjectable(Repository) as Repository + options.dispatch( + startLoading( + currentState.dms.usersAndGroups.user.currentUser ? currentState.dms.usersAndGroups.user.currentUser.Id : '', + ), + ) + try { + const add = groups.map(async group => { + return await repository.security.addMembers(group.Id, [user.Id]) + }) + await Promise.all(add) + } catch (error) { + options.dispatch(setError(error)) + } finally { + options.dispatch(finishLoading()) + options.dispatch(loadUser(user.Id)) + const comparedList: Group[] = arrayComparer(groups, currentState.dms.usersAndGroups.user.memberships.d.results) + options.dispatch(updateGroupList({ d: { __count: comparedList.length, results: comparedList } })) + } + }, + } as InjectableAction & { odataOptions: ODataParams }) export const updateGroupList = (groups: ODataCollectionResponse) => ({ type: 'DMS_USERSANDGROUPS_UPDATE_GROUPS', diff --git a/examples/sn-dms-demo/src/store/workspaces/actions.ts b/examples/sn-dms-demo/src/store/workspaces/actions.ts index 6bde3b112..f1529c70b 100644 --- a/examples/sn-dms-demo/src/store/workspaces/actions.ts +++ b/examples/sn-dms-demo/src/store/workspaces/actions.ts @@ -1,26 +1,28 @@ import { Repository } from '@sensenet/client-core' import { User, Workspace } from '@sensenet/default-content-types' -import { IInjectableActionCallbackParams } from 'redux-di-middleware' +import { AnyAction } from 'redux' +import { InjectableAction } from 'redux-di-middleware' import { rootStateType } from '../../store/rootReducer' -export const getWorkspaces = () => ({ - type: 'GET_WORKSPACES', - inject: async (options: IInjectableActionCallbackParams) => { - if (!options.getState().dms.workspaces.isLoading) { - options.dispatch(loadWorkspaces()) - const repository = options.getInjectable(Repository) - const workspaces = await repository.loadCollection({ - path: '/', - oDataOptions: { - query: 'TypeIs:Workspace -TypeIs:Site', - select: ['DisplayName', 'Id', 'Path'], - orderby: [['DisplayName', 'asc']], - }, - }) - options.dispatch(setWorkspaces(workspaces.d.results)) - } - }, -}) +export const getWorkspaces = () => + ({ + type: 'GET_WORKSPACES', + inject: async options => { + if (!options.getState().dms.workspaces.isLoading) { + options.dispatch(loadWorkspaces()) + const repository = options.getInjectable(Repository) + const workspaces = await repository.loadCollection({ + path: '/', + oDataOptions: { + query: 'TypeIs:Workspace -TypeIs:Site', + select: ['DisplayName', 'Id', 'Path'], + orderby: [['DisplayName', 'asc']], + }, + }) + options.dispatch(setWorkspaces(workspaces.d.results)) + } + }, + } as InjectableAction) export const loadWorkspaces = () => ({ type: 'LOAD_WORKSPACES', @@ -31,25 +33,26 @@ export const setWorkspaces = (workspaces: Workspace[]) => ({ workspaces, }) -export const loadFavoriteWorkspaces = (userName: string) => ({ - type: 'LOAD_FAVORITE_WORKSPACES', - inject: async (options: IInjectableActionCallbackParams) => { - if ( - options.getState().dms.workspaces.favorites === null || - options.getState().dms.workspaces.favorites.length === 0 - ) { - const repository = options.getInjectable(Repository) - const favorites = await repository.load({ - idOrPath: `/Root/IMS/Public/${userName}`, - oDataOptions: { - select: 'FollowedWorkspaces', - expand: 'FollowedWorkspaces', - }, - }) - options.dispatch(setFavoriteWorkspaces(favorites.d.FollowedWorkspaces as Workspace[])) - } - }, -}) +export const loadFavoriteWorkspaces = (userName: string) => + ({ + type: 'LOAD_FAVORITE_WORKSPACES', + inject: async options => { + if ( + options.getState().dms.workspaces.favorites === null || + options.getState().dms.workspaces.favorites.length === 0 + ) { + const repository = options.getInjectable(Repository) + const favorites = await repository.load({ + idOrPath: `/Root/IMS/Public/${userName}`, + oDataOptions: { + select: 'FollowedWorkspaces', + expand: 'FollowedWorkspaces', + }, + }) + options.dispatch(setFavoriteWorkspaces(favorites.d.FollowedWorkspaces as Workspace[])) + } + }, + } as InjectableAction) export const setFavoriteWorkspaces = (workspaces: Workspace[]) => ({ type: 'SET_FAVORITE_WORKSPACES', diff --git a/examples/sn-react-component-docs/stories/Search.stories.tsx b/examples/sn-react-component-docs/stories/Search.stories.tsx index 0ed312113..28cb795fe 100644 --- a/examples/sn-react-component-docs/stories/Search.stories.tsx +++ b/examples/sn-react-component-docs/stories/Search.stories.tsx @@ -1,5 +1,4 @@ -import FormControl from '@material-ui/core/FormControl' -import InputLabel from '@material-ui/core/InputLabel' +import { FormControl, InputLabel } from '@material-ui/core' import { Repository } from '@sensenet/client-core' import { sleepAsync } from '@sensenet/client-utils' import { Folder, PortalSettings, User } from '@sensenet/default-content-types' diff --git a/examples/sn-react-redux-todo-app/package.json b/examples/sn-react-redux-todo-app/package.json index e4c874575..3709411df 100644 --- a/examples/sn-react-redux-todo-app/package.json +++ b/examples/sn-react-redux-todo-app/package.json @@ -52,8 +52,7 @@ "react-dom": "^16.6.3", "react-quill": "^1.3.3", "react-router-redux": "^4.0.8", - "redux": "^4.0.1", - "redux-di-middleware": "3.0.0" + "redux": "^4.0.1" }, "devDependencies": { "@types/jest": "^23.3.10", diff --git a/examples/sn-react-redux-todo-app/src/reducers/todos.ts b/examples/sn-react-redux-todo-app/src/reducers/todos.ts index 3da6efcf1..0af60c4f0 100644 --- a/examples/sn-react-redux-todo-app/src/reducers/todos.ts +++ b/examples/sn-react-redux-todo-app/src/reducers/todos.ts @@ -1,69 +1,76 @@ import { Repository } from '@sensenet/client-core' import { Status, Task } from '@sensenet/default-content-types' import { Query } from '@sensenet/query' -import { AnyAction } from 'redux' +import { Action, AnyAction } from 'redux' +import { InjectableAction } from 'redux-di-middleware' import { rootStateType } from '..' -export const fetch = () => ({ - type: 'FETCH_TASKS', - inject: async (options: IInjectableActionCallbackParams) => { - if (!options.getState().todoList.isFetching) { - options.dispatch(startFetching()) +export const fetch = () => + ({ + type: 'FETCH_TASKS', + inject: async options => { + /** */ + if (!options.getState().todoList.isFetching) { + options.dispatch(startFetching()) + try { + const todos = await options.getInjectable(Repository).loadCollection({ + path: '/Root/Sites/Default_Site/tasks', + oDataOptions: { + query: new Query(q => q.typeIs(Task)).toString(), + select: ['Status', 'Name', 'DisplayName'], + }, + }) + options.dispatch(finishFetching(todos.d.results)) + } catch (error) { + options.dispatch(fetchingError(error)) + } + options.dispatch(updateFilter()) + } + }, + } as InjectableAction) + +export const updateTodo = (todo: Task) => + ({ + type: 'UPDATE_TODO', + inject: async options => { + /** */ try { - const todos = await options.getInjectable(Repository).loadCollection({ - path: '/Root/Sites/Default_Site/tasks', + const updated = await options.getInjectable(Repository).patch({ + idOrPath: todo.Id, + content: todo, oDataOptions: { - query: new Query(q => q.typeIs(Task)).toString(), select: ['Status', 'Name', 'DisplayName'], }, }) - options.dispatch(finishFetching(todos.d.results)) + options.dispatch(todoUpdated(updated.d)) } catch (error) { options.dispatch(fetchingError(error)) } options.dispatch(updateFilter()) - } - }, -}) - -export const updateTodo = (todo: Task) => ({ - type: 'UPDATE_TODO', - inject: async (options: IInjectableActionCallbackParams) => { - try { - const updated = await options.getInjectable(Repository).patch({ - idOrPath: todo.Id, - content: todo, - oDataOptions: { - select: ['Status', 'Name', 'DisplayName'], - }, - }) - options.dispatch(todoUpdated(updated.d)) - } catch (error) { - options.dispatch(fetchingError(error)) - } - options.dispatch(updateFilter()) - }, -}) + }, + } as InjectableAction) export const todoUpdated = (todo: Task) => ({ type: 'TODO_UPDATED', todo, }) -export const removeTodo = (todo: Task) => ({ - type: 'UPDATE_TODO', - inject: async (options: IInjectableActionCallbackParams) => { - try { - const result = await options.getInjectable(Repository).delete({ - idOrPath: todo.Id, - }) - options.dispatch(todoRemoved(result.d.results[0])) - } catch (error) { - options.dispatch(fetchingError(error)) - } - options.dispatch(updateFilter()) - }, -}) +export const removeTodo = (todo: Task) => + ({ + type: 'UPDATE_TODO', + inject: async options => { + /** */ + try { + const result = await options.getInjectable(Repository).delete({ + idOrPath: todo.Id, + }) + options.dispatch(todoRemoved(result.d.results[0])) + } catch (error) { + options.dispatch(fetchingError(error)) + } + options.dispatch(updateFilter()) + }, + } as InjectableAction) export const todoRemoved = (todo: Task) => ({ type: 'TODO_REMOVED', diff --git a/package.json b/package.json index 021256f6c..d697df0da 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "tslint": "^5.12.1", "tslint-config-prettier": "^1.17.0", "tslint-react": "^3.6.0", - "typescript": "3.3.1" + "typescript": "3.2.4" }, "scripts": { "build": "lerna run build", diff --git a/packages/sn-controls-react/src/fieldcontrols/AutoComplete/AutoComplete.tsx b/packages/sn-controls-react/src/fieldcontrols/AutoComplete/AutoComplete.tsx index 464b5b99a..e6100ae29 100644 --- a/packages/sn-controls-react/src/fieldcontrols/AutoComplete/AutoComplete.tsx +++ b/packages/sn-controls-react/src/fieldcontrols/AutoComplete/AutoComplete.tsx @@ -1,12 +1,8 @@ -import CircularProgress from '@material-ui/core/CircularProgress' +import { CircularProgress, InputAdornment, Menu, MenuItem, TextField } from '@material-ui/core' import FormControl from '@material-ui/core/FormControl' import FormControlLabel from '@material-ui/core/FormControlLabel' import FormGroup from '@material-ui/core/FormGroup' import FormLabel from '@material-ui/core/FormLabel' -import InputAdornment from '@material-ui/core/InputAdornment' -import Menu from '@material-ui/core/Menu' -import MenuItem from '@material-ui/core/MenuItem' -import TextField from '@material-ui/core/TextField' import { GenericContent } from '@sensenet/default-content-types' import { Query, QueryExpression, QueryOperators } from '@sensenet/query' import debounce from 'lodash.debounce' diff --git a/packages/sn-controls-react/src/viewcontrols/BrowseView.tsx b/packages/sn-controls-react/src/viewcontrols/BrowseView.tsx index 633184ab5..e87f1a26f 100644 --- a/packages/sn-controls-react/src/viewcontrols/BrowseView.tsx +++ b/packages/sn-controls-react/src/viewcontrols/BrowseView.tsx @@ -1,9 +1,9 @@ /** * @module ViewControls * - */ + */ /** */ +import { Typography } from '@material-ui/core' import Grid from '@material-ui/core/Grid' -import Typography from '@material-ui/core/Typography' import { Repository } from '@sensenet/client-core' import { ControlSchema } from '@sensenet/control-mapper' import { GenericContent } from '@sensenet/default-content-types' diff --git a/packages/sn-document-viewer-react/package.json b/packages/sn-document-viewer-react/package.json index c7363c99e..d4406e279 100644 --- a/packages/sn-document-viewer-react/package.json +++ b/packages/sn-document-viewer-react/package.json @@ -68,7 +68,7 @@ "react-redux": "^6.0.0", "react-test-renderer": "^16.5.2", "redux": "^4.0.0", - "redux-di-middleware": "^3.0.0", + "redux-di-middleware": "^2.0.2", "redux-logger": "^3.0.6", "uuid": "^3.3.2" }, diff --git a/packages/sn-document-viewer-react/src/components/DocumentViewer.tsx b/packages/sn-document-viewer-react/src/components/DocumentViewer.tsx index 1b138c1df..5c2896da4 100644 --- a/packages/sn-document-viewer-react/src/components/DocumentViewer.tsx +++ b/packages/sn-document-viewer-react/src/components/DocumentViewer.tsx @@ -1,6 +1,8 @@ import { SlideProps } from '@material-ui/core/Slide' import React from 'react' import { connect } from 'react-redux' +import { Action } from 'redux' +import { InjectableAction } from 'redux-di-middleware' import { componentType } from '../services' import { pollDocumentData, RootReducerType } from '../store' import { LocalizationStateType, setLocalization } from '../store/Localization' @@ -44,7 +46,11 @@ const mapStateToProps = (state: RootReducerType) => { * @param state the redux state */ const mapDispatchToProps = { - pollDocumentData, + pollDocumentData: pollDocumentData as ( + hostName: string, + idOrPath: string | number, + version?: string, + ) => InjectableAction, setLocalization, } diff --git a/packages/sn-document-viewer-react/src/components/Page.tsx b/packages/sn-document-viewer-react/src/components/Page.tsx index b94da6884..fe7a1ee84 100644 --- a/packages/sn-document-viewer-react/src/components/Page.tsx +++ b/packages/sn-document-viewer-react/src/components/Page.tsx @@ -5,6 +5,9 @@ import { connect } from 'react-redux' import { DocumentData, PreviewImageData } from '../models' import { componentType, ImageUtil } from '../services' import { previewAvailable, RootReducerType, ZoomMode } from '../store' + +import { Action } from 'redux' +import { InjectableAction } from 'redux-di-middleware' import { ShapesWidget } from './page-widgets' /** @@ -28,7 +31,11 @@ const mapStateToProps = (state: RootReducerType, ownProps: { imageIndex: number * @param state the redux state */ const mapDispatchToProps = { - previewAvailable, + previewAvailable: previewAvailable as ( + documentData: DocumentData, + version?: string, + page?: number, + ) => InjectableAction, } /** diff --git a/packages/sn-document-viewer-react/src/store/Document.ts b/packages/sn-document-viewer-react/src/store/Document.ts index 730bf640d..a663229ea 100644 --- a/packages/sn-document-viewer-react/src/store/Document.ts +++ b/packages/sn-document-viewer-react/src/store/Document.ts @@ -1,5 +1,5 @@ -import { Reducer } from 'redux' -import { IInjectableActionCallbackParams } from 'redux-di-middleware' +import { Action, Reducer } from 'redux' +import { InjectableAction } from 'redux-di-middleware' import { PreviewState } from '../Enums' import { DocumentData, DocumentViewerSettings, PreviewImageData, Shape, Shapes } from '../models' import { Dimensions, ImageUtil } from '../services' @@ -35,9 +35,17 @@ export const resetDocumentData = () => ({ * @param idOrPath Id or full path for the document, e.g.: 'Root/Sites/MySite/MyDocLib/('doc.docx') * @param version The document version */ -export const pollDocumentData = (hostName: string, idOrPath: string | number, version: string = 'V1.0A') => ({ +export const pollDocumentData: ( + hostName: string, + idOrPath: string | number, + version?: string, +) => InjectableAction = ( + hostName: string, + idOrPath: string | number, + version: string = 'V1.0A', +) => ({ type: 'SN_POLL_DOCUMENT_DATA_INJECTABLE_ACTION', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const api = options.getInjectable(DocumentViewerSettings) options.dispatch(resetDocumentData()) let docData: DocumentData | undefined @@ -176,9 +184,9 @@ export const rotateShapesForPages = (pages: Array<{ index: number; size: Dimensi /** * Thunk action to call the Save endpoint with the current document state to save changes */ -export const saveChanges = () => ({ +export const saveChanges: () => InjectableAction = () => ({ type: 'SN_DOCVIEWER_SAVE_CHANGES_INJECTABLE_ACTION', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { const api = options.getInjectable(DocumentViewerSettings) options.dispatch(saveChangesRequest()) try { diff --git a/packages/sn-document-viewer-react/src/store/PreviewImages.ts b/packages/sn-document-viewer-react/src/store/PreviewImages.ts index 45348d0cc..e82973ba5 100644 --- a/packages/sn-document-viewer-react/src/store/PreviewImages.ts +++ b/packages/sn-document-viewer-react/src/store/PreviewImages.ts @@ -1,6 +1,6 @@ import { Action } from 'redux' import { Reducer } from 'redux' -import { IInjectableActionCallbackParams } from 'redux-di-middleware' +import { InjectableAction } from 'redux-di-middleware' import { RootReducerType } from '.' import { DocumentData, DocumentViewerSettings, PreviewImageData } from '../models' import { ImageUtil } from '../services' @@ -73,9 +73,12 @@ export const rotateImages = (imageIndexes: number[], amount: number) => ({ * @param documentData * @param version */ -export const getAvailableImages = (documentData: DocumentData, version: string = 'V1.0A') => ({ +export const getAvailableImages: ( + documentData: DocumentData, + version?: string, +) => InjectableAction = (documentData: DocumentData, version: string = 'V1.0A') => ({ type: 'SN_GET_AVAILABLE_IMAGES_INJECTABLE_ACTION', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { options.dispatch(getAvailabelImagesAction(documentData)) const docViewerSettings = options.getInjectable(DocumentViewerSettings) let docData: PreviewImageData[] | undefined @@ -158,9 +161,17 @@ export const setPagePollInterval = (pollInterval: number) => ({ * @param version * @param page */ -export const previewAvailable = (documentData: DocumentData, version: string = 'V1.0A', page: number = 1) => ({ +export const previewAvailable: ( + documentData: DocumentData, + version?: string, + page?: number, +) => InjectableAction = ( + documentData: DocumentData, + version: string = 'V1.0A', + page: number = 1, +) => ({ type: 'SN_DOCVIEWER_PREVIEW_AVAILABLE_INJECTABLE_ACTION', - inject: async (options: IInjectableActionCallbackParams) => { + inject: async options => { options.dispatch(previewAvailableAction(documentData, version, page)) const docViewerApi = options.getInjectable(DocumentViewerSettings) let docData: PreviewImageData | undefined diff --git a/packages/sn-list-controls-react/src/ContentList/CellTemplates/DisplayNameCell.tsx b/packages/sn-list-controls-react/src/ContentList/CellTemplates/DisplayNameCell.tsx index 87f0c3b56..ff65d326a 100644 --- a/packages/sn-list-controls-react/src/ContentList/CellTemplates/DisplayNameCell.tsx +++ b/packages/sn-list-controls-react/src/ContentList/CellTemplates/DisplayNameCell.tsx @@ -1,4 +1,4 @@ -import TableCell from '@material-ui/core/TableCell' +import { TableCell } from '@material-ui/core' import { GenericContent } from '@sensenet/default-content-types' import { Icon, iconType } from '@sensenet/icons-react' import * as React from 'react' diff --git a/packages/sn-list-controls-react/test/ContentListTests.tsx b/packages/sn-list-controls-react/test/ContentListTests.tsx index dbb6ac8cf..681aa85ee 100644 --- a/packages/sn-list-controls-react/test/ContentListTests.tsx +++ b/packages/sn-list-controls-react/test/ContentListTests.tsx @@ -1,8 +1,8 @@ -import Checkbox from '@material-ui/core/Checkbox' +import { Checkbox, TableSortLabel } from '@material-ui/core' import TableRow from '@material-ui/core/TableRow' -import TableSortLabel from '@material-ui/core/TableSortLabel' import { GenericContent, SchemaStore } from '@sensenet/default-content-types' import { mount, shallow } from 'enzyme' + import * as React from 'react' import { ActionsCell, DateCell, ReferenceCell } from '../src/ContentList/CellTemplates' import { ContentList } from '../src/ContentList/ContentList' diff --git a/packages/sn-search-react/src/Components/Fields/PresetField.tsx b/packages/sn-search-react/src/Components/Fields/PresetField.tsx index f4a3a009a..3ee61b36d 100644 --- a/packages/sn-search-react/src/Components/Fields/PresetField.tsx +++ b/packages/sn-search-react/src/Components/Fields/PresetField.tsx @@ -1,5 +1,4 @@ -import ListItemText from '@material-ui/core/ListItemText' -import MenuItem from '@material-ui/core/MenuItem' +import { ListItemText, MenuItem } from '@material-ui/core' import Select, { SelectProps } from '@material-ui/core/Select' import { FieldSetting, GenericContent } from '@sensenet/default-content-types' import { Query } from '@sensenet/query' diff --git a/packages/sn-search-react/src/ExampleApp.tsx b/packages/sn-search-react/src/ExampleApp.tsx index 05d164d21..0eacb2fd3 100644 --- a/packages/sn-search-react/src/ExampleApp.tsx +++ b/packages/sn-search-react/src/ExampleApp.tsx @@ -1,18 +1,12 @@ +import { Checkbox, Divider, FormControl, FormHelperText, InputLabel, ListItemText, MenuItem } from '@material-ui/core' import AppBar from '@material-ui/core/AppBar' import Button from '@material-ui/core/Button' -import Checkbox from '@material-ui/core/Checkbox' import Dialog from '@material-ui/core/Dialog' import DialogActions from '@material-ui/core/DialogActions' import DialogContent from '@material-ui/core/DialogContent' import DialogContentText from '@material-ui/core/DialogContentText' import DialogTitle from '@material-ui/core/DialogTitle' -import Divider from '@material-ui/core/Divider' -import FormControl from '@material-ui/core/FormControl' -import FormHelperText from '@material-ui/core/FormHelperText' import IconButton from '@material-ui/core/IconButton' -import InputLabel from '@material-ui/core/InputLabel' -import ListItemText from '@material-ui/core/ListItemText' -import MenuItem from '@material-ui/core/MenuItem' import Paper from '@material-ui/core/Paper' import Table from '@material-ui/core/Table' import TableBody from '@material-ui/core/TableBody' @@ -23,8 +17,8 @@ import MaterialTextField from '@material-ui/core/TextField' import Toolbar from '@material-ui/core/Toolbar' import Typography from '@material-ui/core/Typography' import { ODataCollectionResponse, Repository } from '@sensenet/client-core' -import { ReferenceFieldSetting } from '@sensenet/default-content-types' import { File as SnFile, Folder, GenericContent, User } from '@sensenet/default-content-types' +import { ReferenceFieldSetting } from '@sensenet/default-content-types' import { Icon, iconType, MaterialIcon } from '@sensenet/icons-react' import { Query } from '@sensenet/query' import React from 'react' diff --git a/packages/sn-search-react/test/PresetFieldTests.tsx b/packages/sn-search-react/test/PresetFieldTests.tsx index 53c5a6a2e..d4498916d 100644 --- a/packages/sn-search-react/test/PresetFieldTests.tsx +++ b/packages/sn-search-react/test/PresetFieldTests.tsx @@ -1,7 +1,7 @@ +import { Select } from '@material-ui/core' import { Query } from '@sensenet/query' import { shallow } from 'enzyme' -import Select from '@material-ui/core/Select' import * as React from 'react' import { PresetField } from '../src/Components/Fields/PresetField' @@ -45,7 +45,7 @@ describe('Preset Fields', () => { />, ) const select = instance.find(Select) - select.props().onChange({ target: { value: 'value1' } } as any, undefined) + select.props().onChange({ target: { value: 'value1' } }) expect(select) }) @@ -60,7 +60,7 @@ describe('Preset Fields', () => { />, ) const select = instance.find(Select) - select.props().onChange({ target: { value: 'value2' } } as any, undefined) + select.props().onChange({ target: { value: 'value2' } }) setTimeout(() => { done() diff --git a/packages/sn-search-react/test/TextFieldTests.tsx b/packages/sn-search-react/test/TextFieldTests.tsx index 68b643537..c200d5b45 100644 --- a/packages/sn-search-react/test/TextFieldTests.tsx +++ b/packages/sn-search-react/test/TextFieldTests.tsx @@ -1,4 +1,4 @@ -import MaterialTextField from '@material-ui/core/TextField' +import { TextField as MaterialTextField } from '@material-ui/core' import { shallow } from 'enzyme' import * as React from 'react' @@ -31,7 +31,7 @@ describe('TextField Component', () => { />, ) const input = instance.find(MaterialTextField) - input.props().onChange({ currentTarget: { value: 'Alma' } } as any) + input.props().onChange({ currentTarget: { value: 'Alma' } }) }) it('onQueryChanged() should be executed on input change with an empty query if no value provided', done => { @@ -47,6 +47,6 @@ describe('TextField Component', () => { />, ) const input = instance.find(MaterialTextField) - input.props().onChange({ currentTarget: {} } as any) + input.props().onChange({ currentTarget: {} }) }) }) diff --git a/packages/sn-search-react/test/TypeFieldTests.tsx b/packages/sn-search-react/test/TypeFieldTests.tsx index ca7736572..c320841b2 100644 --- a/packages/sn-search-react/test/TypeFieldTests.tsx +++ b/packages/sn-search-react/test/TypeFieldTests.tsx @@ -1,8 +1,8 @@ +import { Select } from '@material-ui/core' import { SchemaStore } from '@sensenet/client-core/dist/Schemas/SchemaStore' import { SchemaStore as defaultSchemas, Task, User } from '@sensenet/default-content-types' import { shallow } from 'enzyme' -import Select from '@material-ui/core/Select' import * as React from 'react' import { TypeField } from '../src/Components/Fields/TypeField' @@ -48,7 +48,7 @@ describe('TypeField component', () => { />, ) const select = instance.find(Select) - select.props().onChange({ target: { value: 'User' } } as any, null) + select.props().onChange({ target: { value: 'User' } }) }) it('Selecting multiple values should update the query', done => { @@ -63,6 +63,6 @@ describe('TypeField component', () => { />, ) const select = instance.find(Select) - select.props().onChange({ target: { value: ['User', 'Task'] } } as any, undefined) + select.props().onChange({ target: { value: ['User', 'Task'] } }) }) }) diff --git a/yarn.lock b/yarn.lock index 8778db2d9..4a79ad0bc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -12051,10 +12051,10 @@ redent@^2.0.0: indent-string "^3.0.0" strip-indent "^2.0.0" -redux-di-middleware@3.0.0, redux-di-middleware@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/redux-di-middleware/-/redux-di-middleware-3.0.0.tgz#66485cf46ab7bffd67f070d705da9db220832876" - integrity sha512-U5EEdlMbBscj19LVlQnH60bLGsb6YLv9uxlOwi6JJqqjfno1nsPnMorE/FyKn+q0WTL4ABN3ozSr0hJtQBCbKA== +redux-di-middleware@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/redux-di-middleware/-/redux-di-middleware-2.0.3.tgz#2ae9dd3fbaadce8e97f248595b9089cc56f55661" + integrity sha512-MQnhTcE67bQXABVdaWHvenUeq63J2PvFmRhz23uKfOVjZugMiGwixVOUkZzcnOkfpfy7WeBqo54CvKZqUmZeiA== dependencies: "@furystack/inject" "^1.0.9" redux "^4.0.1" @@ -13840,10 +13840,10 @@ typeface-roboto@^0.0.54: resolved "https://registry.yarnpkg.com/typeface-roboto/-/typeface-roboto-0.0.54.tgz#8f02c9a18d1cfa7f49381a6ff0d21ff061f38ad2" integrity sha512-sOFA1FXgP0gOgBYlS6irwq6hHYA370KE3dPlgYEJHL3PJd5X8gQE0RmL79ONif6fL5JZuGDj+rtOrFeOqz5IZQ== -typescript@3.3.1: - version "3.3.1" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.1.tgz#6de14e1db4b8a006ac535e482c8ba018c55f750b" - integrity sha512-cTmIDFW7O0IHbn1DPYjkiebHxwtCMU+eTy30ZtJNBPF9j2O1ITu5XH2YnBeVRKWHqF+3JQwWJv0Q0aUgX8W7IA== +typescript@3.2.4: + version "3.2.4" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.2.4.tgz#c585cb952912263d915b462726ce244ba510ef3d" + integrity sha512-0RNDbSdEokBeEAkgNbxJ+BLwSManFy9TeXz8uW+48j/xhEXv1ePME60olyzw2XzUqUBNAYFeJadIqAgNqIACwg== ua-parser-js@^0.7.18: version "0.7.19"