Skip to content
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

DEV: switch to using subscription gem to avoid the need to rely on Subscription Client plugin #266

Merged
merged 97 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
27cde86
wip
merefield Sep 4, 2023
c2ffa76
wip
merefield Sep 8, 2023
3a0ba45
wip
merefield Sep 8, 2023
f1e3db4
point to new sub client gem update, add deauthorize action
merefield Sep 22, 2023
bcd6f86
debug
merefield Sep 22, 2023
07bed7e
evolve
merefield Sep 22, 2023
28f1704
debug
merefield Sep 22, 2023
b78914e
evolve
merefield Sep 22, 2023
7628893
Merge branch 'use_subscription_gem' of github.com:paviliondev/discour…
merefield Sep 22, 2023
baf533a
clean up
merefield Sep 22, 2023
4377094
prettier
merefield Sep 22, 2023
051d1db
eslint
merefield Sep 22, 2023
2f206f6
remove redundant client installed check code
merefield Sep 22, 2023
4f887a8
fix
merefield Sep 22, 2023
4f8ab0b
fix
merefield Sep 22, 2023
b454340
convert subscription mixin to service, colocate glimmer files
merefield Sep 23, 2023
d6ca154
rename service class
merefield Sep 23, 2023
a558e19
fix variable reference
merefield Sep 23, 2023
b1fddc3
evolve service
merefield Sep 23, 2023
eefbe0a
debug
merefield Sep 24, 2023
6a1ead0
debug
merefield Sep 24, 2023
26e4267
move subscription back-end call
merefield Sep 24, 2023
f012dc2
fix file inclusion
merefield Sep 24, 2023
ca11dac
tweak route
merefield Sep 24, 2023
390f53a
tweak route
merefield Sep 24, 2023
0b2e66b
tweak route
merefield Sep 24, 2023
e43fbd0
move subscription container to Glimmer
merefield Sep 24, 2023
7f245d6
fix spelling mistake
merefield Sep 24, 2023
a8af37b
remove redundant sub client check
merefield Sep 24, 2023
f97d15a
debug
merefield Sep 24, 2023
dd7f2a7
attempted fix
merefield Sep 24, 2023
9cc65d2
revert
merefield Sep 24, 2023
5192e08
change copy for deauthorize label
merefield Sep 24, 2023
73e8b0a
remove debugging
merefield Sep 24, 2023
d5bd3c3
prettier
merefield Sep 24, 2023
db7d9c1
strip out redundant code from admin wizards route and controller
merefield Sep 24, 2023
15f596e
merge in main
merefield Sep 24, 2023
56181f6
linting
merefield Sep 24, 2023
18001be
rubocop
merefield Sep 24, 2023
885fdd1
remove redundant controller link
merefield Sep 24, 2023
0399cff
remove redundant import
merefield Sep 24, 2023
74a96af
linting
merefield Sep 24, 2023
c89dbbb
linting
merefield Sep 24, 2023
1fdd78b
convert buttons to DButton
merefield Sep 24, 2023
648b976
fix button close
merefield Sep 24, 2023
6755c70
simplify buttons
merefield Sep 24, 2023
0ad8616
linting
merefield Sep 24, 2023
2c109c5
update front-end tests
merefield Sep 24, 2023
8407227
update back-end tests
merefield Sep 24, 2023
43ad578
update FE tests
merefield Sep 24, 2023
45db227
add FE get suppliers stub
merefield Sep 24, 2023
80fcddc
fix front end tests
merefield Sep 25, 2023
ea02e53
prettier
merefield Sep 25, 2023
c5d8003
prettier
merefield Sep 25, 2023
1a32862
namespace fix
merefield Sep 25, 2023
6aa68eb
overcome inheritance that was forcing table look up on tests
merefield Sep 28, 2023
c0082b8
instantiate mocked up interface for more tests
merefield Sep 28, 2023
4422bad
locale changes
merefield Sep 28, 2023
da2a56a
specs: ensure sub client code is mocked out
merefield Sep 28, 2023
13fb5dc
remove redundant code
merefield Sep 28, 2023
c8263ed
change name of subscription stubbing method to add clarity of intent
merefield Sep 28, 2023
4007fd9
fix localisation for deauthorize
merefield Sep 28, 2023
df9a3c6
fix title
merefield Sep 28, 2023
e17f90c
fix title
merefield Sep 28, 2023
fdfccf5
fix titles & labels on sub button
merefield Sep 28, 2023
e120a1a
one more try
merefield Sep 28, 2023
d8d8eee
merge main, bump patch
merefield Oct 4, 2023
44f2394
add front end tests for authorisation and subscription status
merefield Oct 6, 2023
9017871
linting
merefield Oct 6, 2023
0fcbcfb
css tweak
merefield Oct 7, 2023
d5d500f
bump patch
merefield Oct 7, 2023
8dc04bd
merge in of main
merefield Oct 7, 2023
1824738
css tweak
merefield Oct 7, 2023
2b867ce
FEATURE: add a sub refresh button
merefield Oct 9, 2023
06e5b4b
try alternative subscription update
merefield Oct 9, 2023
2617a62
merge in main
merefield Nov 15, 2023
bd71252
temp sub update debugging
merefield Nov 15, 2023
6be518f
first update local subscriptions before retrieving them
merefield Nov 15, 2023
8e2b117
make subscription update happen asynchronously on FE
merefield Nov 15, 2023
f6ce0f5
linting
merefield Nov 15, 2023
a82af2e
make init process async
merefield Nov 15, 2023
a58b13e
only run remote sub update retrieve on update action
merefield Nov 15, 2023
4444f48
prettier
merefield Nov 15, 2023
a575fec
fix some tests
merefield Nov 15, 2023
df3e5b6
COMPATIBILITY: resolve register unbound deprecation
merefield Nov 16, 2023
ee5ef55
fix a FE test involving altered Composer
merefield Nov 16, 2023
a468c2c
prettier
merefield Nov 16, 2023
d297ccd
prettier
merefield Nov 16, 2023
a7d1d5a
fix more FE tests
merefield Nov 16, 2023
4fd128f
prettier
merefield Nov 16, 2023
b0d91cc
IMPROVE: move Pavilion icon to dedicated file and implementation stan…
merefield Nov 17, 2023
cf1e661
restore client install check
merefield Nov 17, 2023
320ebe3
prettier
merefield Nov 17, 2023
591cb9b
IMPROVE: utilise button icon to signify update
merefield Nov 17, 2023
812d3d0
prettier
merefield Nov 17, 2023
fe7b1ec
formatting tweak to prevent change of update button status disturbing…
merefield Nov 17, 2023
f3ca0aa
Don't run a remote subsciption status update on every visit to Wizard…
merefield Nov 17, 2023
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: 0 additions & 10 deletions app/controllers/custom_wizard/admin/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
class CustomWizard::AdminController < ::Admin::AdminController
before_action :ensure_admin

def index
subcription = CustomWizard::Subscription.new
render_json_dump(
subscribed: subcription.subscribed?,
subscription_type: subcription.type,
subscription_attributes: CustomWizard::Subscription.attributes,
subscription_client_installed: CustomWizard::Subscription.client_installed?
)
end

private

def find_wizard
Expand Down
18 changes: 18 additions & 0 deletions app/controllers/custom_wizard/admin/subscription.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# frozen_string_literal: true
class CustomWizard::SubscriptionController < ::Admin::AdminController
before_action :ensure_admin

def index
if params[:update_from_remote]
subscription = CustomWizard::Subscription.new(true)
else
subscription = CustomWizard::Subscription.new
end

render_json_dump(
subscribed: subscription.subscribed?,
subscription_type: subscription.type,
subscription_attributes: CustomWizard::Subscription.attributes,
)
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import I18n from "I18n";
export default class AdminWizardsColumnComponent extends Component {
title = I18n.t("admin.wizard.edit_columns");

@action save() {
@action
save() {
this.args.closeModal();
}

@action resetToDefault() {
@action
resetToDefault() {
this.args.model.reset();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ export default class NextSessionScheduledComponent extends Component {
return moment().isAfter(this.bufferedDateTime);
}

@action submit() {
@action
submit() {
const dateTime = this.bufferedDateTime;
this.args.model.update(moment(dateTime).utc().toISOString());
this.args.closeModal();
}

@action dateTimeChanged(dateTime) {
@action
dateTimeChanged(dateTime) {
this.bufferedDateTime = dateTime;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
import Component from "@ember/component";
import { bind, later } from "@ember/runloop";
import I18n from "I18n";
import Subscription from "../mixins/subscription";
import { inject as service } from "@ember/service";

const customFieldActionMap = {
topic: ["create_topic", "send_message"],
Expand All @@ -27,8 +27,9 @@ const customFieldActionMap = {

const values = ["present", "true", "false"];

export default Component.extend(Subscription, {
export default Component.extend({
classNameBindings: [":mapper-selector", "activeType"],
subscription: service(),

showText: computed("activeType", function () {
return this.showInput("text");
Expand Down Expand Up @@ -130,7 +131,11 @@ export default Component.extend(Subscription, {
return this.connector === "is";
}),

@discourseComputed("site.groups", "guestGroup", "subscriptionType")
@discourseComputed(
"site.groups",
"guestGroup",
"subscription.subscriptionType"
)
groups(groups, guestGroup, subscriptionType) {
let result = groups;
if (!guestGroup) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<DButton
@action={{this.click}}
class="wizard-subscription-badge {{this.subscription.subscriptionType}}"
@title={{this.title}}
>
{{d-icon "pavilion-logo"}}
<span>{{this.label}}</span>
</DButton>
<DButton
@icon={{this.updateIcon}}
@action={{this.update}}
class="btn btn-primary update"
@disabled={{this.updating}}
@title="admin.wizard.subscription.update.title"
>
{{#if this.updating}}
{{loading-spinner size="small"}}
{{/if}}
</DButton>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { inject as service } from "@ember/service";
import { action, computed } from "@ember/object";
import Component from "@glimmer/component";
import { tracked } from "@glimmer/tracking";
import DiscourseURL from "discourse/lib/url";
import I18n from "I18n";

export default class WizardSubscriptionBadge extends Component {
@service subscription;
@tracked updating = false;
@tracked updateIcon = "sync";
basePath = "/admin/plugins/subscription-client";

@computed("subscription.subscriptionType")
get i18nKey() {
return `admin.wizard.subscription.type.${
this.subscription.subscriptionType
? this.subscription.subscriptionType
: "none"
}`;
}

@computed("i18nKey")
get title() {
return `${this.i18nKey}.title`;
}

@computed("i18nKey")
get label() {
return I18n.t(`${this.i18nKey}.label`);
}

@action
click() {
DiscourseURL.routeTo(this.subscription.subscriptionLink);
}

@action
update() {
this.updating = true;
this.updateIcon = null;
this.subscription.updateSubscriptionStatus().finally(() => {
this.updateIcon = "sync";
this.updating = false;
});
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div
class="wizard-subscription-container
{{if this.subscription.subscribed 'subscribed'}}"
>
<div class="subscription-header">
<h4>{{i18n "admin.wizard.subscription.title"}}</h4>

<a href={{subscriptionLink}} title={{i18n subscribedTitle}}>
{{d-icon subscribedIcon}}
{{i18n subscribedLabel}}
</a>
</div>

<div class="subscription-settings">
{{yield}}
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import Component from "@glimmer/component";
import { computed } from "@ember/object";
import { inject as service } from "@ember/service";

export default class WizardSubscriptionContainer extends Component {
@service subscription;

@computed("subscription.subscribed")
get subscribedIcon() {
return this.subscription.subscribed ? "check" : "times";
}

@computed("subscription.subscribed")
get subscribedLabel() {
return `admin.wizard.subscription.${
this.subscription.subscribed ? "subscribed" : "not_subscribed"
}.label`;
}

@computed("subscription.subscribed")
get subscribedTitle() {
return `admin.wizard.subscription.${
this.subscription.subscribed ? "subscribed" : "not_subscribed"
}.title`;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<DButton
@action={{this.click}}
class="btn btn-pavilion-support {{this.subscription.subscriptionType}}"
@title={{this.title}}
@label={{this.label}}
@icon={{this.icon}}
/>
34 changes: 34 additions & 0 deletions assets/javascripts/discourse/components/wizard-subscription-cta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { inject as service } from "@ember/service";
merefield marked this conversation as resolved.
Show resolved Hide resolved
import { action, computed } from "@ember/object";
import Component from "@glimmer/component";

export default class WizardSubscriptionCta extends Component {
@service subscription;

@computed("subscription.subscribed")
get i18nKey() {
return `admin.wizard.subscription.cta.${
this.subscription.subscribed ? "subscribed" : "none"
}`;
}

@computed("subscription.subscribed")
get icon() {
return this.subscription.subscribed ? "far-life-ring" : "external-link-alt";
}

@computed("i18nKey")
get title() {
return `${this.i18nKey}.title`;
}

@computed("i18nKey")
get label() {
return `${this.i18nKey}.label`;
}

@action
click() {
window.open(this.subscription.subscriptionCtaLink, "_blank").focus();
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import SingleSelectComponent from "select-kit/components/single-select";
import Subscription from "../mixins/subscription";
import { inject as service } from "@ember/service";
import { filterValues } from "discourse/plugins/discourse-custom-wizard/discourse/lib/wizard-schema";
import discourseComputed from "discourse-common/utils/decorators";
import I18n from "I18n";
Expand All @@ -12,8 +12,9 @@ const nameKey = function (feature, attribute, value) {
}
};

export default SingleSelectComponent.extend(Subscription, {
export default SingleSelectComponent.extend({
classNames: ["combo-box", "wizard-subscription-selector"],
subscription: service(),

selectKitOptions: {
autoFilterable: false,
Expand All @@ -26,7 +27,7 @@ export default SingleSelectComponent.extend(Subscription, {
},

allowedSubscriptionTypes(feature, attribute, value) {
let attributes = this.subscriptionAttributes[feature];
let attributes = this.subscription.subscriptionAttributes[feature];
if (!attributes || !attributes[attribute]) {
return ["none"];
}
Expand Down Expand Up @@ -59,10 +60,9 @@ export default SingleSelectComponent.extend(Subscription, {
name: I18n.t(nameKey(feature, attribute, value)),
subscriptionRequired,
};

if (subscriptionRequired) {
let subscribed = allowedSubscriptionTypes.includes(
this.subscriptionType
this.subscription.subscriptionType
);
let selectorKey = subscribed ? "subscribed" : "not_subscribed";
let selectorLabel = `admin.wizard.subscription.${selectorKey}.selector`;
Expand Down
Loading
Loading