Skip to content

Commit

Permalink
copy URL to clipboard for Discussion; removed TeamConstraints page
Browse files Browse the repository at this point in the history
  • Loading branch information
tima101 committed Jun 18, 2018
1 parent d141734 commit 449dbbc
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 129 deletions.
7 changes: 0 additions & 7 deletions app/components/common/SettingList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,6 @@ class SettingList extends React.Component<MyProps> {
highlighterSlug={'/team-billing'}
/>
<p />
<ActiveLink
linkText="Team Constraints"
href={`/settings/team-constraints?teamSlug=${currentTeam.slug}`}
as={`/team/${currentTeam.slug}/settings/team-constraints`}
highlighterSlug={'/team-constraints'}
/>
<p />
<ActiveLink
linkText="Team Profile"
href={`/settings/team-profile?teamSlug=${currentTeam.slug}`}
Expand Down
28 changes: 27 additions & 1 deletion app/components/discussions/DiscussionActionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { Discussion, Store } from '../../lib/store';
import MenuWithMenuItems from '../common/MenuWithMenuItems';
import EditDiscussionForm from './EditDiscussionForm';

const dev = process.env.NODE_ENV !== 'production';
const ROOT_URL = dev ? `http://localhost:3000` : 'https://saas-app.async-await.com';

const getMenuOptions = discussion => ({
dataId: discussion._id,
id: `discussion-menu-${discussion._id}`,
Expand All @@ -19,7 +22,7 @@ const getMenuItemOptions = (discussion, component) => [
{
text: 'Copy URL',
dataId: discussion._id,
onClick: component.handleDiscussionMenuClose,
onClick: component.handleCopyUrl,
},
{
text: 'Edit',
Expand All @@ -44,6 +47,29 @@ class DiscussionActionMenu extends React.Component<{ discussion: Discussion; sto
this.setState({ discussionFormOpen: false, selectedDiscussion: null });
};

handleCopyUrl = async (event) => {
const { store } = this.props;
const { currentTeam } = store;
const { currentTopic } = currentTeam;

const id = event.currentTarget.dataset.id;
if (!id) {
return;
}

const selectedDiscussion = currentTopic.discussions.find(d => d._id === id);
const discussionUrl = `${ROOT_URL}/team/${currentTeam.slug}/t/${currentTopic.slug}/${selectedDiscussion.slug}`;

console.log(discussionUrl);

try {
await navigator.clipboard.writeText(discussionUrl);
notify('You successfully copied URL.');
} catch (err) {
notify(err);
}
};

editDiscussion = event => {
const { currentTeam } = this.props.store;
if (!currentTeam) {
Expand Down
2 changes: 1 addition & 1 deletion app/components/posts/PostForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import PostEditor from './PostEditor';

const styles = {
paper: {
width: '75%', // TODO: should 100% when isMobile is true
width: '100%',
padding: '0px 20px 20px 20px',
},
};
Expand Down
2 changes: 1 addition & 1 deletion app/now.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"env": {
"NODE_ENV": "production",
"GA_TRACKING_ID": "UA-xxxxxxxxx-x"
"GA_TRACKING_ID": "UA-114984707-3"
},
"alias": "saas-app.async-await.com",
"scale": {
Expand Down
114 changes: 0 additions & 114 deletions app/pages/settings/team-constraints.tsx

This file was deleted.

5 changes: 0 additions & 5 deletions app/server/routesWithSlug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ export default function routesWithSlug({ server, app }) {
app.render(req, res, '/settings/team-billing', { teamSlug });
});

server.get('/team/:teamSlug/settings/team-constraints', (req, res) => {
const { teamSlug } = req.params;
app.render(req, res, '/settings/team-constraints', { teamSlug });
});

server.get('/team/:teamSlug/settings/team-profile', (req, res) => {
const { teamSlug } = req.params;
app.render(req, res, '/settings/team-profile', { teamSlug });
Expand Down

0 comments on commit 449dbbc

Please sign in to comment.