Skip to content

fix: ability to remove admin area social links #5038

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 4 commits into from
Sep 10, 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
1 change: 0 additions & 1 deletion app/components/widgets/forms/link-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ export default class LinkInput extends Component {

@observes('protocol', 'address')
protocolAddressObserver() {
if (!this.address) {return}
const link = this.linkName?.toLowerCase();
Comment on lines 33 to 34
Copy link
Member Author

Choose a reason for hiding this comment

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

This was not letting us delete the whole eventyay, even in UI we removed eventyay but e was still not removed behind the scenes.

Copy link
Member

Choose a reason for hiding this comment

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

Then please ensure this isn't happening - #4947

Copy link
Member Author

Choose a reason for hiding this comment

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

Looks good to me.

Screenshot at 2020-09-10 19-13-08


let add = this.address;
Expand Down
3 changes: 2 additions & 1 deletion app/mixins/event-wizard.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ export default Mixin.create(MutableArray, CustomFormMixin, {
addItem(type, model) {
if (type === 'socialLinks') {
this.get(`data.event.${type}`).pushObject(this.store.createRecord(model, {
identifier: v1()
identifier : v1(),
isCustom : false
}));
} else if (type === 'customLink') {
this.get('data.event.socialLinks').pushObject(this.store.createRecord(model, {
Expand Down
8 changes: 5 additions & 3 deletions app/models/social-link.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { computed } from '@ember/object';
import attr from 'ember-data/attr';
import ModelBase from 'open-event-frontend/models/base';
import { belongsTo } from 'ember-data/relationships';
import { computedSegmentedLink } from 'open-event-frontend/utils/computed-helpers';
import { computedSegmentedLink, socialPlatforms } from 'open-event-frontend/utils/computed-helpers';

export default ModelBase.extend({
name : attr('string'),
Expand All @@ -19,14 +19,16 @@ export default ModelBase.extend({
// https://github.com/fossasia/open-event-frontend/issues/4777

const normalizedName = this.name?.trim().toLowerCase();
const socialPlatforms = ['facebook', 'twitter', 'github', 'youtube', 'linkedin', 'google'];
if (!socialPlatforms.includes(normalizedName)) {
return 'globe';
}
return normalizedName;
}),

isTwitter: equal('normalizedName', 'twitter'),
isTwitter : equal('normalizedName', 'twitter'),
isCustom : computed('normalizedName', function() {
return !socialPlatforms.includes(this.normalizedName);
}),

segmentedLink: computedSegmentedLink.bind(this)('link')
});
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,55 @@
<label>{{t 'Twitter'}}</label>
<Widgets::Forms::LinkInput
@segmentedLink={{this.socials.segmentedTwitterUrl}}
@linkname="twitter"
@linkName="twitter"
@isSocialLink={{true}}
@inputId="twitter" />
</div>
<div class="field">
<label>{{t 'Facebook'}}</label>
<Widgets::Forms::LinkInput
@segmentedLink={{this.socials.segmentedFacebookUrl}}
@linkname="facebook"
@linkName="facebook"
@isSocialLink={{true}}
@inputId="facebook" />
</div>
<div class="field">
<label>{{t 'Instagram'}}</label>
<Widgets::Forms::LinkInput
@segmentedLink={{this.socials.segmentedInstagramUrl}}
@linkname="instagram"
@linkName="instagram"
@isSocialLink={{true}}
@inputId="instagram" />
</div>
<div class="field">
<label>{{t 'Google Group'}}</label>
<Widgets::Forms::LinkInput
@segmentedLink={{this.socials.segmentedGoogleUrl}}
@linkname="groups.google"
@linkName="groups.google"
@isSocialLink={{true}}
@inputId="google_group" />
</div>
<div class="field">
<label>{{t 'YouTube'}}</label>
<Widgets::Forms::LinkInput
@segmentedLink={{this.socials.segmentedYoutubeUrl}}
@linkname="youtube"
@linkName="youtube"
@isSocialLink={{true}}
@inputId="youtube" />
</div>
<div class="field">
<label>{{t 'GitHub'}}</label>
<Widgets::Forms::LinkInput
@segmentedLink={{this.socials.segmentedGithubUrl}}
@linkname="github"
@linkName="github"
@isSocialLink={{true}}
@inputId="github" />
</div>
<div class="field">
<label>{{t 'Patreon'}}</label>
<Widgets::Forms::LinkInput
@segmentedLink={{this.socials.segmentedPatreonUrl}}
@linkname="patreon"
@linkName="patreon"
@isSocialLink={{true}}
@inputId="patreon" />
</div>
Expand Down
8 changes: 4 additions & 4 deletions app/utils/computed-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { isValidUrl } from 'open-event-frontend/utils/validators';
import { FORM_DATE_FORMAT, FORM_TIME_FORMAT } from 'open-event-frontend/utils/dictionary/date-time';

// Social Platforms
export const socialPlatforms = ['twitter', 'facebook', 'instagram', 'linkedin', 'youtube', 'github', 'gitlab', 'vimeo', 'flicker', 'groups.google'];
export const socialPlatforms = ['twitter', 'facebook', 'instagram', 'linkedin', 'youtube', 'github', 'gitlab', 'patreon', 'vimeo', 'flicker', 'groups.google'];

/**
* Get/set a splitted URL from/to a string URL field
Expand All @@ -30,7 +30,7 @@ export const computedSegmentedLink = function(property) {
if (isSocialUrl) {
return {
protocol : `${splitted[0]}://${splittedDomain[0]}.com/`,
address : splittedDomain.slice(-1) // last element is username
address : splittedDomain.slice(-1)[0] // last element is username
};
}
const isHTTPSOnly = splitted[0] === 'https';
Expand All @@ -41,8 +41,8 @@ export const computedSegmentedLink = function(property) {
},
set(key, value) {
const finalLink = values(value).join('');

if (finalLink && isValidUrl(finalLink.trim())) {
const isUserNamePresent = values(value)[1];
if (finalLink && isValidUrl(finalLink.trim()) && isUserNamePresent) {
this.set(property, finalLink.trim());
} else {
this.set(property, null);
Expand Down