aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/todos
diff options
context:
space:
mode:
authorLibravatar Amine <amine@mouafik.fr>2020-03-31 14:09:05 +0100
committerLibravatar GitHub <noreply@github.com>2020-03-31 14:09:05 +0100
commit899d2bf551e111bdc68608dba02e93782eec9f85 (patch)
tree2ead7fcc3a8f08d74af186931267e9021d21812e /src/features/todos
parentRetry flaky commands on AppVeyor (#526) (diff)
downloadferdium-app-899d2bf551e111bdc68608dba02e93782eec9f85.tar.gz
ferdium-app-899d2bf551e111bdc68608dba02e93782eec9f85.tar.zst
ferdium-app-899d2bf551e111bdc68608dba02e93782eec9f85.zip
#418 #477 Refactor Todo settings, add predefined Todo apps list
* add condition if on todo options * add drop down for todo server * fix error TODOS_FRONTEND * add todo list apps' * update name of dropdown menu to Todo Service * add other service to dropdown menu and subsetting field for user to input url * add Other Service to drop down * fixed typos * reverted wording * fix custom field * fix linting * fix linting * Delete tsconfig.tsbuildinfo * Delete tsconfig.tsbuildinfo * Delete tsconfig.tsbuildinfo * Add regex to validate custom todo url * Add note with source of regex function * Move regex function declaration to function body root * Apply code style * Add migration for todo settings * Apply code style Co-authored-by: romain <romain@jumboprivacy.com> Co-authored-by: Roman <46404814+yourcontact@users.noreply.github.com> Co-authored-by: romain <rpsa@pm.me>
Diffstat (limited to 'src/features/todos')
-rw-r--r--src/features/todos/components/TodosWebview.js27
1 files changed, 25 insertions, 2 deletions
diff --git a/src/features/todos/components/TodosWebview.js b/src/features/todos/components/TodosWebview.js
index e9b1963f7..2626186e9 100644
--- a/src/features/todos/components/TodosWebview.js
+++ b/src/features/todos/components/TodosWebview.js
@@ -9,10 +9,20 @@ import { defineMessages, intlShape } from 'react-intl';
9import { mdiCheckAll } from '@mdi/js'; 9import { mdiCheckAll } from '@mdi/js';
10import SettingsStore from '../../../stores/SettingsStore'; 10import SettingsStore from '../../../stores/SettingsStore';
11 11
12import * as environment from '../../../environment';
13import Appear from '../../../components/ui/effects/Appear'; 12import Appear from '../../../components/ui/effects/Appear';
14import UpgradeButton from '../../../components/ui/UpgradeButton'; 13import UpgradeButton from '../../../components/ui/UpgradeButton';
15 14
15// NOTE: https://stackoverflow.com/questions/5717093/check-if-a-javascript-string-is-a-url
16function validURL(str) {
17 const pattern = new RegExp('^(https?:\\/\\/)?' // protocol
18 + '((([a-z\\d]([a-z\\d-]*[a-z\\d])*)\\.)+[a-z]{2,}|' // domain name
19 + '((\\d{1,3}\\.){3}\\d{1,3}))' // OR ip (v4) address
20 + '(\\:\\d+)?(\\/[-a-z\\d%_.~+]*)*' // port and path
21 + '(\\?[;&a-z\\d%_.~+=-]*)?' // query string
22 + '(\\#[-a-z\\d_]*)?$', 'i'); // fragment locator
23 return !!pattern.test(str);
24}
25
16const messages = defineMessages({ 26const messages = defineMessages({
17 premiumInfo: { 27 premiumInfo: {
18 id: 'feature.todos.premium.info', 28 id: 'feature.todos.premium.info',
@@ -194,6 +204,16 @@ class TodosWebview extends Component {
194 204
195 const { intl } = this.context; 205 const { intl } = this.context;
196 206
207 const isUsingPredefinedTodoServer = stores.settings.all.app.predefinedTodoServer !== 'isUsingCustomTodoService';
208 const todoUrl = isUsingPredefinedTodoServer
209 ? stores.settings.all.app.predefinedTodoServer
210 : stores.settings.all.app.customTodoServer;
211 let isTodoUrlValid = true;
212 if (isUsingPredefinedTodoServer === false) {
213 isTodoUrlValid = validURL(todoUrl);
214 }
215
216
197 return ( 217 return (
198 <div 218 <div
199 className={classes.root} 219 className={classes.root}
@@ -213,6 +233,8 @@ class TodosWebview extends Component {
213 /> 233 />
214 )} 234 )}
215 {isTodosIncludedInCurrentPlan ? ( 235 {isTodosIncludedInCurrentPlan ? (
236 isTodoUrlValid
237 && (
216 <Webview 238 <Webview
217 className={classes.webview} 239 className={classes.webview}
218 onDidAttach={() => { 240 onDidAttach={() => {
@@ -223,8 +245,9 @@ class TodosWebview extends Component {
223 partition="persist:todos" 245 partition="persist:todos"
224 preload="./features/todos/preload.js" 246 preload="./features/todos/preload.js"
225 ref={(webview) => { this.webview = webview ? webview.view : null; }} 247 ref={(webview) => { this.webview = webview ? webview.view : null; }}
226 src={stores.settings.all.app.todoServer || environment.TODOS_FRONTEND} 248 src={todoUrl}
227 /> 249 />
250 )
228 ) : ( 251 ) : (
229 <Appear> 252 <Appear>
230 <div className={classes.premiumContainer}> 253 <div className={classes.premiumContainer}>