Skip to content

Commit

Permalink
fix(updateSite): updateSite no longer attempts to remove unused resou…
Browse files Browse the repository at this point in the history
…rces

AFFECTS PACKAGES:
@esri/hub-sites
  • Loading branch information
drewdaemon committed Sep 1, 2020
1 parent df7a3ce commit ee8d8e1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 30 deletions.
4 changes: 4 additions & 0 deletions packages/sites/src/layout/remove-unused-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import { getItemResources, removeItemResource } from "@esri/arcgis-rest-portal";
import { _getImageCropIdsFromLayout } from "./_get-image-crop-ids-from-layout";
import { ILayout, IEntry } from "./types";

/**
* THIS UTIL IS NO LONGER IN USE BUT MAY BE IN THE FUTURE - TATE
*/

/**
* Removes any image "crop" versions that are no longer
* used in the site layout.
Expand Down
12 changes: 0 additions & 12 deletions packages/sites/src/update-site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { SITE_UI_VERSION } from "./site-ui-version";
import { _ensurePortalDomainKeyword } from "./_ensure-portal-domain-keyword";
import { updateItem, IUpdateItemResponse } from "@esri/arcgis-rest-portal";
import { removeUnusedResources } from "./layout";

/**
* Update an existing site item
Expand Down Expand Up @@ -86,17 +85,6 @@ export function updateSite(
params: { clearEmptyFields: true }
});
})
.then(updateResponse => {
// clean up un-used crop images. The internals of this are failSafed as it's not critical
// and we return the udpateResponse object from the previous step
return removeUnusedResources(
model.item.id,
model.data.values.layout,
hubRequestOptions
).then(_ => {
return updateResponse;
});
})
.catch(err => {
throw Error(`updateSite: Error updating site: ${err}`);
});
Expand Down
18 changes: 0 additions & 18 deletions packages/sites/test/update-site.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import * as portalModule from "@esri/arcgis-rest-portal";
describe("update site", function() {
let getModelSpy: jasmine.Spy;
let updateSpy: jasmine.Spy;
let removeResourcesSpy: jasmine.Spy;

beforeEach(() => {
getModelSpy = spyOn(commonModule, "getModel").and.returnValue(
Expand All @@ -20,11 +19,6 @@ describe("update site", function() {
updateSpy = spyOn(portalModule, "updateItem").and.returnValue(
Promise.resolve({ success: true, id: "3ef" })
);

removeResourcesSpy = spyOn(
layoutModule,
"removeUnusedResources"
).and.returnValue(Promise.resolve());
});

it("ago with allowList and resources to remove", async function() {
Expand Down Expand Up @@ -63,12 +57,6 @@ describe("update site", function() {
expect(updateItem.properties.newProp).toBe(
localSite.item.properties.newProp
);

const resourcesArgs = removeResourcesSpy.calls.argsFor(0);
expect([resourcesArgs[0], resourcesArgs[2]]).toEqual([
localSite.item.id,
ro
]);
});

it("ago without allowList or resources to remove", async function() {
Expand Down Expand Up @@ -108,12 +96,6 @@ describe("update site", function() {
expect(updateItem.properties.newProp).toBe(
localSite.item.properties.newProp
);

const resourcesArgs = removeResourcesSpy.calls.argsFor(0);
expect([resourcesArgs[0], resourcesArgs[2]]).toEqual([
localSite.item.id,
ro
]);
});

it("portal", async function() {
Expand Down

0 comments on commit ee8d8e1

Please sign in to comment.