Skip to content

Commit

Permalink
feat: bulk operations (#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
rofe authored Jun 18, 2024
1 parent 15914fa commit dcc5ef1
Show file tree
Hide file tree
Showing 44 changed files with 4,381 additions and 314 deletions.
100 changes: 76 additions & 24 deletions src/extension/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,59 @@
"bulk_confirm_publish_single": {
"message": "Are you sure you want to publish this file?"
},
"bulk_progress_preview_multiple": {
"bulk_error": {
"message": "Bulk operation failed. Please try again later."
},
"bulk_error_illegal_file_name": {
"message": "Only normalized, small latin letters, digits and hyphens are allowed in file names. The following file name contains illegal characters: $1"
},
"bulk_error_illegal_file_names": {
"message": "Only normalized, small latin letters, digits and hyphens are allowed in file names. The following file names contain illegal characters: $1"
},
"bulk_error_preview_login_required": {
"message": "You need to sign in to generate the preview of more than 100 files."
},
"bulk_error_publish_login_required": {
"message": "You need to sign in to publish more than 100 files."
},
"bulk_previewing_state": {
"message": "Preview for $1 of $2 files generated..."
},
"bulk_progress_publish_multiple": {
"bulk_publishing_state": {
"message": "$1 of $2 files published..."
},
"bulk_result_preview_multiple_failure": {
"message": "Failed to generate preview of $1 files:"
"bulk_result_details": {
"message": "Details"
},
"bulk_result_preview_multiple_success": {
"message": "Preview of $1 files successfully generated."
"bulk_result_path": {
"message": "Path"
},
"bulk_result_preview_multiple_failure": {
"message": "Failed to generate preview of all files."
},
"bulk_result_preview_single_error_invalid_folder_name": {
"message": "Only normalized, small latin letters, digits and hyphens are allowed in folder names"
"bulk_result_preview_multiple_partial_success": {
"message": "Preview of $1 files successfully generated, but $2 failed."
},
"bulk_result_preview_single_error_no_docx": {
"message": "Microsoft Word document, convert to Google Docs first"
"bulk_result_preview_multiple_partial_success_1": {
"message": "Preview of $1 file successfully generated, but $2 failed."
},
"bulk_result_preview_single_error_no_xlsx": {
"message": "Microsoft Excel document, convert to Google Sheets first"
"bulk_result_preview_multiple_success": {
"message": "Preview of $1 files successfully generated."
},
"bulk_result_preview_single_failure": {
"message": "Failed to generate preview of this file:"
"message": "Failed to generate preview of this file."
},
"bulk_result_preview_single_success": {
"message": "Preview of this file successfully generated."
},
"bulk_result_publish_multiple_failure": {
"message": "Failed to publish $1 files:"
"message": "Failed to publish all files."
},
"bulk_result_publish_multiple_partial_success": {
"message": "$1 files successfully published, but $2 failed."
},
"bulk_result_publish_multiple_partial_success_1": {
"message": "1 file successfully published, but $2 failed."
},
"bulk_result_publish_multiple_success": {
"message": "$1 files successfully published."
Expand All @@ -67,13 +91,13 @@
"message": "File must be previewed first"
},
"bulk_result_publish_single_failure": {
"message": "Failed to publish 1 file:"
"message": "Failed to publish this file."
},
"bulk_result_publish_single_success": {
"message": "1 file successfully published."
"message": "File successfully published."
},
"bulk_selection_empty": {
"message": "Select files below"
"message": "Select files"
},
"bulk_selection_multiple": {
"message": "$1 files selected"
Expand Down Expand Up @@ -258,6 +282,10 @@
"config_ux": {
"message": "User experience"
},
"confirm": {
"message": "Please confirm",
"description": "Confirmation modal heading"
},
"copied": {
"message": "Copied"
},
Expand Down Expand Up @@ -292,7 +320,13 @@
"message": "Copy URL"
},
"copy_urls": {
"message": "Copy URLs"
"message": "Copy $1 URLs"
},
"copy_urls_error": {
"message": "Copy to clipboard failed. Please try again."
},
"copy_urls_error_focus": {
"message": "Copy to clipboard failed. Please make sure the window remains focused."
},
"delete": {
"message": "Delete"
Expand Down Expand Up @@ -351,6 +385,9 @@
"error_fatal": {
"message": "Apologies, we seem to be having problems at the moment. Please try again later."
},
"error_job_404": {
"message": "404 Not found: No such job."
},
"error_login_aborted": {
"message": "Sign in aborted."
},
Expand All @@ -363,21 +400,36 @@
"error_preview": {
"message": "Preview generation failed. Please try again later."
},
"error_preview_400": {
"message": "Preview generation failed. Check the file format, name or path."
},
"error_preview_404": {
"message": "404 Not found: Source document does not exist, preview generation failed."
"message": "Source document does not exist, preview generation failed."
},
"error_preview_415": {
"message": "File type not supported. Refer to the documentation for supported file types."
},
"error_preview_not_gdoc_generic": {
"message": "Preview generation failed. Must be Google document or spreadsheet."
},
"error_preview_not_gdoc_ms_word": {
"message": "This is a Microsoft Word document. Please convert it to Google Docs: File > Save as Google Docs"
"error_preview_no_docx": {
"message": "This is a Microsoft Word document, please convert it to Google Docs first."
},
"error_preview_no_xlsx": {
"message": "This is a Microsoft Excel document, please convert it to Google Sheets first."
},
"error_preview_not_gsheet_ms_excel": {
"message": "This is a Microsoft Excel document. Please convert it to Google Sheets: File > Save as Google Sheets"
"error_preview_too_large": {
"message": "File too large. Refer to the documentation for file size limits."
},
"error_preview_svg_invalid": {
"message": "SVG invalid. Make sure it is valid XML and contains no scripts."
},
"error_publish": {
"message": "Publication failed. Please try again later."
},
"error_publish_404": {
"message": "Publication failed, generate preview first."
},
"error_status_404_content": {
"message": "404 Not found: Check your Sidekick configuration or URL."
},
Expand Down Expand Up @@ -478,7 +530,7 @@
"message": "Open URL"
},
"open_urls": {
"message": "Open URLs"
"message": "Open $1 URLs"
},
"open": {
"message": "Open"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ export class ActivityAction extends ConnectedElement {
this.requestUpdate();
},
);

reaction(
() => this.appStore.bulkStore.progress,
() => {
this.requestUpdate();
},
);
}

handleCloseToast() {
Expand Down Expand Up @@ -72,6 +79,19 @@ export class ActivityAction extends ConnectedElement {
return html`
<sp-progress-circle size="s" indeterminate></sp-progress-circle><span>${this.appStore.i18n(this.appStore.state)}</span>
`;
case STATE.BULK_PREVIEWING:
case STATE.BULK_PUBLISHING:
return html`
<sp-progress-circle size="s" indeterminate></sp-progress-circle>
<span>
${this.appStore.bulkStore?.progress
? this.appStore.i18n(this.appStore.state)
.replace('$1', `${this.appStore.bulkStore.progress.processed}`)
.replace('$2', `${this.appStore.bulkStore.progress.total}`)
// show generic state if bulk progress not available
: this.appStore.i18n(this.appStore.state.replace('bulk_', ''))}
</span>
`;
case STATE.LOGIN_REQUIRED:
return html`
${ICONS.INFO}<span>${this.appStore.i18n(this.appStore.state)}</span>
Expand All @@ -87,6 +107,11 @@ export class ActivityAction extends ConnectedElement {
${this.getToastIcon()}<span>${this.appStore.toast.message}</span>
</div>
<div class="actions">
${this.appStore.toast.secondaryCallback && this.appStore.toast.secondaryLabel ? html`
<sp-action-button class="action" quiet @click=${this.appStore.toast.secondaryCallback}>
${this.appStore.toast.secondaryLabel}
</sp-action-button>
` : html``}
${this.appStore.toast.actionCallback && this.appStore.toast.actionLabel ? html`
<sp-action-button class="action" quiet @click=${this.appStore.toast.actionCallback}>
${this.appStore.toast.actionLabel}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2023 Adobe. All rights reserved.
* Copyright 2024 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
Expand All @@ -10,18 +10,21 @@
* governing permissions and limitations under the License.
*/

import { createEnvPlugin } from './env/env.js';
import { createPreviewPlugin } from './preview/preview.js';
import { createReloadPlugin } from './reload/reload.js';
import { createDeletePlugin } from './delete/delete.js';
import { createPublishPlugin } from './publish/publish.js';
import { createUnpublishPlugin } from './unpublish/unpublish.js';
import { css } from 'lit';

export const pluginFactory = (() => ({
createEnvPlugin,
createPreviewPlugin,
createReloadPlugin,
createDeletePlugin,
createPublishPlugin,
createUnpublishPlugin,
}))();
export const style = css`
.container {
display: flex;
align-items: center;
height: 100%;
gap: 12px;
}
.container span {
padding: 0 6px 2px;
}
.container sp-menu-divider {
height: 100%;
}
`;
56 changes: 56 additions & 0 deletions src/extension/app/components/bulk/bulk-info/bulk-info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2024 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/

import { html } from 'lit';
import { customElement } from 'lit/decorators.js';
import { reaction } from 'mobx';
import { ConnectedElement } from '../../connected-element/connected-element.js';
import { style } from './bulk-info.css.js';

@customElement('bulk-info')
export class BulkInfo extends ConnectedElement {
static get styles() {
return [style];
}

/**
* Listen for state changes
*/
async connectedCallback() {
super.connectedCallback();

reaction(
() => this.appStore.bulkStore.selection,
() => {
this.requestUpdate();
},
);
}

render() {
return html`
<div class="container">
<span>
${
// eslint-disable-next-line no-nested-ternary
this.appStore.bulkStore?.selection.length > 0
? (this.appStore.bulkStore.selection.length === 1
? this.appStore.i18n('bulk_selection_single')
: this.appStore.i18n('bulk_selection_multiple')
.replace('$1', `${this.appStore.bulkStore.selection.length}`))
: this.appStore.i18n('bulk_selection_empty')
}
</span>
</div>
`;
}
}
Loading

0 comments on commit dcc5ef1

Please sign in to comment.