Skip to content

Commit 84ee07d

Browse files
committed
[UX][Containers] UI integration.
1 parent d5f4ab7 commit 84ee07d

3 files changed

Lines changed: 54 additions & 33 deletions

File tree

src/ui/options.css

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,25 @@ fieldset:disabled {
114114
flex: 2 2;
115115
}
116116

117-
.per-site-buttons {
117+
#container-options {
118118
display: flex;
119119
flex-flow: row wrap;
120-
justify-content: flex-end;
121-
width: 100%;
122-
text-align: right;
123-
margin: .5em 0 0 0;
120+
justify-content: flex-start;
124121
}
125-
#btn-clear-container {
126-
margin-inline-start: .5em;
122+
123+
#container-options label {
124+
margin-block: auto;
127125
}
128-
#copy-container {
129-
margin-inline: .5em;
126+
127+
#container-options div {
128+
margin-inline-end: 1em;
130129
}
131-
#copy-container-label {
132-
margin-block: auto;
130+
131+
#container-options button{
132+
margin-inline: auto 3.5em;
133133
}
134134

135+
135136
#policy {
136137
display: block;
137138
margin-top: .5em;

src/ui/options.html

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,23 @@ <h3 class="flextabs__tab"><button class="flextabs__toggle">__MSG_SectionGeneral_
8888

8989
<h3 class="flextabs__tab"><button class="flextabs__toggle enforcement_required">__MSG_SectionSitePermissions__</button></h3>
9090
<div class="flextabs__content">
91-
<label for="select-container" id="select-container-label">__MSG_select_container_label__</label>
92-
<select name="select-container" id="select-container">
93-
<option value="default">__MSG_DefaultContainerName__</option>
94-
</select>
9591
<section class="sect-sites">
92+
<div id="container-options">
93+
<div>
94+
<label for="select-container" id="select-container-label">__MSG_select_container_label__</label>
95+
<select name="select-container" id="select-container">
96+
<option value="default">__MSG_DefaultContainerName__</option>
97+
</select>
98+
</div>
99+
<div>
100+
<label for="copy-container" id="copy-container-label">__MSG_copy_container_label__</label>
101+
<select name="copy-container" id="copy-container">
102+
<option value=blank></option>
103+
<option value="default">__MSG_DefaultContainerName__</option>
104+
</select>
105+
</div>
106+
<button id="btn-clear-container">__MSG_clear_container_label__</button>
107+
</div>
96108
<form id="form-newsite" class="browser-style" >
97109
<label id="newsite-label" for="newsite" accesskey="__MSG_WebAddress_accesskey__">__MSG_WebAddress__</label><input name="newsite" id="newsite" type="text" placeholder="[https://]noscript.net"
98110
><button class="add">+</button>
@@ -102,15 +114,6 @@ <h3 class="flextabs__tab"><button class="flextabs__toggle enforcement_required">
102114
<div class="cssload-whirlpool"></div>
103115
</div>
104116
</div>
105-
<div class="per-site-buttons" id="per-site-buttons">
106-
<label for="copy-container" id="copy-container-label">__MSG_copy_container_label__</label>
107-
<select name="copy-container" id="copy-container">
108-
<option value=blank></option>
109-
<option value="default">__MSG_DefaultContainerName__</option>
110-
</select>
111-
<div style="inline-size:0;margin-inline:.5em;border:1px solid #888"></div>
112-
<button id="btn-clear-container">__MSG_clear_container_label__</button>
113-
</div>
114117
</section>
115118
</div>
116119

src/ui/options.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,18 +223,24 @@ document.querySelector("#version").textContent = _("Version",
223223
var currentPolicy = await UI.getPolicy(cookieStoreId);
224224

225225
function updateContainersEnabled() {
226-
let containersEnabled = Boolean(contextStore.enabled && browser.contextualIdentities);
226+
const containersEnabled = Boolean(contextStore.enabled && browser.contextualIdentities);
227227
document.querySelector("#containers-opt").style.display = browser.contextualIdentities? "": "none";
228228
document.querySelector("#opt-containers").disabled = !browser.contextualIdentities;
229229
document.querySelector("#opt-containers").checked = contextStore.enabled;
230-
document.querySelector("#select-container").hidden = !containersEnabled;
231-
document.querySelector("#select-container-label").hidden = !containersEnabled;
232-
document.querySelector("#per-site-buttons").style.display = containersEnabled? "flex" : "none";
230+
document.querySelector("#container-options").style.display = containersEnabled ? "" : "none";
233231
}
234232
updateContainersEnabled();
235233

234+
function constrainContainerCopy() {
235+
containerCopy.disabled = cookieStoreId == "default";
236+
for (const opt of containerCopy.options) {
237+
opt.disabled = opt.value == cookieStoreId;
238+
}
239+
}
240+
236241
async function changeContainer() {
237242
cookieStoreId = containerSelect.value;
243+
constrainContainerCopy();
238244
currentPolicy = await UI.getPolicy(cookieStoreId);
239245
debug("container change", cookieStoreId, currentPolicy);
240246
sitesUI.clear()
@@ -275,13 +281,24 @@ document.querySelector("#version").textContent = _("Version",
275281
}
276282
if (JSON.stringify(newContainers) == JSON.stringify(containers)) return;
277283
containers = newContainers;
278-
var container_options = ""
279-
for (var container of containers) {
280-
container_options += "<option value=" + container.cookieStoreId + ">" + container.name + "</option>"
284+
const options = document.createDocumentFragment();
285+
for (const container of containers) {
286+
const o = options.appendChild(document.createElement("option"));
287+
o.value = container.cookieStoreId;
288+
o.text = container.name;
281289
}
282-
containerSelect.innerHTML = container_options;
290+
while (containerSelect.firstChild) {
291+
containerSelect.removeChild(containerSelect.firstChild);
292+
}
293+
containerSelect.appendChild(options.cloneNode(true));
283294
containerSelect.value = cookieStoreId;
284-
containerCopy.innerHTML = "<option value=blank></option>" + container_options;
295+
while (containerCopy.firstChild) {
296+
containerCopy.removeChild(containerCopy.firstChild);
297+
}
298+
containerCopy.appendChild(document.createElement("option")).value = "blank";
299+
containerCopy.appendChild(options);
300+
301+
constrainContainerCopy();
285302
}
286303
containerSelect.onfocus = updateContainerOptions;
287304
containerCopy.onfocus = updateContainerOptions;

0 commit comments

Comments
 (0)