-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First iteration that allows view operations
- Loading branch information
Showing
26 changed files
with
336,805 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
src/app/services/actions/resource-explorer-action-creators.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { IAction } from '../../../types/action'; | ||
import { FETCH_RESOURCES_SUCCESS, FETCH_RESOURCES_PENDING, FETCH_RESOURCES_ERROR } from '../redux-constants'; | ||
import { IResource } from '../../../types/resources'; | ||
import { IRootState } from '../../../types/root'; | ||
import { IRequestOptions } from '../../../types/request'; | ||
|
||
export function fetchResourcesSuccess(response: object): IAction { | ||
return { | ||
type: FETCH_RESOURCES_SUCCESS, | ||
response | ||
}; | ||
} | ||
|
||
export function fetchResourcesPending(): any { | ||
return { | ||
type: FETCH_RESOURCES_PENDING | ||
}; | ||
} | ||
|
||
export function fetchResourcesError(response: object): IAction { | ||
return { | ||
type: FETCH_RESOURCES_ERROR, | ||
response | ||
}; | ||
} | ||
|
||
export function fetchResources(): Function { | ||
return async (dispatch: Function, getState: Function) => { | ||
try { | ||
const { devxApi }: IRootState = getState(); | ||
const resourcesUrl = `${devxApi.baseUrl}/openapi/tree`; | ||
|
||
const headers = { | ||
'Content-Type': 'application/json' | ||
}; | ||
|
||
const options: IRequestOptions = { headers }; | ||
|
||
dispatch(fetchResourcesPending()); | ||
|
||
const response = await fetch(resourcesUrl, options); | ||
if (response.ok) { | ||
const resources = await response.json() as IResource; | ||
return dispatch(fetchResourcesSuccess(resources)); | ||
} | ||
throw response; | ||
} catch (error) { | ||
return dispatch(fetchResourcesError({ error })); | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,52 @@ | ||
import { combineReducers } from 'redux'; | ||
|
||
import { adaptiveCard } from './adaptive-cards-reducer'; | ||
import { authToken, consentedScopes } from './auth-reducers'; | ||
import { autoComplete } from './autocomplete-reducer'; | ||
import { devxApi } from './devxApi-reducers'; | ||
import { dimensions } from './dimensions-reducers'; | ||
import { permissionsPanelOpen } from './permissions-panel-reducer'; | ||
import { graphExplorerMode } from './graph-explorer-mode-reducer'; | ||
import { policies } from './ocps-reducers'; | ||
import { permissionsPanelOpen } from './permissions-panel-reducer'; | ||
import { scopes } from './permissions-reducer'; | ||
import { profile } from './profile-reducer'; | ||
import { proxyUrl } from './proxy-url-reducer'; | ||
import { sampleQuery } from './query-input-reducers'; | ||
import { isLoadingData } from './query-loading-reducers'; | ||
import { graphResponse } from './query-runner-reducers'; | ||
import { queryRunnerStatus } from './query-runner-status-reducers'; | ||
import { history } from './request-history-reducers'; | ||
import { resources } from './resources-reducer'; | ||
import { responseAreaExpanded } from './response-expanded-reducer'; | ||
import { samples } from './samples-reducers'; | ||
import { snippets } from './snippet-reducer'; | ||
import { termsOfUse } from './terms-of-use-reducer'; | ||
import { theme } from './theme-reducer'; | ||
import { sidebarProperties } from './toggle-sidebar-reducer'; | ||
import { proxyUrl } from './proxy-url-reducer'; | ||
import { policies } from './ocps-reducers'; | ||
|
||
export default combineReducers({ | ||
adaptiveCard, | ||
authToken, | ||
autoComplete, | ||
consentedScopes, | ||
devxApi, | ||
dimensions, | ||
graphExplorerMode, | ||
graphResponse, | ||
devxApi, | ||
history, | ||
isLoadingData, | ||
permissionsPanelOpen, | ||
profile, | ||
proxyUrl, | ||
policies, | ||
queryRunnerStatus, | ||
resources, | ||
responseAreaExpanded, | ||
sampleQuery, | ||
samples, | ||
scopes, | ||
sidebarProperties, | ||
snippets, | ||
termsOfUse, | ||
theme, | ||
dimensions, | ||
permissionsPanelOpen, | ||
policies | ||
theme | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { IAction } from '../../../types/action'; | ||
import { IResource, IResources } from '../../../types/resources'; | ||
import content from '../../utils/resources/resources.json'; | ||
import { FETCH_RESOURCES_ERROR, FETCH_RESOURCES_PENDING, FETCH_RESOURCES_SUCCESS } from '../redux-constants'; | ||
|
||
const res = JSON.parse(JSON.stringify(content)) as IResource; | ||
const initialState: IResources = { | ||
pending: false, | ||
data: { | ||
children: [], | ||
labels: [], | ||
segment: '' | ||
}, | ||
error: null | ||
}; | ||
|
||
export function resources(state: IResources = initialState, action: IAction): IResources { | ||
switch (action.type) { | ||
case FETCH_RESOURCES_SUCCESS: | ||
return { | ||
pending: false, | ||
data: action.response, | ||
error: null | ||
}; | ||
case FETCH_RESOURCES_ERROR: | ||
return { | ||
pending: false, | ||
error: action.response, | ||
data: res | ||
}; | ||
case FETCH_RESOURCES_PENDING: | ||
return { | ||
pending: true, | ||
data: initialState.data, | ||
error: null | ||
}; | ||
default: | ||
return state; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,4 @@ export function getStyleFor(method: string) { | |
return currentTheme.palette.orangeLight; | ||
} | ||
} | ||
|
Oops, something went wrong.