Skip to content

Commit 426d540

Browse files
committed
docs: rewrite the ADR
1 parent 0e46a09 commit 426d540

File tree

1 file changed

+102
-49
lines changed

1 file changed

+102
-49
lines changed

docs/decisions/0002-footer-links.rst

Lines changed: 102 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -44,21 +44,94 @@ Decision
4444
Links
4545
=====
4646

47-
For specifying the footer links, we are going to use `MFE's config mechanism`_.
48-
That would allow to specify a list of links in various ways:
49-
50-
* At build time:
51-
* Via environmental variables
52-
* By providing them in ``env.config.js``, like so:
47+
LMS already has API that is used by the legacy UI footer. Since our goal is to
48+
make the legacy and MFE footers similar, it only makes sence to use the same
49+
API.
50+
51+
``<LMS_BASE>/api/branding/v1/footer`` is the endpoint that can be used to
52+
retreive the information about the footer. A GET request has to be made, with
53+
``Accepts: application/json`` header, to get a JSON object with footer links.
54+
55+
Example:
56+
.. code-block::
57+
58+
GET /api/branding/v1/footer
59+
Accepts: application/json
60+
61+
{
62+
"navigation_links": [
63+
{
64+
"url": "http://example.com/about",
65+
"name": "about",
66+
"title": "About"
67+
},
68+
# ...
69+
],
70+
"social_links": [
71+
{
72+
"url": "http://example.com/social",
73+
"name": "facebook",
74+
"icon-class": "fa-facebook-square",
75+
"title": "Facebook",
76+
"action": "Sign up on Facebook!"
77+
},
78+
# ...
79+
],
80+
"mobile_links": [
81+
{
82+
"url": "http://example.com/android",
83+
"name": "google",
84+
"image": "http://example.com/google.png",
85+
"title": "Google"
86+
},
87+
# ...
88+
],
89+
"legal_links": [
90+
{
91+
"url": "http://example.com/terms-of-service.html",
92+
"name": "terms_of_service",
93+
"title': "Terms of Service"
94+
},
95+
# ...
96+
],
97+
"openedx_link": {
98+
"url": "https://open.edx.org",
99+
"title": "Powered by Open edX",
100+
"image": "http://example.com/openedx.png"
101+
},
102+
"logo_image": "http://example.com/static/images/logo.png",
103+
"copyright": "edX, Open edX and their respective logos are registered trademarks of edX Inc."
104+
}
105+
106+
107+
We are interested in keys that end with ``_links``:
108+
109+
* ``social_links``
110+
* ``buisiness_links``
111+
* ``mobile_links``
112+
* ``connect_links``
113+
* ``openedx_links``
114+
* ``navigation_links``
115+
* ``legal_links``
116+
117+
We don't need ``logo_image`` as it's already supplied via props or MFE config.
118+
We will ignore ``edx_org_link``, as it's specific to the edX only, and most of
119+
the instances that are not hosted with edX remove it. The other keys, like
120+
``copyright``, can be implemented in the future.
121+
122+
We want the footer to stay the same for the users who don't want to use this
123+
feature. So we are going to hide it behind a feature flag
124+
``ENABLE_BRANDING_API``, that can be set via `MFE's config mechanism`_. By
125+
default it will have value of ``false``, and it will be possible to change it
126+
in various ways:
127+
128+
* At build time, by providing them in ``env.config.js``, like so:
53129

54130
.. code-block:: javascript
55131
56132
const config = {
57-
FOOTER_LINKS: [
58-
{"url": "https://google.com", "text": "Terms of service"},
59-
{"url": "https://duckduckgo.com", "text": "Acceptable Use Policy"},
60-
{"url": "https://openedx.org", "text": "Privacy Policy"},
61-
],
133+
ENABLE_BRANDING_API: true,
134+
...
62135
};
63136
64137
export default config;
@@ -68,15 +141,14 @@ That would allow to specify a list of links in various ways:
68141
.. code-block:: python
69142
70143
MFE_CONFIG = {
71-
"FOOTER_LINKS": [
72-
{"url": "https://google.com", "text": "Terms of service"},
73-
{"url": "https://duckduckgo.com", "text": "Acceptable Use Policy"},
74-
{"url": "https://openedx.org", "text": "Privacy Policy"},
75-
],
144+
"ENABLE_BRANDING_API": True,
76145
}
77146
78-
In case the array is undefined or empty, we won't render any links (or it's
79-
container).
147+
If the feature flag is set to ``true``, we will query the API endpoint and get
148+
the links from the response.
149+
150+
This will allow the links in the legacy and MFE footers to be the same, and
151+
configured via the same parameters in the LMS configuration.
80152

81153
.. _MFE's config mechanism: https://github.com/openedx/frontend-platform/blob/master/src/config.js
82154

@@ -101,17 +173,17 @@ Consequences
101173
Positive
102174
========
103175

104-
* There will be an option to make the MFE footer look similar to the legacy UI
105-
footer, without having to create and maintain a fork.
106-
* Can add custom text/urls for links, unlike what branding v1 API allows.
176+
* Legacy and MFE footers will have the same links.
177+
* No need to duplicate the configuration, since both footers will use the
178+
branding API as a source of truth.
107179

108180
Negative
109181
========
110182

111-
* There are already parameters that allow configuring the footer links for the
112-
legacy UI, which means that configuration will be duplicated (potentially in
113-
multiple places), in cases when the aim is to make the links in the legacy UI
114-
and MFE footers that same.
183+
* An additional API request will be required when an MFE is openned.
184+
* Can't easily add custom links. We can in the future implement v2 of the API,
185+
or combine it with the MFE Config API to allow adding custom links.
186+
* Will have to deal with limitations of the branding API.
115187

116188
Rejected Alternatives
117189
*********************
@@ -126,33 +198,14 @@ reading it somewhere else, and passing the values as props to the react
126198
component. We couldn't identify any pros to this approach, and the cons are the
127199
same as the cons from decoupling.
128200

129-
Styling using CSS variables
130-
===========================
131-
132-
Exposing styling customizations through the CSS variables would be similar to
133-
styling via CSS classes, and it would be better aligned with the current
134-
philosophy of Paragon, since it prefers CSS variables over custom CSS classes.
135-
136-
The cons however, is that you can only expose one CSS attribute per variable.
137-
This means that we would either heavily limit the styling options, or would
138-
have to create many variables for each element and CSS attribute.
139-
140-
Brading API V1
201+
MFE Config API
141202
==============
142203

143-
LMS already has an API endpoint which could be used to retrieve the links that
144-
are used in the footer (legacy UI footer uses the same API) in JSON format -
145-
``api/branding/v1/footer``.
146-
147-
The pros of using this approach would be that legacy and MFE footer would use
148-
the same API and would have the same links, without having to duplicate the
149-
configuration.
150-
151-
The cons of using this approach are:
204+
We could've used MFE Config to pass the links to the footer. The main advantage
205+
would be that easy to set custom links and text.
152206

153-
* It would be necessary to make an additional API call from an MFE to get the
154-
links.
155-
* No custom links, only what is allowed by the branding API.
207+
However, it would require duplication the configuration for the links. Also,
208+
branding API has more data and internationalization for links text.
156209

157210
Third party footer
158211
==================

0 commit comments

Comments
 (0)