UX: Move share topic warning to modal flash alert (#15012)

This commit is contained in:
jbrw 2021-11-18 19:24:15 -05:00 committed by GitHub
parent e6670393df
commit 9955f1774d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 23 additions and 38 deletions

View File

@ -22,15 +22,7 @@ export default Controller.extend(
this.set("showNotifyUsers", false); this.set("showNotifyUsers", false);
if (this.model && this.model.read_restricted) { if (this.model && this.model.read_restricted) {
Category.reloadBySlugPath(this.model.slug).then((result) => { this.restrictedGroupWarning();
this.setProperties({
restrictedGroups: result.category.group_permissions.map(
(g) => g.group_name
),
});
});
} else {
this.setProperties({ restrictedGroups: null });
} }
}, },
@ -55,21 +47,6 @@ export default Controller.extend(
); );
}, },
@discourseComputed("restrictedGroups")
hasRestrictedGroups(groups) {
return !!groups;
},
@discourseComputed("restrictedGroups")
restrictedGroupsCount(groups) {
return groups.length;
},
@discourseComputed("restrictedGroups")
restrictedGroupsDisplayText(groups) {
return groups.join(", ");
},
@action @action
onChangeUsers(usernames) { onChangeUsers(usernames) {
this.set("users", usernames.uniq()); this.set("users", usernames.uniq());
@ -134,5 +111,24 @@ export default Controller.extend(
topicTitle: this.topic.title, topicTitle: this.topic.title,
}); });
}, },
restrictedGroupWarning() {
this.appEvents.on("modal:body-shown", () => {
let restrictedGroups;
Category.reloadBySlugPath(this.model.slug).then((result) => {
restrictedGroups = result.category.group_permissions.map(
(g) => g.group_name
);
if (restrictedGroups) {
const message = I18n.t("topic.share.restricted_groups", {
count: restrictedGroups.length,
groupNames: restrictedGroups.join(", "),
});
this.flash(message, "warning");
}
});
});
},
} }
); );

View File

@ -13,12 +13,6 @@
</div> </div>
</div> </div>
{{#if hasRestrictedGroups}}
<div class="link-share-restricted-groups">
{{i18n "topic.share.restricted_groups" count=restrictedGroupsCount}}
{{restrictedGroupsDisplayText}}
</div>
{{/if}}
<div class="link-share-actions"> <div class="link-share-actions">
<div class="sources"> <div class="sources">
{{#each sources as |s|}} {{#each sources as |s|}}

View File

@ -61,7 +61,7 @@ acceptance("Share and Invite modal", function (needs) {
assert.ok(exists(".share-topic-modal"), "it shows the modal"); assert.ok(exists(".share-topic-modal"), "it shows the modal");
assert.ok( assert.ok(
exists(".link-share-restricted-groups"), exists("#modal-alert.alert-warning"),
"it shows restricted warning" "it shows restricted warning"
); );
}); });

View File

@ -13,11 +13,6 @@
} }
} }
.link-share-restricted-groups {
margin-top: 0.5em;
color: var(--danger-medium);
}
.link-share-actions { .link-share-actions {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;

View File

@ -2832,8 +2832,8 @@ en:
instructions: "Share a link to this topic:" instructions: "Share a link to this topic:"
copied: "Topic link copied." copied: "Topic link copied."
restricted_groups: restricted_groups:
one: "Only visible to members of group:" one: "Only visible to members of group: %{groupNames}"
other: "Only visible to members of groups:" other: "Only visible to members of groups: %{groupNames}"
notify_users: notify_users:
title: "Notify" title: "Notify"
instructions: "Notify the following users about this topic:" instructions: "Notify the following users about this topic:"