Skip to content

Commit cc762c8

Browse files
committed
Merge branch 'update-ui-login-flow' into staging
2 parents 81db136 + 806ec09 commit cc762c8

File tree

2 files changed

+60
-26
lines changed

2 files changed

+60
-26
lines changed

preload.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,6 @@ const addBfAccount = async (ev, verifyingOrganization = False) => {
10071007

10081008
api_button.innerText = "Connect with API key instead";
10091009
// set length to 270
1010-
api_button.setAttribute("onclick", "showBFAddAccountSweetalert()");
10111010
api_arrow.classList.add("fas");
10121011
api_arrow.classList.add("fa-arrow-right");
10131012
api_arrow.style.marginLeft = "10px";
@@ -1021,6 +1020,7 @@ const addBfAccount = async (ev, verifyingOrganization = False) => {
10211020
api_button.appendChild(api_arrow);
10221021
swal_actions.parentElement.insertBefore(api_button, div_footer);
10231022
swal_actions.parentElement.insertBefore(helpText, div_footer);
1023+
api_button.addEventListener("click", (e) => showBFAddAccountSweetalert(e));
10241024
} else {
10251025
// hide the cancel button
10261026
let cancel_button = document.getElementsByClassName("swal2-cancel")[0];

scripts/others/renderer.js

+59-25
Original file line numberDiff line numberDiff line change
@@ -1793,7 +1793,7 @@ ipcRenderer.on("selected-generate-metadata-subjects", (event, dirpath, filename)
17931793
didOpen: () => {
17941794
Swal.showLoading();
17951795
},
1796-
}).then((result) => {});
1796+
}).then((result) => { });
17971797
generateSubjectsFileHelper(false);
17981798
}
17991799
});
@@ -1809,7 +1809,7 @@ ipcRenderer.on("selected-generate-metadata-subjects", (event, dirpath, filename)
18091809
didOpen: () => {
18101810
Swal.showLoading();
18111811
},
1812-
}).then((result) => {});
1812+
}).then((result) => { });
18131813
generateSubjectsFileHelper(false);
18141814
}
18151815
}
@@ -1892,7 +1892,7 @@ const generateSubjectsFileHelper = async (uploadBFBoolean) => {
18921892
didOpen: () => {
18931893
Swal.showLoading();
18941894
},
1895-
}).then((result) => {});
1895+
}).then((result) => { });
18961896

18971897
try {
18981898
log.info(`Generating a subjects file.`);
@@ -2002,7 +2002,7 @@ ipcRenderer.on("selected-generate-metadata-samples", (event, dirpath, filename)
20022002
didOpen: () => {
20032003
Swal.showLoading();
20042004
},
2005-
}).then((result) => {});
2005+
}).then((result) => { });
20062006
generateSamplesFileHelper(uploadBFBoolean);
20072007
}
20082008
});
@@ -2018,7 +2018,7 @@ ipcRenderer.on("selected-generate-metadata-samples", (event, dirpath, filename)
20182018
didOpen: () => {
20192019
Swal.showLoading();
20202020
},
2021-
}).then((result) => {});
2021+
}).then((result) => { });
20222022
generateSamplesFileHelper(uploadBFBoolean);
20232023
}
20242024
}
@@ -2100,7 +2100,7 @@ const generateSamplesFileHelper = async (uploadBFBoolean) => {
21002100
didOpen: () => {
21012101
Swal.showLoading();
21022102
},
2103-
}).then((result) => {});
2103+
}).then((result) => { });
21042104

21052105
try {
21062106
let samplesFileResponse = await client.post(
@@ -2620,7 +2620,7 @@ const loadTaxonomySpecies = async (commonName, destinationInput, curationMode) =
26202620
didOpen: () => {
26212621
Swal.showLoading();
26222622
},
2623-
}).then((result) => {});
2623+
}).then((result) => { });
26242624
try {
26252625
let load_taxonomy_species = await client.get(`/taxonomy/species`, {
26262626
params: {
@@ -4926,10 +4926,10 @@ const swalFileListSingleAction = async (fileList, title, helpText, postActionTex
49264926
${helpText ? `<p>${helpText}</p>` : ""}
49274927
<div class="swal-file-list">
49284928
${fileList
4929-
.map(
4930-
(file) => `<div class="swal-file-row"><span class="swal-file-text">${file}</span></div>`
4931-
)
4932-
.join("")}
4929+
.map(
4930+
(file) => `<div class="swal-file-row"><span class="swal-file-text">${file}</span></div>`
4931+
)
4932+
.join("")}
49334933
</div>
49344934
${postActionText ? `<b>${postActionText}</b>` : ""}
49354935
`,
@@ -4959,10 +4959,10 @@ const swalFileListDoubleAction = async (
49594959
${helpText}
49604960
<div class="swal-file-list">
49614961
${fileList
4962-
.map(
4963-
(file) => `<div class="swal-file-row"><span class="swal-file-text">${file}</span></div>`
4964-
)
4965-
.join("")}
4962+
.map(
4963+
(file) => `<div class="swal-file-row"><span class="swal-file-text">${file}</span></div>`
4964+
)
4965+
.join("")}
49664966
</div>
49674967
<b>${confirmationText}</b>
49684968
`,
@@ -4994,10 +4994,10 @@ const swalFileListTripleAction = async (
49944994
${helpText}
49954995
<div class="swal-file-list">
49964996
${fileList
4997-
.map(
4998-
(file) => `<div class="swal-file-row"><span class="swal-file-text">${file}</span></div>`
4999-
)
5000-
.join("")}
4997+
.map(
4998+
(file) => `<div class="swal-file-row"><span class="swal-file-text">${file}</span></div>`
4999+
)
5000+
.join("")}
50015001
</div>
50025002
<b>${confirmationText}</b>
50035003
`,
@@ -6703,9 +6703,8 @@ const listItems = async (jsonObj, uiItem, amount_req, reset) => {
67036703
${dragDropInstructionsText}
67046704
</p>
67056705
<p class="text-center">
6706-
You may also <b>add</b> or <b>import</b> ${
6707-
folderType === undefined ? "folders or files" : folderType + " data"
6708-
} using the buttons in the upper right corner
6706+
You may also <b>add</b> or <b>import</b> ${folderType === undefined ? "folders or files" : folderType + " data"
6707+
} using the buttons in the upper right corner
67096708
</p>
67106709
</div>`
67116710
);
@@ -7393,7 +7392,7 @@ const deleteTreeviewFiles = (sodaJSONObj) => {
73937392
if (
73947393
"manifest.xlsx" in sodaJSONObj["dataset-structure"]["folders"][highLevelFol]["files"] &&
73957394
sodaJSONObj["dataset-structure"]["folders"][highLevelFol]["files"]["manifest.xlsx"][
7396-
"forTreeview"
7395+
"forTreeview"
73977396
]
73987397
) {
73997398
delete sodaJSONObj["dataset-structure"]["folders"][highLevelFol]["files"]["manifest.xlsx"];
@@ -8468,7 +8467,9 @@ ipcRenderer.on("selected-manifest-folder", async (event, result) => {
84688467
}
84698468
});
84708469

8471-
async function showBFAddAccountSweetalert() {
8470+
async function showBFAddAccountSweetalert(ev) {
8471+
console.log("The ev: ", ev)
8472+
let target = ev.target
84728473
await Swal.fire({
84738474
title: bfaddaccountTitle,
84748475
html: bfAddAccountBootboxMessage,
@@ -8518,7 +8519,7 @@ async function showBFAddAccountSweetalert() {
85188519
selected_account: name,
85198520
},
85208521
})
8521-
.then((response) => {
8522+
.then(async (response) => {
85228523
let user_email = response.data.email;
85238524
$("#current-bf-account").text(user_email);
85248525
$("#current-bf-account-generate").text(user_email);
@@ -8528,9 +8529,42 @@ async function showBFAddAccountSweetalert() {
85288529
$("#current-bf-dataset-generate").text("None");
85298530
$(".bf-dataset-span").html("None");
85308531
$("#para-continue-bf-dataset-getting-started").text("");
8532+
// set the workspace field values to the user's current workspace
8533+
let org = response.data.organization;
8534+
$(".bf-organization-span").text(org);
85318535
showHideDropdownButtons("account", "show");
85328536
confirm_click_account_function();
85338537
updateBfAccountList();
8538+
8539+
// If the clicked button has the data attribute "reset-guided-mode-page" and the value is "true"
8540+
// then reset the guided mode page
8541+
if (target?.getAttribute("data-reset-guided-mode-page") == "true") {
8542+
// Get the current page that the user is on in the guided mode
8543+
const currentPage = CURRENT_PAGE.id;
8544+
if (currentPage) {
8545+
await openPage(currentPage);
8546+
}
8547+
}
8548+
8549+
// reset the selected dataset to None
8550+
$(".bf-dataset-span").html("None");
8551+
// reset the current owner span in the manage dataset make pi owner of a dataset tab
8552+
$(".current-permissions").html("None");
8553+
8554+
refreshOrganizationList();
8555+
8556+
8557+
// If the button that triggered the organization has the class
8558+
// guided-change-workspace (from guided mode), handle changes based on the ev id
8559+
// otherwise, reset the FFM UI based on the ev class
8560+
// NOTE: For API Key sign in flow it is more simple to just reset the UI as the new user may be in a separate workspace than the prior user.
8561+
target?.classList.contains("data-reset-guided-mode-page")
8562+
? handleGuidedModeOrgSwitch(target)
8563+
: resetFFMUI(target);
8564+
8565+
datasetList = [];
8566+
defaultBfDataset = null;
8567+
clearDatasetDropdowns();
85348568
})
85358569
.catch((error) => {
85368570
Swal.showValidationMessage(userErrorMessage(error));

0 commit comments

Comments
 (0)