-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(mv3): ✨ Introduces Redirect Rule Management (#1240)
* feat: exporting rules ending regex Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> * feat: ✨ Adding Rule Management UI Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> * feat: ✨ hooking up with background worker. Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> * fix: lint Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> * fix: 🎨 button styling Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> * fix(mv3): 💄 Making UI a bit better Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com> --------- Signed-off-by: Nishant Arora <1895906+whizzzkid@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
183 additions
and
21 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
'use strict' | ||
/* eslint-env browser, webextensions */ | ||
|
||
import html from 'choo/html/index.js' | ||
import browser from 'webextension-polyfill' | ||
|
||
/** | ||
* | ||
* @param {(event: string, value?: any) => void} emit | ||
* @returns | ||
*/ | ||
function ruleItem (emit) { | ||
/** | ||
* Renders Rule Item | ||
* | ||
* @param {{ | ||
* id: string | ||
* origin: string | ||
* target: string | ||
* }} param0 | ||
* @returns | ||
*/ | ||
return function ({ id, origin, target }) { | ||
return html` | ||
<div class="flex flex-row-ns pb0-ns"> | ||
<dl class="flex-grow-1"> | ||
<dt> | ||
<span class="b">${browser.i18n.getMessage('option_redirect_rules_row_origin')}:</span> ${origin} | ||
</dt> | ||
<dt> | ||
<span class="b">${browser.i18n.getMessage('option_redirect_rules_row_target')}:</span> ${target} | ||
</dt> | ||
</dl> | ||
<div class="rule-delete"> | ||
<button class="f6 ph3 pv2 mt0 mb0 bg-transparent b--none red" onclick=${() => emit('redirectRuleDeleteRequest', id)}>X</button> | ||
</div> | ||
</div> | ||
` | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @param {{ | ||
* emit: (event: string, value?: any) => void, | ||
* redirectRules: { | ||
* id: string | ||
* origin: string | ||
* target: string | ||
* }[] | ||
* }} param0 | ||
* @returns | ||
*/ | ||
export default function redirectRuleForm ({ emit, redirectRules }) { | ||
return html` | ||
<form> | ||
<fieldset class="mb3 pa1 pa4-ns pa3 bg-snow-muted charcoal"> | ||
<h2 class="ttu tracked f6 fw4 teal mt0-ns mb3-ns mb1 mt2 ">${browser.i18n.getMessage('option_header_redirect_rules')}</h2> | ||
<div class="flex-row-ns pb0-ns"> | ||
<label for="deleteAllRules"> | ||
<dl> | ||
<dt> | ||
<div class="self-right-ns"> | ||
Found ${redirectRules?.length ?? 0} rules | ||
</div> | ||
</dt> | ||
</dl> | ||
</label> | ||
<div class="self-center-ns"> | ||
<button id="deleteAllRules" class="Button transition-all sans-serif v-mid fw5 nowrap lh-copy bn br1 pa2 pointer focus-outline white bg-red white" onclick=${() => emit('redirectRuleDeleteRequest')}>${browser.i18n.getMessage('option_redirect_rules_reset_all')}</button> | ||
</div> | ||
</div> | ||
<div style="max-height: 250px; overflow-y: auto"> | ||
${redirectRules ? redirectRules.map(ruleItem(emit)) : html`<div>Loading...</div>`} | ||
</div> | ||
</fieldset> | ||
</form> | ||
` | ||
} |
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