Skip to content

Commit

Permalink
[KFI]revert(project): reverted last merge commit
Browse files Browse the repository at this point in the history
  • Loading branch information
gallayl committed Feb 6, 2019
1 parent f1cd71a commit 5e4b734
Show file tree
Hide file tree
Showing 32 changed files with 450 additions and 374 deletions.
2 changes: 1 addition & 1 deletion examples/sn-dms-demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
88 changes: 47 additions & 41 deletions examples/sn-dms-demo/src/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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<rootStateType>) {
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<rootStateType, AnyAction>)

export const loadListActions = (idOrPath: number | string, scenario?: string) => ({
type: 'LOAD_LIST_ACTIONS',
Expand Down Expand Up @@ -174,11 +175,13 @@ export const trackUploadProgress = async <T extends GenericContent>(
}
}

export const uploadFileList = <T extends SnFile>(
export const uploadFileList: <T extends SnFile>(
uploadOptions: Pick<UploadFromFileListOptions<T>, Exclude<keyof UploadFromFileListOptions<T>, 'repository'>>,
) => InjectableAction<rootStateType, Action> = <T extends SnFile>(
uploadOptions: Pick<UploadFromFileListOptions<T>, Exclude<keyof UploadFromFileListOptions<T>, 'repository'>>,
) => ({
type: 'DMS_UPLOAD_FILE_LIST_INJECTABLE_ACTION',
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
inject: async options => {
const api = options.getInjectable(Repository)
await usingAsync(new ObservableValue<UploadProgressInfo>(), async progress => {
progress.subscribe(async currentValue =>
Expand All @@ -200,11 +203,13 @@ export const uploadFileList = <T extends SnFile>(
},
})

export const uploadDataTransfer = <T extends SnFile>(
export const uploadDataTransfer: <T extends SnFile>(
options: Pick<UploadFromEventOptions<T>, Exclude<keyof UploadFromEventOptions<T>, 'repository'>>,
) => InjectableAction<rootStateType, Action> = <T extends SnFile>(
uploadOptions: Pick<UploadFromEventOptions<T>, Exclude<keyof UploadFromEventOptions<T>, 'repository'>>,
) => ({
type: 'DMS_UPLOAD_DATA_TRANSFER_INJECTABLE_ACTION',
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
inject: async options => {
const api = options.getInjectable(Repository)
await usingAsync(new ObservableValue<UploadProgressInfo>(), async progress => {
progress.subscribe(async currentValue =>
Expand Down Expand Up @@ -323,20 +328,21 @@ export const handleDrawerMenu = (open: boolean) => ({
open,
})

export const loadBreadcrumbActions = (idOrPath: number | string) => ({
type: 'LOAD_BREADCRUMB_ACTIONS',
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
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<rootStateType, AnyAction>)
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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'
Expand Down
6 changes: 3 additions & 3 deletions examples/sn-dms-demo/src/store/actionlog/actions.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -34,9 +34,9 @@ export const readLogEntries = (entries: LogEntry[]) => ({
entries,
})

export const initLog = () => ({
export const initLog: () => InjectableAction<rootStateType, ReturnType<typeof addLogEntry>> = () => ({
type: 'SN_DMS_INIT_LOG',
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
inject: async options => {
const repository = options.getInjectable(Repository)
const eventHub = new EventHub(repository)
eventHub.onContentCreated.subscribe(ev => {
Expand Down
83 changes: 47 additions & 36 deletions examples/sn-dms-demo/src/store/documentlibrary/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -26,12 +27,15 @@ export const startLoadingChildren = (idOrPath: number | string) => ({
export const finishLoadingChildren = () => ({
type: 'DMS_DOCLIB_FINISH_LOADING_CHILDREN',
})
export const loadParent = <T extends GenericContent = GenericContent>(
export const loadParent: <T extends GenericContent = GenericContent>(
idOrPath: string | number,
loadParentOptions?: ODataParams<T>,
) => InjectableAction<rootStateType, Action> = <T extends GenericContent = GenericContent>(
idOrPath: number | string,
loadParentOptions?: ODataParams<T>,
) => ({
type: 'DMS_DOCLIB_LOAD_PARENT',
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
inject: async options => {
const prevState = options.getState().dms.documentLibrary
if (prevState.parentIdOrPath === idOrPath) {
return
Expand Down Expand Up @@ -117,9 +121,11 @@ export const loadParent = <T extends GenericContent = GenericContent>(
},
})

export const loadMore = (count: number = loadChunkSize) => ({
export const loadMore: (count?: number) => InjectableAction<rootStateType, Action> = (
count: number = loadChunkSize,
) => ({
type: 'DMS_DOCLIB_LOAD_MORE',
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
inject: async options => {
const currentDocLibState = options.getState().dms.documentLibrary

if (
Expand Down Expand Up @@ -152,7 +158,9 @@ export const loadMore = (count: number = loadChunkSize) => ({
},
})

export const setParent = <T extends GenericContent = GenericContent>(content: T) => ({
export const setParent: <T extends GenericContent = GenericContent>(content: T) => Action & { content: T } = <T>(
content: T,
) => ({
type: 'DMS_DOCLIB_SET_PARENT',
content,
})
Expand All @@ -162,7 +170,9 @@ export const setAncestors = <T extends GenericContent>(ancestors: T[]) => ({
ancestors,
})

export const setItems = <T extends GenericContent = GenericContent>(items: ODataCollectionResponse<T>) => ({
export const setItems: <T extends GenericContent = GenericContent>(
items: ODataCollectionResponse<T>,
) => Action & { items: ODataCollectionResponse<T> } = <T>(items: ODataCollectionResponse<T>) => ({
type: 'DMS_DOCLIB_SET_ITEMS',
items,
})
Expand All @@ -182,36 +192,37 @@ export const setActive = <T extends GenericContent>(active?: T) => ({
active,
})

export const updateChildrenOptions = <T extends GenericContent>(odataOptions: ODataParams<T>) => ({
type: 'DMS_DOCLIB_UPDATE_CHILDREN_OPTIONS',
odataOptions,
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
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 = <T extends GenericContent>(odataOptions: ODataParams<T>) =>
({
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<rootStateType, Action> & { odataOptions: ODataParams<GenericContent> })

export const updateSearchValues = (value: Partial<DocumentLibraryState['searchState']>) => ({
type: 'DMS_DOCLIB_UPDATE_SEARCH_STATE',
Expand Down
30 changes: 24 additions & 6 deletions examples/sn-dms-demo/src/store/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<rootStateType, AnyAction> = (
idOrPath: string | number,
query: string,
displayName: string,
queryType = 'Private',
) => ({
type: 'SN_DMS_SAVE_QUERY',
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
inject: async options => {
const repo = options.getInjectable(Repository)
await repo.executeAction({
idOrPath,
Expand All @@ -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<rootStateType, AnyAction> = (
idOrPath: string | number,
queryType = 'Private',
force: boolean = false,
) => ({
type: 'SN_DMS_GET_QUERIES',
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
inject: async options => {
const state = options.getState()
if (force === false && state.dms.queries.idOrPath === idOrPath && state.dms.queries.queryType === queryType) {
return
Expand Down Expand Up @@ -70,7 +88,7 @@ export const setActive = <T extends Query>(active?: T) => ({
active,
})

export interface QueriesType {
interface QueriesType {
idOrPath: number | string
queryType: QueryType
queries: Query[]
Expand Down
Loading

0 comments on commit 5e4b734

Please sign in to comment.