Skip to content

Commit

Permalink
fix(settings): Integrations settings not "checking" (#1802)
Browse files Browse the repository at this point in the history
Fix integrations settings not showing the correct state for some
domains

close #1775
  • Loading branch information
dpsxp authored Jul 30, 2020
1 parent 364aed8 commit 0c9f7eb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 24 deletions.
36 changes: 18 additions & 18 deletions src/scripts/origins.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default {
url: '*://*.any.do/*',
name: 'Anydo'
},
'asana.com': {
'app.asana.com': {
url: '*://app.asana.com/*',
name: 'Asana'
},
Expand Down Expand Up @@ -62,11 +62,11 @@ export default {
url: '*://*.bitrix24.com/*',
name: 'Bitrix24'
},
'breeze.pm': {
'app.breeze.pm': {
url: '*://app.breeze.pm/*',
name: 'Breeze'
},
'brokerengine.com.au': {
'app.brokerengine.com.au': {
url: '*://app.brokerengine.com.au/*',
name: 'BrokerEngine'
},
Expand All @@ -90,11 +90,11 @@ export default {
url: '*://*.cloudes.me/*',
name: 'Cloudes.me'
},
'clubhouse.io': {
'app.clubhouse.io': {
url: '*://app.clubhouse.io/*',
name: 'Clubhouse'
},
'codeable.io': {
'app.codeable.io': {
url: '*://app.codeable.io/*',
name: 'Codeable'
},
Expand Down Expand Up @@ -232,35 +232,35 @@ export default {
url: '*://keep.google.com/*',
name: 'Google Keep'
},
'khanacademy.org': {
'www.khanacademy.org': {
url: '*://www.khanacademy.org/*',
name: 'KhanAcademy'
},
'mail.google.com': {
url: '*://mail.google.com/*',
name: 'Google Mail'
},
'gqueues.com': {
'www.gqueues.com': {
url: '*://www.gqueues.com/*',
name: 'GQueues'
},
'habitica.com': {
url: '*://habitica.com/*',
name: 'Habitica'
},
'heflo.com': {
'app.heflo.com': {
url: '*://app.heflo.com/*',
name: 'HEFLO'
},
'helprace.com': {
url: '*://*.helprace.com/*',
name: 'Helprace'
},
'helpscout.net': {
'secure.helpscout.net': {
url: '*://secure.helpscout.net/*',
name: 'Helpscout'
},
'huskymarketingplanner.com': {
'app.huskymarketingplanner.com': {
url: '*://app.huskymarketingplanner.com/*',
name: 'Husky Marketing Planner',
file: 'husky-marketing-planner.js'
Expand Down Expand Up @@ -295,7 +295,7 @@ export default {
url: '*://*.kantree.io/*',
name: 'Kantree'
},
'liquidplanner.com': {
'app.liquidplanner.com': {
url: '*://app.liquidplanner.com/*',
name: 'Liquidplanner'
},
Expand All @@ -308,7 +308,7 @@ export default {
name: 'Mantishub',
clone: 'true'
},
'meistertask.com': {
'www.meistertask.com': {
url: '*://www.meistertask.com/*',
name: 'MeisterTask'
},
Expand All @@ -331,7 +331,7 @@ export default {
name: 'Notion',
file: 'notion.js'
},
'nozbe.com': {
'app.nozbe.com': {
url: '*://app.nozbe.com/*',
name: 'Nozbe'
},
Expand All @@ -356,7 +356,7 @@ export default {
url: '*://*.onshape.com/*',
name: 'Onshape'
},
'osticket.com': {
'supportsystem.com': {
url: '*://*.supportsystem.com/*',
name: 'osTicket',
file: 'osticket.js'
Expand Down Expand Up @@ -493,7 +493,7 @@ export default {
url: '*://*.smartboard.cl/*',
name: 'Smartboard'
},
'sourcelair.com': {
'www.sourcelair.com': {
url: '*://www.sourcelair.com/*',
name: 'Sourcelair'
},
Expand Down Expand Up @@ -686,15 +686,15 @@ export default {
url: '*://overv.io/*',
name: 'Overv'
},
'teamleader.eu': {
'app.teamleader.eu': {
url: '*://app.teamleader.eu/*',
name: 'Teamleader'
},
'manageengine.com': {
url: '*://*.manageengine.com/*',
name: 'ManageEngine'
},
'vivifyscrum.com': {
'app.vivifyscrum.com': {
url: '*://app.vivifyscrum.com/*',
name: 'VivifyScrum',
clone: 'true'
Expand All @@ -703,7 +703,7 @@ export default {
url: '*://*.zammad.com/*',
name: 'Zammad'
},
'zenhub.com': {
'app.zenhub.com': {
url: '*://app.zenhub.com/*',
name: 'Zenhub'
}
Expand Down
31 changes: 25 additions & 6 deletions src/scripts/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ document.querySelector('#close-review-prompt').addEventListener('click', dismiss
link.addEventListener('click', changeActiveTab);
});

const isNotTogglApp = (url) => {
return (url || '').match(/toggl\./) === null;
};

const Settings = {
$startAutomatically: null,
$stopAutomatically: null,
Expand Down Expand Up @@ -275,14 +279,15 @@ const Settings = {

for (i = 0; i < items.length; i++) {
current = items[i].getAttribute('data-host');
if (current.indexOf('toggl') === -1) {
if (isNotTogglApp(current)) {
if (current.indexOf(',') !== -1) {
urls = urls.concat(current.split(','));
} else {
urls.push(current);
}
}
}

return { origins: urls };
},
setFromTo: async function () {
Expand Down Expand Up @@ -389,10 +394,24 @@ const Settings = {
checked = 'checked';

if (!Settings.origins[key]) {
tmpkey = key;

// Special case for toggl-button-demo
if (key === 'dom-integration') {
tmpkey = TogglOrigins[key].url
.replace('*://*.', '')
.replace('*://', '')
.replace('/*', '');
}

// Handle cases where subdomain is used (like web.any.do, we remove web from the beginning)
tmpkey = key.split('.');
tmpkey.shift();
tmpkey = tmpkey.join('.');
const isWildcardDomainRegex = new RegExp(/\/\/\*\./);
if (TogglOrigins[key].url.match(isWildcardDomainRegex)) {
tmpkey = key.split('.');
tmpkey.shift();
tmpkey = tmpkey.join('.');
}

if (!Settings.origins[tmpkey]) {
disabled = 'disabled';
checked = '';
Expand All @@ -411,7 +430,7 @@ const Settings = {
}

// Don't show toggl.com as it's not optional
if (key.indexOf('toggl') === -1 && !!TogglOrigins[key].url) {
if (isNotTogglApp(key) && !!TogglOrigins[key].url) {
li = document.createElement('li');
li.id = key;
li.className = disabled;
Expand Down Expand Up @@ -595,7 +614,7 @@ const Settings = {
}

if (
result.origins[i].indexOf('toggl') === -1 &&
isNotTogglApp(result.origins[i]) &&
result.origins[i] !== '*://*/*' &&
!skip
) {
Expand Down

0 comments on commit 0c9f7eb

Please sign in to comment.