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

FIX-2145 change max_line_length to 80 characters #2146

Closed
Closed
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
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ indent_size = 2
indent_style = space
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 180
max_line_length = 80

[*.md]
trim_trailing_whitespace = false
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci_frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
run: yarn lint
working-directory: ./Src/WitsmlExplorer.Frontend
- name: Prettier
run: npx prettier --check .
run: npx prettier . --check
- name: Build
run: yarn build
working-directory: ./Src/WitsmlExplorer.Frontend
Expand Down
102 changes: 75 additions & 27 deletions Src/WitsmlExplorer.Frontend/__testUtils__/testUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@ import { render } from "@testing-library/react";
import { SnackbarProvider } from "notistack";
import React from "react";
import { Filter, FilterContextProvider } from "../contexts/filter";
import NavigationContext, { EMPTY_NAVIGATION_STATE, NavigationState } from "../contexts/navigationContext";
import NavigationContext, {
EMPTY_NAVIGATION_STATE,
NavigationState
} from "../contexts/navigationContext";
import { reducer as navigationReducer } from "../contexts/navigationStateReducer";
import OperationContext from "../contexts/operationContext";
import { DateTimeFormat, DecimalPreference, EMPTY_CONTEXT_MENU, OperationState, TimeZone, UserTheme, reducer as operationReducer } from "../contexts/operationStateReducer";
import {
DateTimeFormat,
DecimalPreference,
EMPTY_CONTEXT_MENU,
OperationState,
TimeZone,
UserTheme,
reducer as operationReducer
} from "../contexts/operationStateReducer";
import { QueryContextProvider, QueryState } from "../contexts/queryContext";
import AxisDefinition from "../models/AxisDefinition";
import BhaRun from "../models/bhaRun";
Expand Down Expand Up @@ -46,26 +57,40 @@ interface RenderWithContextsOptions {

export function renderWithContexts(
ui: React.ReactElement,
{ initialNavigationState, initialOperationState, initialFilter, initialQueryState, ...options }: RenderWithContextsOptions = {}
{
initialNavigationState,
initialOperationState,
initialFilter,
initialQueryState,
...options
}: RenderWithContextsOptions = {}
) {
const Wrapper = ({ children }: { children: React.ReactElement }) => {
const [operationState, dispatchOperation] = React.useReducer(operationReducer, {
contextMenu: EMPTY_CONTEXT_MENU,
progressIndicatorValue: 0,
modals: [],
theme: UserTheme.Compact,
timeZone: TimeZone.Local,
dateTimeFormat: DateTimeFormat.Raw,
decimals: DecimalPreference.Raw,
colors: light,
...initialOperationState
});
const [navigationState, dispatchNavigation] = React.useReducer(navigationReducer, { ...EMPTY_NAVIGATION_STATE, ...initialNavigationState });
const [operationState, dispatchOperation] = React.useReducer(
operationReducer,
{
contextMenu: EMPTY_CONTEXT_MENU,
progressIndicatorValue: 0,
modals: [],
theme: UserTheme.Compact,
timeZone: TimeZone.Local,
dateTimeFormat: DateTimeFormat.Raw,
decimals: DecimalPreference.Raw,
colors: light,
...initialOperationState
}
);
const [navigationState, dispatchNavigation] = React.useReducer(
navigationReducer,
{ ...EMPTY_NAVIGATION_STATE, ...initialNavigationState }
);

return (
<OperationContext.Provider value={{ operationState, dispatchOperation }}>
<ThemeProvider theme={getTheme(operationState.theme)}>
<NavigationContext.Provider value={{ navigationState, dispatchNavigation }}>
<NavigationContext.Provider
value={{ navigationState, dispatchNavigation }}
>
<FilterContextProvider initialFilter={initialFilter}>
<QueryContextProvider initialQueryState={initialQueryState}>
<SnackbarProvider>{children}</SnackbarProvider>
Expand Down Expand Up @@ -145,7 +170,9 @@ export function getJobInfo(overrides?: Partial<JobInfo>): JobInfo {
};
}

export function getNotification(overrides?: Partial<Notification>): Notification {
export function getNotification(
overrides?: Partial<Notification>
): Notification {
return {
serverUrl: new URL("http://example.com"),
isSuccess: true,
Expand All @@ -154,7 +181,9 @@ export function getNotification(overrides?: Partial<Notification>): Notification
};
}

export function getObjectOnWellbore(overrides?: Partial<ObjectOnWellbore>): ObjectOnWellbore {
export function getObjectOnWellbore(
overrides?: Partial<ObjectOnWellbore>
): ObjectOnWellbore {
return {
uid: "uid",
wellboreUid: "wellboreUid",
Expand All @@ -166,7 +195,9 @@ export function getObjectOnWellbore(overrides?: Partial<ObjectOnWellbore>): Obje
};
}

export function getObjectSearchResult(overrides?: Partial<ObjectSearchResult>): ObjectSearchResult {
export function getObjectSearchResult(
overrides?: Partial<ObjectSearchResult>
): ObjectSearchResult {
return {
...getObjectOnWellbore(),
searchProperty: "searchProperty",
Expand Down Expand Up @@ -208,7 +239,9 @@ export function getChangeLog(overrides?: Partial<ChangeLog>): ChangeLog {
};
}

export function getFluidsReport(overrides?: Partial<FluidsReport>): FluidsReport {
export function getFluidsReport(
overrides?: Partial<FluidsReport>
): FluidsReport {
return {
...getObjectOnWellbore(),
dTim: "",
Expand All @@ -220,7 +253,9 @@ export function getFluidsReport(overrides?: Partial<FluidsReport>): FluidsReport
};
}

export function getFormationMarker(overrides?: Partial<FormationMarker>): FormationMarker {
export function getFormationMarker(
overrides?: Partial<FormationMarker>
): FormationMarker {
return {
...getObjectOnWellbore(),
mdPrognosed: getMeasureWithDatum(),
Expand Down Expand Up @@ -333,7 +368,9 @@ export function getTubular(overrides?: Partial<Tubular>): Tubular {
};
}

export function getWbGeometry(overrides?: Partial<WbGeometryObject>): WbGeometryObject {
export function getWbGeometry(
overrides?: Partial<WbGeometryObject>
): WbGeometryObject {
return {
...getObjectOnWellbore(),
dTimReport: "",
Expand All @@ -360,7 +397,10 @@ const getObjectMapping = {
[ObjectType.WbGeometry]: getWbGeometry
};

export function getObject<T extends ObjectType>(objectType: T, overrides?: Partial<ObjectTypeToModel[T]>): ObjectTypeToModel[T] {
export function getObject<T extends ObjectType>(
objectType: T,
overrides?: Partial<ObjectTypeToModel[T]>
): ObjectTypeToModel[T] {
return getObjectMapping[objectType](overrides) as ObjectTypeToModel[T];
}

Expand Down Expand Up @@ -392,7 +432,9 @@ export function getCommonData(overrides?: Partial<CommonData>): CommonData {
};
}

export function getLogCurveInfo(overrides?: Partial<LogCurveInfo>): LogCurveInfo {
export function getLogCurveInfo(
overrides?: Partial<LogCurveInfo>
): LogCurveInfo {
return {
uid: "uid",
mnemonic: "mnemonic",
Expand All @@ -419,7 +461,9 @@ export function getMeasure(overrides?: Partial<Measure>): Measure {
};
}

export function getMeasureWithDatum(overrides?: Partial<MeasureWithDatum>): MeasureWithDatum {
export function getMeasureWithDatum(
overrides?: Partial<MeasureWithDatum>
): MeasureWithDatum {
return {
value: 0,
uom: "m",
Expand All @@ -428,15 +472,19 @@ export function getMeasureWithDatum(overrides?: Partial<MeasureWithDatum>): Meas
};
}

export function getStratigraphicStruct(overrides?: Partial<StratigraphicStruct>): StratigraphicStruct {
export function getStratigraphicStruct(
overrides?: Partial<StratigraphicStruct>
): StratigraphicStruct {
return {
value: "",
kind: "",
...overrides
};
}

export function getAxisDefinition(overrides?: Partial<AxisDefinition>): AxisDefinition {
export function getAxisDefinition(
overrides?: Partial<AxisDefinition>
): AxisDefinition {
return {
uid: "axisDefinitionUid",
order: 1,
Expand Down
103 changes: 66 additions & 37 deletions Src/WitsmlExplorer.Frontend/components/Alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,71 @@ const Alerts = (): React.ReactElement => {
} = useContext(OperationContext);

useEffect(() => {
const unsubscribeOnConnectionStateChanged = NotificationService.Instance.onConnectionStateChanged.subscribe((connected) => {
if (connected) {
setAlert(null);
} else {
setAlert({ content: "Lost connection to notifications service. Please wait for reconnection or refresh browser" });
}
});
const unsubscribeOnJobFinished = NotificationService.Instance.alertDispatcherAsEvent.subscribe((notification) => {
const shouldNotify = notification.serverUrl == null || notification.serverUrl.toString().toLowerCase() === navigationState.selectedServer?.url?.toLowerCase();
if (!shouldNotify) {
return;
}
if (notification.description) {
const content = (
<>
<h4>{notification.message}</h4>
{notification.description.wellName && <span>Well: {notification.description.wellName},</span>}
{notification.description.wellboreName && <span> Wellbore: {notification.description.wellboreName},</span>}
{notification.description.objectName && <span> Name: {notification.description.objectName}</span>}
{notification.reason && (
const unsubscribeOnConnectionStateChanged =
NotificationService.Instance.onConnectionStateChanged.subscribe(
(connected) => {
if (connected) {
setAlert(null);
} else {
setAlert({
content:
"Lost connection to notifications service. Please wait for reconnection or refresh browser"
});
}
}
);
const unsubscribeOnJobFinished =
NotificationService.Instance.alertDispatcherAsEvent.subscribe(
(notification) => {
const shouldNotify =
notification.serverUrl == null ||
notification.serverUrl.toString().toLowerCase() ===
navigationState.selectedServer?.url?.toLowerCase();
if (!shouldNotify) {
return;
}
if (notification.description) {
const content = (
<>
<br />
<span style={{ whiteSpace: "pre-wrap" }}>Reason: {notification.reason}</span>
<h4>{notification.message}</h4>
{notification.description.wellName && (
<span>Well: {notification.description.wellName},</span>
)}
{notification.description.wellboreName && (
<span>
{" "}
Wellbore: {notification.description.wellboreName},
</span>
)}
{notification.description.objectName && (
<span> Name: {notification.description.objectName}</span>
)}
{notification.reason && (
<>
<br />
<span style={{ whiteSpace: "pre-wrap" }}>
Reason: {notification.reason}
</span>
</>
)}
</>
)}
</>
);
setAlert({ severity: notification.severity, content });
} else {
const content = (
<>
<h4>{notification.message}</h4>
{notification.reason && <span style={{ whiteSpace: "pre-wrap" }}>Reason: {notification.reason}</span>}
</>
);
setAlert({ severity: notification.severity, content });
}
});
);
setAlert({ severity: notification.severity, content });
} else {
const content = (
<>
<h4>{notification.message}</h4>
{notification.reason && (
<span style={{ whiteSpace: "pre-wrap" }}>
Reason: {notification.reason}
</span>
)}
</>
);
setAlert({ severity: notification.severity, content });
}
}
);

return function cleanup() {
unsubscribeOnConnectionStateChanged();
Expand All @@ -87,7 +114,9 @@ const Alerts = (): React.ReactElement => {
</IconButton>
}
>
<AlertTitle>{alert?.severity ? capitalize(alert.severity) : "Error"}</AlertTitle>
<AlertTitle>
{alert?.severity ? capitalize(alert.severity) : "Error"}
</AlertTitle>
{alert?.content}
</Alert>
</AlertContainer>
Expand Down
23 changes: 20 additions & 3 deletions Src/WitsmlExplorer.Frontend/components/ContentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,16 @@ const objectViews: Partial<Record<ObjectType, ReactElement>> = {

const ContentView = (): React.ReactElement => {
const { navigationState } = useContext(NavigationContext);
const { selectedWell, selectedWellbore, selectedLogTypeGroup, selectedLogCurveInfo, selectedObjectGroup, selectedObject, selectedServer, currentSelected } = navigationState;
const {
selectedWell,
selectedWellbore,
selectedLogTypeGroup,
selectedLogCurveInfo,
selectedObjectGroup,
selectedObject,
selectedServer,
currentSelected
} = navigationState;
const [view, setView] = useState(<WellsListView />);

useEffect(() => {
Expand All @@ -66,7 +75,13 @@ const ContentView = (): React.ReactElement => {
if (view != null) {
setView(view);
} else {
throw new Error(`No ${isGroup ? "group" : "object"} view is implemented for item: ${JSON.stringify(selectedObjectGroup)}`);
throw new Error(
`No ${
isGroup ? "group" : "object"
} view is implemented for item: ${JSON.stringify(
selectedObjectGroup
)}`
);
}
};

Expand Down Expand Up @@ -96,7 +111,9 @@ const ContentView = (): React.ReactElement => {
} else if (currentSelected === ViewFlags.ObjectSearchView) {
setView(<ObjectSearchListView />);
} else {
throw new Error(`No view is implemented for item: ${JSON.stringify(currentSelected)}`);
throw new Error(
`No view is implemented for item: ${JSON.stringify(currentSelected)}`
);
}
}
}, [currentSelected]);
Expand Down
Loading
Loading