Skip to content

Commit 264be9f

Browse files
committed
Moved fetching of all workspaces if not already to WorkspaceEditorEngine. Fixed route to handle for /workspace/:worksapceId/datasource/:datasourceId. Added NoFocusStrategy for Workspace.
1 parent 2e9dad8 commit 264be9f

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

app/client/src/ce/entities/URLRedirect/URLAssembly.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ export class URLBuilder {
398398
persistExistingParams = false,
399399
suffix,
400400
} = builderParams;
401+
401402
const entityId = this.resolveEntityId(builderParams);
402403

403404
const basePath = this.generateBasePath(entityId, mode);

app/client/src/ce/navigation/FocusStrategy/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ export const getIDEFocusStrategy = (type: IDEType) => {
88
return NoIDEFocusStrategy;
99
case IDE_TYPE.App:
1010
return AppIDEFocusStrategy;
11+
case IDE_TYPE.Workspace:
12+
return NoIDEFocusStrategy;
1113
// Add EE cases below
1214
default:
1315
throw Error("Ide focus strategy not defined");

app/client/src/entities/Engine/WorkspaceEditorEngine.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { call, put } from "redux-saga/effects";
1+
import { call, put, select, take } from "redux-saga/effects";
22
import CodemirrorTernService from "utils/autocomplete/CodemirrorTernService";
33
import {
44
ReduxActionErrorTypes,
@@ -18,6 +18,8 @@ import {
1818
import type { ReduxAction } from "actions/ReduxActionTypes";
1919
import { waitForFetchEnvironments } from "ee/sagas/EnvironmentSagas";
2020
import { fetchingEnvironmentConfigs } from "ee/actions/environmentAction";
21+
import { getWorkspaceFromId } from "ee/selectors/workspaceSelectors";
22+
import { fetchAllWorkspaces } from "ee/actions/workspaceActions";
2123

2224
export default class WorkspaceEditorEngine {
2325
constructor() {
@@ -27,7 +29,8 @@ export default class WorkspaceEditorEngine {
2729
this.completeChore = this.completeChore.bind(this);
2830
}
2931

30-
*loadWorkspace(workspaceId: string) {
32+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
33+
*loadWorkspace(workspaceId: string): any {
3134
// Set the current workspace context
3235
yield put({
3336
type: ReduxActionTypes.SET_CURRENT_WORKSPACE_ID,
@@ -37,6 +40,18 @@ export default class WorkspaceEditorEngine {
3740
},
3841
});
3942

43+
// Check if workspace exists, if not fetch it
44+
const workspace = yield select(getWorkspaceFromId, workspaceId);
45+
46+
if (!workspace) {
47+
yield put(fetchAllWorkspaces({ workspaceId, fetchEntities: true }));
48+
// Wait for workspaces to be fetched
49+
yield take([
50+
ReduxActionTypes.FETCH_ALL_WORKSPACES_SUCCESS,
51+
ReduxActionErrorTypes.FETCH_WORKSPACES_ERROR,
52+
]);
53+
}
54+
4055
// Fetch environment configs for the workspace
4156
yield put(
4257
fetchingEnvironmentConfigs({

app/client/src/pages/workspace/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function Workspace() {
2727
)}
2828
/>
2929
<SentryRoute
30-
path={`${path}/:workspaceId/datasource`}
30+
path={`${path}/:workspaceId/datasource/:datasourceId`}
3131
render={({ match }: { match: { params: { workspaceId: string } } }) => (
3232
<WorkspaceDatasourcesPage workspaceId={match.params.workspaceId} />
3333
)}

0 commit comments

Comments
 (0)