Skip to content
This repository has been archived by the owner on Nov 7, 2022. It is now read-only.

Commit

Permalink
feat: support hlx3 flag and display production host
Browse files Browse the repository at this point in the history
  • Loading branch information
rofe committed Oct 16, 2021
1 parent 11f1507 commit 021f56b
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/extension/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,18 @@ function getSidekickSettings(sidekickurl) {
try {
const params = new URL(sidekickurl).searchParams;
const giturl = params.get('giturl');
const hlx3 = params.get('hlx3') !== 'false';
// check gh url
if (Object.keys(getGitHubSettings(giturl)).length !== 3) {
throw new Error();
}
return {
giturl,
project: params.get('project'),
hlx3,
};
} catch (e) {
console.error('error getting sidekick settings from share url', e);
return {};
}
}
Expand All @@ -57,7 +60,7 @@ function getInnerHost(owner, repo, ref) {
}

function isValidShareURL(shareurl) {
return Object.keys(getSidekickSettings(shareurl)).length === 2;
return Object.keys(getSidekickSettings(shareurl)).length === 3;
}

function isValidGitHubURL(giturl) {
Expand All @@ -79,7 +82,7 @@ function drawConfigs() {
const container = document.getElementById('configs');
container.innerHTML = '';
configs.forEach(({
owner, repo, ref, mountpoints, project,
owner, repo, ref, mountpoints, project, host,
}) => {
const innerHost = getInnerHost(owner, repo, ref);
const section = document.createElement('section');
Expand All @@ -91,7 +94,10 @@ function drawConfigs() {
${mountpoints.length
? `<p>${i18n('config_project_mountpoints')}: ${mountpoints.map((mp) => drawLink(mp)).join(' ')}</p>`
: ''}
</div>
${host
? `<p>${i18n('config_project_host')}: ${drawLink(host)}</p>`
: ''}
</div>
<div>
<button class="shareConfig" title="${i18n('config_share')}">${i18n('config_share')}</button>
<button class="editConfig" title="${i18n('config_edit')}">${i18n('config_edit')}</button>
Expand All @@ -111,7 +117,7 @@ function drawConfigs() {
});
}

async function addConfig({ giturl, project }, cb) {
async function addConfig({ giturl, project, hlx3 }, cb) {
const { owner, repo, ref } = getGitHubSettings(giturl);
const projectConfig = await getProjectConfig(owner, repo, ref);
const mountpoints = await getMountpoints(owner, repo, ref);
Expand All @@ -125,6 +131,7 @@ async function addConfig({ giturl, project }, cb) {
ref,
mountpoints,
project,
hlx3,
...projectConfig,
});
browser.storage.sync
Expand Down

0 comments on commit 021f56b

Please sign in to comment.