Skip to content

UX: fix link for user menu, add requested settings #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 12, 2023
Merged
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
10 changes: 2 additions & 8 deletions common/common.scss
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
.user-portfolio {
grid-row-start: 2;
grid-row-end: 4;
grid-column-start: 1;
grid-column-end: 3;
}
.empty-portfolio {
display: flex;
flex-direction: column;
width: 100%;
align-items: center;

.empty-portfolio-message {
margin: 20px;
margin-top: 2em;
font-size: $font-up-2;
max-width: 500px;
max-width: 30em;
text-align: center;
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{{d-button
class="btn-default"
href=(concat "/u/" user.username_lower "/activity/portfolio")
href=(concat
"/u/"
user.username_lower
"/activity/"
(theme-setting "portfolio_route_name")
)
icon=(theme-setting "portfolio_icon")
label=(theme-prefix "portfolio")
}}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{#link-to "user.portfolio"}}
{{d-icon (theme-setting "portfolio_icon")}}
{{theme-i18n "portfolio"}}{{/link-to}}
<span>{{theme-i18n "portfolio"}}</span>
{{/link-to}}
4 changes: 3 additions & 1 deletion javascripts/discourse/portfolio-route-map.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export default {
resource: "user",
map() {
this.route("portfolio", { path: "activity/portfolio" });
this.route("portfolio", {
path: `activity/${settings.portfolio_route_name}`,
});
},
};
15 changes: 7 additions & 8 deletions javascripts/discourse/routes/user-portfolio.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const filterTags = settings.portfolio_tags.split("|").filter((val) => val);

import DiscourseRoute from "discourse/routes/discourse";
import Category from "discourse/models/category";

Expand All @@ -17,20 +15,21 @@ export default DiscourseRoute.extend({
});
},

model: function () {
model() {
const filterParams = {};
const filterTags = settings.portfolio_tags.replace(/\|/g, "+");
const tagQuery = filterTags ? `?tags=${filterTags}+` : "";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const tagQuery = filterTags ? `?tags=${filterTags}+` : "";
const tagQuery = filterTags ? `?tags=${filterTags}` : "";

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so here's another oddity... without that trailing + the last tag in the list won't work 😅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image


if (settings.portfolio_category > 0) {
filterParams["category"] = settings.portfolio_category;
}

if (filterTags.length > 0) {
filterParams["tags"] = filterTags;
}
filterParams["order"] = settings.portfolio_order;

return this.store.findFiltered("topicList", {
filter:
"topics/created-by/" + this.modelFor("user").get("username_lower"),
filter: `topics/created-by/${this.modelFor("user").get(
"username_lower"
)}${tagQuery}`,
params: filterParams,
});
},
Expand Down
14 changes: 9 additions & 5 deletions javascripts/discourse/templates/user-portfolio.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="user-portfolio">
<div class="user-content user-portfolio">
{{#if model.topics}}
{{#load-more
class="paginated-topics-list"
Expand All @@ -12,10 +12,14 @@
<div class="empty-portfolio">
<div class="empty-portfolio-message">
{{html-safe (theme-i18n "empty_portfolio")}}

<a href={{category.url}}>
{{category.name}}
</a>
{{#if category}}
<p>
{{html-safe (theme-i18n "empty_portfolio_link")}}
<a href={{category.url}}>
{{category.name}}
</a>
</p>
{{/if}}
</div>
</div>
{{/if}}
Expand Down
4 changes: 2 additions & 2 deletions locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ en:
portfolio_thumbnail_style: Thumbnail style for portfolio page (requires discourse-topic-thumbnails to be installed and added to the active theme)
user_card_portfolio_link: Display a portfolio link on user cards?
portfolio: Portfolio
empty_portfolio: |
This portfolio is waiting to be filled<br/>Get started by adding topics to
empty_portfolio: This portfolio is waiting to be filled
empty_portfolio_link: Get started by adding topics to
11 changes: 11 additions & 0 deletions settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,14 @@ portfolio_thumbnail_style:
- list
- none
user_card_portfolio_link: true
portfolio_order:
default: "latest"
type: enum
choices:
- latest
- created
portfolio_route_name:
default: "portfolio"
type: string
description: |
name of the portfolio page in the URL, for example /u/username/activity/<strong>porfolio</strong>