1import{g as D,a as w,i as k,r as b,j as t,e,c,h as a,F as d,ao as s,f as F}from"./index-c165adff.js";const A={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"PublishTextbookConfig"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"publishTextbookConfig"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"publishedAt"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:124,source:{body:` 2 mutation PublishTextbookConfig($id: String!) { 3 publishTextbookConfig(id: $id) { 4 id 5 publishedAt 6 } 7 } 8`,name:"GraphQL request",locationOffset:{line:1,column:1}}}},u={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"query",name:{kind:"Name",value:"QueryTextbookConfigs"},variableDefinitions:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"textbookConfigs"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"publishedAt"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"updatedAt"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"createdByUser"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]}]}}]}}]}}],loc:{start:0,end:161,source:{body:` 9 query QueryTextbookConfigs { 10 textbookConfigs { 11 id 12 name 13 publishedAt 14 updatedAt 15 createdByUser { 16 name 17 } 18 } 19 } 20`,name:"GraphQL request",locationOffset:{line:1,column:1}}}},L={kind:"Document",definitions:[{kind:"OperationDefinition",operation:"mutation",name:{kind:"Name",value:"DeleteTextbookConfig"},variableDefinitions:[{kind:"VariableDefinition",variable:{kind:"Variable",name:{kind:"Name",value:"id"}},type:{kind:"NonNullType",type:{kind:"NamedType",name:{kind:"Name",value:"String"}}},directives:[]}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"deleteTextbookConfig"},arguments:[{kind:"Argument",name:{kind:"Name",value:"id"},value:{kind:"Variable",name:{kind:"Name",value:"id"}}}],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:104,source:{body:` 21 mutation DeleteTextbookConfig($id: String!) { 22 deleteTextbookConfig(id: $id) { 23 id 24 } 25 } 26`,name:"GraphQL request",locationOffset:{line:1,column:1}}}},E=()=>{const{loading:g,data:o}=D(u),{hasRole:h}=w(),[f,{loading:p}]=k(A,{onCompleted:()=>{s.toast.success("Published textbook config")},onError:n=>{s.toast.error(n.message)},refetchQueries:[{query:u}],awaitRefetchQueries:!0}),[v,{loading:N}]=k(L,{onCompleted:()=>{s.toast.success("Deleted textbook config")},onError:n=>{s.toast.error(n.message)},refetchQueries:[{query:u}],awaitRefetchQueries:!0}),[m,x]=b.useState(!1),y=g||N,C=p,S=({publishedAt:n,updatedAt:i})=>!!n||new Date(i).getTime()+30*24*60*60*1e3>Date.now();return t(d,{children:[e(F.Metadata,{title:"Textbook Config",description:"Textbook Configuration Listing page"}),e("h1",{children:"Textbook Config"}),e("div",{css:c` 27 .btn { 28 display: inline-block; 29 padding: 11px 1rem; 30 border-radius: 5px; 31 transition: border-color 0.15s ease-in-out, 32 box-shadow 0.15s ease-in-out; 33 cursor: pointer; 34 font-size: 16px; 35 line-height: 24px; 36 vertical-align: unset; 37 margin-bottom: 1.5rem; 38 } 39 `,children:e("button",{className:"btn btn-primary",onClick:()=>{a.navigate(a.routes.contentModTextbookConfigNew())},children:"New Config"})}),y&&!(o!=null&&o.textbookConfigs)?e("p",{children:"Loading..."}):t(d,{children:[t("table",{className:"table-data",children:[e("thead",{children:t("tr",{children:[e("th",{children:"#"}),e("th",{children:"Name"}),e("th",{children:"Created By"}),e("th",{children:"Actions"})]})}),e("tbody",{children:o.textbookConfigs.map(n=>{const{id:i,name:l,publishedAt:r,createdByUser:T}=n;return e(b.Fragment,{children:(m||S(n))&&t("tr",{children:[t("td",{css:c` 40 white-space: nowrap; 41 `,children:[e("code",{children:e(a.Link,{to:a.routes.contentModTextbookConfigEdit({id:i}
41),children:i.substr(-6)})}),r&&" â "]}),e("td",{children:e(a.Link,{to:a.routes.contentModTextbookConfigEdit({id:i}),children:l})}),e("td",{children:T.name}),t("td",{css:c` 42 white-space: nowrap; 43 & > .btn { 44 font-size: 80%; 45 padding: 4px 8px; 46 } 47 `,children:[e("a",{className:"btn btn-secondary",target:"_blank",href:a.routes.createTextbook({langCode:"en",config:i}),rel:"noreferrer",children:"Try"})," ",e("button",{className:"btn btn-secondary",onClick:()=>{a.navigate(a.routes.contentModTextbookConfigNew({copy:i}))},children:"Copy"}),!r&&t(d,{children:[" ",e("button",{className:"btn btn-secondary",onClick:async()=>{confirm(`Delete: ${l}`)&&await v({variables:{id:i}})},children:"Delete"})]}),h("admin")&&!r&&t(d,{children:[" ",e("button",{className:"btn btn-secondary",disabled:C,onClick:async()=>{confirm(`Publish: ${l}`)&&await f({variables:{id:i}})},children:"Publish"})]})]})]})},i)})})]}),e("button",{className:"btn btn-secondary",onClick:()=>{x(n=>!n)},children:m?"Hide Old":"Show All"})]})]})};export{L as DELETE,A as PUBLISH,u as QUERY,E as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.