Skip to content

Commit

Permalink
chore(release): 4.1.12 (#781)
Browse files Browse the repository at this point in the history
* Telemetry: Normalize Query URL and Redact PII (#734)

* Feature: autocomplete (#480)

* Localized GE.jsons HB (#776)

* Prevent remote dependency and trace information telemetry types from being captured (#770)

* Fix: sample query sample body (#775)

* Fix: stop display of options when fetching suggestions (#778)

* add aria-label (#780)

* chore(release): 4.1.12
  • Loading branch information
ElinorW authored Dec 9, 2020
1 parent 3083a28 commit 2d5c2cb
Show file tree
Hide file tree
Showing 59 changed files with 3,570 additions and 595 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graph-explorer-v2",
"version": "4.1.11",
"version": "4.1.12",
"private": true,
"dependencies": {
"@babel/core": "7.2.2",
Expand Down
38 changes: 38 additions & 0 deletions src/app/services/actions/autocomplete-action-creators.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { suggestions } from '../../../modules/suggestions';
import { IAction } from '../../../types/action';
import {
AUTOCOMPLETE_FETCH_ERROR, AUTOCOMPLETE_FETCH_PENDING,
AUTOCOMPLETE_FETCH_SUCCESS
} from '../redux-constants';

export function fetchAutocompleteSuccess(response: object): IAction {
return {
type: AUTOCOMPLETE_FETCH_SUCCESS,
response,
};
}

export function fetchAutocompleteError(response: object): IAction {
return {
type: AUTOCOMPLETE_FETCH_ERROR,
response,
};
}

export function fetchAutocompletePending(): any {
return {
type: AUTOCOMPLETE_FETCH_PENDING
};
}

export function fetchAutoCompleteOptions(url: string, version: string): Function {
return async (dispatch: Function, getState: Function) => {
const devxApi = getState().devxApi;
dispatch(fetchAutocompletePending());
const autoOptions = await suggestions.getSuggestions(url, devxApi, version);
if (autoOptions) {
return dispatch(fetchAutocompleteSuccess(autoOptions));
}
return dispatch(fetchAutocompleteError({}));
};
}
33 changes: 33 additions & 0 deletions src/app/services/reducers/autocomplete-reducer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { IAction, IApiResponse } from '../../../types/action';
import { AUTOCOMPLETE_FETCH_ERROR, AUTOCOMPLETE_FETCH_PENDING, AUTOCOMPLETE_FETCH_SUCCESS } from '../redux-constants';

const initialState: IApiResponse = {
pending: false,
data: [],
error: null
};

export function autoComplete(state = initialState, action: IAction): IApiResponse {
switch (action.type) {
case AUTOCOMPLETE_FETCH_PENDING:
return {
error: null,
data: null,
pending: true
};
case AUTOCOMPLETE_FETCH_SUCCESS:
return {
pending: false,
data: action.response,
error: null
};
case AUTOCOMPLETE_FETCH_ERROR:
return {
pending: false,
data: null,
error: action.response
};
default:
return state;
}
}
2 changes: 2 additions & 0 deletions src/app/services/reducers/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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 { graphExplorerMode } from './graph-explorer-mode-reducer';
import { scopes } from './permissions-reducer';
Expand All @@ -19,6 +20,7 @@ import { sidebarProperties } from './toggle-sidebar-reducer';
export default combineReducers({
adaptiveCard,
authToken,
autoComplete,
consentedScopes,
graphExplorerMode,
graphResponse,
Expand Down
3 changes: 3 additions & 0 deletions src/app/services/redux-constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ export const GET_CONSENT_ERROR = 'GET_CONSENT_ERROR';
export const GET_CONSENTED_SCOPES_SUCCESS = 'GET_CONSENTED_SCOPES_SUCCESS';
export const SET_DEVX_API_URL_SUCCESS = 'SET_DEVX_API_URL_SUCCESS';
export const REMOVE_ALL_HISTORY_ITEMS_SUCCESS = 'REMOVE_ALL_HISTORY_ITEMS_SUCCESS';
export const AUTOCOMPLETE_FETCH_SUCCESS = 'AUTOCOMPLETE_FETCH_SUCCESS';
export const AUTOCOMPLETE_FETCH_ERROR = 'AUTOCOMPLETE_FETCH_ERROR';
export const AUTOCOMPLETE_FETCH_PENDING = 'AUTOCOMPLETE_FETCH_PENDING';
16 changes: 11 additions & 5 deletions src/app/utils/dynamic-sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,19 @@ import { SortOrder } from '../../types/enums';
* @param {SortOrder} sortOrder the direction to follow Ascending / Descending
* You pass this helper to the array sort function
*/
export function dynamicSort(property: string, sortOrder: SortOrder) {
let order = 1;
if (sortOrder === SortOrder.DESC) {
order = -1;
}
export function dynamicSort(property: string | null, sortOrder: SortOrder) {
let order = 1;
if (sortOrder === SortOrder.DESC) {
order = -1;
}
if (property) {
return (first: any, second: any) => {
const result = (first[property] < second[property]) ? -1 : (first[property] > second[property]) ? 1 : 0;
return result * order;
};
}
return (first: any, second: any) => {
const result = (first < second) ? -1 : (first > second) ? 1 : 0;
return result * order;
};
}
32 changes: 32 additions & 0 deletions src/app/utils/generate-groups.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
export function generateGroupsFromList(list: any[], property: string) {
const map = new Map();
const groups: any[] = [];

let isCollapsed = false;
let previousCount = 0;
let count = 0;

if (!list || list.length === 0 || list.some(e => !e[property])) {
return groups;
}

for (const listItem of list) {
if (!map.has(listItem[property])) {
map.set(listItem[property], true);
count = list.filter(item => item[property] === listItem[property]).length;
if (groups.length > 0) {
isCollapsed = true;
}
groups.push({
name: listItem[property],
key: listItem[property],
startIndex: previousCount,
isCollapsed,
count,
});
previousCount += count;
}
}

return groups;
}
15 changes: 15 additions & 0 deletions src/app/utils/hash-string.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export function stringToHash(input: string) {
let hash = 0;
if (input.length === 0) {
return hash;
}

for (let index = 0; index < input.length; index++) {
const char = input.charCodeAt(index);
// tslint:disable-next-line: no-bitwise
hash = ((hash << 5) - hash) + char;
// tslint:disable-next-line: no-bitwise
hash = hash & hash;
}
return hash;
}
55 changes: 55 additions & 0 deletions src/app/utils/open-api-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import {
IOpenApiParseContent, IParameters, IParameterValue,
IParsedOpenApiResponse, IPathValue, IQueryParameter
} from '../../types/open-api';

export function parseOpenApiResponse(params: IOpenApiParseContent): IParsedOpenApiResponse {
const { response: { paths }, url } = params;

try {
const parameters: IParameters[] = [];
const requestUrl = Object.keys(paths)[0];
const verbs = Object.keys(paths[`${requestUrl}`]);
const pathValues: any = Object.values(paths)[0];

verbs.forEach((verb: string) => {
parameters.push({
verb,
values: getVerbParameterValues(pathValues[`${verb}`]),
links: getLinkValues(pathValues[`${verb}`])
});
});

const createdAt = new Date().toISOString();
return { url, parameters, createdAt };
} catch (error) {
throw new Error(error);
}
}

function getVerbParameterValues(values: IPathValue): IParameterValue[] {
const parameterValues: IParameterValue[] = [];
const queryParameters = values.parameters;
if (queryParameters && queryParameters.length > 0) {
queryParameters.forEach((parameter: IQueryParameter) => {
if (parameter.name && parameter.in === 'query') {
parameterValues.push({
name: parameter.name,
items: (parameter.schema && parameter.schema.items) ? parameter.schema.items.enum : []
});
}
});
}
return parameterValues;
}

function getLinkValues(values: IPathValue): string[] {
const responses = values.responses;
if (responses) {
const responsesAtIndex200 = responses['200'];
if (responsesAtIndex200 && responsesAtIndex200.links) {
return Object.keys(responsesAtIndex200.links);
}
}
return [];
}
Loading

0 comments on commit 2d5c2cb

Please sign in to comment.