Skip to content

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

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
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
34 changes: 18 additions & 16 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)
ast (2.4.3)
base64 (0.2.0)
benchmark (0.4.0)
bigdecimal (3.1.9)
concurrent-ruby (1.3.5)
connection_pool (2.5.0)
connection_pool (2.5.3)
drb (2.2.1)
i18n (1.14.7)
concurrent-ruby (~> 1.0)
json (2.10.2)
language_server-protocol (3.17.0.4)
json (2.12.0)
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.14)
rainbow (3.1.1)
regexp_parser (2.10.0)
rubocop (1.74.0)
rubocop (1.75.5)
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.31.0)
activesupport (>= 4.2.0)
lint_roller (~> 1.1)
rack (>= 1.1)
rubocop (>= 1.72.1, < 2.0)
rubocop (>= 1.75.0, < 2.0)
rubocop-ast (>= 1.38.0, < 2.0)
rubocop-rspec (3.5.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.8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import or from "truth-helpers/helpers/or";
import { or } from "truth-helpers";
import ActivityPubActorHandleLink from "./activity-pub-actor-handle-link";
import ActivityPubActorImage from "./activity-pub-actor-image";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { Input } from "@ember/component";
import { fn, hash } from "@ember/helper";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import DButton from "discourse/components/d-button";
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";
import getURL from "discourse/lib/get-url";
import { i18n } from "discourse-i18n";
import ComboBox from "select-kit/components/combo-box";

const supportedAuthTypes = ["discourse", "mastodon"];

Expand Down Expand Up @@ -121,4 +126,60 @@ export default class ActivityPubAuthorize extends Component {
authorizeDomain() {
window.open(getURL(`/ap/auth/authorize/${this.authType}`), "_self");
}

<template>
<div class={{this.containerClass}}>
<div class="controls">
<ComboBox
@id="user_activity_pub_authorize_auth_type"
class="activity-pub-authorize-auth-type"
@content={{this.authTypes}}
@value={{this.authType}}
@onChange={{fn (mut this.authType)}}
@disabled={{this.verifiedDomain}}
@options={{hash
none="user.discourse_activity_pub.authorize.auth_type.none.label"
}}
/>
{{#if this.verifiedDomain}}
<span class="activity-pub-authorize-verified-domain">
<span>{{this.domain}}</span>
<DButton
@icon="xmark"
@action={{action "clearDomain"}}
@title="user.discourse_activity_pub.clear_domain_button.title"
id="user_activity_pub_authorize_clear_domain"
class="activity-pub-authorize-clear-domain"
/>
</span>
{{else}}
<Input
@value={{this.domain}}
disabled={{this.verifyingDomain}}
placeholder={{this.placeholder}}
id="user_activity_pub_authorize_domain"
{{on "keydown" this.onDomainKeyDown}}
/>
{{/if}}
<DButton
@icon="check"
@action={{action "verifyDomain"}}
@label="user.discourse_activity_pub.verify_domain_button.label"
@title="user.discourse_activity_pub.verify_domain_button.title"
@disabled={{this.verifyDisabled}}
id="user_activity_pub_authorize_verify_domain"
class={{this.verifyBtnClass}}
/>
<DButton
@icon="fingerprint"
@action={{action "authorizeDomain"}}
@label="user.discourse_activity_pub.authorize_button.label"
@title="user.discourse_activity_pub.authorize_button.title"
@disabled={{this.authorizeDisabled}}
id="user_activity_pub_authorize_authorize_domain"
class={{this.authorizeBtnClass}}
/>
</div>
</div>
</template>
}
53 changes: 0 additions & 53 deletions assets/javascripts/discourse/components/activity-pub-authorize.hbs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { Input } from "@ember/component";
import { on } from "@ember/modifier";
import { action } from "@ember/object";
import { service } from "@ember/service";
import { Promise } from "rsvp";
import DButton from "discourse/components/d-button";
import { ajax } from "discourse/lib/ajax";
import DiscourseURL from "discourse/lib/url";
import { extractDomainFromUrl, hostnameValid } from "discourse/lib/utilities";
Expand All @@ -22,8 +24,6 @@ const mastodonFollowUrl = (domain, handle) => {
const mastodonAboutPath = "api/v2/instance";

export default class ActivityPubFollowDomain extends Component {
@service site;

@tracked verifying = false;
@tracked error = null;

Expand Down Expand Up @@ -88,4 +88,37 @@ export default class ActivityPubFollowDomain extends Component {
this.error = i18n("discourse_activity_pub.follow.domain.invalid");
}
}

<template>
<div class="activity-pub-follow-domain">
<label>{{i18n "discourse_activity_pub.follow.domain.label"}}</label>
<div class="activity-pub-follow-domain-controls inline-form">
<Input
{{on "keyup" this.onKeyup}}
@value={{this.domain}}
placeholder={{i18n
"discourse_activity_pub.follow.domain.placeholder"
}}
id="activity_pub_follow_domain_input"
/>
<DButton
@icon="up-right-from-square"
@action={{action "follow"}}
@label="discourse_activity_pub.follow.domain.btn_label"
@title="discourse_activity_pub.follow.domain.btn_title"
@disabled={{this.verifying}}
id="activity_pub_follow_domain_button"
/>
</div>
<div class={{this.footerClass}}>
{{#if this.error}}
{{this.error}}
{{else if this.verifying}}
{{i18n "discourse_activity_pub.follow.domain.verifying"}}
{{else}}
{{i18n "discourse_activity_pub.follow.domain.description"}}
{{/if}}
</div>
</div>
</template>
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import { action } from "@ember/object";
import { service } from "@ember/service";
import DButton from "discourse/components/d-button";
import icon from "discourse/helpers/d-icon";
import discourseLater from "discourse/lib/later";
import { clipboardCopy } from "discourse/lib/utilities";

export default class ActivityPubHandle extends Component {
@service site;
@service siteSettings;

@tracked copied = false;

get showLink() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import didInsert from "@ember/render-modifiers/modifiers/did-insert";
import didUpdate from "@ember/render-modifiers/modifiers/did-update";
import willDestroy from "@ember/render-modifiers/modifiers/will-destroy";
import { service } from "@ember/service";
import icon from "discourse/helpers/d-icon";
import { bind } from "discourse/lib/decorators";
import getURL from "discourse/lib/get-url";
import { i18n } from "discourse-i18n";
Expand All @@ -13,7 +17,6 @@ export default class ActivityPubNavItem extends Component {
@service router;
@service messageBus;
@service site;
@service currentUser;

@tracked visible = false;
@tracked actor;
Expand Down Expand Up @@ -110,4 +113,19 @@ export default class ActivityPubNavItem extends Component {
get active() {
return this.router.currentRouteName.includes(`activityPub.actor`);
}

<template>
<a
class={{this.classes}}
href={{this.href}}
title={{this.title}}
{{didInsert this.setup}}
{{didUpdate this.changeCategory @category}}
{{didUpdate this.changeTag @tag}}
{{willDestroy this.teardown}}
>
{{icon "discourse-activity-pub"}}
{{i18n "discourse_activity_pub.discovery.label"}}
</a>
</template>
}
12 changes: 0 additions & 12 deletions assets/javascripts/discourse/components/activity-pub-nav-item.hbs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ export default class ActivityPubPostActions extends Component {
this.status = status;
}

willDestroy() {
super.willDestroy(...arguments);
this.appEvents.off("activity-pub:post-updated", this, "postUpdated");
}

postUpdated(postId, postProps) {
if (this.post.id === postId) {
this.post.setProperties(postProps);
Expand Down
Loading