Esri / hub.js

TypeScript wrappers for talking to ArcGIS Hub
https://esri.github.io/hub.js/
Apache License 2.0
33 stars 13 forks source link

hub-sites removePage doesn't remove page: model.item is missing `protected` property #342

Open MikeTschudi opened 4 years ago

MikeTschudi commented 4 years ago

In removePage, there are the lines

    .then(() => {
      return unprotectModel(pageModel, requestOptions);
    })
    .then(() => {
      const opts = Object.assign({ id: pageModel.item.id }, requestOptions);
      return removeItem(opts);
    });

pageModel.item.protected is undefined, so protection is not changed in unprotectModel:

export function unprotectModel(model: IModel, requestOptions: IRequestOptions) {
  if (model.item.protected) {
        :        :        :
  } else {
    // act as though we did it
    return Promise.resolve({ success: true });
  }

and so the removeItem call returns "Unable to delete item id. Delete protection is turned on."

Reproducible by deploying Solution cec3b310770d450fbc0163357c501bda, which fails to deploy a Web Mapping Application and so unwinds the deployment.

dbouwman commented 3 years ago

@MikeTschudi I'm not clear on this .protected is/should be a property of all items...

From the REST Docs...

image

So - we'll have to look into how the pageModel was retrieved... does it come from a search response?