Skip to content

Commit 2cd9c3c

Browse files
authored
Create new page to navigate to how to join slack channels 7988 (#8290)
* modified and new html pages * latest changes to issue 7988 * changes to 7988 * I deleted files * requested changes * deleted join-slack-channel.js
1 parent f49c6a2 commit 2cd9c3c

4 files changed

Lines changed: 107 additions & 2 deletions

File tree

_data/internal/communities/project-management.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ leadership:
2020

2121
links:
2222
- name: Slack
23-
url: https://app.slack.com/client/T04502KQX/C010LNXH2JY/details/
23+
url: https://app.slack.com/client/T04502KQX/C010LNXH2JY
2424
- name: GitHub
2525
url: https://github.com/hackforla/product-management
2626

assets/js/communities-of-practice.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,79 @@ document.addEventListener("DOMContentLoaded", function() {
5757
}
5858

5959
setMeetingTimes();
60+
61+
// Function to handle Slack channel button clicks
62+
function setupSlackChannelButtons() {
63+
const slackButtons = document.querySelectorAll('.slack-link');
64+
65+
slackButtons.forEach(button => {
66+
button.addEventListener('click', function(event) {
67+
// Prevent the default link behavior temporarily
68+
event.preventDefault();
69+
70+
// Get the Slack URL from the button's id attribute
71+
const slackUrl = this.id;
72+
73+
// Get the community name from the title attribute or nearby heading
74+
const communityCard = this.closest('.page-card');
75+
const communityName = communityCard ? communityCard.querySelector('.Title4').textContent.trim() : 'Community';
76+
77+
// Save to localStorage
78+
localStorage.setItem('selectedSlackChannel', slackUrl);
79+
localStorage.setItem('selectedCommunityName', communityName);
80+
81+
// Now proceed with the original link behavior
82+
window.location.href = this.href;
83+
});
84+
});
85+
}
86+
87+
// Set up the Slack channel button event listeners
88+
setupSlackChannelButtons();
89+
90+
// Function to get the saved Slack channel URL from localStorage and update the button
91+
function loadSlackChannelButton() {
92+
const savedSlackUrl = localStorage.getItem('selectedSlackChannel');
93+
const savedCommunityName = localStorage.getItem('selectedCommunityName');
94+
95+
const slackButton = document.querySelector('.slack-channel-link');
96+
97+
if (savedSlackUrl && slackButton) {
98+
// Update the button with the saved Slack URL
99+
slackButton.href = savedSlackUrl;
100+
101+
// Update the title attribute if we have the community name
102+
if (savedCommunityName) {
103+
slackButton.title = `${savedCommunityName} Slack channel`;
104+
}
105+
106+
// Add click event to clear localStorage after successful redirect
107+
slackButton.addEventListener('click', function() {
108+
// Clear the stored values after user clicks to join
109+
localStorage.removeItem('selectedSlackChannel');
110+
localStorage.removeItem('selectedCommunityName');
111+
});
112+
} else {
113+
// If no URL was saved, redirect back to communities page or show error
114+
console.error('No Slack channel URL found in localStorage');
115+
116+
// Option 1: Redirect back to communities page
117+
// window.location.href = '/communities-of-practice';
118+
119+
// Option 2: Update button to show error state
120+
if (slackButton) {
121+
slackButton.href = '/communities-of-practice';
122+
slackButton.innerHTML = `
123+
<svg version="1.1" viewBox="0 0 90 90" xmlns="http://www.w3.org/2000/svg" width="20" height="20">
124+
<path d="..." fill="currentColor"/>
125+
</svg>
126+
Return to Communities
127+
`;
128+
slackButton.title = 'Return to Communities of Practice page';
129+
}
130+
}
131+
}
132+
133+
// Load the Slack channel button when page loads
134+
loadSlackChannelButton();
60135
});

pages/communities-of-practice.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ <h3 class = "Title4">{{ community[1].name}}</h3>
7171

7272
{% if community[1].links[0].url %}
7373
{% assign url_links = true %}
74-
<a href="{{ community[1].links[0].url }}" class="btn btn-primary btn-md btn--default cop-btn" target="_blank" title="{{community[1].name}} Slack channel" rel="noopener noreferrer">
74+
<a href="./join-slack-channel.html" id="{{ community[1].links[0].url }}" class="btn btn-primary btn-md btn--default cop-btn slack-link" target="_blank" title="{{community[1].name}} Slack channel" rel="noopener noreferrer">
7575
{% include svg/icon-slack.svg %}
7676
Join Slack Channel
7777
</a>

pages/join-slack-channel.html

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
layout: default
3+
title: Join Slack Channel
4+
permalink: /join-slack-channel
5+
---
6+
7+
<div class="header-container flex-container">
8+
<div class="header-text ">
9+
<h1 class="title1">Join Slack Channel</h1>
10+
<p>
11+
The link below goes to a Slack channel inside Hack for LA's Slack Workspace. If you are already a member of our community, selecting the link below will take you to the channel.
12+
</p>
13+
14+
<div class="align-center link-buttons">
15+
<a href="#" class="btn btn-primary btn-md btn--default cop-btn slack-channel-link" target="_blank" title="Community Slack channel" rel="noopener noreferrer">
16+
{% include svg/icon-slack.svg %}
17+
Join Slack Channel
18+
</a>
19+
</div>
20+
21+
<div>
22+
<p>
23+
If you are not yet a member of our community, please see our <a href="https://www.hackforla.org/getting-started" target="_blank">Getting Started</a> page to join.
24+
</p>
25+
</div>
26+
27+
</div>
28+
</div>
29+
30+
<script type="module" src="assets/js/communities-of-practice.js"></script>

0 commit comments

Comments
 (0)