Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/heroku pg #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"debug": "^3.1.0",
"dotenv": "^4.0.0",
"express": "^4.15.2",
"pg": "^8.11.3",
"tsscmp": "^1.0.6"
},
"devDependencies": {
Expand Down
14 changes: 14 additions & 0 deletions src/dbConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
production: {
client: 'pg',
connection: process.env.DATABASE_URL,
pool: {
min: 2,
max: 10
},
migrations: {
tablename: '',
directory: ''
},
}
};
7 changes: 4 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ app.get('/', (req, res) => {
* Endpoint to receive /helpdesk slash command from Slack.
* Checks verification token and opens a dialog to capture more info.
*/
app.post('/command', async (req, res) => {
app.post('/project', async (req, res) => {
// Verify the signing secret
if (!signature.isVerified(req)) {
debug('Verification token mismatch');
Expand All @@ -58,7 +58,7 @@ app.post('/command', async (req, res) => {

/*
* Endpoint to receive the dialog submission. Checks the verification token
* and creates a Helpdesk ticket
* and creates a project
*/
app.post('/interactive', (req, res) => {
// Verify the signing secret
Expand All @@ -69,9 +69,10 @@ app.post('/interactive', (req, res) => {

const body = JSON.parse(req.body.payload);
res.send('');

ticket.create(body.user.id, body.view);
});

const server = app.listen(process.env.PORT || 5000, () => {
const server = app.listen(process.env.PORT || 3000, () => {
console.log('Express server listening on port %d in %s mode', server.address().port, app.settings.env);
});
243 changes: 216 additions & 27 deletions src/payloads.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ module.exports = {
confirmation: context => {
return {
channel: context.channel_id,
text: 'Helpdesk ticket created!',
text: 'Project created!',
blocks: JSON.stringify([
{
type: 'section',
text: {
type: 'mrkdwn',
text: '*Helpdesk ticket created!*'
text: '*Project created!*'
}
},
{
Expand All @@ -18,15 +18,15 @@ module.exports = {
type: 'section',
text: {
type: 'mrkdwn',
text: `*Title*\n${context.title}\n\n*Description*\n${context.description}`
text: `*Title*\n${context.name}\n`
}
},
{
type: 'context',
elements: [
{
type: 'mrkdwn',
text: `*Urgency*: ${context.urgency}`
text: `*Business Unit*: ${context.bu}`
}
]
}
Expand All @@ -40,7 +40,7 @@ module.exports = {
type: 'modal',
title: {
type: 'plain_text',
text: 'Submit a helpdesk ticket'
text: 'Propose Project'
},
callback_id: 'submit-ticket',
submit: {
Expand All @@ -49,70 +49,259 @@ module.exports = {
},
blocks: [
{
block_id: 'title_block',
block_id: 'bu_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Title'
text: 'Business Unit'
},
element: {
action_id: 'title',
action_id: 'bu',
type: 'static_select',
options: [
{
text: {
type: "plain_text",
text: "AMER"
},
value: "amer"
},
{
text: {
type: "plain_text",
text: "EMEA"
},
value: "emea"
},
{
text: {
type: "plain_text",
text: "APAC"
},
value: "apac"
}
]
},
optional: false
},
{
block_id: 'name_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Project Name'
},
element: {
action_id: 'name',
type: 'plain_text_input'
},
hint: {
optional: false
},
{
block_id: 'type_block',
type: 'input',
label: {
type: 'plain_text',
text: '30 second summary of the problem'
text: 'Type'
},
element: {
action_id: 'type',
type: 'static_select',
options: [
{
text: {
type: "plain_text",
text: "Campaign"
},
value: "campaign"
},
{
text: {
type: "plain_text",
text: "Commerce"
},
value: "commerce"
},
{
text: {
type: "plain_text",
text: "Automation"
},
value: "automation"
}
]
}
},
{
block_id: 'description_block',
block_id: 'brief_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Description'
text: 'Brief'
},
element: {
action_id: 'description',
type: 'plain_text_input',
multiline: true
action_id: 'brief',
type: 'plain_text_input'
},
optional: true
optional: false
},
{
block_id: 'urgency_block',
block_id: 'need_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Importance'
text: 'Need'
},
element: {
action_id: 'urgency',
type: 'static_select',
action_id: 'need',
type: 'multi_static_select',
placeholder: {
type: 'plain_text',
text: 'Select needs'
},
options: [
{
text: {
type: "plain_text",
text: "High"
text: "Copy"
},
value: "high"
value: "copy"
},
{
text: {
type: "plain_text",
text: "Medium"
text: "Creative"
},
value: "medium"
value: "creative"
},
{
text: {
type: "plain_text",
text: "Low"
text: "Journey"
},
value: "low"
value: "journey"
}
]
},
optional: true
optional: false
},
{
block_id: 'comm_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Communications'
},
element: {
action_id: 'communications',
type: 'number_input',
is_decimal_allowed: false
}
},
{
block_id: 'languages_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Languages'
},
element: {
action_id: 'languages',
type: 'multi_static_select',
options: [
{
text: {
type: "plain_text",
text: "English"
},
value: "english"
},
{
text: {
type: "plain_text",
text: "Spanish"
},
value: "spanish"
},
{
text: {
type: "plain_text",
text: "French"
},
value: "french"
}
]
}
},
{
block_id: 'objective_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Objective'
},
element: {
action_id: 'objective',
type: 'multi_static_select',
options: [
{
text: {
type: "plain_text",
text: "New Members"
},
value: "new_members"
},
{
text: {
type: "plain_text",
text: "Cart Conversion"
},
value: "cart_conv"
}
]
}
},
{
block_id: 'goal_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Goal'
},
element: {
action_id: 'goal',
type: 'number_input',
is_decimal_allowed: true
}
},
{
block_id: 'budget_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Budget'
},
element: {
action_id: 'budget',
type: 'number_input',
is_decimal_allowed: true
}
},
{
block_id: 'date_block',
type: 'input',
label: {
type: 'plain_text',
text: 'Due Date'
},
element: {
action_id: 'date',
type: 'datepicker',
placeholder: {
type: 'plain_text',
text: 'Select a date'
}
}
}
]
})
Expand Down
Loading