FEATURE: Always show full page "New Features" to admins (#28383)

We used to show New Features in a tab on the dashboard,
but this could get pushed down the page especially on
our hosting. In 043117ca13
we made a separate What's New page, so this commit removes
the dashboard tab and changes the admin notification to
send the admin to /admin/whats-new instead of the dashboard
tab.
This commit is contained in:
Martin Brennan 2024-08-16 09:12:24 +10:00 committed by GitHub
parent 43abc219d1
commit 3e5976f843
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 18 additions and 61 deletions

View File

@ -18,7 +18,7 @@ export default class DashboardNewFeatures extends Component {
@bind @bind
loadNewFeatures() { loadNewFeatures() {
ajax("/admin/dashboard/whats-new.json") ajax("/admin/whats-new.json")
.then((json) => { .then((json) => {
const items = json.new_features.reduce((acc, feature) => { const items = json.new_features.reduce((acc, feature) => {
const key = moment(feature.released_at || feature.created_at).format( const key = moment(feature.released_at || feature.created_at).format(

View File

@ -1,3 +0,0 @@
import Controller from "@ember/controller";
export default class AdminDashboardNewFeaturesController extends Controller {}

View File

@ -50,11 +50,6 @@ export default class AdminDashboardController extends Controller {
return this.visibleTabs.includes("reports"); return this.visibleTabs.includes("reports");
} }
@computed("visibleTabs")
get isNewFeaturesTabVisible() {
return this.visibleTabs.includes("features");
}
fetchProblems() { fetchProblems() {
if (this.isLoadingProblems) { if (this.isLoadingProblems) {
return; return;
@ -91,7 +86,6 @@ export default class AdminDashboardController extends Controller {
if (versionChecks) { if (versionChecks) {
properties.versionCheck = VersionCheck.create(model.version_check); properties.versionCheck = VersionCheck.create(model.version_check);
} }
properties.hasUnseenFeatures = model.hasUnseenFeatures;
this.setProperties(properties); this.setProperties(properties);
}) })

View File

@ -13,7 +13,6 @@ export default class AdminDashboard extends EmberObject {
const model = AdminDashboard.create(); const model = AdminDashboard.create();
model.setProperties({ model.setProperties({
version_check: json.version_check, version_check: json.version_check,
hasUnseenFeatures: json.has_unseen_features,
}); });
return model; return model;

View File

@ -1,3 +0,0 @@
import DiscourseRoute from "discourse/routes/discourse";
export default class AdminDashboardNewFeaturesRoute extends DiscourseRoute {}

View File

@ -14,10 +14,6 @@ export default function () {
path: "/dashboard/reports", path: "/dashboard/reports",
resetNamespace: true, resetNamespace: true,
}); });
this.route("admin.dashboardNewFeatures", {
path: "/dashboard/whats-new",
resetNamespace: true,
});
}); });
this.route( this.route(

View File

@ -50,17 +50,6 @@
</li> </li>
{{/if}} {{/if}}
{{#if this.isNewFeaturesTabVisible}}
<li class="navigation-item new-features">
<LinkTo @route="admin.dashboardNewFeatures" class="navigation-link">
{{#if this.hasUnseenFeatures}}
{{replace-emoji ":gift:"}}
{{/if}}
{{i18n "admin.dashboard.new_features.title"}}
</LinkTo>
</li>
{{/if}}
<PluginOutlet @name="admin-dashboard-tabs-after" /> <PluginOutlet @name="admin-dashboard-tabs-after" />
</ul> </ul>
</nav> </nav>

View File

@ -12,7 +12,7 @@ export default class extends NotificationTypeBase {
} }
get linkHref() { get linkHref() {
return getURL("/admin/dashboard/whats-new"); return getURL("/admin/whats-new");
} }
get icon() { get icon() {

View File

@ -130,20 +130,6 @@ acceptance("Dashboard", function (needs) {
"its set the value of the filter from the query params" "its set the value of the filter from the query params"
); );
}); });
test("new features", async function (assert) {
await visit("/admin");
await click(".dashboard .navigation-item.new-features .navigation-link");
assert.ok(
exists(
".dashboard .navigation-item.new-features .navigation-link .emoji[title='gift']"
)
);
assert.ok(exists(".dashboard-new-features"));
assert.ok(exists("img.admin-new-feature-item__screenshot"));
});
}); });
acceptance("Dashboard: dashboard_visible_tabs", function (needs) { acceptance("Dashboard: dashboard_visible_tabs", function (needs) {

View File

@ -1,5 +1,5 @@
export default { export default {
"/admin/dashboard/whats-new.json": { "/admin/whats-new.json": {
new_features: [ new_features: [
{ {
id: 1, id: 1,

View File

@ -7,7 +7,6 @@ class Admin::DashboardController < Admin::StaffController
if SiteSetting.version_checks? if SiteSetting.version_checks?
data.merge!(version_check: DiscourseUpdates.check_version.as_json) data.merge!(version_check: DiscourseUpdates.check_version.as_json)
end end
data.merge!(has_unseen_features: DiscourseUpdates.has_unseen_features?(current_user.id))
render json: data render json: data
end end

View File

@ -164,7 +164,7 @@ RSpec.describe Admin::DashboardController do
before { sign_in(admin) } before { sign_in(admin) }
it "is empty by default" do it "is empty by default" do
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
json = response.parsed_body json = response.parsed_body
expect(json["new_features"]).to eq(nil) expect(json["new_features"]).to eq(nil)
@ -172,7 +172,7 @@ RSpec.describe Admin::DashboardController do
it "fails gracefully for invalid JSON" do it "fails gracefully for invalid JSON" do
Discourse.redis.set("new_features", "INVALID JSON") Discourse.redis.set("new_features", "INVALID JSON")
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
json = response.parsed_body json = response.parsed_body
expect(json["new_features"]).to eq(nil) expect(json["new_features"]).to eq(nil)
@ -181,7 +181,7 @@ RSpec.describe Admin::DashboardController do
it "includes new features when available" do it "includes new features when available" do
populate_new_features populate_new_features
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
json = response.parsed_body json = response.parsed_body
@ -195,7 +195,7 @@ RSpec.describe Admin::DashboardController do
populate_new_features populate_new_features
DiscourseUpdates.mark_new_features_as_seen(admin.id) DiscourseUpdates.mark_new_features_as_seen(admin.id)
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
json = response.parsed_body json = response.parsed_body
@ -209,7 +209,7 @@ RSpec.describe Admin::DashboardController do
expect(DiscourseUpdates.get_last_viewed_feature_date(admin.id)).to eq(nil) expect(DiscourseUpdates.get_last_viewed_feature_date(admin.id)).to eq(nil)
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(DiscourseUpdates.get_last_viewed_feature_date(admin.id)).to be_within_one_second_of( expect(DiscourseUpdates.get_last_viewed_feature_date(admin.id)).to be_within_one_second_of(
date2, date2,
@ -218,7 +218,7 @@ RSpec.describe Admin::DashboardController do
date2 = 10.minutes.ago date2 = 10.minutes.ago
populate_new_features(date1, date2) populate_new_features(date1, date2)
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(DiscourseUpdates.get_last_viewed_feature_date(admin.id)).to be_within_one_second_of( expect(DiscourseUpdates.get_last_viewed_feature_date(admin.id)).to be_within_one_second_of(
date2, date2,
@ -233,7 +233,7 @@ RSpec.describe Admin::DashboardController do
expect(DiscourseUpdates.new_features_last_seen(admin.id)).to eq(nil) expect(DiscourseUpdates.new_features_last_seen(admin.id)).to eq(nil)
expect(DiscourseUpdates.has_unseen_features?(admin.id)).to eq(true) expect(DiscourseUpdates.has_unseen_features?(admin.id)).to eq(true)
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(DiscourseUpdates.new_features_last_seen(admin.id)).not_to eq(nil) expect(DiscourseUpdates.new_features_last_seen(admin.id)).not_to eq(nil)
@ -244,7 +244,7 @@ RSpec.describe Admin::DashboardController do
end end
it "doesn't error when there are no new features" do it "doesn't error when there are no new features" do
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
end end
end end
@ -255,7 +255,7 @@ RSpec.describe Admin::DashboardController do
it "includes new features when available" do it "includes new features when available" do
populate_new_features populate_new_features
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
json = response.parsed_body json = response.parsed_body
@ -270,7 +270,7 @@ RSpec.describe Admin::DashboardController do
expect(DiscourseUpdates.get_last_viewed_feature_date(moderator.id)).to eq(nil) expect(DiscourseUpdates.get_last_viewed_feature_date(moderator.id)).to eq(nil)
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(DiscourseUpdates.get_last_viewed_feature_date(moderator.id)).to eq(nil) expect(DiscourseUpdates.get_last_viewed_feature_date(moderator.id)).to eq(nil)
end end
@ -280,7 +280,7 @@ RSpec.describe Admin::DashboardController do
before { sign_in(user) } before { sign_in(user) }
it "denies access with a 404 response" do it "denies access with a 404 response" do
get "/admin/dashboard/whats-new.json" get "/admin/whats-new.json"
expect(response.status).to eq(404) expect(response.status).to eq(404)
expect(response.parsed_body["errors"]).to include(I18n.t("not_found")) expect(response.parsed_body["errors"]).to include(I18n.t("not_found"))

View File

@ -1,7 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
describe "Admin Dashboard New Features Page", type: :system do describe "Admin New Features Page", type: :system do
let(:new_features_page) { PageObjects::Pages::AdminDashboardNewFeatures.new } let(:new_features_page) { PageObjects::Pages::AdminNewFeatures.new }
fab!(:admin) fab!(:admin)
before { sign_in(admin) } before { sign_in(admin) }

View File

@ -2,9 +2,9 @@
module PageObjects module PageObjects
module Pages module Pages
class AdminDashboardNewFeatures < PageObjects::Pages::Base class AdminNewFeatures < PageObjects::Pages::Base
def visit def visit
page.visit("/admin/dashboard/whats-new") page.visit("/admin/whats-new")
self self
end end