This repository has been archived by the owner on Jul 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TMP: add unlink from pmo button in user preferences
depends on: discourse/discourse#8084
- Loading branch information
Showing
13 changed files
with
359 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
assets/javascripts/discourse/connectors/above-user-preferences/mozilla-iam.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import showModal from "discourse/lib/show-modal" | ||
import { ajax } from "discourse/lib/ajax" | ||
|
||
export default { | ||
setupComponent(args, component) { | ||
}, | ||
|
||
reload() { | ||
window.location.reload() | ||
}, | ||
|
||
actions: { | ||
unlink() { | ||
const container = Discourse.__container__; | ||
const controller = container.lookup("controller:dinopark-unlink-modal") | ||
controller.setProperties({ | ||
user: this.get("model") | ||
}) | ||
showModal("dinopark-unlink-modal") | ||
}, | ||
}, | ||
|
||
shouldRender(args, component) { | ||
return args.model.get("mozilla_iam.dinopark_enabled") | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
assets/javascripts/discourse/controllers/dinopark-unlink-modal.js.es6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ModalFunctionality from "discourse/mixins/modal-functionality" | ||
import { ajax } from "discourse/lib/ajax" | ||
|
||
export default Ember.Controller.extend(ModalFunctionality, { | ||
|
||
reload(url) { | ||
window.location.reload() | ||
}, | ||
|
||
actions: { | ||
continue() { | ||
this.set("submitted", true) | ||
return ajax("/mozilla_iam/dinopark_unlink.json", { | ||
type: "POST" | ||
}).then(result => { | ||
if (result.success) { | ||
this.reload() | ||
} else { | ||
this.fail(result.message || I18n.t("dinopark.unlink.failed")) | ||
} | ||
}, () => { | ||
this.fail(I18n.t("dinopark.unlink.failed")) | ||
}) | ||
}, | ||
|
||
cancel() { | ||
this.modal.send("closeModal") | ||
} | ||
} | ||
}); |
9 changes: 9 additions & 0 deletions
9
assets/javascripts/discourse/templates/connectors/above-user-preferences/mozilla-iam.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div class="dinopark-preferences-banner alert alert-info"> | ||
{{{i18n "dinopark.preferences.linked_description"}}} | ||
<div class="buttons"> | ||
<button class="btn btn-medium unlink" title="{{i18n "dinopark.preferences.unlink_long"}}" {{action "unlink"}}> | ||
{{d-icon "unlink" label=(i18n "dinopark.preferences.unlink_long")}} | ||
<span aria-hidden>{{i18n 'dinopark.preferences.unlink'}}</span> | ||
</button> | ||
</div> | ||
</div> |
26 changes: 26 additions & 0 deletions
26
assets/javascripts/discourse/templates/modal/dinopark-unlink-modal.hbs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{{#d-modal-body class="dinopark-unlink-modal" title="dinopark.unlink.title"}} | ||
<p>{{i18n "dinopark.unlink.description_1"}}</p> | ||
<p>{{i18n "dinopark.unlink.description_2"}}</p> | ||
<div class="discourse-fields"> | ||
<div>{{i18n "dinopark.unlink.username"}}:</div> | ||
<div class="value value-username">{{user.username}}</div> | ||
|
||
<div>{{i18n "dinopark.unlink.name"}}:</div> | ||
<div class="value value-name">{{user.name}}</div> | ||
|
||
<div>{{i18n "dinopark.unlink.bio"}}:</div> | ||
<div class="value value-bio">{{{user.bio_cooked}}}</div> | ||
|
||
<div>{{i18n "dinopark.unlink.location"}}:</div> | ||
<div class="value value-location">{{user.location}}</div> | ||
|
||
<div>{{i18n "dinopark.unlink.avatar"}}:</div> | ||
<div class="value value-avatar">{{bound-avatar user "medium"}}</div> | ||
</div> | ||
{{/d-modal-body}} | ||
<div class="modal-footer"> | ||
{{#conditional-loading-spinner condition=submitted size="small"}} | ||
{{d-button label="dinopark.unlink.continue" class="btn-primary" action=(action "continue")}} | ||
{{d-button label="dinopark.unlink.cancel" action=(action "cancel")}} | ||
{{/conditional-loading-spinner}} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.