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-158944 #820

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions acrobat/blocks/verb-widget/limits.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const LIMITS = {
fillsign: {
maxFileSize: 100000000, // 1 MB
maxFileSizeFriendly: '100 MB', // 1 MB
maxFileSize: 100000000, // 100 MB
maxFileSizeFriendly: '100 MB', // 100 MB
acceptedFiles: ['application/pdf'],
maxNumFiles: 1,
mobileApp: true,
Expand Down
52 changes: 29 additions & 23 deletions acrobat/blocks/verb-widget/verb-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,6 @@ const setUser = () => {
localStorage.setItem('unity.user', 'true');
};

const handleError = (err, errTxt, str, strTwo) => {
err.classList.add('verb-error');
err.classList.remove('hide');
errTxt.textContent = `${window.mph[str]} ${strTwo || ''}`;

setTimeout(() => {
err.classList.remove('verb-error');
err.classList.add('hide');
}, 5000);
};

const setDraggingClass = (widget, shouldToggle) => {
// eslint-disable-next-line chai-friendly/no-unused-expressions
shouldToggle ? widget.classList.add('dragging') : widget.classList.remove('dragging');
Expand Down Expand Up @@ -176,39 +165,56 @@ export default async function init(element) {
});

// Errors, Analytics & Logging
const handleError = (str) => {
errorState.classList.add('verb-error');
errorState.classList.remove('hide');
errorStateText.textContent = str;

setTimeout(() => {
errorState.classList.remove('verb-error');
errorState.classList.add('hide');
}, 5000);
};

window.addEventListener('unity:show-error-toast', (e) => {
// eslint-disable-next-line no-console
console.log(`⛔️ Error Code - ${e.detail?.code}`);

if (e.detail?.code === 'only_accept_one_file') {
handleError(errorState, errorStateText, 'verb-widget-error-multi');
if (e.detail?.code.includes('error_only_accept_one_file')) {
handleError(e.detail?.message);
verbAnalytics('error', VERB);
}

if (e.detail?.code === 'unsupported_type') {
handleError(errorState, errorStateText, 'verb-widget-error-unsupported');
if (e.detail?.code.includes('error_unsupported_type')) {
handleError(e.detail?.message);
verbAnalytics('error:unsupported_type', VERB);
}

if (e.detail?.code === 'empty_file') {
handleError(errorState, errorStateText, 'verb-widget-error-empty');
if (e.detail?.code.includes('error_empty_file')) {
handleError(e.detail?.message);
verbAnalytics('error:empty_file', VERB);
}

// Code may be wrong. should be 'file_too_large'
if (e.detail?.code === 'file_too_largempty_file') {
handleError(errorState, errorStateText, 'verb-widget-error-large', LIMITS[VERB].maxFileSizeFriendly);
if (e.detail?.code.includes('error_file_too_large')) {
handleError(e.detail?.message);
verbAnalytics('error', VERB);
}

if (e.detail?.code === 'max_page_count') {
handleError(errorState, errorStateText, 'verb-widget-error-max', LIMITS[VERB].maxNumFiles);
if (e.detail?.code.includes('error_max_page_count')) {
handleError(e.detail?.message);
verbAnalytics('error:max_page_count', VERB);
}

if (e.detail?.code.includes('error_generic')
|| e.detail?.code.includes('error_max_quota_exceeded')
|| e.detail?.code.includes('error_no_storage_provision')
|| e.detail?.code.includes('error_duplicate_asset')) {
handleError(e.detail?.message);
verbAnalytics('error', VERB);
}

// acrobat:verb-fillsign:error:page_count_missing_from_metadata_api
// acrobat:verb-fillsign:error:403
// acrobat:verb-fillsign:error
// LANA for 403
});
}
Expand Down
10 changes: 5 additions & 5 deletions acrobat/scripts/alloy/verb-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ if (params.dropzone2) {
appTags.push('dropzone2');
}

export default function init(eventName, verb) {
console.log(`📡 Event Name - acrobat:verb-${verb}:${eventName}`);
export default function init(eventName, verb, metaData) {
console.log(`📡 Event Name - acrobat:verb-${verb}:${eventName} - metaData: ${metaData?.type} / ${metaData?.size} `);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ [eslint] <no-console> reported by reviewdog 🐶
Unexpected console statement.

const event = {
documentUnloading: true,
data: {
Expand Down Expand Up @@ -66,10 +66,10 @@ export default function init(eventName, verb) {
dcweb2: {
event: { pagename: `acrobat:verb-${verb}:${eventName}` },
content: {
type: 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
size: '2-5MB',
type: metaData?.type,
size: metaData?.size,
count: 1,
extension: 'docx',
// extension: 'docx', may not be needed
},
source: {
user_agent: navigator.userAgent,
Expand Down
3 changes: 1 addition & 2 deletions acrobat/scripts/scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ const setLibs = (prodLibs, location) => {
if (branch === 'main' && hostname === 'www.stage.adobe.com') return 'https://www.stage.adobe.com/libs';
if (!(hostname.includes('.hlx.') || hostname.includes('local') || hostname.includes('stage'))) return prodLibs;
if (branch === 'local') return 'http://localhost:6456/libs';
const tld = hostname.includes('live') ? 'live' : 'page';
return branch.includes('--') ? `https://${branch}.hlx.${tld}/libs` : `https://${branch}--milo--adobecom.hlx.${tld}/libs`;
return branch.includes('--') ? `https://${branch}.hlx.live/libs` : `https://${branch}--milo--adobecom.hlx.live/libs`;
};

const getLocale = (locales, pathname = window.location.pathname) => {
Expand Down
Loading