Liferay.Loader.define("layout-taglib@16.0.1/layout_classed_model_usages_view/js/ViewUsages",["module","exports","require","@frontend-taglib-clay$clayui/button","@frontend-taglib-clay$clayui/loading-indicator","@frontend-taglib-clay$clayui/pagination","@frontend-taglib-clay$clayui/table","frontend-js-web","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function ViewUsages({getUsagesURL:e}){const[t,a]=(0,o.useState)(1),[c,f]=(0,o.useState)(0),[d,s]=(0,o.useState)([]),[g,y]=(0,o.useState)(!1),onUsagesLoad=t=>{y(!0);const a=new URL(e);a.searchParams.set("pageIndex",t),(0,u.fetch)(a).then((e=>e.json())).then((({totalNumberOfPages:e,usages:t})=>{s(t),y(!1),f(e)})).catch((()=>function openErrorToast(){(0,u.openToast)({message:Liferay.Language.get("an-unexpected-error-occurred"),title:Liferay.Language.get("error"),type:"danger"})}()))};if((0,o.useEffect)((()=>{onUsagesLoad(1)}),[]),!d.length)return o.default.createElement("p",{className:"text-secondary"},Liferay.Language.get("there-are-no-usages"));return o.default.createElement("div",{className:"cadmin"},g?o.default.createElement(n.default,{className:"my-7",size:"sm"}):o.default.createElement(i.default,{borderless:!0,hover:!1},o.default.createElement(i.default.Body,null,d.map((({id:e,name:t,type:a,url:n})=>o.default.createElement(i.default.Row,{flex:!0,key:e},o.default.createElement(i.default.Cell,{expanded:!0},o.default.createElement("p",{className:"font-weight-bold m-0 text-truncate",title:t},t),o.default.createElement("p",{className:"m-0 text-secondary"},a)),n&&o.default.createElement(i.default.Cell,null,o.default.createElement(r.ClayButtonWithIcon,{"aria-label":Liferay.Language.get("view-usage"),displayType:"secondary",onClick:()=>(0,u.openModal)({title:Liferay.Language.get("preview"),url:n}),size:"sm",symbol:"view",title:Liferay.Language.get("view-usage")}))))))),c>1&&o.default.createElement(l.ClayPaginationWithBasicItems,{active:t,ellipsisBuffer:2,ellipsisProps:{"aria-label":Liferay.Language.get("more"),title:Liferay.Language.get("more")},onActiveChange:e=>{e>0&&e<=c&&(a(e),onUsagesLoad(e))},totalPages:c}))};var r=a("@frontend-taglib-clay$clayui/button"),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/loading-indicator")),l=a("@frontend-taglib-clay$clayui/pagination"),i=_interopRequireDefault(a("@frontend-taglib-clay$clayui/table")),u=a("frontend-js-web"),o=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"));function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}}}));
//# sourceMappingURL=ViewUsages.js.map