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

Replace Canny with Nolt (closes #775) #1107

Open
wants to merge 7 commits into
base: the-future
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
29 changes: 0 additions & 29 deletions app/components/canny-feedback-script.js

This file was deleted.

13 changes: 13 additions & 0 deletions app/components/nolt-feedback-script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint no-undef: "off" */
import Component from '@ember/component';

export default Component.extend({
didInsertElement() {
this._super(...arguments);

nolt('init', {
selector: '.nolt-button',
Copy link
Member

Choose a reason for hiding this comment

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

Hmmm. Would it be better to create a component that detects its own id and uses that to build a selector?

url: 'https://kitsu.nolt.io/',
});
},
});
5 changes: 5 additions & 0 deletions app/gql/queries/noltToken.gql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
query noltToken {
session {
noltToken
}
}
15 changes: 7 additions & 8 deletions app/initializers/browser-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ function adwords() {
}

/**
* Inject Canny's SDK script into the `head` on initialization.
* Inject Nolt's SDK script into the `head` on initialization.
Copy link
Member

Choose a reason for hiding this comment

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

LOL

*/
function canny() {
const c = function() {
c.q.push(arguments);
function nolt() {
window.noltQueue = window.noltQueue || [];
window.nolt = function() {
noltQueue.push(arguments); /* eslint no-undef: "off" */
};
c.q = [];
window.Canny = c;
injectScript('https://canny.io/sdk.js').catch(() => {});
injectScript('https://cdn.nolt.io/widgets.js').catch(() => {});
}

/**
Expand Down Expand Up @@ -61,7 +60,7 @@ export function initialize() {

// Inject scripts
adwords();
canny();
nolt();
onesignal();
}

Expand Down
13 changes: 0 additions & 13 deletions app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,6 @@ RouterInstance.map(function() {
this.route('account');
});

this.route('feedback', function() {
this.route('bugs');
this.route('bugs-anything', { path: '/bugs/*path' });
this.route('feature-requests');
this.route('feature-requests-anything', { path: '/feature-requests/*path' });
this.route('database-requests');
this.route('database-requests-anything', { path: '/database-requests/*path' });
this.route('mobile-bugs');
this.route('mobile-bugs-anything', { path: '/mobile-bugs/*path' });
this.route('mobile-features');
this.route('mobile-features-anything', { path: '/mobile-features/*path' });
});

this.route('admin', function() {
this.route('reports', function() {
this.route('index', { path: '/open' });
Expand Down
14 changes: 14 additions & 0 deletions app/routes/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import preferredLocale from 'preferred-locale';
import { LANGUAGE_CODES } from 'client/utils/languages';
import momentLocale from 'client/utils/languages-moment';
import config from 'client/config/environment';
import noltTokenQuery from 'client/gql/queries/noltToken';

export default Route.extend(ApplicationRouteMixin, {
features: service(),
Expand All @@ -18,6 +19,7 @@ export default Route.extend(ApplicationRouteMixin, {
metrics: service(),
moment: service(),
raven: service(),
apollo: service(),
cache: storageFor('last-used'),
local: storageFor('local-cache'),

Expand Down Expand Up @@ -150,6 +152,9 @@ export default Route.extend(ApplicationRouteMixin, {
this._loadTheme(user);
get(this, 'moment').changeTimeZone(get(user, 'timeZone') || moment.tz.guess());

// nolt
this._setupNolt();

// notifications
this._registerNotifications();

Expand All @@ -172,6 +177,15 @@ export default Route.extend(ApplicationRouteMixin, {
});
},

_setupNolt() {
get(this, 'apollo').query({ query: noltTokenQuery }, 'session').then(({ noltToken }) => {
// eslint-disable-next-line no-undef
nolt('identify', {
jwt: noltToken,
});
}).catch(() => {});
},

_registerNotifications() {
if (get(this, 'session.account.feedCompleted')) {
window.OneSignal.push(() => {
Expand Down
20 changes: 0 additions & 20 deletions app/routes/feedback.js

This file was deleted.

12 changes: 0 additions & 12 deletions app/routes/feedback/bugs-anything.js

This file was deleted.

7 changes: 0 additions & 7 deletions app/routes/feedback/bugs.js

This file was deleted.

12 changes: 0 additions & 12 deletions app/routes/feedback/database-requests-anything.js

This file was deleted.

7 changes: 0 additions & 7 deletions app/routes/feedback/database-requests.js

This file was deleted.

12 changes: 0 additions & 12 deletions app/routes/feedback/feature-requests-anything.js

This file was deleted.

7 changes: 0 additions & 7 deletions app/routes/feedback/feature-requests.js

This file was deleted.

12 changes: 0 additions & 12 deletions app/routes/feedback/mobile-bugs-anything.js

This file was deleted.

7 changes: 0 additions & 7 deletions app/routes/feedback/mobile-bugs.js

This file was deleted.

12 changes: 0 additions & 12 deletions app/routes/feedback/mobile-features-anything.js

This file was deleted.

7 changes: 0 additions & 7 deletions app/routes/feedback/mobile-features.js

This file was deleted.

9 changes: 4 additions & 5 deletions app/services/ajax.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,13 @@ export default AjaxService.extend({
set(this, 'host', config.kitsu.APIHost);
},

headers: computed('session.isAuthenticated', function() {
headers: computed('session.token', function() {
const headers = {
accept: 'application/vnd.api+json'
};
const isAuthenticated = get(this, 'session.isAuthenticated');
if (isAuthenticated) {
const { access_token: accessToken } = get(this, 'session.data.authenticated');
headers.Authorization = `Bearer ${accessToken}`;
const token = get(this, 'session.token');
if (token) {
headers.Authorization = `Bearer ${token}`;
}
return headers;
}).readOnly()
Expand Down
22 changes: 22 additions & 0 deletions app/services/apollo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { computed, get } from '@ember/object';
import { inject as service } from '@ember/service';
import ApolloService from 'ember-apollo-client/services/apollo';
import { setContext } from 'apollo-link-context';

export default ApolloService.extend({
session: service(),

link: computed('session.token', function() {
const httpLink = this._super(...arguments);

const token = get(this, 'session.token');

const authLink = setContext(() => {
if (!token) return {};

return { headers: { Authorization: `Bearer ${token}` } };
});

return authLink.concat(httpLink);
})
});
9 changes: 9 additions & 0 deletions app/services/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,15 @@ export default Session.extend({
return sessionId === userId;
},

/**
* Get the access token. Returns undefined when not authenticated.
*/
token: computed('isAuthenticated', 'data.authenticated', function() {
if (!this.isAuthenticated) return;

return get(this, 'data.authenticated.access_token');
}),

/**
* Get the account information for the sessioned user
*/
Expand Down
13 changes: 4 additions & 9 deletions app/templates/components/application/site-header.hbs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{nolt-feedback-script}}

<nav id="kitsu-navbar" class="navbar navbar-fixed-top navbar-light primary-nav" role="navigation">
<div class="container">
<div class="row">
Expand Down Expand Up @@ -88,17 +90,10 @@
{{link-to (t "header.groups") "groups.index" class="nav-link"}}
</li>
{{! Feedback}}
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle {{if isFeedbackRoute "active"}}" href="#" data-toggle="dropdown" data-href-to-ignore=true>
<li class="nav-item nolt-button">
<a class="nav-link" href="#" data-href-to-ignore=true>
Copy link
Member

Choose a reason for hiding this comment

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

We should probably link this to https://feedback.kitsu.io/ to still function in case the Nolt widget breaks or gets blocked

{{t "header.feedback"}}
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href={{href-to "feedback.bugs"}}>{{t "feedback.bugs"}}</a>
<a class="dropdown-item" href={{href-to "feedback.feature-requests"}}>{{t "feedback.features"}}</a>
<a class="dropdown-item" href="https://kitsu-stuff.com" target="_blank" rel="noopener">{{t "feedback.database"}}</a>
Copy link
Member

Choose a reason for hiding this comment

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

We still need this 😅

Copy link
Member

Choose a reason for hiding this comment

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

I'm shocked I didn't notice this

<a class="dropdown-item" href={{href-to "feedback.mobile-bugs"}}>{{t "feedback.mobile-bugs"}}</a>
<a class="dropdown-item" href={{href-to "feedback.mobile-features"}}>{{t "feedback.mobile-features"}}</a>
</div>
</li>
</ul>
</div>
Expand Down
46 changes: 0 additions & 46 deletions app/templates/feedback.hbs

This file was deleted.

Loading