c.81a49b25.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import{a as s,H as i,e,t,L as a,N as o,at as r,a0 as n,a1 as l,$ as c,o as h,au as d,ai as p,s as m,d as _,r as v,n as u}from"./main-ad130be7.js";import{c as y}from"./c.4a97632a.js";import"./c.f1291e50.js";import"./c.2ee83bd0.js";import{s as g}from"./c.4266acdb.js";import{f,a as $}from"./c.fe747ba2.js";import{m as b}from"./c.f6611997.js";import{u as x}from"./c.25ed1ae4.js";import"./c.5d3ce9d6.js";import"./c.82e03b89.js";import"./c.743a15a1.js";import"./c.710a50fc.js";import"./c.8e28b461.js";let k=s([u("hacs-update-dialog")],(function(s,i){class u extends i{constructor(...i){super(...i),s(this)}}return{F:u,d:[{kind:"field",decorators:[e()],key:"repository",value:void 0},{kind:"field",decorators:[e({type:Boolean})],key:"_updating",value:()=>!1},{kind:"field",decorators:[e()],key:"_error",value:void 0},{kind:"field",decorators:[e({attribute:!1})],key:"_releaseNotes",value:()=>[]},{kind:"field",decorators:[t()],key:"_repository",value:void 0},{kind:"method",key:"firstUpdated",value:async function(s){a(o(u.prototype),"firstUpdated",this).call(this,s),this._repository=await f(this.hass,this.repository),this._repository&&("commit"!==this._repository.version_or_commit&&(this._releaseNotes=await r(this.hass,String(this._repository.id))),n(this.hass,(s=>this._error=s),l.ERROR))}},{kind:"method",key:"render",value:function(){var s;return this.active&&this._repository?c`
  2. <hacs-dialog
  3. .active=${this.active}
  4. .title=${this.hacs.localize("dialog_update.title")}
  5. .hass=${this.hass}
  6. >
  7. <div class=${h({content:!0,narrow:this.narrow})}>
  8. <p class="message">
  9. ${this.hacs.localize("dialog_update.message",{name:this._repository.name})}
  10. </p>
  11. <div class="version-container">
  12. <div class="version-element">
  13. <span class="version-number">${this._repository.installed_version}</span>
  14. <small class="version-text">${this.hacs.localize("dialog_update.downloaded_version")}</small>
  15. </div>
  16. <span class="version-separator">
  17. <ha-svg-icon
  18. .path=${d}
  19. ></ha-svg-icon>
  20. </span>
  21. <div class="version-element">
  22. <span class="version-number">${this._repository.available_version}</span>
  23. <small class="version-text">${this.hacs.localize("dialog_update.available_version")}</small>
  24. </div>
  25. </div>
  26. </div>
  27. ${this._releaseNotes.length>0?this._releaseNotes.map((s=>c`
  28. <ha-expansion-panel
  29. .header=${s.name&&s.name!==s.tag?`${s.tag}: ${s.name}`:s.tag}
  30. outlined
  31. ?expanded=${1===this._releaseNotes.length}
  32. >
  33. ${s.body?b.html(s.body,this._repository):this.hacs.localize("dialog_update.no_info")}
  34. </ha-expansion-panel>
  35. `)):""}
  36. ${this._repository.can_download?"":c`<ha-alert alert-type="error" .rtl=${y(this.hass)}>
  37. ${this.hacs.localize("confirm.home_assistant_version_not_correct",{haversion:this.hass.config.version,minversion:this._repository.homeassistant})}
  38. </ha-alert>`}
  39. ${"integration"===this._repository.category?c`<p>${this.hacs.localize("dialog_download.restart")}</p>`:""}
  40. ${null!==(s=this._error)&&void 0!==s&&s.message?c`<ha-alert alert-type="error" .rtl=${y(this.hass)}>
  41. ${this._error.message}
  42. </ha-alert>`:""}
  43. </div>
  44. <mwc-button
  45. slot="primaryaction"
  46. ?disabled=${!this._repository.can_download}
  47. @click=${this._updateRepository}
  48. raised
  49. >
  50. ${this._updating?c`<ha-circular-progress active size="small"></ha-circular-progress>`:this.hacs.localize("common.update")}
  51. </mwc-button
  52. >
  53. <div class="secondary" slot="secondaryaction">
  54. <hacs-link .url=${this._getChanglogURL()||""}>
  55. <mwc-button>${this.hacs.localize("dialog_update.changelog")}
  56. </mwc-button>
  57. </hacs-link>
  58. <hacs-link .url="https://github.com/${this._repository.full_name}">
  59. <mwc-button>${this.hacs.localize("common.repository")}
  60. </mwc-button>
  61. </hacs-link>
  62. </div>
  63. </hacs-dialog>
  64. `:c``}},{kind:"method",key:"_updateRepository",value:async function(){this._updating=!0,"commit"!==this._repository.version_or_commit?await $(this.hass,String(this._repository.id),this._repository.available_version):await $(this.hass,String(this._repository.id)),"plugin"===this._repository.category&&"storage"===this.hacs.info.lovelace_mode&&await x(this.hass,this._repository,this._repository.available_version),this._updating=!1,this.dispatchEvent(new Event("hacs-dialog-closed",{bubbles:!0,composed:!0})),"plugin"===this._repository.category&&g(this,{title:this.hacs.localize("common.reload"),text:c`${this.hacs.localize("dialog.reload.description")}<br />${this.hacs.localize("dialog.reload.confirm")}`,dismissText:this.hacs.localize("common.cancel"),confirmText:this.hacs.localize("common.reload"),confirm:()=>{p.location.href=p.location.href}})}},{kind:"method",key:"_getChanglogURL",value:function(){return"commit"===this._repository.version_or_commit?`https://github.com/${this._repository.full_name}/compare/${this._repository.installed_version}...${this._repository.available_version}`:`https://github.com/${this._repository.full_name}/releases`}},{kind:"get",static:!0,key:"styles",value:function(){return[m,_,v`
  65. .content {
  66. width: 360px;
  67. display: contents;
  68. }
  69. ha-expansion-panel {
  70. margin: 8px 0;
  71. }
  72. ha-expansion-panel[expanded] {
  73. padding-bottom: 16px;
  74. }
  75. .secondary {
  76. display: flex;
  77. }
  78. .message {
  79. text-align: center;
  80. margin: 0;
  81. }
  82. .version-container {
  83. margin: 24px 0 12px 0;
  84. width: 360px;
  85. min-width: 100%;
  86. max-width: 100%;
  87. display: flex;
  88. flex-direction: row;
  89. }
  90. .version-element {
  91. display: flex;
  92. flex-direction: column;
  93. flex: 1;
  94. padding: 0 12px;
  95. text-align: center;
  96. }
  97. .version-text {
  98. color: var(--secondary-text-color);
  99. }
  100. .version-number {
  101. font-size: 1.5rem;
  102. margin-bottom: 4px;
  103. }
  104. `]}}]}}),i);export{k as HacsUpdateDialog};