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

Chore: Code cleanup #2251

Merged
merged 22 commits into from
Jan 18, 2023
Merged
Show file tree
Hide file tree
Changes from 21 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
2 changes: 0 additions & 2 deletions src/app/services/actions/ocps-action-creators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ export function getPoliciesPending(): AppAction {
};
}


// TODO: Test this function
export function getPolicies() {
return async (dispatch: Function) => {
try {
Expand Down
12 changes: 0 additions & 12 deletions src/app/services/reducers/toggle-sidebar-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,7 @@ export function sidebarProperties(state = initialState, action: AppAction): any
case TOGGLE_SIDEBAR_SUCCESS:
return action.response;
case QUERY_GRAPH_RUNNING:
if (state.mobileScreen) {
return {
...state,
showSidebar: false
};
}
case SET_SAMPLE_QUERY_SUCCESS:
if (state.mobileScreen) {
return {
...state,
showSidebar: false
};
}
case VIEW_HISTORY_ITEM_SUCCESS:
if (state.mobileScreen) {
return {
Expand Down
13 changes: 3 additions & 10 deletions src/app/utils/query-parameter-sanitization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,7 @@ function sanitizeQueryParameter(queryParameter: string): string {
.trim();

switch (key) {
case '$top': {
if (!isPositiveInteger(value)) {
value = '<invalid-value>';
}
break;
}

case '$top':
case '$skip': {
if (!isPositiveInteger(value)) {
value = '<invalid-value>';
Expand Down Expand Up @@ -255,8 +249,8 @@ function sanitizeSearchQueryOptionValue(queryOptionValue: string): string {
return sanitizedQueryString;
}

for (let segment of searchSegments) {
segment = segment.trim();
for (const searchSegment of searchSegments) {
const segment = searchSegment.trim();

// No processing needed for logicalOperators operators; append operator to query string.
if (LOGICAL_OPERATORS.includes(segment.toLowerCase())) {
Expand Down Expand Up @@ -417,7 +411,6 @@ function sanitizeFilterQueryOptionValue(queryParameterValue: string): string {
QUERY_FUNCTIONS.forEach((funcName) => {
if (segment.toLowerCase().startsWith(funcName)) {
queryFunctionPrefix = funcName;
return;
}
});
if (queryFunctionPrefix) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/common/monaco/Monaco.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { formatJsonStringForAllBrowsers } from './util/format-json';

interface IMonaco {
body: object | string | undefined;
onChange?: OnChange | undefined;
onChange?: OnChange;
verb?: string;
language?: string;
readOnly?: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/query-response/query-response.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}

.share-query-params {
font-family: 'monospace';
font-family: 'monospace', 'courier';
font-size: 12px;
width: '100%';
overflow-x: auto;
Expand Down
4 changes: 2 additions & 2 deletions src/app/views/query-response/response/Response.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { AppDispatch, useAppSelector } from '../../../../store';
import { getContentType } from '../../../services/actions/query-action-creator-util';
import { convertVhToPx, getResponseHeight } from '../../common/dimensions/dimensions-adjustment';
import ResponseDisplay from './ResponseDisplay';
import { responseMessages } from './ResponseMessages';
import { ResponseMessages } from './ResponseMessages';

const Response = () => {
const { dimensions: { response }, graphResponse, responseAreaExpanded, sampleQuery, authToken, graphExplorerMode } =
Expand All @@ -20,7 +20,7 @@ const Response = () => {
const contentType = getContentType(headers);
return (
<div style={{ display: 'block' }}>
{responseMessages(graphResponse, sampleQuery, authToken, graphExplorerMode, dispatch)}
{ResponseMessages(graphResponse, sampleQuery, authToken, graphExplorerMode, dispatch)}
{!contentDownloadUrl && !throwsCorsError && headers &&
<ResponseDisplay
contentType={contentType}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface ODataLink {
name: string;
}

export function responseMessages(
export function ResponseMessages(
graphResponse: IGraphResponse,
sampleQuery: IQuery,
authToken: IAuthenticateResult,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ISuggestionsList } from '../../../../../../types/auto-complete';
import { classNames } from '../../../../classnames';
import { autoCompleteStyles } from '../AutoComplete.styles';

const styledSuggesions = (props: any) => {
const StyledSuggesions = (props: any) => {
const { filteredSuggestions, activeSuggestion, onClick }: ISuggestionsList = props;
const classes = classNames(props);

Expand Down Expand Up @@ -46,5 +46,5 @@ const styledSuggesions = (props: any) => {
};

// @ts-ignore
const SuggestionsList = styled(styledSuggesions, autoCompleteStyles);
const SuggestionsList = styled(StyledSuggesions, autoCompleteStyles);
export default SuggestionsList;
39 changes: 19 additions & 20 deletions src/app/views/query-runner/request/headers/HeadersList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,25 @@ const HeadersList = ({
const itemContent: any = headerStyles().itemContent;
if (column) {
const fieldContent = item[column.fieldName as keyof any] as string;
switch (column.key) {
case 'button':
return <div>
<IconButton
iconProps={{ iconName: 'Delete' }}
title={translateMessage('Remove request header')}
ariaLabel={translateMessage('Remove request header')}
onClick={() => handleOnHeaderDelete(item)}
/>
<span style={{fontSize: 'large', position: 'relative', bottom: '3px'}}>|</span>
<IconButton
iconProps={{ iconName: 'Edit' }}
title={translateMessage('Edit request header')}
ariaLabel={translateMessage('Edit request header')}
onClick={() => handleOnHeaderEdit(item)}
/>
</div>;

default:
return <div style={itemContent}>{fieldContent}</div>;
if(column.key === 'button') {
return <div>
<IconButton
iconProps={{ iconName: 'Delete' }}
title={translateMessage('Remove request header')}
ariaLabel={translateMessage('Remove request header')}
onClick={() => handleOnHeaderDelete(item)}
/>
<span style={{fontSize: 'large', position: 'relative', bottom: '3px'}}>|</span>
<IconButton
iconProps={{ iconName: 'Edit' }}
title={translateMessage('Edit request header')}
ariaLabel={translateMessage('Edit request header')}
onClick={() => handleOnHeaderEdit(item)}
/>
</div>;
}
else{
return <div style={itemContent}>{fieldContent}</div>;
}
}
};
Expand Down
2 changes: 1 addition & 1 deletion src/app/views/sidebar/history/har-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export function generateHar(entries: Entry[]): HarFormat {
}

export function exportQuery(content: HarFormat, requestUrl: string) {
const url = requestUrl.substr(8).split('/');
const url = requestUrl.substring(8).split('/');
url.pop();

const filename = `${url.join('_')}.har`;
Expand Down
5 changes: 2 additions & 3 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { setDevxApiUrl } from './app/services/actions/devxApi-action-creators';
import { setGraphExplorerMode } from './app/services/actions/explorer-mode-action-creator';
import { getGraphProxyUrl } from './app/services/actions/proxy-action-creator';
import { bulkAddHistoryItems } from './app/services/actions/request-history-action-creators';
import { changeThemeSuccess } from './app/services/actions/theme-action-creator';
import { changeTheme, changeThemeSuccess } from './app/services/actions/theme-action-creator';
import { isValidHttpsUrl } from './app/utils/external-link-validation';
import App from './app/views/App';
import { historyCache } from './modules/cache/history-utils';
Expand All @@ -26,7 +26,6 @@ import { loadGETheme } from './themes';
import { readTheme } from './themes/theme-utils';
import { IDevxAPI } from './types/devx-api';
import { Mode } from './types/enums';
import { changeTheme } from './app/services/actions/theme-action-creator';
import { fetchResources } from './app/services/actions/resource-explorer-action-creators';

// removes the loading spinner from GE html after the app is loaded
Expand Down Expand Up @@ -56,7 +55,7 @@ function setCurrentSystemTheme(): void {
applyCurrentSystemTheme(currentTheme);
}
function getOSTheme(): string {
let currentSystemTheme: string = 'light';
let currentSystemTheme: string;
const currentSystemThemeDark = window.matchMedia(
'(prefers-color-scheme: dark)'
);
Expand Down
2 changes: 1 addition & 1 deletion src/styles/_reset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockq
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
font-size: 100%;
vertical-align: baseline; }

/* HTML5 display-role reset for older browsers */
Expand Down
1 change: 1 addition & 0 deletions src/telemetry/filters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export function filterRemoteDependencyData(envelope: ITelemetryItem): boolean {
break;
case GRAPH_API_SANDBOX_URL:
baseData.name = sanitizeGraphAPISandboxUrl(target);
break;
default:
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/types/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export interface IRequestComponent {
export interface IRequestOptions {
headers?: {};
method?: string;
body?: string | undefined;
body?: string;
}

export interface IRequestState {
Expand Down