mirror of
https://github.com/discourse/discourse.git
synced 2025-01-16 03:22:43 +08:00
FIX: Add back missing API key 'peek' step (#30683)
In #30096 we converted the API keys UI to follow the new admin UI guidelines. During this conversion, the step where you get a chance to copy the API key after creating, was lost due to a rebase mistake. This re-introduces it.
This commit is contained in:
parent
f4b417462b
commit
b1bae9b785
|
@ -24,6 +24,8 @@ export default class AdminConfigAreasApiKeysNew extends Component {
|
||||||
@tracked loadingScopes = false;
|
@tracked loadingScopes = false;
|
||||||
@tracked scopes = null;
|
@tracked scopes = null;
|
||||||
|
|
||||||
|
@tracked generatedApiKey = null;
|
||||||
|
|
||||||
userModes = [
|
userModes = [
|
||||||
{ id: "all", name: i18n("admin.api.all_users") },
|
{ id: "all", name: i18n("admin.api.all_users") },
|
||||||
{ id: "single", name: i18n("admin.api.single_user") },
|
{ id: "single", name: i18n("admin.api.single_user") },
|
||||||
|
@ -93,8 +95,8 @@ export default class AdminConfigAreasApiKeysNew extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.store.createRecord("api-key").save(payload);
|
const result = await this.store.createRecord("api-key").save(payload);
|
||||||
this.router.transitionTo("adminApiKeys");
|
this.generatedApiKey = result.payload.key;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
popupAjaxError(error);
|
popupAjaxError(error);
|
||||||
}
|
}
|
||||||
|
@ -148,169 +150,183 @@ export default class AdminConfigAreasApiKeysNew extends Component {
|
||||||
<template>
|
<template>
|
||||||
<BackButton @route="adminApiKeys.index" @label="admin.api_keys.back" />
|
<BackButton @route="adminApiKeys.index" @label="admin.api_keys.back" />
|
||||||
|
|
||||||
<div class="admin-config-area user-field">
|
<div class="admin-config-area">
|
||||||
<div class="admin-config-area__primary-content">
|
<div class="admin-config-area__primary-content">
|
||||||
<div class="admin-config-area-card">
|
<div class="admin-config-area-card">
|
||||||
<ConditionalLoadingSection @isLoading={{this.loadingScopes}}>
|
{{#if this.generatedApiKey}}
|
||||||
<Form
|
<div>{{i18n "admin.api.not_shown_again"}}</div>
|
||||||
@onSubmit={{this.save}}
|
<div class="generated-api-key">{{this.generatedApiKey}}</div>
|
||||||
@data={{this.formData}}
|
<DButton
|
||||||
as |form transientData|
|
@route="adminApiKeys.index"
|
||||||
>
|
@label="admin.api_keys.continue"
|
||||||
<form.Field
|
class="continue btn-danger"
|
||||||
@name="description"
|
/>
|
||||||
@title={{i18n "admin.api.description"}}
|
{{else}}
|
||||||
@format="large"
|
<ConditionalLoadingSection @isLoading={{this.loadingScopes}}>
|
||||||
@validation="required"
|
<Form
|
||||||
as |field|
|
@onSubmit={{this.save}}
|
||||||
|
@data={{this.formData}}
|
||||||
|
as |form transientData|
|
||||||
>
|
>
|
||||||
<field.Input />
|
|
||||||
</form.Field>
|
|
||||||
|
|
||||||
<form.Field
|
|
||||||
@name="user_mode"
|
|
||||||
@title={{i18n "admin.api.user_mode"}}
|
|
||||||
@format="large"
|
|
||||||
@validation="required"
|
|
||||||
as |field|
|
|
||||||
>
|
|
||||||
<field.Select as |select|>
|
|
||||||
{{#each this.userModes as |userMode|}}
|
|
||||||
<select.Option
|
|
||||||
@value={{userMode.id}}
|
|
||||||
>{{userMode.name}}</select.Option>
|
|
||||||
{{/each}}
|
|
||||||
</field.Select>
|
|
||||||
</form.Field>
|
|
||||||
|
|
||||||
{{#if (eq transientData.user_mode "single")}}
|
|
||||||
<form.Field
|
<form.Field
|
||||||
@name="user"
|
@name="description"
|
||||||
@title={{i18n "admin.api.user"}}
|
@title={{i18n "admin.api.description"}}
|
||||||
@format="large"
|
@format="large"
|
||||||
@validation="required"
|
@validation="required"
|
||||||
as |field|
|
as |field|
|
||||||
>
|
>
|
||||||
<field.Custom>
|
<field.Input />
|
||||||
<EmailGroupUserChooser
|
|
||||||
@value={{this.username}}
|
|
||||||
@onChange={{fn this.updateUsername field}}
|
|
||||||
@options={{hash
|
|
||||||
maximum=1
|
|
||||||
filterPlaceholder="admin.api.user_placeholder"
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</field.Custom>
|
|
||||||
</form.Field>
|
</form.Field>
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
<form.Field
|
<form.Field
|
||||||
@name="scope_mode"
|
@name="user_mode"
|
||||||
@title={{i18n "admin.api.scope_mode"}}
|
@title={{i18n "admin.api.user_mode"}}
|
||||||
@format="large"
|
@format="large"
|
||||||
@validation="required"
|
@validation="required"
|
||||||
as |field|
|
as |field|
|
||||||
>
|
>
|
||||||
<field.Select as |select|>
|
<field.Select as |select|>
|
||||||
{{#each this.scopeModes as |scopeMode|}}
|
{{#each this.userModes as |userMode|}}
|
||||||
<select.Option
|
<select.Option
|
||||||
@value={{scopeMode.id}}
|
@value={{userMode.id}}
|
||||||
>{{scopeMode.name}}</select.Option>
|
>{{userMode.name}}</select.Option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</field.Select>
|
</field.Select>
|
||||||
</form.Field>
|
</form.Field>
|
||||||
|
|
||||||
{{#if (eq transientData.scope_mode "granular")}}
|
{{#if (eq transientData.user_mode "single")}}
|
||||||
<h2 class="scopes-title">{{i18n "admin.api.scopes.title"}}</h2>
|
<form.Field
|
||||||
<p>{{i18n "admin.api.scopes.description"}}</p>
|
@name="user"
|
||||||
<table class="scopes-table grid">
|
@title={{i18n "admin.api.user"}}
|
||||||
<thead>
|
@format="large"
|
||||||
<tr>
|
@validation="required"
|
||||||
<td></td>
|
as |field|
|
||||||
<td></td>
|
>
|
||||||
<td>{{i18n "admin.api.scopes.allowed_urls"}}</td>
|
<field.Custom>
|
||||||
<td>{{i18n
|
<EmailGroupUserChooser
|
||||||
"admin.api.scopes.optional_allowed_parameters"
|
@value={{this.username}}
|
||||||
}}</td>
|
@onChange={{fn this.updateUsername field}}
|
||||||
</tr>
|
@options={{hash
|
||||||
</thead>
|
maximum=1
|
||||||
<tbody>
|
filterPlaceholder="admin.api.user_placeholder"
|
||||||
<form.Object @name="scopes" as |scopesObject scopeName|>
|
}}
|
||||||
<tr class="scope-resource-name">
|
/>
|
||||||
<td><b>{{scopeName}}</b></td>
|
</field.Custom>
|
||||||
<td></td>
|
</form.Field>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
<form.Field
|
||||||
|
@name="scope_mode"
|
||||||
|
@title={{i18n "admin.api.scope_mode"}}
|
||||||
|
@format="large"
|
||||||
|
@validation="required"
|
||||||
|
as |field|
|
||||||
|
>
|
||||||
|
<field.Select as |select|>
|
||||||
|
{{#each this.scopeModes as |scopeMode|}}
|
||||||
|
<select.Option
|
||||||
|
@value={{scopeMode.id}}
|
||||||
|
>{{scopeMode.name}}</select.Option>
|
||||||
|
{{/each}}
|
||||||
|
</field.Select>
|
||||||
|
</form.Field>
|
||||||
|
|
||||||
|
{{#if (eq transientData.scope_mode "granular")}}
|
||||||
|
<h2 class="scopes-title">{{i18n
|
||||||
|
"admin.api.scopes.title"
|
||||||
|
}}</h2>
|
||||||
|
<p>{{i18n "admin.api.scopes.description"}}</p>
|
||||||
|
<table class="scopes-table grid">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td></td>
|
<td></td>
|
||||||
|
<td>{{i18n "admin.api.scopes.allowed_urls"}}</td>
|
||||||
|
<td>{{i18n
|
||||||
|
"admin.api.scopes.optional_allowed_parameters"
|
||||||
|
}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<form.Object @name="scopes" as |scopesObject scopeName|>
|
||||||
|
<tr class="scope-resource-name">
|
||||||
|
<td><b>{{scopeName}}</b></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<scopesObject.Collection
|
<scopesObject.Collection
|
||||||
@name={{scopeName}}
|
@name={{scopeName}}
|
||||||
@tagName="tr"
|
@tagName="tr"
|
||||||
as |topicsCollection index collectionData|
|
as |topicsCollection index collectionData|
|
||||||
>
|
>
|
||||||
<td>
|
<td>
|
||||||
<topicsCollection.Field
|
<topicsCollection.Field
|
||||||
@name="enabled"
|
@name="enabled"
|
||||||
@title={{collectionData.key}}
|
@title={{collectionData.key}}
|
||||||
@showTitle={{false}}
|
|
||||||
as |field|
|
|
||||||
>
|
|
||||||
<field.Checkbox />
|
|
||||||
</topicsCollection.Field>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class="scope-name">{{collectionData.name}}</div>
|
|
||||||
<DTooltip
|
|
||||||
@icon="circle-question"
|
|
||||||
@content={{i18n
|
|
||||||
(concat
|
|
||||||
"admin.api.scopes.descriptions."
|
|
||||||
scopeName
|
|
||||||
"."
|
|
||||||
collectionData.key
|
|
||||||
)
|
|
||||||
class="scope-tooltip"
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<DButton
|
|
||||||
@icon="link"
|
|
||||||
@action={{fn this.showURLs collectionData.urls}}
|
|
||||||
class="btn-info"
|
|
||||||
/>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<topicsCollection.Object
|
|
||||||
@name="params"
|
|
||||||
as |paramsObject name|
|
|
||||||
>
|
|
||||||
<paramsObject.Field
|
|
||||||
@name={{name}}
|
|
||||||
@title={{name}}
|
|
||||||
@showTitle={{false}}
|
@showTitle={{false}}
|
||||||
as |field|
|
as |field|
|
||||||
>
|
>
|
||||||
<field.Input placeholder={{name}} />
|
<field.Checkbox />
|
||||||
</paramsObject.Field>
|
</topicsCollection.Field>
|
||||||
</topicsCollection.Object>
|
</td>
|
||||||
</td>
|
<td>
|
||||||
</scopesObject.Collection>
|
<div
|
||||||
</form.Object>
|
class="scope-name"
|
||||||
</tbody>
|
>{{collectionData.name}}</div>
|
||||||
</table>
|
<DTooltip
|
||||||
{{/if}}
|
@icon="circle-question"
|
||||||
|
@content={{i18n
|
||||||
|
(concat
|
||||||
|
"admin.api.scopes.descriptions."
|
||||||
|
scopeName
|
||||||
|
"."
|
||||||
|
collectionData.key
|
||||||
|
)
|
||||||
|
class="scope-tooltip"
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<DButton
|
||||||
|
@icon="link"
|
||||||
|
@action={{fn this.showURLs collectionData.urls}}
|
||||||
|
class="btn-info"
|
||||||
|
/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<topicsCollection.Object
|
||||||
|
@name="params"
|
||||||
|
as |paramsObject name|
|
||||||
|
>
|
||||||
|
<paramsObject.Field
|
||||||
|
@name={{name}}
|
||||||
|
@title={{name}}
|
||||||
|
@showTitle={{false}}
|
||||||
|
as |field|
|
||||||
|
>
|
||||||
|
<field.Input placeholder={{name}} />
|
||||||
|
</paramsObject.Field>
|
||||||
|
</topicsCollection.Object>
|
||||||
|
</td>
|
||||||
|
</scopesObject.Collection>
|
||||||
|
</form.Object>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<form.Actions>
|
<form.Actions>
|
||||||
<form.Submit class="save" @label="admin.api_keys.save" />
|
<form.Submit class="save" @label="admin.api_keys.save" />
|
||||||
<form.Button
|
<form.Button
|
||||||
@route="adminApiKeys.index"
|
@route="adminApiKeys.index"
|
||||||
@label="admin.api_keys.cancel"
|
@label="admin.api_keys.cancel"
|
||||||
class="btn-default"
|
class="btn-default"
|
||||||
/>
|
/>
|
||||||
</form.Actions>
|
</form.Actions>
|
||||||
</Form>
|
</Form>
|
||||||
</ConditionalLoadingSection>
|
</ConditionalLoadingSection>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -100,6 +100,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.generated-api-key {
|
||||||
|
margin: 1em 0;
|
||||||
|
}
|
||||||
|
|
||||||
.api-key {
|
.api-key {
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
|
|
@ -5403,6 +5403,7 @@ en:
|
||||||
edit: "Edit"
|
edit: "Edit"
|
||||||
save: "Save"
|
save: "Save"
|
||||||
cancel: "Cancel"
|
cancel: "Cancel"
|
||||||
|
continue: "Continue"
|
||||||
back: "Back to API keys"
|
back: "Back to API keys"
|
||||||
revoke: "Revoke"
|
revoke: "Revoke"
|
||||||
undo_revoke: "Undo revoke"
|
undo_revoke: "Undo revoke"
|
||||||
|
|
|
@ -22,6 +22,10 @@ describe "Admin API Keys Page", type: :system do
|
||||||
api_keys_page.visit_page
|
api_keys_page.visit_page
|
||||||
api_keys_page.add_api_key(description: "Second Integration")
|
api_keys_page.add_api_key(description: "Second Integration")
|
||||||
|
|
||||||
|
expect(api_keys_page).to have_generated_api_key
|
||||||
|
|
||||||
|
api_keys_page.click_continue
|
||||||
|
|
||||||
expect(api_keys_page).to have_api_key_listed("Second Integration")
|
expect(api_keys_page).to have_api_key_listed("Second Integration")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,10 @@ module PageObjects
|
||||||
page.has_no_css?(table_selector, text: name)
|
page.has_no_css?(table_selector, text: name)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def has_generated_api_key?
|
||||||
|
page.has_css?(".generated-api-key")
|
||||||
|
end
|
||||||
|
|
||||||
def add_api_key(description:)
|
def add_api_key(description:)
|
||||||
page.find(header_actions_selector, text: I18n.t("admin_js.admin.api_keys.add")).click
|
page.find(header_actions_selector, text: I18n.t("admin_js.admin.api_keys.add")).click
|
||||||
|
|
||||||
|
@ -34,6 +38,10 @@ module PageObjects
|
||||||
form.find(".save").click
|
form.find(".save").click
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def click_continue
|
||||||
|
page.find("button", text: I18n.t("admin_js.admin.api_keys.continue")).click
|
||||||
|
end
|
||||||
|
|
||||||
def click_edit(description)
|
def click_edit(description)
|
||||||
row = page.find(row_selector, text: description)
|
row = page.find(row_selector, text: description)
|
||||||
row.find("button", text: I18n.t("admin_js.admin.api_keys.edit")).click
|
row.find("button", text: I18n.t("admin_js.admin.api_keys.edit")).click
|
||||||
|
|
Loading…
Reference in New Issue
Block a user