Skip to content

Commit

Permalink
fix disabled false on button
Browse files Browse the repository at this point in the history
  • Loading branch information
Sartxi committed Sep 16, 2024
1 parent 35788f9 commit 5932770
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions libs/utils/sidekick-decorate.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import userCanPublishPage from '../tools/utils/publish.js';

const PUBLISH_BTN = '.publish.plugin button';
const BACKUP_PROFILE = '.profile-email';
const PROFILE = '.profile-email';
const CONFIRM_MESSAGE = 'Are you sure? This will publish to production.';

export default function stylePublish(sk) {
const setupPublishBtn = async (page, btn) => {
const { canPublish, message } = await userCanPublishPage(page, false);
btn.setAttribute('disabled', !canPublish);
if (canPublish) {
btn.removeAttribute('disabled');
} else {
btn.setAttribute('disabled', true);
}
const messageText = btn.querySelector('span');
const text = canPublish ? CONFIRM_MESSAGE : message;
if (messageText) {
Expand Down Expand Up @@ -94,7 +98,7 @@ export default function stylePublish(sk) {
const page = {
webPath: window.location.pathname,
// added for edge case where the statusfetched event isnt fired on refresh
profile: { email: sk.shadowRoot.querySelector(BACKUP_PROFILE)?.innerText },
profile: { email: sk.shadowRoot.querySelector(PROFILE)?.innerText },
};
setupPublishBtn(page, btn);
}
Expand Down

0 comments on commit 5932770

Please sign in to comment.