Skip to content

Commit f1257bb

Browse files
mux: use getmanyforenv for app actions [INTEG-3018] (#10064)
* use getmanyforenv for app actions * add envs and spaces * fix test
1 parent f089ada commit f1257bb

3 files changed

Lines changed: 5 additions & 17 deletions

File tree

apps/mux/frontend/src/index.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { vi } from 'vitest';
99
vi.mock('contentful-management', () => ({
1010
createClient: vi.fn(() => ({
1111
appAction: {
12-
getMany: vi.fn(() => Promise.resolve({ items: [] })),
12+
getManyForEnvironment: vi.fn(() => Promise.resolve({ items: [] })),
1313
},
1414
appActionCall: {
1515
createWithResponse: vi.fn(() =>

apps/mux/frontend/src/index.tsx

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ import {
5353
generateAutoCaptions,
5454
} from './util/muxApi';
5555
import Sidebar from './locations/Sidebar';
56-
import { APP_ORGANIZATION_ID, isMarketplaceVersion } from './util/constants';
5756

5857
const delay = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));
5958

@@ -105,7 +104,6 @@ export class App extends React.Component<AppProps, AppState> {
105104
muxPlayerRef = React.createRef<any>(); // eslint-disable-line @typescript-eslint/no-explicit-any
106105
getSignedTokenActionId: string;
107106
private pollPending = false;
108-
orgId: string;
109107

110108
constructor(props: AppProps) {
111109
super(props);
@@ -153,10 +151,6 @@ export class App extends React.Component<AppProps, AppState> {
153151
storyboardToken: undefined,
154152
raw: undefined,
155153
};
156-
157-
this.orgId = isMarketplaceVersion({ appId: this.props.sdk.ids.app })
158-
? APP_ORGANIZATION_ID
159-
: this.props.sdk.ids.organization;
160154
}
161155

162156
// eslint-disable-next-line @typescript-eslint/ban-types
@@ -212,9 +206,9 @@ export class App extends React.Component<AppProps, AppState> {
212206
};
213207

214208
async componentDidMount() {
215-
const appActionsResponse = await this.cmaClient.appAction.getMany({
216-
organizationId: this.orgId,
217-
appDefinitionId: this.props.sdk.ids.app!,
209+
const appActionsResponse = await this.cmaClient.appAction.getManyForEnvironment({
210+
environmentId: this.props.sdk.ids.environment,
211+
spaceId: this.props.sdk.ids.space,
218212
});
219213
this.getSignedTokenActionId =
220214
appActionsResponse.items.find((x) => x.name === 'getSignedUrlTokens')?.sys.id ?? '';
@@ -509,7 +503,7 @@ export class App extends React.Component<AppProps, AppState> {
509503
response: { body },
510504
} = await this.cmaClient.appActionCall.createWithResponse(
511505
{
512-
organizationId: this.orgId,
506+
organizationId: this.props.sdk.ids.organization,
513507
appDefinitionId: this.props.sdk.ids.app!,
514508
appActionId: this.getSignedTokenActionId,
515509
},

apps/mux/frontend/src/util/constants.ts

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)