{{#explorer-container hideSchema=hideSchema everEditing=everEditing}} {{#if disallow}}

{{i18n "explorer.admins_only"}}

{{else}} {{#unless selectedQueryId}}
{{text-field value=search placeholderKey="explorer.search_placeholder"}} {{d-button action="showCreate" icon="plus" class="no-text btn-right"}} {{d-button action="importQuery" label="explorer.import.label" icon="upload btn-right"}}
{{#if showCreate}}
{{text-field value=newQueryName placeholderKey="explorer.create_placeholder"}} {{d-button action="create" disabled=createDisabled label="explorer.create" icon="plus" class="btn-primary"}}
{{/if}} {{#if othersDirty}}
{{fa-icon "warning"}} {{i18n "explorer.others_dirty"}}
{{/if}} {{/unless}} {{#if content.length}} {{#unless selectedItem.fake}}
{{#if selectedItem}} {{#if editing}}
{{d-button action="goHome" icon="chevron-left" class="previous"}}
{{text-field value=selectedItem.name}}
{{textarea value=selectedItem.description placeholder=(i18n "explorer.description_placeholder")}}
{{else}}
{{d-button action="goHome" icon="chevron-left" class="previous"}}

{{selectedItem.name}} {{#unless editDisabled}} {{d-icon "pencil"}} {{/unless}}

{{selectedItem.description}}
{{/if}} {{! the SQL editor will show the first time you }} {{#if everEditing}}
{{explorer-schema schema=schema hideSchema=hideSchema}}
{{ace-editor content=selectedItem.sql mode="sql"}}
{{else}}
{{hljs-code-view value=selectedItem.sql codeClass="sql"}}
{{/if}}
{{#if everEditing}} {{d-button action="save" label="explorer.save" disabled=saveDisabled class="btn-primary"}} {{else}} {{#unless editDisabled}} {{d-button action="editName" label="explorer.edit" icon="pencil" class="btn-primary"}} {{/unless}} {{/if}} {{d-button action="download" label="explorer.export" disabled=runDisabled icon="download"}}
{{#if selectedItem.destroyed}} {{d-button action="recover" class="" icon="undo" label="explorer.recover"}} {{else}} {{#if everEditing}} {{d-button action="discard" class="btn-danger" icon="undo" label="explorer.undo" disabled=saveDisabled}} {{/if}} {{#unless editDisabled}} {{d-button action="destroy" class="btn-danger" icon="trash" label="explorer.delete"}} {{/unless}} {{/if}}
{{/if}}
{{#if selectedItem.hasParams}}
{{#each selectedItem.param_info as |pinfo|}} {{param-input params=selectedItem.params info=pinfo}} {{!
{{param-field params=selectedItem.params pname=pinfo.identifier type=pinfo.type} {{pinfo.identifier}
}} {{/each}}
{{/if}} {{#if runDisabled}} {{#if saveDisabled}} {{d-button label="explorer.run" disabled="true" class="btn-primary"}} {{else}} {{d-button action="saverun" label="explorer.saverun"}} {{/if}} {{else}} {{d-button action="run" label="explorer.run" disabled=runDisabled class="btn-primary" type="submit"}} {{/if}}

{{/unless}} {{conditional-loading-spinner condition=loading}} {{#unless selectedItem.fake}} {{#if results}}
{{#if showResults}} {{query-result query=selectedItem content=results}} {{else}} {{#each results.errors as |err|}}
{{~err}}
{{/each}} {{/if}}
{{/if}} {{/unless}} {{#if showRecentQueries}}
{{#each filteredContent as |query|}} {{else}}
{{i18n "explorer.no_search_results"}} {{/each}}
{{directory-toggle field="name" labelKey="explorer.query_name" order=order asc=asc}}
{{directory-toggle field="username" labelKey="explorer.query_user" order=order asc=asc}}
{{directory-toggle field="last_run_at" labelKey="explorer.query_time" order=order asc=asc}}
{{query.name}} {{query.description}} {{#if query.username}} {{query.username}} {{/if}} {{#if query.last_run_at}} {{bound-date query.last_run_at}} {{else}} {{bound-date query.created_at}} {{/if}}
{{/if}}
{{/if}} {{/if}} {{/explorer-container}}