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

Mass Deleter: Show blog name in confirm modal #1648

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
24 changes: 24 additions & 0 deletions src/content_scripts/modals.css
Original file line number Diff line number Diff line change
Expand Up @@ -142,3 +142,27 @@
#xkit-modal .buttons :is(a, button, input).blue {
background-color: rgb(var(--blue));
}

.xkit-modal-tag,
.xkit-modal-blog {
display: inline-block;

font-size: 1rem;
line-height: 1.5;
}

.xkit-modal-tag {
padding: 0 0.5em;
border-radius: 1em;
margin: 0.25rem 0;

background-color: rgb(var(--deprecated-accent));
color: rgb(var(--navy));
}

.xkit-modal-blog {
font-weight: 700;
}

.xkit-modal-tag::before { content: '#'; }
.xkit-modal-blog::before { content: '@'; }
33 changes: 18 additions & 15 deletions src/features/mass_deleter.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { dom } from '../utils/dom.js';
import { megaEdit } from '../utils/mega_editor.js';
import { modalCancelButton, modalCompleteButton, showErrorModal, showModal } from '../utils/modals.js';
import { createBlogSpan, modalCancelButton, modalCompleteButton, showErrorModal, showModal } from '../utils/modals.js';
import { addSidebarItem, removeSidebarItem } from '../utils/sidebar.js';
import { apiFetch } from '../utils/tumblr_helpers.js';

Expand Down Expand Up @@ -56,7 +56,7 @@ const confirmDeleteDrafts = event => {

showModal({
title: 'Delete drafts?',
message: ['Every draft on this blog dated before ', beforeElement, ' will be deleted.'],
message: ['Every draft on ', createBlogSpan(blogName), ' dated before ', beforeElement, ' will be deleted.'],
buttons: [
modalCancelButton,
dom(
Expand Down Expand Up @@ -146,19 +146,23 @@ const showNoDraftsError = () => showModal({
buttons: [modalCompleteButton]
});

const showClearQueuePrompt = () => showModal({
title: 'Clear your queue?',
message: [
'All posts in this blog\'s queue will be deleted.\n',
'Scheduled posts will not be affected.'
],
buttons: [
modalCancelButton,
dom('button', { class: 'red' }, { click: () => clearQueue().catch(showErrorModal) }, ['Clear it!'])
]
});
const showClearQueuePrompt = () => {
const blogName = location.pathname.split('/')[2];

showModal({
title: 'Clear your queue?',
message: [
'All posts in ', createBlogSpan(blogName), '\'s queue will be deleted.\n',
'Scheduled posts will not be affected.'
],
buttons: [
modalCancelButton,
dom('button', { class: 'red' }, { click: () => clearQueue({ blogName }).catch(showErrorModal) }, ['Clear it!'])
]
});
};

const clearQueue = async function () {
const clearQueue = async function ({ blogName }) {
const foundPostsElement = dom('span', null, null, ['Gathering queued posts...']);
const deleteCountElement = dom('span');

Expand All @@ -174,7 +178,6 @@ const clearQueue = async function () {
});

const queuedPosts = [];
const blogName = location.pathname.split('/')[2];
let resource = `/v2/blog/${blogName}/posts/queue?limit=50`;

while (resource) {
Expand Down
23 changes: 0 additions & 23 deletions src/features/mass_privater.css

This file was deleted.

5 changes: 1 addition & 4 deletions src/features/mass_privater.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { dom } from '../utils/dom.js';
import { megaEdit } from '../utils/mega_editor.js';
import { showModal, modalCancelButton, modalCompleteButton, hideModal, showErrorModal } from '../utils/modals.js';
import { showModal, modalCancelButton, modalCompleteButton, hideModal, showErrorModal, createTagSpan, createBlogSpan } from '../utils/modals.js';
import { addSidebarItem, removeSidebarItem } from '../utils/sidebar.js';
import { apiFetch } from '../utils/tumblr_helpers.js';
import { userBlogs } from '../utils/user.js';

const getPostsFormId = 'xkit-mass-privater-get-posts';

const createBlogOption = ({ name, title, uuid }) => dom('option', { value: uuid, title }, null, [name]);
const createTagSpan = tag => dom('span', { class: 'mass-privater-tag' }, null, [tag]);
const createBlogSpan = name => dom('span', { class: 'mass-privater-blog' }, null, [name]);
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

const dateTimeFormat = new Intl.DateTimeFormat(document.documentElement.lang, {
Expand Down Expand Up @@ -280,4 +278,3 @@ const sidebarOptions = {

export const main = async () => addSidebarItem(sidebarOptions);
export const clean = async () => removeSidebarItem(sidebarOptions.id);
export const stylesheet = true;
23 changes: 0 additions & 23 deletions src/features/tag_replacer.css

This file was deleted.

5 changes: 1 addition & 4 deletions src/features/tag_replacer.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { dom } from '../utils/dom.js';
import { megaEdit } from '../utils/mega_editor.js';
import { showModal, modalCancelButton, modalCompleteButton, showErrorModal } from '../utils/modals.js';
import { showModal, modalCancelButton, modalCompleteButton, showErrorModal, createTagSpan, createBlogSpan } from '../utils/modals.js';
import { addSidebarItem, removeSidebarItem } from '../utils/sidebar.js';
import { apiFetch } from '../utils/tumblr_helpers.js';
import { userBlogs } from '../utils/user.js';

const getPostsFormId = 'xkit-tag-replacer-get-posts';

const createBlogOption = ({ name, title, uuid }) => dom('option', { value: uuid, title }, null, [name]);
const createTagSpan = tag => dom('span', { class: 'tag-replacer-tag' }, null, [tag]);
const createBlogSpan = name => dom('span', { class: 'tag-replacer-blog' }, null, [name]);
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));

const showInitialPrompt = async () => {
Expand Down Expand Up @@ -207,4 +205,3 @@ const sidebarOptions = {

export const main = async () => addSidebarItem(sidebarOptions);
export const clean = async () => removeSidebarItem(sidebarOptions.id);
export const stylesheet = true;
3 changes: 3 additions & 0 deletions src/utils/modals.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@ export const showErrorModal = exception => {
buttons: [modalCompleteButton]
});
};

export const createTagSpan = tag => dom('span', { class: 'xkit-modal-tag' }, null, [tag]);
export const createBlogSpan = name => dom('span', { class: 'xkit-modal-blog' }, null, [name]);