Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions config/locales/client.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8411,6 +8411,7 @@ en:
experimental: "Experimental"
secret_list:
invalid_input: "Input fields cannot be empty or contain vertical bar character."
already_exists: "Entry for %{key} already exists."
default_categories:
modal_description:
one: "Would you like to apply this change historically? This will change preferences for %{count} existing user."
Expand Down
35 changes: 20 additions & 15 deletions frontend/discourse/admin/components/admin-config-areas/flags.gjs
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { service } from "@ember/service";
import AdminFlagItem from "discourse/admin/components/admin-flag-item";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { removeValueFromArray } from "discourse/lib/array-tools";
import { bind } from "discourse/lib/decorators";
import { trackedArray } from "discourse/lib/tracked-tools";
import { i18n } from "discourse-i18n";

export default class AdminConfigAreasFlags extends Component {
@service site;

@tracked flags = this.site.flagTypes;
@trackedArray flags = this.site.flagTypes;

@bind
isFirstFlag(flag) {
Expand All @@ -24,7 +25,7 @@ export default class AdminConfigAreasFlags extends Component {
}

@action
moveFlagCallback(flag, direction) {
async moveFlagCallback(flag, direction) {
const fallbackFlags = [...this.flags];

const flags = this.flags;
Expand All @@ -39,23 +40,27 @@ export default class AdminConfigAreasFlags extends Component {

this.flags = flags;

return ajax(`/admin/config/flags/${flag.id}/reorder/${direction}`, {
type: "PUT",
}).catch((error) => {
try {
await ajax(`/admin/config/flags/${flag.id}/reorder/${direction}`, {
type: "PUT",
});
} catch (error) {
this.flags = fallbackFlags;
return popupAjaxError(error);
});
}
}

@action
deleteFlagCallback(flag) {
return ajax(`/admin/config/flags/${flag.id}`, {
type: "DELETE",
})
.then(() => {
this.flags.removeObject(flag);
})
.catch((error) => popupAjaxError(error));
async deleteFlagCallback(flag) {
try {
await ajax(`/admin/config/flags/${flag.id}`, {
type: "DELETE",
});

removeValueFromArray(this.flags, flag);
} catch (error) {
popupAjaxError(error);
}
}

<template>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class AdminConfigAreasUserFieldsList extends Component {
moveUp(field) {
const idx = this.sortedFields.indexOf(field);
if (idx) {
const prev = this.sortedFields.objectAt(idx - 1);
const prev = this.sortedFields[idx - 1];
const prevPos = prev.get("position");

prev.update({ position: field.get("position") });
Expand All @@ -40,7 +40,7 @@ export default class AdminConfigAreasUserFieldsList extends Component {
moveDown(field) {
const idx = this.sortedFields.indexOf(field);
if (idx > -1) {
const next = this.sortedFields.objectAt(idx + 1);
const next = this.sortedFields[idx + 1];
const nextPos = next.get("position");

next.update({ position: field.get("position") });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import GroupSelector from "discourse/components/group-selector";
import PluginOutlet from "discourse/components/plugin-outlet";
import lazyHash from "discourse/helpers/lazy-hash";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { trackedArray } from "discourse/lib/tracked-tools";
import CategorySelector from "discourse/select-kit/components/category-selector";
import TagChooser from "discourse/select-kit/components/tag-chooser";
import { eq } from "discourse/truth-helpers";
Expand All @@ -25,11 +26,11 @@ export default class AdminConfigAreasWebhookForm extends Component {

@tracked loadingExtras = true;

@tracked webhookEventTypes = [];
@tracked defaultEventTypes = {};
@tracked groupedEventTypes = {};
@tracked contentTypes = [];
@tracked deliveryStatuses = [];
@trackedArray webhookEventTypes = [];

constructor() {
super(...arguments);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { action } from "@ember/object";
import { service } from "@ember/service";
import AdminConfigAreaEmptyList from "discourse/admin/components/admin-config-area-empty-list";
import WebhookItem from "discourse/admin/components/webhook-item";
import ConditionalLoadingSpinner from "discourse/components/conditional-loading-spinner";
import LoadMore from "discourse/components/load-more";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { removeValueFromArray } from "discourse/lib/array-tools";
import { i18n } from "discourse-i18n";
Expand Down Expand Up @@ -31,33 +33,44 @@ export default class AdminConfigAreasWebhooksList extends Component {
<template>
<div class="container admin-api_keys">
{{#if this.webhooks.content}}
<table class="d-table admin-web_hooks__items">
<thead class="d-table__header">
<tr class="d-table__row">
<th class="d-table__header-cell">{{i18n
"admin.web_hooks.delivery_status.title"
}}</th>
<th class="d-table__header-cell">{{i18n
"admin.web_hooks.payload_url"
}}</th>
<th class="d-table__header-cell">{{i18n
"admin.web_hooks.description_label"
}}</th>
<th class="d-table__header-cell">{{i18n
"admin.web_hooks.controls"
}}</th>
</tr>
</thead>
<tbody class="d-table__body">
{{#each this.webhooks.content as |webhook|}}
<WebhookItem
@webhook={{webhook}}
@deliveryStatuses={{this.webhooks.extras.delivery_statuses}}
@destroy={{this.destroyWebhook}}
/>
{{/each}}
</tbody>
</table>
<LoadMore @action={{this.webhooks.loadMore}}>
<table class="d-table admin-web_hooks__items">
<thead class="d-table__header">
<tr class="d-table__row">
<th class="d-table__header-cell">{{i18n
"admin.web_hooks.delivery_status.title"
}}</th>
<th class="d-table__header-cell">{{i18n
"admin.web_hooks.payload_url"
}}</th>
<th class="d-table__header-cell">{{i18n
"admin.web_hooks.description_label"
}}</th>
<th class="d-table__header-cell">{{i18n
"admin.web_hooks.controls"
}}</th>
</tr>
</thead>
<tbody class="d-table__body">
{{#each this.webhooks.content as |webhook|}}
<WebhookItem
@webhook={{webhook}}
@deliveryStatuses={{this.webhooks.extras.delivery_statuses}}
@destroy={{this.destroyWebhook}}
/>
{{/each}}
{{#if this.webhooks.loadingMore}}
<tr class="d-table__row">
<td class="d-table__cell" colspan="4">
<ConditionalLoadingSpinner
@condition={{this.webhooks.loadingMore}}
/>
</td>
</tr>
{{/if}}
</tbody>
</table>
</LoadMore>
{{else}}
<AdminConfigAreaEmptyList
@ctaLabel="admin.web_hooks.add"
Expand Down
2 changes: 1 addition & 1 deletion frontend/discourse/admin/components/admin-flags-form.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export default class AdminFlagsForm extends Component {
type: "POST",
data,
});
this.site.flagTypes.pushObject(response.flag);
this.site.flagTypes.push(response.flag);
this.router.transitionTo("adminConfig.flags");
} catch (error) {
popupAjaxError(error);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default class AdminUserFieldsForm extends Component {
this.originalRequirement = data.requirement;

if (isNew) {
this.adminUserFields.userFields.pushObject(this.args.userField);
this.adminUserFields.userFields.push(this.args.userField);
}

this.router.transitionTo("adminUserFields.index");
Expand Down
7 changes: 5 additions & 2 deletions frontend/discourse/admin/components/dashboard-problems.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import concatClass from "discourse/helpers/concat-class";
import icon from "discourse/helpers/d-icon";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { removeValueFromArray } from "discourse/lib/array-tools";
import { eq } from "discourse/truth-helpers";
import { i18n } from "discourse-i18n";

Expand All @@ -17,14 +18,16 @@ export default class DashboardProblems extends Component {
async dismissProblem(problem) {
try {
await ajax(`/admin/admin_notices/${problem.id}`, { type: "DELETE" });
this.args.problems.removeObject(problem);
removeValueFromArray(this.args.problems, problem);
} catch (error) {
popupAjaxError(error);
}
}

get problems() {
return this.args.problems.sort((a, b) => compare(a?.priority, b?.priority));
return this.args.problems.toSorted((a, b) =>
compare(a?.priority, b?.priority)
);
}

<template>
Expand Down
16 changes: 6 additions & 10 deletions frontend/discourse/admin/components/edit-category-security.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { buildCategoryPanel } from "discourse/admin/components/edit-category-pan
import CategoryPermissionRow from "discourse/components/category-permission-row";
import PluginOutlet from "discourse/components/plugin-outlet";
import lazyHash from "discourse/helpers/lazy-hash";
import discourseComputed from "discourse/lib/decorators";
import PermissionType from "discourse/models/permission-type";
import ComboBox from "discourse/select-kit/components/combo-box";
import { i18n } from "discourse-i18n";
Expand All @@ -17,23 +16,20 @@ export default class EditCategorySecurity extends buildCategoryPanel(

@not("selectedGroup") noGroupSelected;

@discourseComputed("[email protected]_type")
everyonePermission(permissions) {
return permissions.find((p) => p.group_name === "everyone");
get everyonePermission() {
return this.category.permissions.find((p) => p.group_name === "everyone");
}

@discourseComputed("[email protected]_type")
everyoneGrantedFull() {
get everyoneGrantedFull() {
return (
this.everyonePermission &&
this.everyonePermission.permission_type === PermissionType.FULL
);
}

@discourseComputed("everyonePermission")
minimumPermission(everyonePermission) {
return everyonePermission
? everyonePermission.permission_type
get minimumPermission() {
return this.everyonePermission
? this.everyonePermission.permission_type
: PermissionType.READONLY;
}

Expand Down
3 changes: 2 additions & 1 deletion frontend/discourse/admin/components/edit-category-tab.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { empty } from "@ember/object/computed";
import { scheduleOnce } from "@ember/runloop";
import { underscore } from "@ember/string";
import { classNameBindings, tagName } from "@ember-decorators/component";
import { addUniqueValueToArray } from "discourse/lib/array-tools";
import { propertyEqual } from "discourse/lib/computed";
import discourseComputed from "discourse/lib/decorators";
import getURL from "discourse/lib/get-url";
Expand Down Expand Up @@ -43,7 +44,7 @@ export default class EditCategoryTab extends Component {
}

_addToCollection() {
this.panels.addObject(this.tabClassName);
addUniqueValueToArray(this.panels, this.tabClassName);
}

@discourseComputed("params.slug", "params.parentSlug")
Expand Down
5 changes: 3 additions & 2 deletions frontend/discourse/admin/components/edit-category-tags.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { LinkTo } from "@ember/routing";
import { buildCategoryPanel } from "discourse/admin/components/edit-category-panel";
import DButton from "discourse/components/d-button";
import TextField from "discourse/components/text-field";
import { removeValueFromArray } from "discourse/lib/array-tools";
import TagChooser from "discourse/select-kit/components/tag-chooser";
import TagGroupChooser from "discourse/select-kit/components/tag-group-chooser";
import { i18n } from "discourse-i18n";
Expand All @@ -25,14 +26,14 @@ export default class EditCategoryTags extends buildCategoryPanel("tags") {

@action
addRequiredTagGroup() {
this.category.required_tag_groups.pushObject({
this.category.required_tag_groups.push({
min_count: 1,
});
}

@action
deleteRequiredTagGroup(rtg) {
this.category.required_tag_groups.removeObject(rtg);
removeValueFromArray(this.category.required_tag_groups, rtg);
}

<template>
Expand Down
Loading
Loading