Skip to content

Commit

Permalink
Merge pull request #3660 from DFE-Digital/revert-3630-remove-widget-f…
Browse files Browse the repository at this point in the history
…uncationality

Revert "Remove code that starts and appends chat widget to the DOM"
  • Loading branch information
StackedPancakez authored Nov 14, 2023
2 parents 9db608d + 42f64ca commit 5e55c4c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
17 changes: 15 additions & 2 deletions app/webpacker/controllers/chat_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ export default class extends Controller {
const closeTime = dayjs().set('hour', 17).set('minute', 30).tz(timeZone);
const now = dayjs().tz(timeZone);
const weekend = [6, 0].includes(now.get('day'));
const disabled = true; // temporary to disable chat

return !disabled && !weekend && now >= openTime && now <= closeTime;
return !weekend && now >= openTime && now <= closeTime;
}

start(e) {
Expand All @@ -43,6 +42,8 @@ export default class extends Controller {
this.chatTarget.textContent = 'Starting chat...';
}

this.appendZendeskScript();

this.waitForZendeskScript(() => {
this.showWebWidget();
this.waitForWebWidget(() => {
Expand All @@ -51,6 +52,18 @@ export default class extends Controller {
});
}

appendZendeskScript() {
if (this.zendeskScriptLoaded) {
return;
}

const script = document.createElement('script');
script.setAttribute('id', 'ze-snippet');
script.src =
'https://static.zdassets.com/ekr/snippet.js?key=34a8599c-cfec-4014-99bd-404a91839e37';
document.body.appendChild(script);
}

waitForWebWidget(callback) {
const interval = setInterval(() => {
if (window.zEACLoaded) {
Expand Down
5 changes: 0 additions & 5 deletions app/webpacker/styles/links-and-buttons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,3 @@ body a.govuk-back-link {
display: inline-block;
}
}

// Default Zendesk chat button (hidden as we use our own).
#launcher {
display: none;
}
2 changes: 1 addition & 1 deletion config/initializers/secure_headers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
google_doubleclick = %w[*.doubleclick.net *.googleads.g.doubleclick.net *.ad.doubleclick.net *.fls.doubleclick.net stats.g.doubleclick.net]
google_apis = %w[*.googleapis.com googleapis.com https://fonts.googleapis.com]

zendesk = %w[api.eu-1.smooch.io *.zendesk.com static.zdassets.com https://*.zopim.com wss://*.zopim.com dfesupport-tpuk.zendesk.com ekr.zdassets.com]
zendesk = %w[wss://api.eu-1.smooch.io/faye api.eu-1.smooch.io *.zendesk.com static.zdassets.com https://*.zopim.com wss://*.zopim.com dfesupport-tpuk.zendesk.com ekr.zdassets.com]
facebook = %w[*.facebook.com *.facebook.net *.connect.facebook.net]
govuk = %w[*.gov.uk www.gov.uk]
jquery = %w[code.jquery.com]
Expand Down
2 changes: 1 addition & 1 deletion spec/features/chat_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
context "when chat is online" do
let(:date) { Time.zone.local(2021, 1, 1, 9) }

xscenario "viewing the chat section of the talk to us component" do
scenario "viewing the chat section of the talk to us component" do
visit_on_date root_path
dismiss_cookies

Expand Down
2 changes: 1 addition & 1 deletion spec/javascript/controllers/chat_controller_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ describe('ChatController', () => {
return document.querySelector('a').textContent;
}

xdescribe('when the chat is online', () => {
describe('when the chat is online', () => {
beforeEach(() => {
chatShowSpy = jest.fn(() => true);
chatOpenSpy = jest.fn();
Expand Down

0 comments on commit 5e55c4c

Please sign in to comment.