c.167d87ac.js 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. import{a as o,h as t,e,$ as i,w as a,r as s,n as r,t as n,L as h,N as l,ai as c,a2 as d,a3 as p,m as u,c as y,aN as m,aO as f,aP as v,E as _,aQ as g,z as b,aR as k,aS as w,aT as $,aU as x,aV as z,aW as j,ah as R,am as L,ar as S,as as F,aX as I,d as P}from"./main-bfa41146.js";import"./c.09384688.js";import{e as C}from"./c.50bfd408.js";import"./c.dc6e12fb.js";import{r as E}from"./c.6e0bb230.js";import{g as T}from"./c.f2bb3724.js";import{s as U}from"./c.70483bd2.js";import"./c.d1eec9d1.js";import{f as D}from"./c.fe747ba2.js";import{m as K}from"./c.cae7ccdd.js";import"./c.886b012a.js";import"./c.aa41e25c.js";import"./c.497c36cc.js";import"./c.8e28b461.js";import"./c.6fe7dd6c.js";import"./c.a7d20849.js";import"./c.48057b49.js";import"./c.743a15a1.js";o([r("hass-subpage")],(function(o,t){return{F:class extends t{constructor(...t){super(...t),o(this)}},d:[{kind:"field",decorators:[e({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[e()],key:"header",value:void 0},{kind:"field",decorators:[e({type:Boolean,attribute:"main-page"})],key:"mainPage",value:()=>!1},{kind:"field",decorators:[e({type:String,attribute:"back-path"})],key:"backPath",value:void 0},{kind:"field",decorators:[e({type:Boolean,reflect:!0})],key:"narrow",value:()=>!1},{kind:"field",decorators:[e({type:Boolean})],key:"supervisor",value:()=>!1},{kind:"field",decorators:[E(".content")],key:"_savedScrollPos",value:void 0},{kind:"method",key:"render",value:function(){var o;return i`
  2. <div class="toolbar">
  3. ${this.mainPage||null!==(o=history.state)&&void 0!==o&&o.root?i`
  4. <ha-menu-button
  5. .hassio=${this.supervisor}
  6. .hass=${this.hass}
  7. .narrow=${this.narrow}
  8. ></ha-menu-button>
  9. `:this.backPath?i`
  10. <a href=${this.backPath}>
  11. <ha-icon-button-arrow-prev
  12. .hass=${this.hass}
  13. ></ha-icon-button-arrow-prev>
  14. </a>
  15. `:i`
  16. <ha-icon-button-arrow-prev
  17. .hass=${this.hass}
  18. @click=${this._backTapped}
  19. ></ha-icon-button-arrow-prev>
  20. `}
  21. <div class="main-title">${this.header}</div>
  22. <slot name="toolbar-icon"></slot>
  23. </div>
  24. <div class="content" @scroll=${this._saveScrollPos}><slot></slot></div>
  25. `}},{kind:"method",decorators:[a({passive:!0})],key:"_saveScrollPos",value:function(o){this._savedScrollPos=o.target.scrollTop}},{kind:"method",key:"_backTapped",value:function(){history.back()}},{kind:"get",static:!0,key:"styles",value:function(){return s`
  26. :host {
  27. display: block;
  28. height: 100%;
  29. background-color: var(--primary-background-color);
  30. }
  31. :host([narrow]) {
  32. width: 100%;
  33. position: fixed;
  34. }
  35. .toolbar {
  36. display: flex;
  37. align-items: center;
  38. font-size: 20px;
  39. height: var(--header-height);
  40. padding: 0 16px;
  41. pointer-events: none;
  42. background-color: var(--app-header-background-color);
  43. font-weight: 400;
  44. color: var(--app-header-text-color, white);
  45. border-bottom: var(--app-header-border-bottom, none);
  46. box-sizing: border-box;
  47. }
  48. .toolbar a {
  49. color: var(--sidebar-text-color);
  50. text-decoration: none;
  51. }
  52. ha-menu-button,
  53. ha-icon-button-arrow-prev,
  54. ::slotted([slot="toolbar-icon"]) {
  55. pointer-events: auto;
  56. color: var(--sidebar-icon-color);
  57. }
  58. .main-title {
  59. margin: 0 0 0 24px;
  60. line-height: 20px;
  61. flex-grow: 1;
  62. }
  63. .content {
  64. position: relative;
  65. width: 100%;
  66. height: calc(100% - 1px - var(--header-height));
  67. overflow-y: auto;
  68. overflow: auto;
  69. -webkit-overflow-scrolling: touch;
  70. }
  71. `}}]}}),t);let M=o([r("hacs-repository-panel")],(function(o,t){class a extends t{constructor(...t){super(...t),o(this)}}return{F:a,d:[{kind:"field",decorators:[e({attribute:!1})],key:"hacs",value:void 0},{kind:"field",decorators:[e({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[e({attribute:!1})],key:"narrow",value:void 0},{kind:"field",decorators:[e({attribute:!1})],key:"isWide",value:void 0},{kind:"field",decorators:[e({attribute:!1})],key:"route",value:void 0},{kind:"field",decorators:[e({attribute:!1})],key:"_repository",value:void 0},{kind:"field",decorators:[n()],key:"_error",value:void 0},{kind:"method",key:"connectedCallback",value:function(){h(l(a.prototype),"connectedCallback",this).call(this),document.body.addEventListener("keydown",this._generateMyLink)}},{kind:"method",key:"disconnectedCallback",value:function(){h(l(a.prototype),"disconnectedCallback",this).call(this),document.body.removeEventListener("keydown",this._generateMyLink)}},{kind:"field",key:"_generateMyLink",value(){return o=>{if(!(o.ctrlKey||o.shiftKey||o.metaKey||o.altKey)&&"m"===o.key&&c.location.pathname.startsWith("/hacs/repository/")){if(!this._repository)return;const o=new URLSearchParams({redirect:"hacs_repository",owner:this._repository.full_name.split("/")[0],repository:this._repository.full_name.split("/")[1],category:this._repository.category});window.open(`https://my.home-assistant.io/create-link/?${o.toString()}`,"_blank")}}}},{kind:"method",key:"firstUpdated",value:async function(o){h(l(a.prototype),"firstUpdated",this).call(this,o);const t=C();if(Object.entries(t).length){let o;const e=`${t.owner}/${t.repository}`;if(o=this.hacs.repositories.find((o=>o.full_name.toLocaleLowerCase()===e.toLocaleLowerCase())),!o&&t.category){if(!await U(this,{title:this.hacs.localize("my.add_repository_title"),text:this.hacs.localize("my.add_repository_description",{repository:e}),confirmText:this.hacs.localize("common.add"),dismissText:this.hacs.localize("common.cancel")}))return void(this._error=this.hacs.localize("my.repository_not_found",{repository:e}));try{await d(this.hass,e,t.category),this.hacs.repositories=await p(this.hass),o=this.hacs.repositories.find((o=>o.full_name.toLocaleLowerCase()===e.toLocaleLowerCase()))}catch(o){return void(this._error=o)}}o?this._fetchRepository(String(o.id)):this._error=this.hacs.localize("my.repository_not_found",{repository:e})}else{const o=this.route.path.indexOf("/",1),t=this.route.path.substr(o+1);if(!t)return void(this._error="Missing repositoryId from route");this._fetchRepository(t)}}},{kind:"method",key:"updated",value:function(o){h(l(a.prototype),"updated",this).call(this,o),o.has("repositories")&&this._repository&&this._fetchRepository()}},{kind:"method",key:"_fetchRepository",value:async function(o){try{this._repository=await D(this.hass,o||String(this._repository.id))}catch(o){this._error=null==o?void 0:o.message}}},{kind:"field",key:"_getAuthors",value:()=>u((o=>{const t=[];if(!o.authors)return t;if(o.authors.forEach((o=>t.push(o.replace("@","")))),0===t.length){const e=o.full_name.split("/")[0];if(["custom-cards","custom-components","home-assistant-community-themes"].includes(e))return t;t.push(e)}return t}))},{kind:"method",key:"render",value:function(){if(this._error)return i`<hass-error-screen .error=${this._error}></hass-error-screen>`;if(!this._repository)return i`<hass-loading-screen></hass-loading-screen>`;const o=this._getAuthors(this._repository);return i`
  72. <hass-subpage
  73. .hass=${this.hass}
  74. .narrow=${this.narrow}
  75. .route=${this.route}
  76. .header=${this._repository.name}
  77. hasFab
  78. >
  79. <ha-icon-overflow-menu
  80. slot="toolbar-icon"
  81. narrow
  82. .hass=${this.hass}
  83. .items=${[{path:y,label:this.hacs.localize("common.repository"),action:()=>c.open(`https://github.com/${this._repository.full_name}`,"_blank","noreferrer=true")},{path:m,label:this.hacs.localize("repository_card.update_information"),action:()=>this._refreshReopsitoryInfo()},{path:f,label:this.hacs.localize("repository_card.redownload"),action:()=>this._downloadRepositoryDialog(),hideForUninstalled:!0},{category:"plugin",hideForUninstalled:!0,path:v,label:this.hacs.localize("repository_card.open_source"),action:()=>c.open(`/hacsfiles/${this._repository.local_path.split("/").pop()}/${this._repository.file_name}`,"_blank","noreferrer=true")},{path:_,label:this.hacs.localize("repository_card.open_issue"),action:()=>c.open(`https://github.com/${this._repository.full_name}/issues`,"_blank","noreferrer=true")},{hideForId:"172733314",path:g,label:this.hacs.localize("repository_card.report"),hideForUninstalled:!0,action:()=>c.open(`https://github.com/hacs/integration/issues/new?assignees=ludeeus&labels=flag&template=removal.yml&repo=${this._repository.full_name}&title=Request for removal of ${this._repository.full_name}`,"_blank","noreferrer=true")},{hideForId:"172733314",hideForUninstalled:!0,path:b,label:this.hacs.localize("common.remove"),action:()=>this._removeRepositoryDialog()}].filter((o=>(!o.category||this._repository.category===o.category)&&(!o.hideForId||String(this._repository.id)!==o.hideForId)&&(!o.hideForUninstalled||this._repository.installed_version)))}
  84. >
  85. </ha-icon-overflow-menu>
  86. <div class="content">
  87. <div class="chips">
  88. ${this._repository.installed?i`
  89. <ha-chip title="${this.hacs.localize("dialog_info.version_installed")}" hasIcon>
  90. <ha-svg-icon slot="icon" .path=${k}></ha-svg-icon>
  91. ${this._repository.installed_version}
  92. </ha-chip>
  93. `:""}
  94. ${o?o.map((o=>i`<hacs-link .url="https://github.com/${o}">
  95. <ha-chip title="${this.hacs.localize("dialog_info.author")}" hasIcon>
  96. <ha-svg-icon slot="icon" .path=${w}></ha-svg-icon>
  97. @${o}
  98. </ha-chip>
  99. </hacs-link>`)):""}
  100. ${this._repository.downloads?i` <ha-chip hasIcon title="${this.hacs.localize("dialog_info.downloads")}">
  101. <ha-svg-icon slot="icon" .path=${$}></ha-svg-icon>
  102. ${this._repository.downloads}
  103. </ha-chip>`:""}
  104. <ha-chip title="${this.hacs.localize("dialog_info.stars")}" hasIcon>
  105. <ha-svg-icon slot="icon" .path=${x}></ha-svg-icon>
  106. ${this._repository.stars}
  107. </ha-chip>
  108. <hacs-link .url="https://github.com/${this._repository.full_name}/issues">
  109. <ha-chip title="${this.hacs.localize("dialog_info.open_issues")}" hasIcon>
  110. <ha-svg-icon slot="icon" .path=${z}></ha-svg-icon>
  111. ${this._repository.issues}
  112. </ha-chip>
  113. </hacs-link>
  114. </div>
  115. ${K.html(this._repository.additional_info||this.hacs.localize("dialog_info.no_info"),this._repository)}
  116. </div>
  117. ${this._repository.installed_version?"":i`<ha-fab
  118. .label=${this.hacs.localize("common.download")}
  119. .extended=${!this.narrow}
  120. @click=${this._downloadRepositoryDialog}
  121. >
  122. <ha-svg-icon slot="icon" .path=${j}></ha-svg-icon>
  123. </ha-fab>`}
  124. </hass-subpage>
  125. `}},{kind:"method",key:"_downloadRepositoryDialog",value:function(){this.dispatchEvent(new CustomEvent("hacs-dialog",{detail:{type:"download",repository:this._repository.id},bubbles:!0,composed:!0}))}},{kind:"method",key:"_removeRepositoryDialog",value:async function(){if("integration"===this._repository.category&&this._repository.config_flow){if((await T(this.hass)).some((o=>o.domain===this._repository.domain))){if(await U(this,{title:this.hacs.localize("dialog.configured.title"),text:this.hacs.localize("dialog.configured.message",{name:this._repository.name}),dismissText:this.hacs.localize("common.ignore"),confirmText:this.hacs.localize("common.navigate"),confirm:()=>{R("/config/integrations",{replace:!0})}}))return}}this.dispatchEvent(new CustomEvent("hacs-dialog",{detail:{type:"progress",title:this.hacs.localize("dialog.remove.title"),confirmText:this.hacs.localize("dialog.remove.title"),content:this.hacs.localize("dialog.remove.message",{name:this._repository.name}),confirm:async()=>{await this._repositoryRemove()}},bubbles:!0,composed:!0}))}},{kind:"method",key:"_repositoryRemove",value:async function(){var o;if("plugin"===this._repository.category&&"yaml"!==(null===(o=this.hacs.info)||void 0===o?void 0:o.lovelace_mode)){(await L(this.hass)).filter((o=>o.url.startsWith(`/hacsfiles/${this._repository.full_name.split("/")[1]}/${this._repository.file_name}`))).forEach((async o=>{await S(this.hass,String(o.id))}))}await F(this.hass,String(this._repository.id)),history.back()}},{kind:"method",key:"_refreshReopsitoryInfo",value:async function(){await I(this.hass,String(this._repository.id))}},{kind:"get",static:!0,key:"styles",value:function(){return[P,s`
  126. hass-loading-screen {
  127. --app-header-background-color: var(--sidebar-background-color);
  128. --app-header-text-color: var(--sidebar-text-color);
  129. height: 100vh;
  130. }
  131. hass-subpage {
  132. position: absolute;
  133. width: 100vw;
  134. }
  135. ha-svg-icon {
  136. color: var(--hcv-text-color-on-background);
  137. }
  138. ha-fab {
  139. position: fixed;
  140. float: right;
  141. right: calc(18px + env(safe-area-inset-right));
  142. bottom: calc(16px + env(safe-area-inset-bottom));
  143. z-index: 1;
  144. }
  145. ha-fab.rtl {
  146. float: left;
  147. right: auto;
  148. left: calc(18px + env(safe-area-inset-left));
  149. }
  150. .content {
  151. padding: 12px;
  152. margin-bottom: 64px;
  153. }
  154. .chips {
  155. display: flex;
  156. flex-wrap: wrap;
  157. padding-bottom: 8px;
  158. gap: 4px;
  159. }
  160. @media all and (max-width: 500px) {
  161. .content {
  162. margin: 8px 4px 64px;
  163. }
  164. }
  165. `]}}]}}),t);export{M as HacsRepositoryPanel};