Skip to content

DEV: [gjs-codemod] Convert all templates to gjs #125

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
Jun 5, 2025
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
1 change: 1 addition & 0 deletions .discourse-compatibility
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
< 3.5.0.beta5-dev: be64a5ea30dcda658a74e22a9e7b5fd8cd7632c8
< 3.5.0.beta1-dev: b7181ad63238adf843d27b2d0db13cb6354df379
< 3.4.0.beta2-dev: ff810c65d88e3a208b1126e94ec9ba637d6e997e
< 3.4.0.beta1-dev: 5a44de571484b2652d7ba57b16e3e1519e4d7317
Expand Down
44 changes: 23 additions & 21 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14,42 +14,44 @@ GEM
securerandom (>= 0.3)
tzinfo (~> 2.0, >= 2.0.5)
uri (>= 0.13.1)
ast (2.4.2)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
ast (2.4.3)
base64 (0.3.0)
benchmark (0.4.1)
bigdecimal (3.2.0)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
drb (2.2.1)
connection_pool (2.5.3)
drb (2.2.3)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.10.2)
language_server-protocol (3.17.0.4)
json (2.12.2)
language_server-protocol (3.17.0.5)
lint_roller (1.1.0)
logger (1.6.6)
logger (1.7.0)
minitest (5.25.5)
parallel (1.26.3)
parser (3.3.7.1)
parallel (1.27.0)
parser (3.3.8.0)
ast (~> 2.4.1)
racc
prettier_print (1.2.1)
prism (1.4.0)
racc (1.8.1)
rack (3.1.12)
rack (3.1.15)
rainbow (3.1.1)
regexp_parser (2.10.0)
rubocop (1.74.0)
rubocop (1.75.8)
json (~> 2.3)
language_server-protocol (~> 3.17.0.2)
lint_roller (~> 1.1.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.9.3, < 3.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 4.0)
rubocop-ast (1.38.1)
parser (>= 3.3.1.0)
rubocop-ast (1.44.1)
parser (>= 3.3.7.2)
prism (~> 1.4)
rubocop-capybara (2.22.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
Expand All @@ -65,13 +67,13 @@ GEM
rubocop-factory_bot (2.27.1)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rails (2.30.3)
rubocop-rails (2.32.0)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
rubocop (>= 1.72.1, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-rspec (3.5.0)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.44.0, < 2.0)
rubocop-rspec (3.6.0)
lint_roller (~> 1.1)
rubocop (~> 1.72, >= 1.72.1)
rubocop-rspec_rails (2.31.0)
Expand All @@ -97,4 +99,4 @@ DEPENDENCIES
syntax_tree

BUNDLED WITH
2.6.6
2.6.9

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

134 changes: 134 additions & 0 deletions assets/javascripts/discourse/components/modal/user-notes.gjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { Textarea } from "@ember/component";
import { fn } from "@ember/helper";
import { action } from "@ember/object";
import { service } from "@ember/service";
import CookText from "discourse/components/cook-text";
import DButton from "discourse/components/d-button";
import DModal from "discourse/components/d-modal";
import UserLink from "discourse/components/user-link";
import ageWithTooltip from "discourse/helpers/age-with-tooltip";
import avatar from "discourse/helpers/avatar";
import { popupAjaxError } from "discourse/lib/ajax-error";
import { i18n } from "discourse-i18n";

export default class UserNotesModal extends Component {
@service dialog;
@service store;

@tracked newNote;
@tracked userId = this.args.model.userId;
@tracked saving = false;
postId = this.args.model.postId;
callback = this.args.model.callback;

#refreshCount() {
if (this.callback) {
this.callback(this.args.model.note.length);
}
}

get attachDisabled() {
return this.saving || !this.newNote || this.newNote.length === 0;
}

@action
async attachNote() {
const note = this.store.createRecord("user-note");
const userId = parseInt(this.userId, 10);

this.saving = true;

const args = {
raw: this.newNote,
user_id: userId,
};

if (this.postId) {
args.post_id = parseInt(this.postId, 10);
}

try {
await note.save(args);
this.newNote = "";
this.args.model.note.insertAt(0, note);
this.#refreshCount();
} catch (error) {
popupAjaxError(error);
} finally {
this.saving = false;
}
}

@action
removeNote(note) {
this.dialog.deleteConfirm({
message: i18n("user_notes.delete_confirm"),
didConfirm: () => {
note
.destroyRecord()
.then(() => {
this.args.model.note.removeObject(note);
this.#refreshCount();
})
.catch(popupAjaxError);
},
});
}

<template>
<DModal
@closeModal={{@closeModal}}
@title={{i18n "user_notes.title"}}
class="user-notes-modal"
>
<Textarea @value={{this.newNote}} />
<DButton
@action={{this.attachNote}}
@label="user_notes.attach"
@disabled={{this.attachDisabled}}
class="btn-primary"
/>

{{#each @model.note as |n|}}
<div class="user-note">
<div class="posted-by">
<UserLink @user={{n.created_by}}>
{{avatar n.created_by imageSize="small"}}
</UserLink>
</div>
<div class="note-contents">
<div class="note-info">
<span class="username">{{n.created_by.username}}</span>
<span class="post-date">{{ageWithTooltip n.created_at}}</span>

{{#if n.can_delete}}
<span class="controls">
<DButton
@action={{fn this.removeNote n}}
@icon="far-trash-can"
@title="user_notes.remove"
class="btn-small btn-danger"
/>
</span>
{{/if}}
</div>

<div class="cooked">
<CookText @rawText={{n.raw}} />
</div>

{{#if n.post_id}}
<a href={{n.post_url}} class="btn btn-small">
{{i18n "user_notes.show_post"}}
</a>
{{/if}}
</div>

<div class="clearfix"></div>
</div>
{{/each}}
</DModal>
</template>
}
52 changes: 0 additions & 52 deletions assets/javascripts/discourse/components/modal/user-notes.hbs

This file was deleted.

Loading