@itwin/manage-versions-react
Advanced tools
Comparing version 0.8.0 to 1.0.0
@@ -5,2 +5,19 @@ { | ||
{ | ||
"version": "1.0.0", | ||
"tag": "@itwin/manage-versions-react_v1.0.0", | ||
"date": "Wed, 21 Jun 2023 16:43:17 GMT", | ||
"comments": { | ||
"none": [ | ||
{ | ||
"comment": "Upgraded iModelsApi to v2" | ||
} | ||
], | ||
"major": [ | ||
{ | ||
"comment": "iTwinui-react update to 2.x" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"version": "0.8.0", | ||
@@ -7,0 +24,0 @@ "tag": "@itwin/manage-versions-react_v0.8.0", |
# Change Log - @itwin/manage-versions-react | ||
This log was last generated on Mon, 27 Feb 2023 09:10:34 GMT and should not be manually modified. | ||
This log was last generated on Wed, 21 Jun 2023 16:43:17 GMT and should not be manually modified. | ||
## 1.0.0 | ||
Wed, 21 Jun 2023 16:43:17 GMT | ||
### Breaking changes | ||
- iTwinui-react update to 2.x | ||
## 0.8.0 | ||
@@ -6,0 +13,0 @@ Mon, 27 Feb 2023 09:10:34 GMT |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@itwin/itwinui-react"),t=require("react"),a=require("@itwin/itwinui-icons-react");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,r=s(t);!function(e){e.Authorization="Authorization",e.ContentType="Content-Type",e.Prefer="Prefer"}(n||(n={}));class i extends Error{constructor(e,t){super(null==e?void 0:e.message),this.code=null==e?void 0:e.code,this.statusCode=t}}class o{constructor(e,t){this._errorMessagePrefix="@itwin/manage-versions-react",this._defaultErrorMessage="HTTP error without a message.",this._token=e,this._log=t}async get(e,t){var a;const s={method:"GET",url:e,headers:Object.assign({},null==t?void 0:t.headers),signal:null===(a=null==t?void 0:t.abortController)||void 0===a?void 0:a.signal};return this.makeRequest(s)}async post(e,t,a){var s;const n={method:"POST",url:e,headers:Object.assign({},null==a?void 0:a.headers),body:t,signal:null===(s=null==a?void 0:a.abortController)||void 0===s?void 0:s.signal};return this.makeRequest(n)}async patch(e,t,a){var s;const n={method:"PATCH",url:e,headers:Object.assign({},null==a?void 0:a.headers),body:t,signal:null===(s=null==a?void 0:a.abortController)||void 0===s?void 0:s.signal};return this.makeRequest(n)}async delete(e,t){var a;const s={method:"DELETE",url:e,headers:Object.assign({},null==t?void 0:t.headers),signal:null===(a=null==t?void 0:t.abortController)||void 0===a?void 0:a.signal};return this.makeRequest(s)}async makeRequest(e){this.prepareHeaders(e);try{const t=await fetch(e.url,{method:e.method,headers:e.headers,body:e.body?JSON.stringify(e.body):void 0,signal:null==e?void 0:e.signal}),a=await t.json();if(!t.ok)throw new i(null==a?void 0:a.error,t.status);return a}catch(t){throw this.logError(t,e),t}}prepareHeaders(e){e.headers=Object.assign({[n.Authorization]:this._token,[n.ContentType]:"application/json"},e.headers)}logError(e,t){var a;null===(a=this._log)||void 0===a||a.call(this,`${this._errorMessagePrefix} - ${e.message||this._defaultErrorMessage}`,{request:this.getRequestToLog(t),error:e})}getRequestToLog(e){const t=Object.assign({},e.headers);return delete t[n.Authorization],{headers:t,url:e.url,method:e.method}}}class l{static getBaseUrl(e){return`https://${e?`${e}-`:""}api.bentley.com`}static buildVersionsUrl(e,t,a){return`${this.getBaseUrl(a)}/imodels/${e}/namedversions${t?`/${t}`:""}`}static buildChangesetUrl(e,t){return`${this.getBaseUrl(t)}/imodels/${e}/changesets`}}l.getQuery=e=>{const t=Object.entries(e).filter((([e,t])=>!!t)).map((([e,t])=>`$${e}=${t}`)).join("&");return t?`?${t}`:""};class d{constructor(e,t,a){this._http=new o(e,a),this._serverEnvironmentPrefix=t}async get(e,t={}){return this._http.get(`${l.buildChangesetUrl(e,this._serverEnvironmentPrefix)}${l.getQuery(Object.assign({orderBy:"index+desc"},t))}`,{headers:{[n.Prefer]:"return=representation"}}).then((e=>e.changesets))}}class c{constructor(e,t,a){this._http=new o(e,a),this._serverEnvironmentPrefix=t}async get(e,t={}){return this._http.get(`${l.buildVersionsUrl(e,void 0,this._serverEnvironmentPrefix)}${l.getQuery(t)}`,{headers:{[n.Prefer]:"return=representation"}}).then((e=>e.namedVersions))}async create(e,t){return this._http.post(l.buildVersionsUrl(e,void 0,this._serverEnvironmentPrefix),t).then((e=>e.namedVersion))}async update(e,t,a){return this._http.patch(l.buildVersionsUrl(e,t,this._serverEnvironmentPrefix),a).then((e=>e.namedVersion))}} | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@itwin/itwinui-react"),t=require("react"),a=require("@itwin/itwinui-icons-react");function s(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,i=s(t);!function(e){e.Authorization="Authorization",e.ContentType="Content-Type",e.Prefer="Prefer",e.Accept="Accept"}(n||(n={}));class r extends Error{constructor(e,t){super(null==e?void 0:e.message),this.code=null==e?void 0:e.code,this.statusCode=t}}class o{constructor(e,t){this._errorMessagePrefix="@itwin/manage-versions-react",this._defaultErrorMessage="HTTP error without a message.",this._token=e,this._log=t}async get(e,t){var a;const s={method:"GET",url:e,headers:Object.assign({},null==t?void 0:t.headers),signal:null===(a=null==t?void 0:t.abortController)||void 0===a?void 0:a.signal};return this.makeRequest(s)}async post(e,t,a){var s;const n={method:"POST",url:e,headers:Object.assign({},null==a?void 0:a.headers),body:t,signal:null===(s=null==a?void 0:a.abortController)||void 0===s?void 0:s.signal};return this.makeRequest(n)}async patch(e,t,a){var s;const n={method:"PATCH",url:e,headers:Object.assign({},null==a?void 0:a.headers),body:t,signal:null===(s=null==a?void 0:a.abortController)||void 0===s?void 0:s.signal};return this.makeRequest(n)}async delete(e,t){var a;const s={method:"DELETE",url:e,headers:Object.assign({},null==t?void 0:t.headers),signal:null===(a=null==t?void 0:t.abortController)||void 0===a?void 0:a.signal};return this.makeRequest(s)}async makeRequest(e){this.prepareHeaders(e);try{const t=await fetch(e.url,{method:e.method,headers:e.headers,body:e.body?JSON.stringify(e.body):void 0,signal:null==e?void 0:e.signal}),a=await t.json();if(!t.ok)throw new r(null==a?void 0:a.error,t.status);return a}catch(t){throw this.logError(t,e),t}}prepareHeaders(e){e.headers=Object.assign({[n.Authorization]:this._token,[n.Accept]:"application/vnd.bentley.itwin-platform.v2+json",[n.ContentType]:"application/json"},e.headers)}logError(e,t){var a;null===(a=this._log)||void 0===a||a.call(this,`${this._errorMessagePrefix} - ${e.message||this._defaultErrorMessage}`,{request:this.getRequestToLog(t),error:e})}getRequestToLog(e){const t=Object.assign({},e.headers);return delete t[n.Authorization],{headers:t,url:e.url,method:e.method}}}class l{static getBaseUrl(e){return`https://${e?`${e}-`:""}api.bentley.com`}static buildVersionsUrl(e,t,a){return`${this.getBaseUrl(a)}/imodels/${e}/namedversions${t?`/${t}`:""}`}static buildChangesetUrl(e,t){return`${this.getBaseUrl(t)}/imodels/${e}/changesets`}}l.getQuery=e=>{const t=Object.entries(e).filter((([e,t])=>!!t)).map((([e,t])=>`$${e}=${t}`)).join("&");return t?`?${t}`:""};class d{constructor(e,t,a){this._http=new o(e,a),this._serverEnvironmentPrefix=t}async get(e,t={}){return this._http.get(`${l.buildChangesetUrl(e,this._serverEnvironmentPrefix)}${l.getQuery(Object.assign({orderBy:"index+desc"},t))}`,{headers:{[n.Prefer]:"return=representation",[n.Accept]:"application/vnd.bentley.itwin-platform.v2+json"}}).then((e=>e.changesets))}}class c{constructor(e,t,a){this._http=new o(e,a),this._serverEnvironmentPrefix=t}async get(e,t={}){return this._http.get(`${l.buildVersionsUrl(e,void 0,this._serverEnvironmentPrefix)}${l.getQuery(t)}`,{headers:{[n.Prefer]:"return=representation",[n.Accept]:"application/vnd.bentley.itwin-platform.v2+json"}}).then((e=>e.namedVersions))}async create(e,t){return this._http.post(l.buildVersionsUrl(e,void 0,this._serverEnvironmentPrefix),t).then((e=>e.namedVersion))}async update(e,t,a){return this._http.patch(l.buildVersionsUrl(e,t,this._serverEnvironmentPrefix),a).then((e=>e.namedVersion))}} | ||
/*! ***************************************************************************** | ||
@@ -15,2 +15,2 @@ Copyright (c) Microsoft Corporation. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */const u=r.default.createContext(void 0),m=e=>{const{children:t}=e,a=function(e,t){var a={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(a[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(a[s[n]]=e[s[n]])}return a}(e,["children"]);return r.default.createElement(u.Provider,{value:a},t)},g=()=>{const e=r.default.useContext(u);if(void 0===e)throw new Error("useConfig must be used within a ConfigContext");return e};function h(e,t){void 0===t&&(t={});var a=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===a&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}h(".iac-changes-table .iui-table-body .iui-cell{word-break:break-word}");h(".iac-additional-info{display:flex;justify-content:space-between;padding:11px 12px;background-color:#f8f9fb;background-color:var(--iui-color-background-2)}.iac-additional-info span{flex-shrink:0}.iac-additional-info span:not(:last-child){margin-right:16px}.iac-additional-info .iac-cell-ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:1}");h(".iac-version-modal .iui-modal-dialog{max-width:min(600px,50%)}.iac-version-modal-overlay{position:fixed;z-index:99999;height:100vh;width:100vw;top:0;left:0}.iac-version-modal .iui-input-container{margin-bottom:11px}");const f=t=>{var a,s;const{initialVersion:n,isLoading:i,title:o,actionName:l,onClose:d,onActionClick:c,children:u}=t,{stringsOverrides:m}=g(),[h,f]=r.default.useState({name:null!==(a=null==n?void 0:n.name)&&void 0!==a?a:"",description:null!==(s=null==n?void 0:n.description)&&void 0!==s?s:""}),v=e=>{const t=e.target.name,a=e.target.value;f((e=>Object.assign(Object.assign({},e),{[t]:null!=a?a:""})))},p=e=>e.length<=255;return r.default.createElement(r.default.Fragment,null,r.default.createElement(e.Modal,{title:o,isOpen:!0,onClose:d,className:"iac-version-modal"},r.default.createElement(e.LabeledInput,{name:"name",label:m.name,onChange:v,value:h.name,status:p(h.name)?void 0:"negative",message:p(h.name)?void 0:m.messageValueTooLong.replace("{{length}}",255..toString()),required:!0,setFocus:!0,autoComplete:"off"}),r.default.createElement(e.LabeledTextarea,{name:"description",label:m.description,onChange:v,value:h.description,status:p(h.description)?void 0:"negative",message:p(h.description)?void 0:m.messageValueTooLong.replace("{{length}}",255..toString()),rows:3,autoComplete:"off"}),u,r.default.createElement(e.ModalButtonBar,null,r.default.createElement(e.Button,{styleType:"high-visibility",onClick:()=>c(h.name,h.description),disabled:!(h.name&&(h.name!==(null==n?void 0:n.name)||h.description!==(null==n?void 0:n.description))&&p(h.name)&&p(h.description))},l),r.default.createElement(e.Button,{onClick:d},m.cancel)),i&&r.default.createElement("div",{className:"iui-progress-indicator-overlay"},r.default.createElement(e.ProgressRadial,{indeterminate:!0}))),i&&r.default.createElement("div",{className:"iac-version-modal-overlay"}))},v=t=>{const{latestVersion:a,changeset:s,onClose:n,onCreate:i}=t,{accessToken:o,imodelId:l,apiOverrides:d,stringsOverrides:u,log:m}=g(),[h,v]=r.default.useState(!1),p=r.default.useMemo((()=>new c(o,null==d?void 0:d.serverEnvironmentPrefix,m)),[o,null==d?void 0:d.serverEnvironmentPrefix,m]);return r.default.createElement(f,{title:u.createNamedVersion,actionName:u.create,isLoading:h,onClose:n,onActionClick:(t,a)=>{v(!0),e.toaster.closeAll(),p.create(l,{name:t,description:a,changeSetId:s.id}).then((()=>{v(!1),i(),e.toaster.positive(u.messageVersionCreated.replace("{{name}}",t),{hasCloseButton:!0})})).catch((t=>{v(!1),e.toaster.negative((e=>{switch(e){case"NamedVersionExists":return u.messageVersionNameExists;case"InsufficientPermissions":return u.messageInsufficientPermissionsToCreateVersion;default:return u.messageCouldNotCreateVersion}})(t.code),{hasCloseButton:!0})}))}},r.default.createElement("div",{className:"iui-input-container"},r.default.createElement("div",{className:"iui-label"},"Latest included change"),r.default.createElement("div",{className:"iac-additional-info"},r.default.createElement("span",null,"#",s.index),r.default.createElement("span",null,new Date(s.pushDateTime).toLocaleString()))),a&&r.default.createElement("div",{className:"iui-input-container"},r.default.createElement("div",{className:"iui-label"},"Latest Named Version"),r.default.createElement("div",{className:"iac-additional-info"},r.default.createElement("span",{className:"iac-cell-ellipsis"},a.name),r.default.createElement("span",null,new Date(a.createdDateTime).toLocaleString()))))};var p;!function(e){e[e.NotStarted=0]="NotStarted",e[e.InProgress=1]="InProgress",e[e.Finished=2]="Finished",e[e.Failed=3]="Failed"}(p||(p={}));const C=t=>{const{changesets:s,status:n,loadMoreChanges:i,onVersionCreated:o,latestVersion:l}=t,{stringsOverrides:d}=g(),[c,u]=r.default.useState(!1),[m,h]=r.default.useState(void 0),f=r.default.useCallback((e=>!e._links.namedVersion),[]),C=r.default.useMemo((()=>[{Header:"Name",columns:[{id:"INDEX",Header:"#",accessor:"index",width:90},{id:"DESCRIPTION",Header:d.description,accessor:"description"},{id:"CHANGED_FILES",Header:d.changedFiles,Cell:e=>{var t;const a=null===(t=e.row.original.synchronizationInfo)||void 0===t?void 0:t.changedFiles;return(null==a?void 0:a.length)?a.join(", "):""}},{id:"PUSH_DATE",Header:d.time,accessor:"pushDateTime",maxWidth:220,Cell:e=>r.default.createElement("span",null,new Date(e.row.original.pushDateTime).toLocaleString())},{id:"changes-table-actions",width:62,Cell:t=>{const s=t.data[t.row.index];return r.default.createElement(r.default.Fragment,null,f(s)&&r.default.createElement(e.IconButton,{onClick:()=>{h(s),u(!0)},title:d.createNamedVersion,styleType:"borderless"},r.default.createElement(a.SvgNamedVersionAdd,null)))}}]}]),[f,d.changedFiles,d.createNamedVersion,d.description,d.time]),b=r.default.useMemo((()=>n===p.Failed?d.messageFailedGetChanges:d.messageNoChanges),[n,d.messageFailedGetChanges,d.messageNoChanges]);return r.default.createElement(r.default.Fragment,null,r.default.createElement(e.Table,{columns:C,data:s,isLoading:n===p.InProgress||n===p.NotStarted,emptyTableContent:b,onBottomReached:i,className:"iac-changes-table"}),c&&r.default.createElement(v,{changeset:m,onCreate:()=>{u(!1),o()},onClose:()=>u(!1),latestVersion:l}))};h(".iac-versions-table .iui-table-body .iui-cell{word-break:break-word}");const b=t=>{const{version:a,onClose:s,onUpdate:n}=t,{accessToken:i,imodelId:o,apiOverrides:l,stringsOverrides:d,log:u}=g(),[m,h]=r.default.useState(!1),v=r.default.useMemo((()=>new c(i,null==l?void 0:l.serverEnvironmentPrefix,u)),[i,null==l?void 0:l.serverEnvironmentPrefix,u]);return r.default.createElement(f,{title:d.updateNamedVersion,actionName:d.update,initialVersion:a,isLoading:m,onClose:s,onActionClick:(t,s)=>{h(!0),e.toaster.closeAll(),v.update(o,a.id,{name:t,description:s}).then((()=>{h(!1),n(),e.toaster.positive(d.messageVersionUpdated.replace("{{name}}",t),{hasCloseButton:!0})})).catch((t=>{h(!1),e.toaster.negative((e=>{switch(e){case"NamedVersionExists":return d.messageVersionNameExists;case"InsufficientPermissions":return d.messageInsufficientPermissionsToUpdateVersion;default:return d.messageCouldNotUpdateVersion}})(t.code),{hasCloseButton:!0})}))}})},E=t=>{const{versions:s,status:n,onVersionUpdated:i,loadMoreVersions:o,onViewClick:l}=t,{stringsOverrides:d}=g(),[c,u]=r.default.useState(void 0),[m,h]=r.default.useState(!1),f=r.default.useMemo((()=>{const t=[{Header:"Name",columns:[{id:"NAME",Header:d.name,accessor:"name"},{id:"DESCRIPTION",Header:d.description,accessor:"description"},{id:"CREATED_DATE",Header:d.time,accessor:"createdDateTime",maxWidth:220,Cell:e=>r.default.createElement("span",null,new Date(e.row.original.createdDateTime).toLocaleString())},{id:"versions-table-actions",width:62,Cell:t=>r.default.createElement(r.default.Fragment,null,r.default.createElement(e.IconButton,{onClick:()=>{u(t.row.original),h(!0)},title:d.updateNamedVersion,styleType:"borderless"},r.default.createElement(a.SvgEdit,null)))}]}];return l&&t[0].columns.splice(3,0,{id:"versions-table-view",width:100,Cell:e=>r.default.createElement("span",{className:"iui-anchor",onClick:()=>l(e.row.original)},d.view)}),t}),[l,d.description,d.name,d.time,d.updateNamedVersion,d.view]),v=r.default.useMemo((()=>n===p.Failed?d.messageFailedGetNamedVersions:d.messageNoNamedVersions),[n,d.messageFailedGetNamedVersions,d.messageNoNamedVersions]);return r.default.createElement(r.default.Fragment,null,r.default.createElement(e.Table,{columns:f,data:s,isLoading:n===p.InProgress||n===p.NotStarted,emptyTableContent:v,onBottomReached:o,className:"iac-versions-table"}),m&&r.default.createElement(b,{version:c,onUpdate:()=>{h(!1),i()},onClose:()=>h(!1)}))},V={namedVersions:"Named Versions",changes:"Changes",name:"Name",description:"Description",time:"Time",changedFiles:"Changed Files",createNamedVersion:"Create a Named Version",cancel:"Cancel",create:"Create",updateNamedVersion:"Update a Named Version",update:"Update",view:"View",messageFailedGetNamedVersions:"Could not get Named Versions. Please try again later.",messageNoNamedVersions:"There are no Named Versions created. To create first go to Changes.",messageFailedGetChanges:"Could not get changes. Please try again later.",messageNoChanges:"There are no changes synchronized.",messageVersionCreated:'Named Version "{{name}}" was successfully created.',messageVersionNameExists:"Named Version with the same name already exists.",messageInsufficientPermissionsToCreateVersion:"You do not have the required permissions to create a Named Version.",messageCouldNotCreateVersion:"Could not create a Named Version. Please try again later.",messageVersionUpdated:'Named Version "{{name}}" was successfully updated.',messageInsufficientPermissionsToUpdateVersion:"You do not have the required permissions to update a Named Version.",messageCouldNotUpdateVersion:"Could not update a Named Version. Please try again later.",messageValueTooLong:"The value exceeds allowed {{length}} characters."};var N;exports.ManageVersionsTabs=void 0,(N=exports.ManageVersionsTabs||(exports.ManageVersionsTabs={}))[N.Versions=0]="Versions",N[N.Changes=1]="Changes";exports.ManageVersions=t=>{const{accessToken:a,apiOverrides:s,imodelId:n,stringsOverrides:i=V,log:o,onViewClick:l,currentTab:u=exports.ManageVersionsTabs.Versions,onTabChange:g}=t,h=r.default.useMemo((()=>new c(a,null==s?void 0:s.serverEnvironmentPrefix,o)),[a,null==s?void 0:s.serverEnvironmentPrefix,o]),f=r.default.useMemo((()=>new d(a,null==s?void 0:s.serverEnvironmentPrefix,o)),[a,null==s?void 0:s.serverEnvironmentPrefix,o]),[v,b]=r.default.useState(u);r.default.useEffect((()=>{b(u)}),[u]);const[N,y]=r.default.useState(),[w,T]=r.default.useState(p.NotStarted),[x,P]=r.default.useState(),[k,S]=r.default.useState(p.NotStarted),O=r.default.useCallback((e=>{b(e),null==g||g(e)}),[g]),M=r.default.useCallback((e=>{T(p.InProgress),h.get(n,{top:100,skip:e}).then((e=>{T(p.Finished),y((t=>[...null!=t?t:[],...e]))})).catch((()=>T(p.Failed)))}),[n,h]),I=r.default.useCallback((()=>{N&&N.length%100!=0||M(null==N?void 0:N.length)}),[M,N]),F=r.default.useCallback((()=>{y(void 0),M()}),[M]);r.default.useEffect((()=>{w===p.NotStarted&&M()}),[M,w]);const _=r.default.useCallback((()=>{x&&x.length%100!=0||(S(p.InProgress),f.get(n,{top:100,skip:null==x?void 0:x.length}).then((e=>{S(p.Finished),P([...null!=x?x:[],...e])})).catch((()=>S(p.Failed))))}),[f,x,n]);r.default.useEffect((()=>{v===exports.ManageVersionsTabs.Changes&&k===p.NotStarted&&_()}),[k,v,_]);const D=r.default.useCallback((()=>{O(exports.ManageVersionsTabs.Versions),F(),P(void 0),S(p.NotStarted)}),[O,F]),U=r.default.useMemo((()=>[...null!=N?N:[]].sort(((e,t)=>new Date(e.createdDateTime).valueOf()<new Date(t.createdDateTime).valueOf()?1:-1))[0]),[N]);return r.default.createElement(m,{accessToken:a,imodelId:n,apiOverrides:s,stringsOverrides:i,log:o},r.default.createElement("div",null,r.default.createElement(e.HorizontalTabs,{labels:[i.namedVersions,i.changes],activeIndex:v,onTabSelected:e=>O(e),type:"borderless"}),v===exports.ManageVersionsTabs.Versions&&r.default.createElement(E,{versions:null!=N?N:[],status:w,onVersionUpdated:F,loadMoreVersions:I,onViewClick:l}),v===exports.ManageVersionsTabs.Changes&&r.default.createElement(C,{changesets:null!=x?x:[],status:k,loadMoreChanges:_,onVersionCreated:D,latestVersion:U})))}; | ||
***************************************************************************** */const u=i.default.createContext(void 0),m=e=>{const{children:t}=e,a=function(e,t){var a={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(a[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(s=Object.getOwnPropertySymbols(e);n<s.length;n++)t.indexOf(s[n])<0&&Object.prototype.propertyIsEnumerable.call(e,s[n])&&(a[s[n]]=e[s[n]])}return a}(e,["children"]);return i.default.createElement(u.Provider,{value:a},t)},g=()=>{const e=i.default.useContext(u);if(void 0===e)throw new Error("useConfig must be used within a ConfigContext");return e};function h(e,t){void 0===t&&(t={});var a=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],n=document.createElement("style");n.type="text/css","top"===a&&s.firstChild?s.insertBefore(n,s.firstChild):s.appendChild(n),n.styleSheet?n.styleSheet.cssText=e:n.appendChild(document.createTextNode(e))}}h(".iac-changes-table .iui-table-body .iui-table-cell{word-break:break-word}");h(".iac-additional-info{display:flex;justify-content:space-between;padding:var(--iui-size-s);background-color:var(--iui-color-background-backdrop)}.iac-additional-info span{flex-shrink:0}.iac-additional-info span:not(:last-child){margin-right:var(--iui-size-m)}.iac-additional-info .iac-cell-ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:1}");h(".iac-version-modal .iui-modal-dialog{max-width:min(600px,50%)}.iac-version-modal-overlay{position:fixed;z-index:99999;height:100vh;width:100vw;top:0;left:0}.iac-version-modal .iui-input-container{margin-bottom:var(--iui-size-s)}");const f=t=>{var a,s;const{initialVersion:n,isLoading:r,title:o,actionName:l,onClose:d,onActionClick:c,children:u}=t,{stringsOverrides:m}=g(),[h,f]=i.default.useState({name:null!==(a=null==n?void 0:n.name)&&void 0!==a?a:"",description:null!==(s=null==n?void 0:n.description)&&void 0!==s?s:""}),v=e=>{const t=e.target.name,a=e.target.value;f((e=>Object.assign(Object.assign({},e),{[t]:null!=a?a:""})))},p=e=>e.length<=255;return i.default.createElement(i.default.Fragment,null,i.default.createElement(e.Modal,{title:o,isOpen:!0,onClose:d,className:"iac-version-modal"},i.default.createElement(e.LabeledInput,{name:"name",label:m.name,onChange:v,value:h.name,status:p(h.name)?void 0:"negative",message:p(h.name)?void 0:m.messageValueTooLong.replace("{{length}}",255..toString()),required:!0,setFocus:!0,autoComplete:"off"}),i.default.createElement(e.LabeledTextarea,{name:"description",label:m.description,onChange:v,value:h.description,status:p(h.description)?void 0:"negative",message:p(h.description)?void 0:m.messageValueTooLong.replace("{{length}}",255..toString()),rows:3,autoComplete:"off"}),u,i.default.createElement(e.ModalButtonBar,null,i.default.createElement(e.Button,{styleType:"high-visibility",onClick:()=>c(h.name,h.description),disabled:!(h.name&&(h.name!==(null==n?void 0:n.name)||h.description!==(null==n?void 0:n.description))&&p(h.name)&&p(h.description))},l),i.default.createElement(e.Button,{onClick:d},m.cancel)),r&&i.default.createElement("div",{className:"iui-progress-indicator-overlay"},i.default.createElement(e.ProgressRadial,{indeterminate:!0}))),r&&i.default.createElement("div",{className:"iac-version-modal-overlay"}))},v=t=>{const{latestVersion:a,changeset:s,onClose:n,onCreate:r}=t,{accessToken:o,imodelId:l,apiOverrides:d,stringsOverrides:u,log:m}=g(),[h,v]=i.default.useState(!1),p=i.default.useMemo((()=>new c(o,null==d?void 0:d.serverEnvironmentPrefix,m)),[o,null==d?void 0:d.serverEnvironmentPrefix,m]);return i.default.createElement(f,{title:u.createNamedVersion,actionName:u.create,isLoading:h,onClose:n,onActionClick:(t,a)=>{v(!0),e.toaster.closeAll(),p.create(l,{name:t,description:a,changeSetId:s.id}).then((()=>{v(!1),r(),e.toaster.positive(u.messageVersionCreated.replace("{{name}}",t),{hasCloseButton:!0})})).catch((t=>{v(!1),e.toaster.negative((e=>{switch(e){case"NamedVersionExists":return u.messageVersionNameExists;case"InsufficientPermissions":return u.messageInsufficientPermissionsToCreateVersion;default:return u.messageCouldNotCreateVersion}})(t.code),{hasCloseButton:!0})}))}},i.default.createElement("div",{className:"iui-input-container"},i.default.createElement("div",{className:"iui-label"},"Latest included change"),i.default.createElement("div",{className:"iac-additional-info"},i.default.createElement("span",null,"#",s.index),i.default.createElement("span",null,new Date(s.pushDateTime).toLocaleString()))),a&&i.default.createElement("div",{className:"iui-input-container"},i.default.createElement("div",{className:"iui-label"},"Latest Named Version"),i.default.createElement("div",{className:"iac-additional-info"},i.default.createElement("span",{className:"iac-cell-ellipsis"},a.name),i.default.createElement("span",null,new Date(a.createdDateTime).toLocaleString()))))};var p;!function(e){e[e.NotStarted=0]="NotStarted",e[e.InProgress=1]="InProgress",e[e.Finished=2]="Finished",e[e.Failed=3]="Failed"}(p||(p={}));const C=t=>{const{changesets:s,status:n,loadMoreChanges:r,onVersionCreated:o,latestVersion:l}=t,{stringsOverrides:d}=g(),[c,u]=i.default.useState(!1),[m,h]=i.default.useState(void 0),f=i.default.useCallback((e=>!e._links.namedVersion),[]),C=i.default.useMemo((()=>[{Header:"Name",columns:[{id:"INDEX",Header:"#",accessor:"index",width:90},{id:"DESCRIPTION",Header:d.description,accessor:"description"},{id:"CHANGED_FILES",Header:d.changedFiles,Cell:e=>{var t;const a=null===(t=e.row.original.synchronizationInfo)||void 0===t?void 0:t.changedFiles;return(null==a?void 0:a.length)?a.join(", "):""}},{id:"PUSH_DATE",Header:d.time,accessor:"pushDateTime",maxWidth:220,Cell:e=>i.default.createElement("span",null,new Date(e.row.original.pushDateTime).toLocaleString())},{id:"changes-table-actions",width:62,Cell:t=>{const s=t.data[t.row.index];return i.default.createElement(i.default.Fragment,null,f(s)&&i.default.createElement(e.IconButton,{onClick:()=>{h(s),u(!0)},title:d.createNamedVersion,styleType:"borderless"},i.default.createElement(a.SvgNamedVersionAdd,null)))}}]}]),[f,d.changedFiles,d.createNamedVersion,d.description,d.time]),b=i.default.useMemo((()=>n===p.Failed?d.messageFailedGetChanges:d.messageNoChanges),[n,d.messageFailedGetChanges,d.messageNoChanges]);return i.default.createElement(i.default.Fragment,null,i.default.createElement(e.Table,{columns:C,data:s,isLoading:n===p.InProgress||n===p.NotStarted,emptyTableContent:b,onBottomReached:r,className:"iac-changes-table"}),c&&i.default.createElement(v,{changeset:m,onCreate:()=>{u(!1),o()},onClose:()=>u(!1),latestVersion:l}))};h(".iac-versions-table .iui-table-body .iui-table-cell{word-break:break-word}");const b=t=>{const{version:a,onClose:s,onUpdate:n}=t,{accessToken:r,imodelId:o,apiOverrides:l,stringsOverrides:d,log:u}=g(),[m,h]=i.default.useState(!1),v=i.default.useMemo((()=>new c(r,null==l?void 0:l.serverEnvironmentPrefix,u)),[r,null==l?void 0:l.serverEnvironmentPrefix,u]);return i.default.createElement(f,{title:d.updateNamedVersion,actionName:d.update,initialVersion:a,isLoading:m,onClose:s,onActionClick:(t,s)=>{h(!0),e.toaster.closeAll(),v.update(o,a.id,{name:t,description:s}).then((()=>{h(!1),n(),e.toaster.positive(d.messageVersionUpdated.replace("{{name}}",t),{hasCloseButton:!0})})).catch((t=>{h(!1),e.toaster.negative((e=>{switch(e){case"NamedVersionExists":return d.messageVersionNameExists;case"InsufficientPermissions":return d.messageInsufficientPermissionsToUpdateVersion;default:return d.messageCouldNotUpdateVersion}})(t.code),{hasCloseButton:!0})}))}})},E=t=>{const{versions:s,status:n,onVersionUpdated:r,loadMoreVersions:o,onViewClick:l}=t,{stringsOverrides:d}=g(),[c,u]=i.default.useState(void 0),[m,h]=i.default.useState(!1),f=i.default.useMemo((()=>{const t=[{Header:"Name",columns:[{id:"NAME",Header:d.name,accessor:"name"},{id:"DESCRIPTION",Header:d.description,accessor:"description"},{id:"CREATED_DATE",Header:d.time,accessor:"createdDateTime",maxWidth:220,Cell:e=>i.default.createElement("span",null,new Date(e.row.original.createdDateTime).toLocaleString())},{id:"versions-table-actions",width:62,Cell:t=>i.default.createElement(i.default.Fragment,null,i.default.createElement(e.IconButton,{onClick:()=>{u(t.row.original),h(!0)},title:d.updateNamedVersion,styleType:"borderless"},i.default.createElement(a.SvgEdit,null)))}]}];return l&&t[0].columns.splice(3,0,{id:"versions-table-view",width:100,Cell:e=>i.default.createElement("span",{className:"iui-anchor",onClick:()=>l(e.row.original)},d.view)}),t}),[l,d.description,d.name,d.time,d.updateNamedVersion,d.view]),v=i.default.useMemo((()=>n===p.Failed?d.messageFailedGetNamedVersions:d.messageNoNamedVersions),[n,d.messageFailedGetNamedVersions,d.messageNoNamedVersions]);return i.default.createElement(i.default.Fragment,null,i.default.createElement(e.Table,{columns:f,data:s,isLoading:n===p.InProgress||n===p.NotStarted,emptyTableContent:v,onBottomReached:o,className:"iac-versions-table"}),m&&i.default.createElement(b,{version:c,onUpdate:()=>{h(!1),r()},onClose:()=>h(!1)}))},V={namedVersions:"Named Versions",changes:"Changes",name:"Name",description:"Description",time:"Time",changedFiles:"Changed Files",createNamedVersion:"Create a Named Version",cancel:"Cancel",create:"Create",updateNamedVersion:"Update a Named Version",update:"Update",view:"View",messageFailedGetNamedVersions:"Could not get Named Versions. Please try again later.",messageNoNamedVersions:"There are no Named Versions created. To create first go to Changes.",messageFailedGetChanges:"Could not get changes. Please try again later.",messageNoChanges:"There are no changes synchronized.",messageVersionCreated:'Named Version "{{name}}" was successfully created.',messageVersionNameExists:"Named Version with the same name already exists.",messageInsufficientPermissionsToCreateVersion:"You do not have the required permissions to create a Named Version.",messageCouldNotCreateVersion:"Could not create a Named Version. Please try again later.",messageVersionUpdated:'Named Version "{{name}}" was successfully updated.',messageInsufficientPermissionsToUpdateVersion:"You do not have the required permissions to update a Named Version.",messageCouldNotUpdateVersion:"Could not update a Named Version. Please try again later.",messageValueTooLong:"The value exceeds allowed {{length}} characters."};var N;exports.ManageVersionsTabs=void 0,(N=exports.ManageVersionsTabs||(exports.ManageVersionsTabs={}))[N.Versions=0]="Versions",N[N.Changes=1]="Changes";exports.ManageVersions=t=>{const{accessToken:a,apiOverrides:s,imodelId:n,stringsOverrides:r=V,log:o,onViewClick:l,currentTab:u=exports.ManageVersionsTabs.Versions,onTabChange:g}=t,h=i.default.useMemo((()=>new c(a,null==s?void 0:s.serverEnvironmentPrefix,o)),[a,null==s?void 0:s.serverEnvironmentPrefix,o]),f=i.default.useMemo((()=>new d(a,null==s?void 0:s.serverEnvironmentPrefix,o)),[a,null==s?void 0:s.serverEnvironmentPrefix,o]),[v,b]=i.default.useState(u);i.default.useEffect((()=>{b(u)}),[u]);const[N,y]=i.default.useState(),[w,T]=i.default.useState(p.NotStarted),[x,P]=i.default.useState(),[k,S]=i.default.useState(p.NotStarted),O=i.default.useCallback((e=>{b(e),null==g||g(e)}),[g]),M=i.default.useCallback((e=>{T(p.InProgress),h.get(n,{top:100,skip:e}).then((e=>{T(p.Finished),y((t=>[...null!=t?t:[],...e]))})).catch((()=>T(p.Failed)))}),[n,h]),I=i.default.useCallback((()=>{N&&N.length%100!=0||M(null==N?void 0:N.length)}),[M,N]),F=i.default.useCallback((()=>{y(void 0),M()}),[M]);i.default.useEffect((()=>{w===p.NotStarted&&M()}),[M,w]);const _=i.default.useCallback((()=>{x&&x.length%100!=0||(S(p.InProgress),f.get(n,{top:100,skip:null==x?void 0:x.length}).then((e=>{S(p.Finished),P([...null!=x?x:[],...e])})).catch((()=>S(p.Failed))))}),[f,x,n]);i.default.useEffect((()=>{v===exports.ManageVersionsTabs.Changes&&k===p.NotStarted&&_()}),[k,v,_]);const j=i.default.useCallback((()=>{O(exports.ManageVersionsTabs.Versions),F(),P(void 0),S(p.NotStarted)}),[O,F]),D=i.default.useMemo((()=>[...null!=N?N:[]].sort(((e,t)=>new Date(e.createdDateTime).valueOf()<new Date(t.createdDateTime).valueOf()?1:-1))[0]),[N]);return i.default.createElement(e.ThemeProvider,{theme:"inherit"},i.default.createElement(m,{accessToken:a,imodelId:n,apiOverrides:s,stringsOverrides:r,log:o},i.default.createElement("div",null,i.default.createElement(e.HorizontalTabs,{labels:[r.namedVersions,r.changes],activeIndex:v,onTabSelected:e=>O(e),type:"borderless"}),v===exports.ManageVersionsTabs.Versions&&i.default.createElement(E,{versions:null!=N?N:[],status:w,onVersionUpdated:F,loadMoreVersions:I,onViewClick:l}),v===exports.ManageVersionsTabs.Changes&&i.default.createElement(C,{changesets:null!=x?x:[],status:k,loadMoreChanges:_,onVersionCreated:j,latestVersion:D}))))}; |
export declare enum HttpHeaderNames { | ||
Authorization = "Authorization", | ||
ContentType = "Content-Type", | ||
Prefer = "Prefer" | ||
Prefer = "Prefer", | ||
Accept = "Accept" | ||
} | ||
@@ -6,0 +7,0 @@ export declare type ApimCodes = "NamedVersionExists" | "InsufficientPermissions"; |
@@ -1,2 +0,2 @@ | ||
import{Modal as e,LabeledInput as t,LabeledTextarea as s,ModalButtonBar as n,Button as a,ProgressRadial as i,toaster as r,IconButton as o,Table as l,HorizontalTabs as d}from"@itwin/itwinui-react";import c from"react";import{SvgNamedVersionAdd as m,SvgEdit as u}from"@itwin/itwinui-icons-react";var g;!function(e){e.Authorization="Authorization",e.ContentType="Content-Type",e.Prefer="Prefer"}(g||(g={}));class h extends Error{constructor(e,t){super(null==e?void 0:e.message),this.code=null==e?void 0:e.code,this.statusCode=t}}class v{constructor(e,t){this._errorMessagePrefix="@itwin/manage-versions-react",this._defaultErrorMessage="HTTP error without a message.",this._token=e,this._log=t}async get(e,t){var s;const n={method:"GET",url:e,headers:Object.assign({},null==t?void 0:t.headers),signal:null===(s=null==t?void 0:t.abortController)||void 0===s?void 0:s.signal};return this.makeRequest(n)}async post(e,t,s){var n;const a={method:"POST",url:e,headers:Object.assign({},null==s?void 0:s.headers),body:t,signal:null===(n=null==s?void 0:s.abortController)||void 0===n?void 0:n.signal};return this.makeRequest(a)}async patch(e,t,s){var n;const a={method:"PATCH",url:e,headers:Object.assign({},null==s?void 0:s.headers),body:t,signal:null===(n=null==s?void 0:s.abortController)||void 0===n?void 0:n.signal};return this.makeRequest(a)}async delete(e,t){var s;const n={method:"DELETE",url:e,headers:Object.assign({},null==t?void 0:t.headers),signal:null===(s=null==t?void 0:t.abortController)||void 0===s?void 0:s.signal};return this.makeRequest(n)}async makeRequest(e){this.prepareHeaders(e);try{const t=await fetch(e.url,{method:e.method,headers:e.headers,body:e.body?JSON.stringify(e.body):void 0,signal:null==e?void 0:e.signal}),s=await t.json();if(!t.ok)throw new h(null==s?void 0:s.error,t.status);return s}catch(t){throw this.logError(t,e),t}}prepareHeaders(e){e.headers=Object.assign({[g.Authorization]:this._token,[g.ContentType]:"application/json"},e.headers)}logError(e,t){var s;null===(s=this._log)||void 0===s||s.call(this,`${this._errorMessagePrefix} - ${e.message||this._defaultErrorMessage}`,{request:this.getRequestToLog(t),error:e})}getRequestToLog(e){const t=Object.assign({},e.headers);return delete t[g.Authorization],{headers:t,url:e.url,method:e.method}}}class p{static getBaseUrl(e){return`https://${e?`${e}-`:""}api.bentley.com`}static buildVersionsUrl(e,t,s){return`${this.getBaseUrl(s)}/imodels/${e}/namedversions${t?`/${t}`:""}`}static buildChangesetUrl(e,t){return`${this.getBaseUrl(t)}/imodels/${e}/changesets`}}p.getQuery=e=>{const t=Object.entries(e).filter((([e,t])=>!!t)).map((([e,t])=>`$${e}=${t}`)).join("&");return t?`?${t}`:""};class C{constructor(e,t,s){this._http=new v(e,s),this._serverEnvironmentPrefix=t}async get(e,t={}){return this._http.get(`${p.buildChangesetUrl(e,this._serverEnvironmentPrefix)}${p.getQuery(Object.assign({orderBy:"index+desc"},t))}`,{headers:{[g.Prefer]:"return=representation"}}).then((e=>e.changesets))}}class f{constructor(e,t,s){this._http=new v(e,s),this._serverEnvironmentPrefix=t}async get(e,t={}){return this._http.get(`${p.buildVersionsUrl(e,void 0,this._serverEnvironmentPrefix)}${p.getQuery(t)}`,{headers:{[g.Prefer]:"return=representation"}}).then((e=>e.namedVersions))}async create(e,t){return this._http.post(p.buildVersionsUrl(e,void 0,this._serverEnvironmentPrefix),t).then((e=>e.namedVersion))}async update(e,t,s){return this._http.patch(p.buildVersionsUrl(e,t,this._serverEnvironmentPrefix),s).then((e=>e.namedVersion))}} | ||
import{Modal as e,LabeledInput as t,LabeledTextarea as n,ModalButtonBar as s,Button as a,ProgressRadial as i,toaster as r,IconButton as o,Table as l,ThemeProvider as d,HorizontalTabs as c}from"@itwin/itwinui-react";import m from"react";import{SvgNamedVersionAdd as u,SvgEdit as g}from"@itwin/itwinui-icons-react";var h;!function(e){e.Authorization="Authorization",e.ContentType="Content-Type",e.Prefer="Prefer",e.Accept="Accept"}(h||(h={}));class v extends Error{constructor(e,t){super(null==e?void 0:e.message),this.code=null==e?void 0:e.code,this.statusCode=t}}class p{constructor(e,t){this._errorMessagePrefix="@itwin/manage-versions-react",this._defaultErrorMessage="HTTP error without a message.",this._token=e,this._log=t}async get(e,t){var n;const s={method:"GET",url:e,headers:Object.assign({},null==t?void 0:t.headers),signal:null===(n=null==t?void 0:t.abortController)||void 0===n?void 0:n.signal};return this.makeRequest(s)}async post(e,t,n){var s;const a={method:"POST",url:e,headers:Object.assign({},null==n?void 0:n.headers),body:t,signal:null===(s=null==n?void 0:n.abortController)||void 0===s?void 0:s.signal};return this.makeRequest(a)}async patch(e,t,n){var s;const a={method:"PATCH",url:e,headers:Object.assign({},null==n?void 0:n.headers),body:t,signal:null===(s=null==n?void 0:n.abortController)||void 0===s?void 0:s.signal};return this.makeRequest(a)}async delete(e,t){var n;const s={method:"DELETE",url:e,headers:Object.assign({},null==t?void 0:t.headers),signal:null===(n=null==t?void 0:t.abortController)||void 0===n?void 0:n.signal};return this.makeRequest(s)}async makeRequest(e){this.prepareHeaders(e);try{const t=await fetch(e.url,{method:e.method,headers:e.headers,body:e.body?JSON.stringify(e.body):void 0,signal:null==e?void 0:e.signal}),n=await t.json();if(!t.ok)throw new v(null==n?void 0:n.error,t.status);return n}catch(t){throw this.logError(t,e),t}}prepareHeaders(e){e.headers=Object.assign({[h.Authorization]:this._token,[h.Accept]:"application/vnd.bentley.itwin-platform.v2+json",[h.ContentType]:"application/json"},e.headers)}logError(e,t){var n;null===(n=this._log)||void 0===n||n.call(this,`${this._errorMessagePrefix} - ${e.message||this._defaultErrorMessage}`,{request:this.getRequestToLog(t),error:e})}getRequestToLog(e){const t=Object.assign({},e.headers);return delete t[h.Authorization],{headers:t,url:e.url,method:e.method}}}class C{static getBaseUrl(e){return`https://${e?`${e}-`:""}api.bentley.com`}static buildVersionsUrl(e,t,n){return`${this.getBaseUrl(n)}/imodels/${e}/namedversions${t?`/${t}`:""}`}static buildChangesetUrl(e,t){return`${this.getBaseUrl(t)}/imodels/${e}/changesets`}}C.getQuery=e=>{const t=Object.entries(e).filter((([e,t])=>!!t)).map((([e,t])=>`$${e}=${t}`)).join("&");return t?`?${t}`:""};class f{constructor(e,t,n){this._http=new p(e,n),this._serverEnvironmentPrefix=t}async get(e,t={}){return this._http.get(`${C.buildChangesetUrl(e,this._serverEnvironmentPrefix)}${C.getQuery(Object.assign({orderBy:"index+desc"},t))}`,{headers:{[h.Prefer]:"return=representation",[h.Accept]:"application/vnd.bentley.itwin-platform.v2+json"}}).then((e=>e.changesets))}}class E{constructor(e,t,n){this._http=new p(e,n),this._serverEnvironmentPrefix=t}async get(e,t={}){return this._http.get(`${C.buildVersionsUrl(e,void 0,this._serverEnvironmentPrefix)}${C.getQuery(t)}`,{headers:{[h.Prefer]:"return=representation",[h.Accept]:"application/vnd.bentley.itwin-platform.v2+json"}}).then((e=>e.namedVersions))}async create(e,t){return this._http.post(C.buildVersionsUrl(e,void 0,this._serverEnvironmentPrefix),t).then((e=>e.namedVersion))}async update(e,t,n){return this._http.patch(C.buildVersionsUrl(e,t,this._serverEnvironmentPrefix),n).then((e=>e.namedVersion))}} | ||
/*! ***************************************************************************** | ||
@@ -15,2 +15,2 @@ Copyright (c) Microsoft Corporation. | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */const E=c.createContext(void 0),N=e=>{const{children:t}=e,s=function(e,t){var s={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(s[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(n=Object.getOwnPropertySymbols(e);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(e,n[a])&&(s[n[a]]=e[n[a]])}return s}(e,["children"]);return c.createElement(E.Provider,{value:s},t)},V=()=>{const e=c.useContext(E);if(void 0===e)throw new Error("useConfig must be used within a ConfigContext");return e};function b(e,t){void 0===t&&(t={});var s=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===s&&n.firstChild?n.insertBefore(a,n.firstChild):n.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}b(".iac-changes-table .iui-table-body .iui-cell{word-break:break-word}");b(".iac-additional-info{display:flex;justify-content:space-between;padding:11px 12px;background-color:#f8f9fb;background-color:var(--iui-color-background-2)}.iac-additional-info span{flex-shrink:0}.iac-additional-info span:not(:last-child){margin-right:16px}.iac-additional-info .iac-cell-ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:1}");b(".iac-version-modal .iui-modal-dialog{max-width:min(600px,50%)}.iac-version-modal-overlay{position:fixed;z-index:99999;height:100vh;width:100vw;top:0;left:0}.iac-version-modal .iui-input-container{margin-bottom:11px}");const w=r=>{var o,l;const{initialVersion:d,isLoading:m,title:u,actionName:g,onClose:h,onActionClick:v,children:p}=r,{stringsOverrides:C}=V(),[f,E]=c.useState({name:null!==(o=null==d?void 0:d.name)&&void 0!==o?o:"",description:null!==(l=null==d?void 0:d.description)&&void 0!==l?l:""}),N=e=>{const t=e.target.name,s=e.target.value;E((e=>Object.assign(Object.assign({},e),{[t]:null!=s?s:""})))},b=e=>e.length<=255;return c.createElement(c.Fragment,null,c.createElement(e,{title:u,isOpen:!0,onClose:h,className:"iac-version-modal"},c.createElement(t,{name:"name",label:C.name,onChange:N,value:f.name,status:b(f.name)?void 0:"negative",message:b(f.name)?void 0:C.messageValueTooLong.replace("{{length}}",255..toString()),required:!0,setFocus:!0,autoComplete:"off"}),c.createElement(s,{name:"description",label:C.description,onChange:N,value:f.description,status:b(f.description)?void 0:"negative",message:b(f.description)?void 0:C.messageValueTooLong.replace("{{length}}",255..toString()),rows:3,autoComplete:"off"}),p,c.createElement(n,null,c.createElement(a,{styleType:"high-visibility",onClick:()=>v(f.name,f.description),disabled:!(f.name&&(f.name!==(null==d?void 0:d.name)||f.description!==(null==d?void 0:d.description))&&b(f.name)&&b(f.description))},g),c.createElement(a,{onClick:h},C.cancel)),m&&c.createElement("div",{className:"iui-progress-indicator-overlay"},c.createElement(i,{indeterminate:!0}))),m&&c.createElement("div",{className:"iac-version-modal-overlay"}))},y=e=>{const{latestVersion:t,changeset:s,onClose:n,onCreate:a}=e,{accessToken:i,imodelId:o,apiOverrides:l,stringsOverrides:d,log:m}=V(),[u,g]=c.useState(!1),h=c.useMemo((()=>new f(i,null==l?void 0:l.serverEnvironmentPrefix,m)),[i,null==l?void 0:l.serverEnvironmentPrefix,m]);return c.createElement(w,{title:d.createNamedVersion,actionName:d.create,isLoading:u,onClose:n,onActionClick:(e,t)=>{g(!0),r.closeAll(),h.create(o,{name:e,description:t,changeSetId:s.id}).then((()=>{g(!1),a(),r.positive(d.messageVersionCreated.replace("{{name}}",e),{hasCloseButton:!0})})).catch((e=>{g(!1),r.negative((e=>{switch(e){case"NamedVersionExists":return d.messageVersionNameExists;case"InsufficientPermissions":return d.messageInsufficientPermissionsToCreateVersion;default:return d.messageCouldNotCreateVersion}})(e.code),{hasCloseButton:!0})}))}},c.createElement("div",{className:"iui-input-container"},c.createElement("div",{className:"iui-label"},"Latest included change"),c.createElement("div",{className:"iac-additional-info"},c.createElement("span",null,"#",s.index),c.createElement("span",null,new Date(s.pushDateTime).toLocaleString()))),t&&c.createElement("div",{className:"iui-input-container"},c.createElement("div",{className:"iui-label"},"Latest Named Version"),c.createElement("div",{className:"iac-additional-info"},c.createElement("span",{className:"iac-cell-ellipsis"},t.name),c.createElement("span",null,new Date(t.createdDateTime).toLocaleString()))))};var x;!function(e){e[e.NotStarted=0]="NotStarted",e[e.InProgress=1]="InProgress",e[e.Finished=2]="Finished",e[e.Failed=3]="Failed"}(x||(x={}));const T=e=>{const{changesets:t,status:s,loadMoreChanges:n,onVersionCreated:a,latestVersion:i}=e,{stringsOverrides:r}=V(),[d,u]=c.useState(!1),[g,h]=c.useState(void 0),v=c.useCallback((e=>!e._links.namedVersion),[]),p=c.useMemo((()=>[{Header:"Name",columns:[{id:"INDEX",Header:"#",accessor:"index",width:90},{id:"DESCRIPTION",Header:r.description,accessor:"description"},{id:"CHANGED_FILES",Header:r.changedFiles,Cell:e=>{var t;const s=null===(t=e.row.original.synchronizationInfo)||void 0===t?void 0:t.changedFiles;return(null==s?void 0:s.length)?s.join(", "):""}},{id:"PUSH_DATE",Header:r.time,accessor:"pushDateTime",maxWidth:220,Cell:e=>c.createElement("span",null,new Date(e.row.original.pushDateTime).toLocaleString())},{id:"changes-table-actions",width:62,Cell:e=>{const t=e.data[e.row.index];return c.createElement(c.Fragment,null,v(t)&&c.createElement(o,{onClick:()=>{h(t),u(!0)},title:r.createNamedVersion,styleType:"borderless"},c.createElement(m,null)))}}]}]),[v,r.changedFiles,r.createNamedVersion,r.description,r.time]),C=c.useMemo((()=>s===x.Failed?r.messageFailedGetChanges:r.messageNoChanges),[s,r.messageFailedGetChanges,r.messageNoChanges]);return c.createElement(c.Fragment,null,c.createElement(l,{columns:p,data:t,isLoading:s===x.InProgress||s===x.NotStarted,emptyTableContent:C,onBottomReached:n,className:"iac-changes-table"}),d&&c.createElement(y,{changeset:g,onCreate:()=>{u(!1),a()},onClose:()=>u(!1),latestVersion:i}))};b(".iac-versions-table .iui-table-body .iui-cell{word-break:break-word}");const P=e=>{const{version:t,onClose:s,onUpdate:n}=e,{accessToken:a,imodelId:i,apiOverrides:o,stringsOverrides:l,log:d}=V(),[m,u]=c.useState(!1),g=c.useMemo((()=>new f(a,null==o?void 0:o.serverEnvironmentPrefix,d)),[a,null==o?void 0:o.serverEnvironmentPrefix,d]);return c.createElement(w,{title:l.updateNamedVersion,actionName:l.update,initialVersion:t,isLoading:m,onClose:s,onActionClick:(e,s)=>{u(!0),r.closeAll(),g.update(i,t.id,{name:e,description:s}).then((()=>{u(!1),n(),r.positive(l.messageVersionUpdated.replace("{{name}}",e),{hasCloseButton:!0})})).catch((e=>{u(!1),r.negative((e=>{switch(e){case"NamedVersionExists":return l.messageVersionNameExists;case"InsufficientPermissions":return l.messageInsufficientPermissionsToUpdateVersion;default:return l.messageCouldNotUpdateVersion}})(e.code),{hasCloseButton:!0})}))}})},k=e=>{const{versions:t,status:s,onVersionUpdated:n,loadMoreVersions:a,onViewClick:i}=e,{stringsOverrides:r}=V(),[d,m]=c.useState(void 0),[g,h]=c.useState(!1),v=c.useMemo((()=>{const e=[{Header:"Name",columns:[{id:"NAME",Header:r.name,accessor:"name"},{id:"DESCRIPTION",Header:r.description,accessor:"description"},{id:"CREATED_DATE",Header:r.time,accessor:"createdDateTime",maxWidth:220,Cell:e=>c.createElement("span",null,new Date(e.row.original.createdDateTime).toLocaleString())},{id:"versions-table-actions",width:62,Cell:e=>c.createElement(c.Fragment,null,c.createElement(o,{onClick:()=>{m(e.row.original),h(!0)},title:r.updateNamedVersion,styleType:"borderless"},c.createElement(u,null)))}]}];return i&&e[0].columns.splice(3,0,{id:"versions-table-view",width:100,Cell:e=>c.createElement("span",{className:"iui-anchor",onClick:()=>i(e.row.original)},r.view)}),e}),[i,r.description,r.name,r.time,r.updateNamedVersion,r.view]),p=c.useMemo((()=>s===x.Failed?r.messageFailedGetNamedVersions:r.messageNoNamedVersions),[s,r.messageFailedGetNamedVersions,r.messageNoNamedVersions]);return c.createElement(c.Fragment,null,c.createElement(l,{columns:v,data:t,isLoading:s===x.InProgress||s===x.NotStarted,emptyTableContent:p,onBottomReached:a,className:"iac-versions-table"}),g&&c.createElement(P,{version:d,onUpdate:()=>{h(!1),n()},onClose:()=>h(!1)}))},S={namedVersions:"Named Versions",changes:"Changes",name:"Name",description:"Description",time:"Time",changedFiles:"Changed Files",createNamedVersion:"Create a Named Version",cancel:"Cancel",create:"Create",updateNamedVersion:"Update a Named Version",update:"Update",view:"View",messageFailedGetNamedVersions:"Could not get Named Versions. Please try again later.",messageNoNamedVersions:"There are no Named Versions created. To create first go to Changes.",messageFailedGetChanges:"Could not get changes. Please try again later.",messageNoChanges:"There are no changes synchronized.",messageVersionCreated:'Named Version "{{name}}" was successfully created.',messageVersionNameExists:"Named Version with the same name already exists.",messageInsufficientPermissionsToCreateVersion:"You do not have the required permissions to create a Named Version.",messageCouldNotCreateVersion:"Could not create a Named Version. Please try again later.",messageVersionUpdated:'Named Version "{{name}}" was successfully updated.',messageInsufficientPermissionsToUpdateVersion:"You do not have the required permissions to update a Named Version.",messageCouldNotUpdateVersion:"Could not update a Named Version. Please try again later.",messageValueTooLong:"The value exceeds allowed {{length}} characters."};var O;!function(e){e[e.Versions=0]="Versions",e[e.Changes=1]="Changes"}(O||(O={}));const F=e=>{const{accessToken:t,apiOverrides:s,imodelId:n,stringsOverrides:a=S,log:i,onViewClick:r,currentTab:o=O.Versions,onTabChange:l}=e,m=c.useMemo((()=>new f(t,null==s?void 0:s.serverEnvironmentPrefix,i)),[t,null==s?void 0:s.serverEnvironmentPrefix,i]),u=c.useMemo((()=>new C(t,null==s?void 0:s.serverEnvironmentPrefix,i)),[t,null==s?void 0:s.serverEnvironmentPrefix,i]),[g,h]=c.useState(o);c.useEffect((()=>{h(o)}),[o]);const[v,p]=c.useState(),[E,V]=c.useState(x.NotStarted),[b,w]=c.useState(),[y,P]=c.useState(x.NotStarted),F=c.useCallback((e=>{h(e),null==l||l(e)}),[l]),I=c.useCallback((e=>{V(x.InProgress),m.get(n,{top:100,skip:e}).then((e=>{V(x.Finished),p((t=>[...null!=t?t:[],...e]))})).catch((()=>V(x.Failed)))}),[n,m]),_=c.useCallback((()=>{v&&v.length%100!=0||I(null==v?void 0:v.length)}),[I,v]),D=c.useCallback((()=>{p(void 0),I()}),[I]);c.useEffect((()=>{E===x.NotStarted&&I()}),[I,E]);const U=c.useCallback((()=>{b&&b.length%100!=0||(P(x.InProgress),u.get(n,{top:100,skip:null==b?void 0:b.length}).then((e=>{P(x.Finished),w([...null!=b?b:[],...e])})).catch((()=>P(x.Failed))))}),[u,b,n]);c.useEffect((()=>{g===O.Changes&&y===x.NotStarted&&U()}),[y,g,U]);const j=c.useCallback((()=>{F(O.Versions),D(),w(void 0),P(x.NotStarted)}),[F,D]),L=c.useMemo((()=>[...null!=v?v:[]].sort(((e,t)=>new Date(e.createdDateTime).valueOf()<new Date(t.createdDateTime).valueOf()?1:-1))[0]),[v]);return c.createElement(N,{accessToken:t,imodelId:n,apiOverrides:s,stringsOverrides:a,log:i},c.createElement("div",null,c.createElement(d,{labels:[a.namedVersions,a.changes],activeIndex:g,onTabSelected:e=>F(e),type:"borderless"}),g===O.Versions&&c.createElement(k,{versions:null!=v?v:[],status:E,onVersionUpdated:D,loadMoreVersions:_,onViewClick:r}),g===O.Changes&&c.createElement(T,{changesets:null!=b?b:[],status:y,loadMoreChanges:U,onVersionCreated:j,latestVersion:L})))};export{F as ManageVersions,O as ManageVersionsTabs}; | ||
***************************************************************************** */const b=m.createContext(void 0),N=e=>{const{children:t}=e,n=function(e,t){var n={};for(var s in e)Object.prototype.hasOwnProperty.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var a=0;for(s=Object.getOwnPropertySymbols(e);a<s.length;a++)t.indexOf(s[a])<0&&Object.prototype.propertyIsEnumerable.call(e,s[a])&&(n[s[a]]=e[s[a]])}return n}(e,["children"]);return m.createElement(b.Provider,{value:n},t)},V=()=>{const e=m.useContext(b);if(void 0===e)throw new Error("useConfig must be used within a ConfigContext");return e};function w(e,t){void 0===t&&(t={});var n=t.insertAt;if(e&&"undefined"!=typeof document){var s=document.head||document.getElementsByTagName("head")[0],a=document.createElement("style");a.type="text/css","top"===n&&s.firstChild?s.insertBefore(a,s.firstChild):s.appendChild(a),a.styleSheet?a.styleSheet.cssText=e:a.appendChild(document.createTextNode(e))}}w(".iac-changes-table .iui-table-body .iui-table-cell{word-break:break-word}");w(".iac-additional-info{display:flex;justify-content:space-between;padding:var(--iui-size-s);background-color:var(--iui-color-background-backdrop)}.iac-additional-info span{flex-shrink:0}.iac-additional-info span:not(:last-child){margin-right:var(--iui-size-m)}.iac-additional-info .iac-cell-ellipsis{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex-shrink:1}");w(".iac-version-modal .iui-modal-dialog{max-width:min(600px,50%)}.iac-version-modal-overlay{position:fixed;z-index:99999;height:100vh;width:100vw;top:0;left:0}.iac-version-modal .iui-input-container{margin-bottom:var(--iui-size-s)}");const y=r=>{var o,l;const{initialVersion:d,isLoading:c,title:u,actionName:g,onClose:h,onActionClick:v,children:p}=r,{stringsOverrides:C}=V(),[f,E]=m.useState({name:null!==(o=null==d?void 0:d.name)&&void 0!==o?o:"",description:null!==(l=null==d?void 0:d.description)&&void 0!==l?l:""}),b=e=>{const t=e.target.name,n=e.target.value;E((e=>Object.assign(Object.assign({},e),{[t]:null!=n?n:""})))},N=e=>e.length<=255;return m.createElement(m.Fragment,null,m.createElement(e,{title:u,isOpen:!0,onClose:h,className:"iac-version-modal"},m.createElement(t,{name:"name",label:C.name,onChange:b,value:f.name,status:N(f.name)?void 0:"negative",message:N(f.name)?void 0:C.messageValueTooLong.replace("{{length}}",255..toString()),required:!0,setFocus:!0,autoComplete:"off"}),m.createElement(n,{name:"description",label:C.description,onChange:b,value:f.description,status:N(f.description)?void 0:"negative",message:N(f.description)?void 0:C.messageValueTooLong.replace("{{length}}",255..toString()),rows:3,autoComplete:"off"}),p,m.createElement(s,null,m.createElement(a,{styleType:"high-visibility",onClick:()=>v(f.name,f.description),disabled:!(f.name&&(f.name!==(null==d?void 0:d.name)||f.description!==(null==d?void 0:d.description))&&N(f.name)&&N(f.description))},g),m.createElement(a,{onClick:h},C.cancel)),c&&m.createElement("div",{className:"iui-progress-indicator-overlay"},m.createElement(i,{indeterminate:!0}))),c&&m.createElement("div",{className:"iac-version-modal-overlay"}))},T=e=>{const{latestVersion:t,changeset:n,onClose:s,onCreate:a}=e,{accessToken:i,imodelId:o,apiOverrides:l,stringsOverrides:d,log:c}=V(),[u,g]=m.useState(!1),h=m.useMemo((()=>new E(i,null==l?void 0:l.serverEnvironmentPrefix,c)),[i,null==l?void 0:l.serverEnvironmentPrefix,c]);return m.createElement(y,{title:d.createNamedVersion,actionName:d.create,isLoading:u,onClose:s,onActionClick:(e,t)=>{g(!0),r.closeAll(),h.create(o,{name:e,description:t,changeSetId:n.id}).then((()=>{g(!1),a(),r.positive(d.messageVersionCreated.replace("{{name}}",e),{hasCloseButton:!0})})).catch((e=>{g(!1),r.negative((e=>{switch(e){case"NamedVersionExists":return d.messageVersionNameExists;case"InsufficientPermissions":return d.messageInsufficientPermissionsToCreateVersion;default:return d.messageCouldNotCreateVersion}})(e.code),{hasCloseButton:!0})}))}},m.createElement("div",{className:"iui-input-container"},m.createElement("div",{className:"iui-label"},"Latest included change"),m.createElement("div",{className:"iac-additional-info"},m.createElement("span",null,"#",n.index),m.createElement("span",null,new Date(n.pushDateTime).toLocaleString()))),t&&m.createElement("div",{className:"iui-input-container"},m.createElement("div",{className:"iui-label"},"Latest Named Version"),m.createElement("div",{className:"iac-additional-info"},m.createElement("span",{className:"iac-cell-ellipsis"},t.name),m.createElement("span",null,new Date(t.createdDateTime).toLocaleString()))))};var x;!function(e){e[e.NotStarted=0]="NotStarted",e[e.InProgress=1]="InProgress",e[e.Finished=2]="Finished",e[e.Failed=3]="Failed"}(x||(x={}));const P=e=>{const{changesets:t,status:n,loadMoreChanges:s,onVersionCreated:a,latestVersion:i}=e,{stringsOverrides:r}=V(),[d,c]=m.useState(!1),[g,h]=m.useState(void 0),v=m.useCallback((e=>!e._links.namedVersion),[]),p=m.useMemo((()=>[{Header:"Name",columns:[{id:"INDEX",Header:"#",accessor:"index",width:90},{id:"DESCRIPTION",Header:r.description,accessor:"description"},{id:"CHANGED_FILES",Header:r.changedFiles,Cell:e=>{var t;const n=null===(t=e.row.original.synchronizationInfo)||void 0===t?void 0:t.changedFiles;return(null==n?void 0:n.length)?n.join(", "):""}},{id:"PUSH_DATE",Header:r.time,accessor:"pushDateTime",maxWidth:220,Cell:e=>m.createElement("span",null,new Date(e.row.original.pushDateTime).toLocaleString())},{id:"changes-table-actions",width:62,Cell:e=>{const t=e.data[e.row.index];return m.createElement(m.Fragment,null,v(t)&&m.createElement(o,{onClick:()=>{h(t),c(!0)},title:r.createNamedVersion,styleType:"borderless"},m.createElement(u,null)))}}]}]),[v,r.changedFiles,r.createNamedVersion,r.description,r.time]),C=m.useMemo((()=>n===x.Failed?r.messageFailedGetChanges:r.messageNoChanges),[n,r.messageFailedGetChanges,r.messageNoChanges]);return m.createElement(m.Fragment,null,m.createElement(l,{columns:p,data:t,isLoading:n===x.InProgress||n===x.NotStarted,emptyTableContent:C,onBottomReached:s,className:"iac-changes-table"}),d&&m.createElement(T,{changeset:g,onCreate:()=>{c(!1),a()},onClose:()=>c(!1),latestVersion:i}))};w(".iac-versions-table .iui-table-body .iui-table-cell{word-break:break-word}");const k=e=>{const{version:t,onClose:n,onUpdate:s}=e,{accessToken:a,imodelId:i,apiOverrides:o,stringsOverrides:l,log:d}=V(),[c,u]=m.useState(!1),g=m.useMemo((()=>new E(a,null==o?void 0:o.serverEnvironmentPrefix,d)),[a,null==o?void 0:o.serverEnvironmentPrefix,d]);return m.createElement(y,{title:l.updateNamedVersion,actionName:l.update,initialVersion:t,isLoading:c,onClose:n,onActionClick:(e,n)=>{u(!0),r.closeAll(),g.update(i,t.id,{name:e,description:n}).then((()=>{u(!1),s(),r.positive(l.messageVersionUpdated.replace("{{name}}",e),{hasCloseButton:!0})})).catch((e=>{u(!1),r.negative((e=>{switch(e){case"NamedVersionExists":return l.messageVersionNameExists;case"InsufficientPermissions":return l.messageInsufficientPermissionsToUpdateVersion;default:return l.messageCouldNotUpdateVersion}})(e.code),{hasCloseButton:!0})}))}})},S=e=>{const{versions:t,status:n,onVersionUpdated:s,loadMoreVersions:a,onViewClick:i}=e,{stringsOverrides:r}=V(),[d,c]=m.useState(void 0),[u,h]=m.useState(!1),v=m.useMemo((()=>{const e=[{Header:"Name",columns:[{id:"NAME",Header:r.name,accessor:"name"},{id:"DESCRIPTION",Header:r.description,accessor:"description"},{id:"CREATED_DATE",Header:r.time,accessor:"createdDateTime",maxWidth:220,Cell:e=>m.createElement("span",null,new Date(e.row.original.createdDateTime).toLocaleString())},{id:"versions-table-actions",width:62,Cell:e=>m.createElement(m.Fragment,null,m.createElement(o,{onClick:()=>{c(e.row.original),h(!0)},title:r.updateNamedVersion,styleType:"borderless"},m.createElement(g,null)))}]}];return i&&e[0].columns.splice(3,0,{id:"versions-table-view",width:100,Cell:e=>m.createElement("span",{className:"iui-anchor",onClick:()=>i(e.row.original)},r.view)}),e}),[i,r.description,r.name,r.time,r.updateNamedVersion,r.view]),p=m.useMemo((()=>n===x.Failed?r.messageFailedGetNamedVersions:r.messageNoNamedVersions),[n,r.messageFailedGetNamedVersions,r.messageNoNamedVersions]);return m.createElement(m.Fragment,null,m.createElement(l,{columns:v,data:t,isLoading:n===x.InProgress||n===x.NotStarted,emptyTableContent:p,onBottomReached:a,className:"iac-versions-table"}),u&&m.createElement(k,{version:d,onUpdate:()=>{h(!1),s()},onClose:()=>h(!1)}))},O={namedVersions:"Named Versions",changes:"Changes",name:"Name",description:"Description",time:"Time",changedFiles:"Changed Files",createNamedVersion:"Create a Named Version",cancel:"Cancel",create:"Create",updateNamedVersion:"Update a Named Version",update:"Update",view:"View",messageFailedGetNamedVersions:"Could not get Named Versions. Please try again later.",messageNoNamedVersions:"There are no Named Versions created. To create first go to Changes.",messageFailedGetChanges:"Could not get changes. Please try again later.",messageNoChanges:"There are no changes synchronized.",messageVersionCreated:'Named Version "{{name}}" was successfully created.',messageVersionNameExists:"Named Version with the same name already exists.",messageInsufficientPermissionsToCreateVersion:"You do not have the required permissions to create a Named Version.",messageCouldNotCreateVersion:"Could not create a Named Version. Please try again later.",messageVersionUpdated:'Named Version "{{name}}" was successfully updated.',messageInsufficientPermissionsToUpdateVersion:"You do not have the required permissions to update a Named Version.",messageCouldNotUpdateVersion:"Could not update a Named Version. Please try again later.",messageValueTooLong:"The value exceeds allowed {{length}} characters."};var F;!function(e){e[e.Versions=0]="Versions",e[e.Changes=1]="Changes"}(F||(F={}));const I=e=>{const{accessToken:t,apiOverrides:n,imodelId:s,stringsOverrides:a=O,log:i,onViewClick:r,currentTab:o=F.Versions,onTabChange:l}=e,u=m.useMemo((()=>new E(t,null==n?void 0:n.serverEnvironmentPrefix,i)),[t,null==n?void 0:n.serverEnvironmentPrefix,i]),g=m.useMemo((()=>new f(t,null==n?void 0:n.serverEnvironmentPrefix,i)),[t,null==n?void 0:n.serverEnvironmentPrefix,i]),[h,v]=m.useState(o);m.useEffect((()=>{v(o)}),[o]);const[p,C]=m.useState(),[b,V]=m.useState(x.NotStarted),[w,y]=m.useState(),[T,k]=m.useState(x.NotStarted),I=m.useCallback((e=>{v(e),null==l||l(e)}),[l]),_=m.useCallback((e=>{V(x.InProgress),u.get(s,{top:100,skip:e}).then((e=>{V(x.Finished),C((t=>[...null!=t?t:[],...e]))})).catch((()=>V(x.Failed)))}),[s,u]),D=m.useCallback((()=>{p&&p.length%100!=0||_(null==p?void 0:p.length)}),[_,p]),j=m.useCallback((()=>{C(void 0),_()}),[_]);m.useEffect((()=>{b===x.NotStarted&&_()}),[_,b]);const U=m.useCallback((()=>{w&&w.length%100!=0||(k(x.InProgress),g.get(s,{top:100,skip:null==w?void 0:w.length}).then((e=>{k(x.Finished),y([...null!=w?w:[],...e])})).catch((()=>k(x.Failed))))}),[g,w,s]);m.useEffect((()=>{h===F.Changes&&T===x.NotStarted&&U()}),[T,h,U]);const A=m.useCallback((()=>{I(F.Versions),j(),y(void 0),k(x.NotStarted)}),[I,j]),L=m.useMemo((()=>[...null!=p?p:[]].sort(((e,t)=>new Date(e.createdDateTime).valueOf()<new Date(t.createdDateTime).valueOf()?1:-1))[0]),[p]);return m.createElement(d,{theme:"inherit"},m.createElement(N,{accessToken:t,imodelId:s,apiOverrides:n,stringsOverrides:a,log:i},m.createElement("div",null,m.createElement(c,{labels:[a.namedVersions,a.changes],activeIndex:h,onTabSelected:e=>I(e),type:"borderless"}),h===F.Versions&&m.createElement(S,{versions:null!=p?p:[],status:b,onVersionUpdated:j,loadMoreVersions:D,onViewClick:r}),h===F.Changes&&m.createElement(P,{changesets:null!=w?w:[],status:T,loadMoreChanges:U,onVersionCreated:A,latestVersion:L}))))};export{I as ManageVersions,F as ManageVersionsTabs}; |
export declare enum HttpHeaderNames { | ||
Authorization = "Authorization", | ||
ContentType = "Content-Type", | ||
Prefer = "Prefer" | ||
Prefer = "Prefer", | ||
Accept = "Accept" | ||
} | ||
@@ -6,0 +7,0 @@ export declare type ApimCodes = "NamedVersionExists" | "InsufficientPermissions"; |
@@ -5,6 +5,18 @@ { | ||
"repository": "https://github.com/iTwin/admin-components-react/tree/main/packages/modules/manage-versions", | ||
"version": "0.8.0", | ||
"version": "1.0.0", | ||
"main": "cjs/index.js", | ||
"module": "esm/index.js", | ||
"types": "cjs/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./esm/index.d.ts", | ||
"default": "./esm/index.js" | ||
}, | ||
"require": { | ||
"types": "./cjs/index.d.ts", | ||
"default": "./cjs/index.js" | ||
} | ||
} | ||
}, | ||
"author": "Bentley Systems, Inc.", | ||
@@ -24,5 +36,4 @@ "license": "MIT", | ||
"dependencies": { | ||
"@itwin/itwinui-css": "^0.9.0", | ||
"@itwin/itwinui-icons-react": "^1.2.0", | ||
"@itwin/itwinui-react": "^1.35.0", | ||
"@itwin/itwinui-icons-react": "^2.2.0", | ||
"@itwin/itwinui-react": "^2.11.4", | ||
"classnames": "^2.2.6" | ||
@@ -36,3 +47,3 @@ }, | ||
"@types/react-dom": "^17.0.0", | ||
"@types/react-table": "^7.0.29", | ||
"@types/react-table": "~7.7.14", | ||
"@typescript-eslint/eslint-plugin": "^4.20.0", | ||
@@ -53,3 +64,3 @@ "@typescript-eslint/parser": "^4.20.0", | ||
"node-sass": "^6.0.0", | ||
"postcss": "^8.2.8", | ||
"postcss": "8.4.20", | ||
"prettier": "^2.0.5", | ||
@@ -56,0 +67,0 @@ "react": "^17.0.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
68238
5
909
933
2
+ Added@itwin/itwinui-icons-react@2.9.0(transitive)
+ Added@itwin/itwinui-illustrations-react@2.1.0(transitive)
+ Added@itwin/itwinui-react@2.12.26(transitive)
- Removed@itwin/itwinui-css@^0.9.0
- Removed@itwin/itwinui-css@0.63.30.9.0(transitive)
- Removed@itwin/itwinui-icons-react@1.16.0(transitive)
- Removed@itwin/itwinui-illustrations-react@1.3.1(transitive)
- Removed@itwin/itwinui-react@1.48.3(transitive)
Updated@itwin/itwinui-react@^2.11.4