Skip to content

Commit

Permalink
Can view file in edit modal. Minor fixes in controllers.
Browse files Browse the repository at this point in the history
  • Loading branch information
kyleqhua committed May 15, 2020
1 parent c0ec677 commit 87ead36
Show file tree
Hide file tree
Showing 6 changed files with 87 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ruby-2.5.6
ruby-2.6.3
5 changes: 3 additions & 2 deletions app/controllers/api/assignments_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ def create
authorize Assignment
participant_ids_string = single_assignment_params.fetch(:participant_ids)
participant_ids = participant_ids_string.split(/,/)
created_assignments = []
if participant_ids.empty?
render json: { error: 'Participant must be populated'}, status: :unprocessable_entity
return
Expand All @@ -30,7 +31,7 @@ def create
prepare_bulk_assignment(participant_ids, action_item, due_date).each do |assignment|
assignment_sentry_helper(assignment)
if assignment.save
AssignmentMailer.with(assignment: assignment, action_item: action_item).new_assignment.deliver_now
#AssignmentMailer.with(assignment: assignment, action_item: action_item).new_assignment.deliver_now
created_assignments.append(assignment)
else
action_item.destroy
Expand Down Expand Up @@ -177,7 +178,7 @@ def prepare_single_assignment(participant_id, action_item, due_date)
end

def action_item_params
action_item_param = params.require(:assignment).permit(:title,
action_item_param = params.permit(:title,
:description,
:category,
:file)
Expand Down
7 changes: 4 additions & 3 deletions app/javascript/components/ActionItemCreationPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ActionItemCreationPage extends React.Component {
)
.catch(error => {
this.setState({ submissionStatus: 'error' });
Sentry.configureScope(function(scope) {
Sentry.configureScope(function (scope) {
scope.setExtra('file', 'ActionItemCreationPage');
scope.setExtra('action', 'apiPost (handleSubmit)');
scope.setExtra('participantIds', participantIds);
Expand All @@ -213,7 +213,7 @@ class ActionItemCreationPage extends React.Component {
}),
)
.catch(error => {
Sentry.configureScope(function(scope) {
Sentry.configureScope(function (scope) {
scope.setExtra('file', 'ActionItemCreationPage');
scope.setExtra('action', 'apiDelete');
scope.setExtra('templateActionItemId', templateActionItem.id);
Expand Down Expand Up @@ -275,7 +275,7 @@ class ActionItemCreationPage extends React.Component {
}));
})
.catch(error => {
Sentry.configureScope(function(scope) {
Sentry.configureScope(function (scope) {
scope.setExtra('file', 'ActionItemCreationPage');
scope.setExtra('action', 'apiPost (createActionItem)');
scope.setExtra('template', JSON.stringify(actionItem));
Expand Down Expand Up @@ -619,6 +619,7 @@ class ActionItemCreationPage extends React.Component {
categorySelected={this.state.modalActionItem.category}
dueDate={this.state.modalActionItem.dueDate}
handleFileChange={this.handleFileEdit}
files={this.state.files}
type="edit"
/>
) : null}
Expand Down
16 changes: 13 additions & 3 deletions app/javascript/components/ActionItemModal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,14 @@ class ActionItemModal extends React.Component {
this.setState({ [name]: value });
};

showFile = () => {
if (this.props.actionItem.fileIndex != null) {
const file = this.props.files[this.props.actionItem.fileIndex];
const objectURL = window.URL.createObjectURL(file);
window.open(objectURL, '_blank');
}
};

handleSubmit = () => {
const { participantId, actionItemId, actionItem } = this.props;
const { title, description, categorySelected, dueDate } = this.state;
Expand Down Expand Up @@ -201,9 +209,11 @@ class ActionItemModal extends React.Component {
<DialogActions disableSpacing>
<Grid container justify="flex-end" alignItems="center">
<Grid item>
{actionItem.fileName
? actionItem.fileName
: 'No file currently uploaded'}
<Button className={classes.checkboxTextStyle} onClick={this.showFile}>
{actionItem.fileName
? actionItem.fileName
: 'No file currently uploaded'}
</Button>
<input
type="file"
onChange={e =>
Expand Down
2 changes: 1 addition & 1 deletion config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
end

# Store uploaded files on the local file system (see config/storage.yml for options).
config.active_storage.service = :amazon
config.active_storage.service = :local

# Don't care if the mailer can't send.
config.action_mailer.perform_caching = false
Expand Down
85 changes: 65 additions & 20 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2886,6 +2886,15 @@ cli-width@^2.0.0:
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.1.tgz#b0433d0b4e9c847ef18868a4ef16fd5fc8271c48"
integrity sha512-GRMWDxpOB6Dgk2E5Uo+3eEBvtOOlimMmpbFiKuLFnQzYDavtLFY3K5ona41jgN/WdRZtG7utuVSVTL4HbZHGkw==

cliui@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-4.1.0.tgz#348422dbe82d800b3022eef4f6ac10bf2e4d1b49"
integrity sha512-4FG+RSG9DL7uEwRUZXZn3SS34DiDPfzP0VOiEwtUWlE+AR2EIg+hSyvrIgUUfhdgR/UkAeW2QHgeP+hWrXs7jQ==
dependencies:
string-width "^2.1.1"
strip-ansi "^4.0.0"
wrap-ansi "^2.0.0"

cliui@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5"
Expand Down Expand Up @@ -4987,6 +4996,11 @@ gensync@^1.0.0-beta.1:
resolved "https://registry.yarnpkg.com/gensync/-/gensync-1.0.0-beta.1.tgz#58f4361ff987e5ff6e1e7a210827aa371eaac269"
integrity sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==

get-caller-file@^1.0.1:
version "1.0.3"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-1.0.3.tgz#f978fa4c90d1dfe7ff2d6beda2a515e713bdcf4a"
integrity sha512-3t6rVToeoZfYSGd8YoLFR2DJkiQrIiUrGcjvFX2mDw3bn6k2OtwHN0TNCLbBO+w8qTvimhDkv+LSscbJY1vE6w==

get-caller-file@^2.0.1:
version "2.0.5"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
Expand Down Expand Up @@ -5409,7 +5423,7 @@ html-encoding-sniffer@^1.0.2:
dependencies:
whatwg-encoding "^1.0.1"

html-entities@^1.3.1:
html-entities@^1.2.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/html-entities/-/html-entities-1.3.1.tgz#fb9a1a4b5b14c5daba82d3e34c6ae4fe701a0e44"
integrity sha512-rhE/4Z3hIhzHAUKbW8jVcCyuT5oJCXXqhN/6mXXVCpzTmvJnoH2HL/bt3EZ6p55jbFJBeAe1ZNpL5BugLujxNA==
Expand Down Expand Up @@ -8133,7 +8147,7 @@ os-homedir@^1.0.0:
resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3"
integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M=

os-locale@^3.1.0:
os-locale@^3.0.0, os-locale@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a"
integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q==
Expand Down Expand Up @@ -8604,7 +8618,7 @@ popper.js@^1.16.1-lts:
resolved "https://registry.yarnpkg.com/popper.js/-/popper.js-1.16.1.tgz#2a223cb3dc7b6213d740e40372be40de43e65b1b"
integrity sha512-Wb4p1J4zyFTbM+u6WuO4XstYx4Ky9Cewe4DWrel7B0w6VVICvPwdOpotjzcf6eD8TsckVnIMNONQyPIUFOUbCQ==

portfinder@^1.0.26:
portfinder@^1.0.25:
version "1.0.26"
resolved "https://registry.yarnpkg.com/portfinder/-/portfinder-1.0.26.tgz#475658d56ca30bed72ac7f1378ed350bd1b64e70"
integrity sha512-Xi7mKxJHHMI3rIUrnm/jjUgwhbYMkp/XKEcZX3aG4BrumLpq3nmoQMX+ClYnDZnZ/New7IatC1no5RX0zo1vXQ==
Expand Down Expand Up @@ -10004,6 +10018,11 @@ require-directory@^2.1.1:
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I=

require-main-filename@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"
integrity sha1-l/cXtp1IeE9fUmpsWqj/3aBVpNE=

require-main-filename@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b"
Expand Down Expand Up @@ -10555,14 +10574,13 @@ [email protected]:
json3 "^3.3.2"
url-parse "^1.4.3"

[email protected].20:
version "0.3.20"
resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.20.tgz#b26a283ec562ef8b2687b44033a4eeceac75d855"
integrity sha512-SpmVOVpdq0DJc0qArhF3E5xsxvaiqGNb73XfgBpK1y3UD5gs8DSo8aCTsuT5pX8rssdc2NDIzANwP9eCAiSdTA==
[email protected].19:
version "0.3.19"
resolved "https://registry.yarnpkg.com/sockjs/-/sockjs-0.3.19.tgz#d976bbe800af7bd20ae08598d582393508993c0d"
integrity sha512-V48klKZl8T6MzatbLlzzRNhMepEys9Y4oGFpypBFFn1gLI/QQ9HtLLyWJNbPlwGLelOVOEijUbTTJeLLI59jLw==
dependencies:
faye-websocket "^0.10.0"
uuid "^3.4.0"
websocket-driver "0.6.5"
uuid "^3.0.1"

sort-keys@^1.0.0:
version "1.1.2"
Expand Down Expand Up @@ -10668,7 +10686,7 @@ spdy-transport@^3.0.0:
readable-stream "^3.0.6"
wbuf "^1.7.3"

spdy@^4.0.2:
spdy@^4.0.1:
version "4.0.2"
resolved "https://registry.yarnpkg.com/spdy/-/spdy-4.0.2.tgz#b74f466203a3eda452c02492b91fb9e84a27677b"
integrity sha512-r46gZQZQV+Kl9oItvl1JZZqJKGr+oEkB08A6BzkiR7593/7IbtuncXHd2YoYeTsG4157ZssMu9KYvUHLcjcDoA==
Expand Down Expand Up @@ -10825,7 +10843,7 @@ string-width@^1.0.1:
is-fullwidth-code-point "^1.0.0"
strip-ansi "^3.0.0"

"string-width@^1.0.2 || 2", string-width@^2.1.1:
"string-width@^1.0.2 || 2", string-width@^2.0.0, string-width@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"
integrity sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==
Expand Down Expand Up @@ -11722,7 +11740,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713"
integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=

uuid@^3.3.2, uuid@^3.4.0:
uuid@^3.0.1, uuid@^3.3.2:
version "3.4.0"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
Expand Down Expand Up @@ -11983,13 +12001,6 @@ webpack@^4.41.2:
watchpack "^1.6.1"
webpack-sources "^1.4.1"

[email protected]:
version "0.6.5"
resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.6.5.tgz#5cb2556ceb85f4373c6d8238aa691c8454e13a36"
integrity sha1-XLJVbOuF9Dc8bYI4qmkchFThOjY=
dependencies:
websocket-extensions ">=0.1.1"

websocket-driver@>=0.5.1:
version "0.7.3"
resolved "https://registry.yarnpkg.com/websocket-driver/-/websocket-driver-0.7.3.tgz#a2d4e0d4f4f116f1e6297eba58b05d430100e9f9"
Expand Down Expand Up @@ -12089,6 +12100,14 @@ worker-farm@^1.7.0:
dependencies:
errno "~0.1.7"

wrap-ansi@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-2.1.0.tgz#d8fc3d284dd05794fe84973caecdd1cf824fdd85"
integrity sha1-2Pw9KE3QV5T+hJc8rs3Rz4JP3YU=
dependencies:
string-width "^1.0.1"
strip-ansi "^3.0.1"

wrap-ansi@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-3.0.1.tgz#288a04d87eda5c286e060dfe8f135ce8d007f8ba"
Expand Down Expand Up @@ -12176,7 +12195,7 @@ xtend@^4.0.0, xtend@^4.0.1, xtend@~4.0.1:
resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54"
integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==

y18n@^4.0.0:
"y18n@^3.2.1 || ^4.0.0", y18n@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b"
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==
Expand Down Expand Up @@ -12210,6 +12229,14 @@ yargs-parser@^10.0.0:
dependencies:
camelcase "^4.1.0"

yargs-parser@^11.1.1:
version "11.1.1"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-11.1.1.tgz#879a0865973bca9f6bab5cbdf3b1c67ec7d3bcf4"
integrity sha512-C6kB/WJDiaxONLJQnF8ccx9SEeoTTLek8RVbaOIsrAUS8VrBEXfmeSnCZxygc+XC2sNMBIwOOnfcxiynjHsVSQ==
dependencies:
camelcase "^5.0.0"
decamelize "^1.2.0"

yargs-parser@^13.1.0, yargs-parser@^13.1.2:
version "13.1.2"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38"
Expand All @@ -12218,6 +12245,24 @@ yargs-parser@^13.1.0, yargs-parser@^13.1.2:
camelcase "^5.0.0"
decamelize "^1.2.0"

[email protected]:
version "12.0.5"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-12.0.5.tgz#05f5997b609647b64f66b81e3b4b10a368e7ad13"
integrity sha512-Lhz8TLaYnxq/2ObqHDql8dX8CJi97oHxrjUcYtzKbbykPtVW9WB+poxI+NM2UIzsMgNCZTIf0AQwsjK5yMAqZw==
dependencies:
cliui "^4.0.0"
decamelize "^1.2.0"
find-up "^3.0.0"
get-caller-file "^1.0.1"
os-locale "^3.0.0"
require-directory "^2.1.1"
require-main-filename "^1.0.1"
set-blocking "^2.0.0"
string-width "^2.0.0"
which-module "^2.0.0"
y18n "^3.2.1 || ^4.0.0"
yargs-parser "^11.1.1"

[email protected]:
version "13.2.4"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.2.4.tgz#0b562b794016eb9651b98bd37acf364aa5d6dc83"
Expand Down

0 comments on commit 87ead36

Please sign in to comment.