FEATURE: Swap to raw for topic list (#6)

In order to get access to other topic list status icons (i.e. solved), we must use raw templates.
This commit is contained in:
Justin DiRose 2020-06-12 12:55:10 -05:00 committed by GitHub
parent caa15f3567
commit 895fd41f39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 45 additions and 188 deletions

View File

@ -1,151 +1,2 @@
require:
- rubocop-discourse
AllCops:
TargetRubyVersion: 2.4
DisabledByDefault: true
Exclude:
- "db/schema.rb"
- "bundle/**/*"
- "vendor/**/*"
- "node_modules/**/*"
- "public/**/*"
- "plugins/**/gems/**/*"
# Prefer &&/|| over and/or.
Style/AndOr:
Enabled: true
Style/FrozenStringLiteralComment:
Enabled: true
# Do not use braces for hash literals when they are the last argument of a
# method call.
Style/BracesAroundHashParameters:
Enabled: true
# Align `when` with `case`.
Layout/CaseIndentation:
Enabled: true
# Align comments with method definitions.
Layout/CommentIndentation:
Enabled: true
# No extra empty lines.
Layout/EmptyLines:
Enabled: true
# Use Ruby >= 1.9 syntax for hashes. Prefer { a: :b } over { :a => :b }.
Style/HashSyntax:
Enabled: true
# Two spaces, no tabs (for indentation).
Layout/IndentationWidth:
Enabled: true
Layout/SpaceAfterColon:
Enabled: true
Layout/SpaceAfterComma:
Enabled: true
Layout/SpaceAroundEqualsInParameterDefault:
Enabled: true
Layout/SpaceAroundKeyword:
Enabled: true
Layout/SpaceAroundOperators:
Enabled: true
Layout/SpaceBeforeFirstArg:
Enabled: true
# Defining a method with parameters needs parentheses.
Style/MethodDefParentheses:
Enabled: true
# Use `foo {}` not `foo{}`.
Layout/SpaceBeforeBlockBraces:
Enabled: true
# Use `foo { bar }` not `foo {bar}`.
Layout/SpaceInsideBlockBraces:
Enabled: true
# Use `{ a: 1 }` not `{a:1}`.
Layout/SpaceInsideHashLiteralBraces:
Enabled: true
Layout/SpaceInsideParens:
Enabled: true
# Detect hard tabs, no hard tabs.
Layout/Tab:
Enabled: true
# Blank lines should not have any spaces.
Layout/TrailingEmptyLines:
Enabled: true
# No trailing whitespace.
Layout/TrailingWhitespace:
Enabled: true
Lint/Debugger:
Enabled: true
Layout/BlockAlignment:
Enabled: true
# Align `end` with the matching keyword or starting expression except for
# assignments, where it should be aligned with the LHS.
Layout/EndAlignment:
Enabled: true
EnforcedStyleAlignWith: variable
# Use my_method(my_arg) not my_method( my_arg ) or my_method my_arg.
Lint/RequireParentheses:
Enabled: true
Lint/ShadowingOuterLocalVariable:
Enabled: true
Layout/MultilineMethodCallIndentation:
Enabled: true
EnforcedStyle: indented
Layout/HashAlignment:
Enabled: true
Bundler/OrderedGems:
Enabled: false
Style/SingleLineMethods:
Enabled: true
Style/Semicolon:
Enabled: true
AllowAsExpressionSeparator: true
Style/RedundantReturn:
Enabled: true
DiscourseCops/NoChdir:
Enabled: true
Exclude:
- 'spec/**/*' # Specs are run sequentially, so chdir can be used
- 'plugins/*/spec/**/*'
DiscourseCops/NoURIEscapeEncode:
Enabled: true
Style/GlobalVars:
Enabled: true
Severity: warning
Exclude:
- 'lib/tasks/**/*'
- 'script/**/*'
- 'spec/**/*.rb'
- 'plugins/*/spec/**/*'
inherit_gem:
rubocop-discourse: default.yml

View File

@ -1,6 +0,0 @@
export default Ember.Component.extend({
click() {
this.selectTopic(this.topic.id);
return false;
}
});

View File

@ -12,6 +12,20 @@ export default Ember.Component.extend({
return order === "activity";
},
// need to handle clicks here since links are in a raw view
didInsertElement() {
const topicLinks = this.element.getElementsByClassName(
"knowledge-explorer-topic-link"
);
for (let i = 0, max = topicLinks.length; i < max; i++) {
topicLinks[i].addEventListener("click", e => {
const topicId = e.target.dataset.topicId;
this.selectTopic(topicId);
});
}
},
actions: {
sortListActivity() {
this.sortBy("activity");

View File

@ -25,14 +25,15 @@ export default {
return data;
});
});
}
else {
} else {
promise = promise.then(data => {
data.topics.topic_list.topics = data.topics.topic_list.topics.map(topic => {
topic = Topic.create(topic);
return topic;
});
return data;
data.topics.topic_list.topics = data.topics.topic_list.topics.map(
topic => {
topic = Topic.create(topic);
return topic;
}
);
return data;
});
}

View File

@ -1 +0,0 @@
<span class="knowledge-explorer-topic-link">{{topic.title}}</span>

View File

@ -24,26 +24,7 @@
</thead>
<tbody>
{{#each topics as |topic|}}
<tr>
<td class="main-link">
<span class="link-top-line">
{{topic-status topic=topic}}
{{knowledge-explorer-topic-link
topic=topic
selectTopic=selectTopic
}}
</span>
<span class="link-bottom-line">
{{category-link topic.category}}
{{#each topic.tags as |tag|}}
<span class="discourse-tag">{{tag}}</span>
{{/each}}
</span>
</td>
<td>
{{format-date topic.bumped_at format="tiny" noTitle="true"}}
</td>
</tr>
{{raw "knowledge-explorer-topic-list-item" topic=topic}}
{{/each}}
</tbody>
</table>

View File

@ -0,0 +1 @@
<a data-topic-id="{{topic.id}}" class="knowledge-explorer-topic-link">{{{topic.fancyTitle}}}</a>

View File

@ -0,0 +1,15 @@
<tr>
<td class="main-link">
<span class="link-top-line">
{{~raw "topic-status" topic=topic}}
{{~raw "knowledge-explorer-topic-link" topic=topic}}
</span>
<span class="link-bottom-line">
{{category-link topic.category}}
{{discourse-tags topic mode="list"}}
</span>
</td>
<td>
{{format-date topic.bumped_at format="tiny" noTitle="true"}}
</td>
</tr>

View File

@ -132,13 +132,14 @@
max-width: 30vw;
}
.discourse-tags {
font-weight: normal;
font-size: $font-down-1;
}
.knowledge-explorer-topic-link {
color: $tertiary;
cursor: pointer;
}
.discourse-tag {
padding-right: 5px;
}
}
.knowledge-explorer-topic {
display: flex;