Skip to content

feat: Add cookie policy editor and fix hide behaviour #5073

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 2 commits into from
Sep 15, 2020
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
39 changes: 25 additions & 14 deletions app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import classic from 'ember-classic-decorator';
import { computed } from '@ember/object';
import { computed, action } from '@ember/object';
import { inject as service } from '@ember/service';
import { filterBy } from '@ember/object/computed';
import Controller from '@ember/controller';
Expand All @@ -23,20 +23,31 @@ export default class ApplicationController extends Controller {
@filterBy('model.pages', 'place', 'footer')
footerPages;

@computed
get showCookie() {
getCookieSeen(write) {
const cookieName = 'seen-cookie-message';
const cookie = this.cookies.read(cookieName);
let cookieExists = false;
cookieExists = !(cookie != null && cookie === 'yes');
let date = moment();
date = date.add(30, 'day');
const expires = date.toISOString();
const options = {
path: '/',
expires
};
this.cookies.write(cookieName, 'yes', options);
return cookieExists;
const cookieExists = cookie === 'yes';
if (write) {
let date = moment();
date = date.add(30, 'day');
const expires = date.toISOString();
const options = {
path: '/',
expires
};
this.cookies.write(cookieName, 'yes', options);
}
return !cookieExists;
}

@computed
get showCookie() {
return this.getCookieSeen();
}

@action
hideCookieMessage() {
this.getCookieSeen(true);
this.showCookie = false;
}
}
24 changes: 12 additions & 12 deletions app/models/setting.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,16 +102,16 @@ export default ModelBase.extend({
* Computed properties
*/

segmentedSupportUrl : computedSegmentedLink.bind(this)('supportUrl'),
segmentedFacebookUrl : computedSegmentedLink.bind(this)('facebookUrl'),
segmentedInstagramUrl : computedSegmentedLink.bind(this)('instagramUrl'),
segmentedPatreonUrl : computedSegmentedLink.bind(this)('patreonUrl'),
segmentedTwitterUrl : computedSegmentedLink.bind(this)('twitterUrl'),
segmentedGoogleUrl : computedSegmentedLink.bind(this)('googleUrl'),
segmentedYoutubeUrl : computedSegmentedLink.bind(this)('youtubeUrl'),
segmentedGithubUrl : computedSegmentedLink.bind(this)('githubUrl'),
segmentedAndroidAppUrl : computedSegmentedLink.bind(this)('androidAppUrl'),
segmentedWebAppUrl : computedSegmentedLink.bind(this)('webAppUrl'),
segmentedFrontendUrl : computedSegmentedLink.bind(this)('frontendUrl'),
segmentedStaticDomain : computedSegmentedLink.bind(this)('staticDomain')
segmentedSupportUrl : computedSegmentedLink.bind(this)('supportUrl'),
segmentedFacebookUrl : computedSegmentedLink.bind(this)('facebookUrl'),
segmentedInstagramUrl : computedSegmentedLink.bind(this)('instagramUrl'),
segmentedPatreonUrl : computedSegmentedLink.bind(this)('patreonUrl'),
segmentedTwitterUrl : computedSegmentedLink.bind(this)('twitterUrl'),
segmentedGoogleUrl : computedSegmentedLink.bind(this)('googleUrl'),
segmentedYoutubeUrl : computedSegmentedLink.bind(this)('youtubeUrl'),
segmentedGithubUrl : computedSegmentedLink.bind(this)('githubUrl'),
segmentedAndroidAppUrl : computedSegmentedLink.bind(this)('androidAppUrl'),
segmentedWebAppUrl : computedSegmentedLink.bind(this)('webAppUrl'),
segmentedFrontendUrl : computedSegmentedLink.bind(this)('frontendUrl'),
segmentedStaticDomain : computedSegmentedLink.bind(this)('staticDomain')
});
2 changes: 1 addition & 1 deletion app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id='device-type-identifier'></div>
{{#if this.showCookie}}
<div class="ui inline warning large message">
<i class="close icon" onclick={{action (mut this.showCookie) false}} role="button"></i>
<i class="close icon" onclick={{action 'hideCookieMessage'}} role="button"></i>
{{this.model.cookiePolicy}}
{{#if this.model.cookiePolicyLink}}
<p><a href="{{this.model.cookiePolicyLink}}">Click here For more information</a></p>
Copy link
Member

Choose a reason for hiding this comment

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

Please change to "Click here for more information."

(no capital F in For)

Expand Down
16 changes: 16 additions & 0 deletions app/templates/components/forms/admin/settings/system-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,22 @@
<Widgets::Forms::LinkInput @segmentedLink={{this.settings.segmentedStaticDomain}} @inputId="api_url" />
</div>
<div class="ui hidden divider"></div>
<h3 class="ui header">
{{t 'Cookie Policy'}}
</h3>
<div class="field">
<label>
{{t 'Cookie Policy URL'}}
</label>
<Input type="url" @value={{this.settings.cookiePolicyLink}} />
</div>
<div class="field">
<label>{{t 'Cookie Policy'}}</label>
<Textarea
@rows="3"
@value={{this.settings.cookiePolicy}} />
</div>
<div class="ui hidden divider"></div>
<Forms::Admin::Settings::System::SocialMediaToken @settings={{this.settings}} />
<div class="ui hidden divider"></div>
<Forms::Admin::Settings::System::CaptchaForm @settings={{this.settings}} />
Expand Down