Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-160237: Caas Bulk Publisher v2 (Beta) #3176

Merged
merged 79 commits into from
Nov 14, 2024
Merged

Conversation

cmiqueo
Copy link
Contributor

@cmiqueo cmiqueo commented Nov 12, 2024

This is parallel beta version of the Caas BulkPublisher Tool

It provides a new and easier to use UI with predetermined Presets for the consumers.

Resolves: MWPW-160237 & MWPW-161613

Preset Mode:
image

Advanced Mode
image

Test URLs:

@aem-code-sync aem-code-sync bot temporarily deployed to bulkpublisher-beta November 12, 2024 04:10 Inactive
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

eslint

🚫 [eslint] <quotes> reported by reviewdog 🐶
Strings must use singlequote.

if (e.target.value === "dark") {


🚫 [eslint] <no-multiple-empty-lines> reported by reviewdog 🐶
More than 1 blank line not allowed.

const init = async () => {

@aem-code-sync aem-code-sync bot temporarily deployed to bulkpublisher-beta November 12, 2024 04:20 Inactive
@aem-code-sync aem-code-sync bot temporarily deployed to bulkpublisher-beta November 12, 2024 04:29 Inactive
@aem-code-sync aem-code-sync bot temporarily deployed to bulkpublisher-beta November 12, 2024 04:35 Inactive
@aem-code-sync aem-code-sync bot temporarily deployed to bulkpublisher-beta November 12, 2024 04:41 Inactive
@aem-code-sync aem-code-sync bot temporarily deployed to bulkpublisher-beta November 12, 2024 07:01 Inactive
Copy link
Contributor

aem-code-sync bot commented Nov 12, 2024

@cmiqueo cmiqueo requested a review from JackySun9 November 12, 2024 23:47
Copy link
Contributor

@sanrai sanrai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be good as this is a beta version and not merged into main bulk publisher yet.

Copy link
Contributor

Reminder to set the Ready for Stage label - to queue this to get merged to stage & production.

@cmiqueo cmiqueo added trivial PR doesn't require E2E testing by a reviewer CaaS CaaS related code zero-impact Ready for Stage labels Nov 14, 2024
Copy link
Contributor

This PR does not qualify for the zero-impact label as it touches code outside of the allowed areas. The label is auto applied, do not manually apply the label.

Copy link
Contributor

@chrischrischris chrischrischris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

I'd prefer if all the root level code be moved out into it's own function(s). Even if just a giant setup function called first thing from init. Or if it needs to run before init, the setup function can be called from the root at bottom of the file near the init declaration.

Even better would be to break out each setup item into its own function so you get something like:

function setup() {
  getPresets();
  checkDarkTheme();
  setupListeners();
  etc...
}

const successArr = [];
let index = 0;
let keepGoing = true;
const now = new Date();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this just be inlined into getPageDom? I don't see any use case where the now param isn't new Date()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chrischrischris
Can you explain this more?

if (!keepGoing) break;

try {
const rawUrl = page.Path || page.path || page.url || page.URL || page.Url || page;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit might want to use case-insensitive lookup. Something like:

function getProp(obj, prop) {
    const lowerCaseProp = prop.toLowerCase();
    for (const key in obj) {
        if (obj.hasOwnProperty(key) && key.toLowerCase() === lowerCaseProp) {
            return obj[key];
        }
    }
    return undefined;
}

}
} catch (e) {
// eslint-disable-next-line no-console
console.log(`ERROR: ${e.message}`);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be pushed into the error array?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +20 to +21
const SIGNEDIN = BODY.querySelector('.status-signed-in');
const SIGNEDOUT = BODY.querySelector('.status-signed-out');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: add EL or some other indicator that it's an html element

Suggested change
const SIGNEDIN = BODY.querySelector('.status-signed-in');
const SIGNEDOUT = BODY.querySelector('.status-signed-out');
const SIGNEDIN_EL = BODY.querySelector('.status-signed-in');
const SIGNEDOUT_EL = BODY.querySelector('.status-signed-out');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is already merged, I will be implementing these changes in my latest PR #3299

if (caasEnvValue === 'prod' && !draftOnly.checked) {
publishWarning.style.height = '30px';
} else {
publishWarning.style.height = '0';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious as to why not display: none

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using height just for the CSS transition effect

};

// preset options
const presetsJsonPath = 'https://milo.adobe.com/drafts/caas/bppresets.json';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably not be in a drafts folder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will implement after beta

const presetsJsonPath = 'https://milo.adobe.com/drafts/caas/bppresets.json';
let presetsData = {};

fetchExcelJson(presetsJsonPath).then((presets) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a bit strange that this just runs at the root level. Could you instead wrap it in a function and call from init?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines +343 to +347
const useDarkTheme = localStorage.getItem('bp-theme') === 'dark'
? true
: localStorage.getItem('bp-theme') === 'light'
? false
: window.matchMedia('(prefers-color-scheme: dark)').matches;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to avoid nested ternary. Something like:

Suggested change
const useDarkTheme = localStorage.getItem('bp-theme') === 'dark'
? true
: localStorage.getItem('bp-theme') === 'light'
? false
: window.matchMedia('(prefers-color-scheme: dark)').matches;
const theme = localStorage.getItem('bp-theme');
const useDarkTheme = theme === 'dark' ||
(theme !== 'light' && window.matchMedia('(prefers-color-scheme: dark)').matches);

Comment on lines +343 to +355
const useDarkTheme = localStorage.getItem('bp-theme') === 'dark'
? true
: localStorage.getItem('bp-theme') === 'light'
? false
: window.matchMedia('(prefers-color-scheme: dark)').matches;
/* eslint-enable no-nested-ternary */

if (useDarkTheme) {
document.querySelector('.bulk-publisher').classList.add('dark');
document.querySelector('#option-dark').checked = true;
} else {
document.querySelector('#option-light').checked = true;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit break out into a function called from init

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@milo-pr-merge milo-pr-merge bot merged commit c834273 into stage Nov 14, 2024
34 checks passed
@milo-pr-merge milo-pr-merge bot deleted the bulkpublisher-beta branch November 14, 2024 17:30
@milo-pr-merge milo-pr-merge bot mentioned this pull request Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CaaS CaaS related code Ready for Stage trivial PR doesn't require E2E testing by a reviewer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants