* set up refactored onboarding * create onboarding page * add in first slide and change slide functionality * fix test suite * profile refactor * profile refactor * refactor to api * add checkbox fields * add checkbox fields * remove puts * add basic css * add styling * add redirect * hide back and next at first and last slides * test refactored onboarding * test refactored onboarding * remove article edits * Fix schema * Add deleted file back in * Add default value for checked_t&c column * Adjust HTML structure to keep nav buttons in place * Fix ESLint issues on Onboarding.jsx file * Handling for undefined or empty followedTags on getUserTags * Fix codeclimate issues * Fix codeclimate issues * Fix more codeclimate issues * Fix more codeclimate issues * Update Onboarding snapshots * Uncheck the CoC and T&C checkboxes on render * Update snapshots * Return false instead of raising error * Update spec to use new onboarding * Redirect to onboarding if haven't seen it yet * Prevent redirect to onboarding from /signout_confirm * Use assign_attributes instead of saving twice * Move COC and T&C checkbox page to second slide * Add 'go back to original page' functionality * Reuse ready prototype logic * Keep track of the last visited onboarding page * Fix email subscription bug * Fix overflow issue for tags page * Remove height to prevent page container scrolling * Check for CoC and T&C for displaying onboarding * Add InstantClick redirect and preserve referrer in client * Fix async update + check by using localStorage * Turn off onboarding for tests * Finalize design for onboarding * Finalize design for onboarding * Make bulk follows during onboarding * Fix bulk follow test
122 lines
3.6 KiB
JavaScript
122 lines
3.6 KiB
JavaScript
import { h } from 'preact';
|
|
import PropTypes from 'prop-types';
|
|
import ConfigImage from 'images/three-dots.svg';
|
|
import GroupImage from 'images/organization.svg';
|
|
|
|
const Channels = ({
|
|
activeChannelId,
|
|
chatChannels,
|
|
handleSwitchChannel,
|
|
expanded,
|
|
filterQuery,
|
|
channelsLoaded,
|
|
incomingVideoCallChannelIds,
|
|
}) => {
|
|
const channels = chatChannels.map(channel => {
|
|
const isActive = parseInt(activeChannelId, 10) === channel.chat_channel_id;
|
|
const lastOpened = channel.last_opened_at;
|
|
const isUnopened =
|
|
new Date(channel.channel_last_message_at) > new Date(lastOpened) &&
|
|
channel.channel_messages_count > 0;
|
|
let newMessagesIndicator = isUnopened ? 'new' : 'old';
|
|
if (incomingVideoCallChannelIds.indexOf(channel.chat_channel_id) > -1) {
|
|
newMessagesIndicator = 'video';
|
|
}
|
|
const otherClassname = isActive
|
|
? 'chatchanneltab--active'
|
|
: 'chatchanneltab--inactive';
|
|
return (
|
|
<button
|
|
type="button"
|
|
key={channel.id}
|
|
className="chatchanneltabbutton"
|
|
onClick={handleSwitchChannel}
|
|
data-channel-id={channel.chat_channel_id}
|
|
data-channel-slug={channel.channel_modified_slug}
|
|
>
|
|
<span
|
|
className={`chatchanneltab ${otherClassname} chatchanneltab--${newMessagesIndicator}`}
|
|
data-channel-id={channel.chat_channel_id}
|
|
data-channel-slug={channel.channel_modified_slug}
|
|
style={{
|
|
border: `1px solid ${channel.channel_color}`,
|
|
boxShadow: `3px 3px 0px ${channel.channel_color}`,
|
|
}}
|
|
>
|
|
<span
|
|
data-channel-slug={channel.channel_modified_slug}
|
|
className={`chatchanneltabindicator chatchanneltabindicator--${newMessagesIndicator}`}
|
|
data-channel-id={channel.chat_channel_id}
|
|
>
|
|
<img
|
|
src={channel.channel_image}
|
|
alt="pic"
|
|
className="chatchanneltabindicatordirectimage"
|
|
/>
|
|
</span>
|
|
{channel.channel_name}
|
|
</span>
|
|
</button>
|
|
);
|
|
});
|
|
let topNotice = '';
|
|
if (
|
|
expanded &&
|
|
filterQuery.length === 0 &&
|
|
channelsLoaded &&
|
|
(channels.length === 0 || channels[0].messages_count === 0)
|
|
) {
|
|
topNotice = (
|
|
<div className="chatchannels__channelslistheader">
|
|
<span role="img" aria-label="emoji">
|
|
👋
|
|
</span>{' '}
|
|
Welcome to
|
|
<b> DEV Connect</b>! You may message anyone you mutually follow.
|
|
</div>
|
|
);
|
|
}
|
|
let channelsListFooter = '';
|
|
if (channels.length === 30) {
|
|
channelsListFooter = (
|
|
<div className="chatchannels__channelslistfooter">...</div>
|
|
);
|
|
}
|
|
let configFooter = '';
|
|
if (expanded) {
|
|
configFooter = (
|
|
<div className="chatchannels__config">
|
|
<img alt="" src={ConfigImage} style={{ height: '18px' }} />
|
|
<div className="chatchannels__configmenu">
|
|
<a href="/settings">DEV Settings</a>
|
|
<a href="/report-abuse">Report Abuse</a>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|
|
return (
|
|
<div className="chatchannels">
|
|
<div
|
|
className="chatchannels__channelslist"
|
|
id="chatchannels__channelslist"
|
|
>
|
|
{topNotice}
|
|
{channels}
|
|
{channelsListFooter}
|
|
</div>
|
|
{configFooter}
|
|
</div>
|
|
);
|
|
};
|
|
|
|
Channels.propTypes = {
|
|
activeChannelId: PropTypes.number.isRequired,
|
|
chatChannels: PropTypes.array.isRequired,
|
|
handleSwitchChannel: PropTypes.func.isRequired,
|
|
expanded: PropTypes.bool.isRequired,
|
|
filterQuery: PropTypes.string.isRequired,
|
|
channelsLoaded: PropTypes.bool.isRequired,
|
|
incomingVideoCallChannelIds: PropTypes.array.isRequired,
|
|
};
|
|
|
|
export default Channels;
|