Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

redundant type definition cleanup #111

Merged
merged 5 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions examples/sn-dms-demo/src/Actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,7 @@ export const trackUploadProgress = async <T extends GenericContent>(
dispatch: Dispatch,
api: Repository,
) => {
let currentUpload: ExtendedUploadProgressInfo | undefined = getState().dms.uploads.uploads.find(
u => u.guid === currentValue.guid,
)
let currentUpload = getState().dms.uploads.uploads.find(u => u.guid === currentValue.guid)
if (currentUpload) {
dispatch(updateUploadItem(currentValue))
} else {
Expand Down
31 changes: 14 additions & 17 deletions examples/sn-dms-demo/src/Reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ export const email: Reducer<string, Action & { email?: string }> = (state = '',
return state
}
}
export const registrationError: Reducer<string | null, Action> = (state: string | null = null, action: AnyAction) => {
export const registrationError: Reducer<string | null, Action> = (state = null, action: AnyAction) => {
switch (action.type) {
case 'USER_REGISTRATION_FAILURE':
return resources.USER_IS_ALREADY_REGISTERED
default:
return state
}
}
export const isRegistering: Reducer<boolean> = (state: boolean = false, action: AnyAction) => {
export const isRegistering: Reducer<boolean> = (state = false, action: AnyAction) => {
switch (action.type) {
case 'USER_REGISTRATION_REQUEST':
return true
Expand All @@ -49,7 +49,7 @@ export const isRegistering: Reducer<boolean> = (state: boolean = false, action:
}
}

export const registrationDone: Reducer<boolean> = (state: boolean = false, action: AnyAction) => {
export const registrationDone: Reducer<boolean> = (state = false, action: AnyAction) => {
switch (action.type) {
case 'USER_REGISTRATION_SUCCESS':
return true
Expand All @@ -62,7 +62,7 @@ export const registrationDone: Reducer<boolean> = (state: boolean = false, actio
}
}

export const captcha: Reducer<boolean> = (state: boolean = false, action: AnyAction) => {
export const captcha: Reducer<boolean> = (state = false, action: AnyAction) => {
switch (action.type) {
case 'VERIFY_CAPTCHA_SUCCESS':
return true
Expand All @@ -79,7 +79,7 @@ export const register = combineReducers({
captcha,
})

export const open: Reducer<boolean> = (state: boolean = false, action: AnyAction) => {
export const open: Reducer<boolean> = (state = false, action: AnyAction) => {
switch (action.type) {
case 'OPEN_ACTIONMENU':
return true
Expand All @@ -90,7 +90,7 @@ export const open: Reducer<boolean> = (state: boolean = false, action: AnyAction
}
}

export const actions: Reducer<ActionModel[]> = (state: ActionModel[] = [], action: AnyAction) => {
export const actions: Reducer<ActionModel[]> = (state = [], action: AnyAction) => {
switch (action.type) {
case 'LOAD_CONTENT_ACTIONS_SUCCESS':
const result: { d: { Actions: ActionModel[] } } = (action.result as Actions.PromiseReturns<
Expand All @@ -104,7 +104,7 @@ export const actions: Reducer<ActionModel[]> = (state: ActionModel[] = [], actio
}
}

export const id: Reducer<number | null> = (state: number | null = null, action: AnyAction) => {
export const id: Reducer<number | null> = (state = null, action: AnyAction) => {
switch (action.type) {
case 'OPEN_ACTIONMENU':
return action.id || null
Expand Down Expand Up @@ -248,7 +248,7 @@ export const isSelectionModeOn: Reducer<boolean> = (state = false, action: AnyAc
}
}

export const userActions: Reducer<ActionModel[]> = (state: ActionModel[] = [], action: AnyAction) => {
export const userActions: Reducer<ActionModel[]> = (state = [], action: AnyAction) => {
switch (action.type) {
case 'LOAD_USER_ACTIONS_SUCCESS':
const result = action.result as Actions.PromiseReturns<typeof loadUserActions>
Expand All @@ -258,7 +258,7 @@ export const userActions: Reducer<ActionModel[]> = (state: ActionModel[] = [], a
}
}

export const addNewTypes: Reducer<ActionModel[]> = (state: ActionModel[] = [], action: AnyAction) => {
export const addNewTypes: Reducer<ActionModel[]> = (state = [], action: AnyAction) => {
switch (action.type) {
case 'LOAD_TYPES_TO_ADDNEW_LIST_SUCCESS':
const result = action.result as Actions.PromiseReturns<typeof loadTypesToAddNewList>
Expand All @@ -268,7 +268,7 @@ export const addNewTypes: Reducer<ActionModel[]> = (state: ActionModel[] = [], a
}
}

export const actionmenuContent: Reducer<GenericContent> = (state: GenericContent | null = null, action: AnyAction) => {
export const actionmenuContent: Reducer<GenericContent | null> = (state = null, action: AnyAction) => {
switch (action.type) {
case 'OPEN_ACTIONMENU':
return action.content
Expand Down Expand Up @@ -435,7 +435,7 @@ export const viewer: Reducer<{ isOpened: boolean; currentDocumentId: number }, A
return state
}

export const isOpened: Reducer<boolean> = (state: boolean = false, action: AnyAction) => {
export const isOpened: Reducer<boolean> = (state = false, action: AnyAction) => {
switch (action.type) {
case 'OPEN_DIALOG':
return true
Expand All @@ -445,10 +445,7 @@ export const isOpened: Reducer<boolean> = (state: boolean = false, action: AnyAc
return state
}

export const onClose: Reducer<() => void | undefined> = (
state: () => void | undefined = () => undefined,
action: AnyAction,
) => {
export const onClose: Reducer<() => void | undefined> = (state = () => undefined, action: AnyAction) => {
switch (action.type) {
case 'OPEN_DIALOG':
return action.onClose
Expand All @@ -471,7 +468,7 @@ export const dialogContent: Reducer<React.Component | undefined> = (
return state
}

export const dialogTitle: Reducer<string> = (state: string = '', action: AnyAction) => {
export const dialogTitle: Reducer<string> = (state = '', action: AnyAction) => {
switch (action.type) {
case 'OPEN_DIALOG':
return action.title
Expand All @@ -498,7 +495,7 @@ export const versions = (state: GenericContent[] = [], action: AnyAction) => {
}
}

export const menuOpen: Reducer<boolean> = (state: boolean = false, action: AnyAction) => {
export const menuOpen: Reducer<boolean> = (state = false, action: AnyAction) => {
switch (action.type) {
case 'HANDLE_DRAWERMENU':
return action.open
Expand Down
6 changes: 3 additions & 3 deletions examples/sn-dms-demo/src/ViewerSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import { v1 } from 'uuid'
/**
* Adds a globally unique ID to the shape
*/
const addGuidToShape: <T extends Shape>(shape: T) => T = shape => {
const addGuidToShape = <T extends Shape>(shape: T) => {
shape.guid = v1()
return shape
}

export const getViewerSettings: (repo: Repository) => DocumentViewerSettings = (repo: Repository) =>
export const getViewerSettings = (repo: Repository) =>
new DocumentViewerSettings({
saveChanges: async (documentData, pages) => {
const reqBody = {
Expand Down Expand Up @@ -67,7 +67,7 @@ export const getViewerSettings: (repo: Repository) => DocumentViewerSettings = (
pageAttributes: (documentData.PageAttributes && JSON.parse(documentData.PageAttributes)) || [],
}
},
isPreviewAvailable: async (documentData, version, page: number) => {
isPreviewAvailable: async (documentData, version, page) => {
const responseBody = await repo.executeAction<{ page: number }, PreviewImageData & { PreviewAvailable: string }>({
idOrPath: documentData.idOrPath,
method: 'POST',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class AddNewMenu extends React.Component<
)
}
public render() {
return <AddNewButton contentType="" onClick={(e: React.MouseEvent<HTMLElement>) => this.handleButtonClick(e)} />
return <AddNewButton contentType="" onClick={e => this.handleButtonClick(e)} />
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/sn-dms-demo/src/components/BreadCrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class BreadCrumb extends React.Component<
) : (
<Icon
style={styles.breadCrumbIconLast}
onClick={(e: React.MouseEvent<HTMLElement>) => this.handleActionMenuClick(e, ancestor)}
onClick={e => this.handleActionMenuClick(e, ancestor)}
type={iconType.materialui}
iconName={icons.arrowDropDown}
/>
Expand All @@ -150,7 +150,7 @@ class BreadCrumb extends React.Component<
{!isLast ? (
<Icon
style={styles.breadCrumbIcon}
onClick={(e: React.MouseEvent<HTMLElement>) => this.handleActionMenuClick(e, ancestor)}
onClick={e => this.handleActionMenuClick(e, ancestor)}
type={iconType.materialui}
iconName={icons.arrowRight}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class VersionsDialog extends React.Component<
</TableRow>
</TableHead>
<TableBody>
{versions.map((version, index: number) => (
{versions.map((version, index) => (
<TableRow key={index}>
<TableCell padding="checkbox" className={classes.versionNumber}>
{this.formatVersionNumber(version.Version || '')}
Expand Down Expand Up @@ -286,7 +286,7 @@ class VersionsDialog extends React.Component<
) : (
<Paper>
<Typography style={styles.mobileVersionsTitle}>{resources.VERSIONS}</Typography>
{versions.map((version, index: number) => (
{versions.map((version, index) => (
<ExpansionPanel
style={styles.innerMobileList}
key={`panel${index}`}
Expand Down
2 changes: 1 addition & 1 deletion examples/sn-dms-demo/src/components/MessageBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class MessageBar extends React.Component<
e.messageEntry && e.messageEntry.bulkMessage && e.messageEntry.bulkMessage

const grouped = groupBy(newProps.entries.filter(e => e.messageEntry), getBulkMessageKey)
const msgSegments: MessageBarState['digestedMessageEntries'] = [...lastState.digestedMessageEntries]
const msgSegments = [...lastState.digestedMessageEntries]
for (const type in grouped) {
if (grouped[type]) {
const groupedEntries = grouped[type]
Expand Down
2 changes: 1 addition & 1 deletion examples/sn-dms-demo/src/components/Pickers/PathPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ class PathPicker extends React.Component<
type={iconType.materialui}
iconName="keyboard_arrow_right"
style={this.isHovered ? styles.openIcon : { display: 'none' }}
onClick={(e: React.MouseEvent<HTMLElement>) => this.handleClick(e, item)}
onClick={e => this.handleClick(e, item)}
/>
) : null}
</MenuItem>
Expand Down
6 changes: 3 additions & 3 deletions examples/sn-dms-demo/src/components/Upload/UploadButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export interface UploadButtonState {
anchorElement: HTMLElement | undefined
}

export const UPLOAD_FILE_BUTTON_ID: string = 'sn-dms-upload-button'
export const UPLOAD_FOLDER_BUTTON_ID: string = 'sn-dms-upload-button'
export const UPLOAD_MENU_ID: string = 'sn-dms-upload-button'
export const UPLOAD_FILE_BUTTON_ID = 'sn-dms-upload-button'
export const UPLOAD_FOLDER_BUTTON_ID = 'sn-dms-upload-button'
export const UPLOAD_MENU_ID = 'sn-dms-upload-button'

export class UploadButton extends React.Component<UploadButtonProps, UploadButtonState> {
private readonly uploadFileButtonId = `${UPLOAD_FILE_BUTTON_ID}-${v1()}`
Expand Down
3 changes: 3 additions & 0 deletions examples/sn-dms-demo/src/pages/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class DashboardComponent extends React.Component<
<Switch>
<Route
path="/documents"
// tslint:disable-next-line: no-unnecessary-type-annotation
component={(props: RouteComponentProps<any>) => (
<Switch>
<Route path={props.match.url + '/shared'}>
Expand Down Expand Up @@ -222,6 +223,7 @@ class DashboardComponent extends React.Component<
<Switch>
<Route
path="/documents"
// tslint:disable-next-line: no-unnecessary-type-annotation
component={(props: RouteComponentProps<any>) => (
<Switch>
<Route path={props.match.url + '/shared'}>
Expand All @@ -248,6 +250,7 @@ class DashboardComponent extends React.Component<
/>
<Route
path="/users"
// tslint:disable-next-line: no-unnecessary-type-annotation
component={(props: RouteComponentProps<any>) => (
<Switch>
<Route
Expand Down
3 changes: 2 additions & 1 deletion examples/sn-dms-demo/src/store/actionlog/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IInjectableActionCallbackParams } from 'redux-di-middleware'
import { resources } from '../../assets/resources'
import { rootStateType } from '../../store/rootReducer'

export const logActions: string[] = ['CheckIn', 'Checkout', 'UndoCheckOut', 'Approve', 'Reject', 'Publish']
export const logActions = ['CheckIn', 'Checkout', 'UndoCheckOut', 'Approve', 'Reject', 'Publish']

export interface MessageEntry {
verbosity: 'info' | 'error'
Expand Down Expand Up @@ -37,6 +37,7 @@ export const readLogEntries = createAction((entries: LogEntry[]) => ({

export const initLog = createAction(() => ({
type: 'SN_DMS_INIT_LOG',
// tslint:disable-next-line: no-unnecessary-type-annotation
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
const repository = options.getInjectable(Repository)
const eventHub = new EventHub(repository)
Expand Down
3 changes: 3 additions & 0 deletions examples/sn-dms-demo/src/store/documentlibrary/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export const finishLoadingChildren = createAction(() => ({
export const loadParent = createAction(
<T extends GenericContent = GenericContent>(idOrPath: number | string, loadParentOptions?: ODataParams<T>) => ({
type: 'DMS_DOCLIB_LOAD_PARENT',
// tslint:disable-next-line: no-unnecessary-type-annotation
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
const prevState = options.getState().dms.documentLibrary
if (prevState.parentIdOrPath === idOrPath) {
Expand Down Expand Up @@ -119,6 +120,7 @@ export const loadParent = createAction(

export const loadMore = createAction((count: number = loadChunkSize) => ({
type: 'DMS_DOCLIB_LOAD_MORE',
// tslint:disable-next-line: no-unnecessary-type-annotation
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
const currentDocLibState = options.getState().dms.documentLibrary

Expand Down Expand Up @@ -187,6 +189,7 @@ export const setActive = createAction(<T extends GenericContent>(active?: T) =>
export const updateChildrenOptions = createAction(<T extends GenericContent>(odataOptions: ODataParams<T>) => ({
type: 'DMS_DOCLIB_UPDATE_CHILDREN_OPTIONS',
odataOptions,
// tslint:disable-next-line: no-unnecessary-type-annotation
inject: async (options: IInjectableActionCallbackParams<rootStateType>) => {
const currentState = options.getState()
const parentPath = currentState.dms.documentLibrary.parent ? currentState.dms.documentLibrary.parent.Path : ''
Expand Down
5 changes: 1 addition & 4 deletions examples/sn-dms-demo/src/store/edited/reducers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ import { GenericContent } from '@sensenet/default-content-types'
import { loadContent, PromiseReturns } from '@sensenet/redux/dist/Actions'
import { AnyAction, Reducer } from 'redux'

export const editedContent: Reducer<GenericContent | null> = (
state: GenericContent | null = null,
action: AnyAction,
) => {
export const editedContent: Reducer<GenericContent | null> = (state = null, action: AnyAction) => {
switch (action.type) {
case 'LOAD_EDITED_CONTENT_SUCCESS':
return (action.result as PromiseReturns<typeof loadContent>).d
Expand Down
Loading