Skip to content

Commit

Permalink
Hide MFA Zone file action if no mfa required
Browse files Browse the repository at this point in the history
  • Loading branch information
michielbdejong committed Dec 30, 2023
1 parent f38c66e commit 5c7b414
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
7 changes: 2 additions & 5 deletions css/tabview.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@
white-space: pre-wrap;
}

tr[data-requires-mfa="true"] {
background-color: #f03030;
}
tr[data-requires-mfa="false"] {
background-color: #30f030;
tr[data-requires-mfa="false"] .fileactions a[data-action="mfa"] {
display: none;
}
32 changes: 16 additions & 16 deletions js/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ var mfazoneFileListPlugin = {

fileList.fileActions.registerAction({
name: 'mfa',
displayName: '',
displayName: 'MFA Zone',
type: 1,
mime: 'all',
permissions: OC.PERMISSION_NONE,
// iconClass: 'icon-category-security',
iconClass: 'icon-category-security',
actionHandler: function(fileName, context) {
if (confirm('You must enable two factor authentication to use MFAZone app. Do you want to enable 2FA?')) {
window.location.href = OC.generateUrl('/settings/user/security');
Expand Down Expand Up @@ -46,20 +46,20 @@ var mfazoneFileListPlugin = {
}
});
// console.log('IDS>>>>>>', ids);
const trs = document.getElementsByTagName('tr');
for (let i=1; i<trs.length; i++) {
console.log('data-requires-mfa attribute of', trs[i].getAttribute('data-file'), trs[i].getAttribute('data-requires-mfa'));
if (trs[i].getAttribute('data-requires-mfa') === 'true') {
console.log('adding icon to', trs[i]);
const divs = trs[i].getElementsByClassName('action-mfa');
if (divs.length === 1) {
const icon = divs[0].getElementsByTagName('span')[0];
const text = divs[0].getElementsByTagName('span')[1];
icon.classList.add('icon-category-security');
text.innerText = 'MFA Zone';
}
}
}
// const trs = document.getElementsByTagName('tr');
// for (let i=1; i<trs.length; i++) {
// console.log('data-requires-mfa attribute of', trs[i].getAttribute('data-file'), trs[i].getAttribute('data-requires-mfa'));
// if (trs[i].getAttribute('data-requires-mfa') === 'true') {
// console.log('adding icon to', trs[i]);
// const divs = trs[i].getElementsByClassName('action-mfa');
// if (divs.length === 1) {
// const icon = divs[0].getElementsByTagName('span')[0];
// const text = divs[0].getElementsByTagName('span')[1];
// icon.classList.add('icon-category-security');
// text.innerText = 'MFA Zone';
// }
// }
// }

// const statusUrl = OC.generateUrl('/apps/mfazones/getList');
}
Expand Down

0 comments on commit 5c7b414

Please sign in to comment.