mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 02:15:46 +08:00
f13ec11c64
* Added scopes UI * Create scopes when creating a new API key * Show scopes on the API key show route * Apply scopes on API requests * Extend scopes from plugins * Add missing scopes. A mapping can be associated with multiple controller actions * Only send scopes if the use global key option is disabled. Use the discourse plugin registry to add new scopes * Add not null validations and index for api_key_id * Annotate model * DEV: Move default mappings to ApiKeyScope * Remove unused attribute and improve UI for existing keys * Support multiple parameters separated by a comma
71 lines
2.2 KiB
Handlebars
71 lines
2.2 KiB
Handlebars
{{#link-to "adminApiKeys.index" class="go-back"}}
|
|
{{d-icon "arrow-left"}}
|
|
{{i18n "admin.api.all_api_keys"}}
|
|
{{/link-to}}
|
|
|
|
<div class="api-key">
|
|
{{#if model.id}}
|
|
{{#admin-form-row label="admin.api.key"}}
|
|
<div>{{model.key}}</div>
|
|
{{/admin-form-row}}
|
|
{{#admin-form-row}}
|
|
{{i18n "admin.api.not_shown_again"}}
|
|
{{/admin-form-row}}
|
|
{{#admin-form-row}}
|
|
{{d-button icon="angle-right" label="admin.api.continue" action=(action "continue") class="btn-primary"}}
|
|
{{/admin-form-row}}
|
|
{{else}}
|
|
{{#admin-form-row label="admin.api.description"}}
|
|
{{input value=model.description maxlength="255" placeholder=(i18n "admin.api.description_placeholder")}}
|
|
{{/admin-form-row}}
|
|
|
|
{{#admin-form-row label="admin.api.user_mode"}}
|
|
{{combo-box content=userModes value=userMode onChange=(action "changeUserMode")}}
|
|
{{/admin-form-row}}
|
|
|
|
{{#if showUserSelector}}
|
|
{{#admin-form-row label="admin.api.user"}}
|
|
{{user-selector single="true"
|
|
usernames=model.username
|
|
placeholderKey="admin.api.user_placeholder"
|
|
}}
|
|
{{/admin-form-row}}
|
|
{{/if}}
|
|
|
|
{{#admin-form-row label="admin.api.use_global_key"}}
|
|
{{input type="checkbox" checked=useGlobalKey}}
|
|
{{/admin-form-row}}
|
|
|
|
{{#unless useGlobalKey}}
|
|
{{#each-in scopes as |resource actions|}}
|
|
<table class="scopes-table">
|
|
<thead>
|
|
<tr>
|
|
<td><b>{{resource}}</b></td>
|
|
<td></td>
|
|
<td>{{i18n "admin.api.scopes.optional_allowed_parameters"}}</td>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
{{#each actions as |act|}}
|
|
<tr>
|
|
<td>{{input type="checkbox" checked=act.selected}}</td>
|
|
<td><b>{{act.name}}</b></td>
|
|
<td>
|
|
{{#each act.params as |p|}}
|
|
<div>
|
|
{{input maxlength="255" value=(get act p) placeholder=p}}
|
|
</div>
|
|
{{/each}}
|
|
</td>
|
|
</tr>
|
|
{{/each}}
|
|
</tbody>
|
|
</table>
|
|
{{/each-in}}
|
|
{{/unless}}
|
|
|
|
{{d-button icon="check" label="admin.api.save" action=(action "save") class="btn-primary" disabled=saveDisabled}}
|
|
{{/if}}
|
|
</div>
|