Skip to content

Commit

Permalink
remove dead code (#8796)
Browse files Browse the repository at this point in the history
  • Loading branch information
BLoe authored Jul 11, 2024
1 parent 7854315 commit d4dce5d
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 60 deletions.
1 change: 0 additions & 1 deletion src/data/service/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,6 @@ export const {
useGetStandaloneModDefinitionQuery,
useGetAllStandaloneModDefinitionsQuery,
useDeleteStandaloneModDefinitionMutation,
useSaveStandaloneModDefinitionMutation,
useGetEditablePackagesQuery,
useGetModDefinitionQuery,
useCreateModDefinitionMutation,
Expand Down
2 changes: 0 additions & 2 deletions src/pageEditor/hooks/useCreateModFromModComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,6 @@ function useCreateModFromModComponent(
await upsertModComponentFormState({
modComponentFormState: newModComponent,
options: {
// Don't push to cloud since we're saving it with the mod
pushToCloud: false,
// Permissions are already checked above
checkPermissions: false,
// Need to provide user feedback
Expand Down
1 change: 0 additions & 1 deletion src/pageEditor/hooks/useSaveMod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ function useSaveMod(): ModSaver {
upsertModComponentFormState({
modComponentFormState,
options: {
pushToCloud: false,
// Permissions were already checked earlier in the save function here
checkPermissions: false,
// Notified and reactivated once in safeSave below
Expand Down
37 changes: 0 additions & 37 deletions src/pageEditor/hooks/useUpsertModComponentFormState.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { selectActivatedModComponents } from "@/store/extensionsSelectors";

const axiosMock = new MockAdapter(axios);
const defaultOptions = {
pushToCloud: false,
checkPermissions: false,
notifySuccess: true,
reactivateEveryTab: false,
Expand Down Expand Up @@ -74,40 +73,4 @@ describe("useUpsertModComponentFormState", () => {
}),
);
});

it("pushes mod component to the cloud with the same updateTimestamp that is saved to redux", async () => {
const modComponentFormState = formStateFactory();

const { result, getReduxStore, waitForEffect } = renderHook(() =>
useUpsertModComponentFormState(),
);
await waitForEffect();

const upsertModComponentFormState = result.current;
await upsertModComponentFormState({
modComponentFormState,
options: { ...defaultOptions, pushToCloud: true },
});

const modComponents = selectActivatedModComponents(
getReduxStore().getState() as { options: ModComponentState },
);

const expectedFields = {
id: modComponentFormState.uuid,
extensionPointId: modComponentFormState.starterBrick.metadata.id,
updateTimestamp: expectedUpdateDate.toISOString(),
};

expect(modComponents).toHaveLength(1);
expect(modComponents[0]).toEqual(expect.objectContaining(expectedFields));

expect(axiosMock.history.put).toHaveLength(1);
expect(axiosMock.history.put[0].url).toBe(
`/api/extensions/${modComponentFormState.uuid}/`,
);
expect(JSON.parse(axiosMock.history.put[0].data)).toEqual(
expect.objectContaining(expectedFields),
);
});
});
20 changes: 1 addition & 19 deletions src/pageEditor/hooks/useUpsertModComponentFormState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ import { Events } from "@/telemetry/events";
import { getLinkedApiClient } from "@/data/service/apiClient";
import { objToYaml } from "@/utils/objToYaml";
import { modComponentWithInnerDefinitions } from "@/pageEditor/starterBricks/base";
import {
useGetEditablePackagesQuery,
useSaveStandaloneModDefinitionMutation,
} from "@/data/service/api";
import { useGetEditablePackagesQuery } from "@/data/service/api";
import modComponentsSlice from "@/store/extensionsSlice";
import { selectSessionId } from "@/pageEditor/store/session/sessionSelectors";
import { type ModComponentFormState } from "@/pageEditor/starterBricks/formStateTypes";
Expand Down Expand Up @@ -76,10 +73,6 @@ function selectErrorMessage(error: unknown): string {
}

type SaveOptions = {
/**
* True to save a copy of the ModComponentBase to the user's account
*/
pushToCloud: boolean;
/**
* Should the permissions be checked before saving?
*/
Expand Down Expand Up @@ -125,8 +118,6 @@ function useUpsertModComponentFormState(): SaveCallback {
const dispatch = useDispatch();
const sessionId = useSelector(selectSessionId);
const { data: editablePackages } = useGetEditablePackagesQuery();
const [saveStandaloneModDefinition] =
useSaveStandaloneModDefinitionMutation();

const saveModComponentFormState = useCallback(
async (
Expand Down Expand Up @@ -218,15 +209,6 @@ function useUpsertModComponentFormState(): SaveCallback {
}),
);

if (options.pushToCloud && !modComponent._deployment) {
await saveStandaloneModDefinition({
modComponent: {
...modComponent,
updateTimestamp,
},
}).unwrap();
}

dispatch(markClean(modComponentFormState.uuid));
} catch (error) {
return onStepError(error, "saving mod");
Expand Down

0 comments on commit d4dce5d

Please sign in to comment.