Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { containerForHeader } from "../../Common/FormComponents/common/styleLibr
import ListObjects from "../ListBuckets/Objects/ListObjects/ListObjects";
import { IAM_SCOPES } from "../../../../common/SecureComponent/permissions";
import {
errorInConnection,
newMessage,
resetMessages,
setIsOpeningOD,
Expand Down Expand Up @@ -70,7 +71,8 @@ let wsInFlight: boolean = false;

const initWSConnection = (
openCallback?: () => void,
onMessageCallback?: (message: IMessageEvent) => void
onMessageCallback?: (message: IMessageEvent) => void,
connErrorCallback?: (message: string) => void
) => {
if (wsInFlight) {
return;
Expand Down Expand Up @@ -104,10 +106,17 @@ const initWSConnection = (

const reconnectFn = () => {
if (errorCounter <= 5) {
initWSConnection(() => {}, onMessageCallback);
initWSConnection(() => {}, onMessageCallback, connErrorCallback);
errorCounter += 1;
} else {
console.error("Websocket not available.");
console.error(
"Websocket not available. Please review that your environment settings are enabled to allow websocket connections and that requests are made from the same origin."
);
if (connErrorCallback) {
connErrorCallback(
"Couldn't establish WebSocket connection. Please review your configuration and try again."
);
}
}
};

Expand Down Expand Up @@ -245,6 +254,7 @@ const BrowserHandler = () => {
try {
const newRequestID = currentRequestID + 1;
dispatch(resetMessages());
dispatch(errorInConnection(false));

const request: WebsocketRequest = {
bucket_name: bucketName,
Expand All @@ -266,7 +276,18 @@ const BrowserHandler = () => {
const dupRequest = () => {
initWSRequest(path, date);
};
initWSConnection(dupRequest, onMessageCallBack);

const fatalWSError = (message: string) => {
dispatch(
setErrorSnackMessage({
errorMessage: message,
detailedError: message,
})
);
dispatch(errorInConnection(true));
};

initWSConnection(dupRequest, onMessageCallBack, fatalWSError);
}
},
[bucketName, rewindEnabled, showDeleted, dispatch, onMessageCallBack]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,13 @@ const ListObjectsTable = ({ internalPaths }: IListObjectTable) => {
const selectedObjects = useSelector(
(state: AppState) => state.objectBrowser.selectedObjects
);
const connectionError = useSelector(
(state: AppState) => state.objectBrowser.connectionError
);
const anonymousMode = useSelector(
(state: AppState) => state.system.anonymousMode
);

const displayListObjects = hasPermission(bucketName, [
IAM_SCOPES.S3_LIST_BUCKET,
IAM_SCOPES.S3_ALL_LIST_BUCKET,
Expand Down Expand Up @@ -228,6 +232,21 @@ const ListObjectsTable = ({ internalPaths }: IListObjectTable) => {
return elements;
};

let errorMessage =
!displayListObjects && !anonymousMode
? permissionTooltipHelper(
[IAM_SCOPES.S3_LIST_BUCKET, IAM_SCOPES.S3_ALL_LIST_BUCKET],
"view Objects in this bucket"
)
: `This location is empty${
!rewindEnabled ? ", please try uploading a new file" : ""
}`;

if (connectionError) {
errorMessage =
"Objects List unavailable. Please review your WebSockets configuration and try again";
}

return (
<TableWrapper
itemActions={tableActions}
Expand All @@ -241,16 +260,7 @@ const ListObjectsTable = ({ internalPaths }: IListObjectTable) => {
} ${detailsOpen ? "actionsPanelOpen" : ""}`}
selectedItems={selectedObjects}
onSelect={!anonymousMode ? selectListObjects : undefined}
customEmptyMessage={
!displayListObjects && !anonymousMode
? permissionTooltipHelper(
[IAM_SCOPES.S3_LIST_BUCKET, IAM_SCOPES.S3_ALL_LIST_BUCKET],
"view Objects in this bucket"
)
: `This location is empty${
!rewindEnabled ? ", please try uploading a new file" : ""
}`
}
customEmptyMessage={errorMessage}
sortConfig={{
currentSort: currentSortField,
currentDirection: sortDirection,
Expand Down
10 changes: 10 additions & 0 deletions portal-ui/src/screens/Console/ObjectBrowser/objectBrowserSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const initialState: ObjectBrowserState = {
objectDetailsOpen: false,
loadingVersions: true,
loadingObjectInfo: true,
connectionError: false,
rewind: {
...defaultRewind,
},
Expand Down Expand Up @@ -365,6 +366,14 @@ export const objectBrowserSlice = createSlice({
setAnonymousAccessOpen: (state, action: PayloadAction<boolean>) => {
state.anonymousAccessOpen = action.payload;
},
errorInConnection: (state, action: PayloadAction<boolean>) => {
state.connectionError = action.payload;
if (action.payload) {
state.loadingObjects = false;
state.loadingObjectInfo = false;
state.objectDetailsOpen = false;
}
},
},
});
export const {
Expand Down Expand Up @@ -412,6 +421,7 @@ export const {
setSelectedBucket,
setLongFileOpen,
setAnonymousAccessOpen,
errorInConnection,
} = objectBrowserSlice.actions;

export default objectBrowserSlice.reducer;
1 change: 1 addition & 0 deletions portal-ui/src/screens/Console/ObjectBrowser/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export interface ObjectBrowserState {
retentionConfig: IRetentionConfig | null;
longFileOpen: boolean;
anonymousAccessOpen: boolean;
connectionError: boolean;
}

export interface ObjectManager {
Expand Down