Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
scratch-www
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
scratch-www
Commits
bc3a454f
Commit
bc3a454f
authored
Mar 12, 2020
by
Paul Kaplan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split project report flow into multiple steps
parent
a2929e5b
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
277 additions
and
190 deletions
+277
-190
src/components/modal/report/form-step.jsx
src/components/modal/report/form-step.jsx
+89
-0
src/components/modal/report/modal.jsx
src/components/modal/report/modal.jsx
+110
-182
src/components/modal/report/modal.scss
src/components/modal/report/modal.scss
+1
-8
src/components/modal/report/report-options.js
src/components/modal/report/report-options.js
+77
-0
No files found.
src/components/modal/report/form-step.jsx
0 → 100644
View file @
bc3a454f
const
bindAll
=
require
(
'
lodash.bindall
'
);
const
PropTypes
=
require
(
'
prop-types
'
);
const
React
=
require
(
'
react
'
);
const
FormattedMessage
=
require
(
'
react-intl
'
).
FormattedMessage
;
const
classNames
=
require
(
'
classnames
'
);
const
Form
=
require
(
'
../../forms/form.jsx
'
);
const
Button
=
require
(
'
../../forms/button.jsx
'
);
const
Spinner
=
require
(
'
../../spinner/spinner.jsx
'
);
const
FlexRow
=
require
(
'
../../flex-row/flex-row.jsx
'
);
require
(
'
../../forms/button.scss
'
);
/**
* Step to be used in a form progression. Provides wrapping form element,
* renders children input elements, then provides a next button row
* that responds to form validation and submission spinner.
*/
class
FormStep
extends
React
.
Component
{
constructor
(
props
)
{
super
(
props
);
this
.
state
=
{
valid
:
false
};
bindAll
(
this
,
[
'
handleValid
'
,
'
handleInvalid
'
]);
}
handleValid
()
{
this
.
setState
({
valid
:
true
});
}
handleInvalid
()
{
this
.
setState
({
valid
:
false
});
}
render
()
{
const
{
onNext
,
children
,
isWaiting
,
nextLabel
}
=
this
.
props
;
// Allow submit to be force-enabled by submitEnabled prop. Otherwise use form validation,
// with default being not-submittable.
const
submitEnabled
=
(
this
.
props
.
submitEnabled
||
this
.
state
.
valid
)
&&
!
isWaiting
;
const
submitDisabledParam
=
submitEnabled
?
{}
:
{
disabled
:
'
disabled
'
};
return
(
<
Form
onInvalid=
{
this
.
handleInvalid
}
onValid=
{
this
.
handleValid
}
onValidSubmit=
{
onNext
}
>
{
children
}
<
FlexRow
className=
"action-buttons"
>
<
Button
className=
{
classNames
(
'
action-button
'
,
'
submit-button
'
,
{
disabled
:
!
submitEnabled
}
)
}
{
...
submitDisabledParam
}
key=
"submitButton"
type=
"submit"
>
{
isWaiting
?
(
<
div
className=
"action-button-text"
>
<
Spinner
/>
<
FormattedMessage
id=
"report.sending"
/>
</
div
>
)
:
(
<
div
className=
"action-button-text"
>
<
FormattedMessage
{
...
nextLabel
}
/>
</
div
>
)
}
</
Button
>
</
FlexRow
>
</
Form
>
);
}
}
FormStep
.
propTypes
=
{
children
:
PropTypes
.
node
.
isRequired
,
isWaiting
:
PropTypes
.
bool
,
nextLabel
:
PropTypes
.
shape
({
id
:
PropTypes
.
string
.
isRequired
}).
isRequired
,
onNext
:
PropTypes
.
func
.
isRequired
,
submitEnabled
:
PropTypes
.
bool
};
FormStep
.
defaultProps
=
{
isWaiting
:
false
,
submitEnabled
:
false
};
module
.
exports
=
FormStep
;
src/components/modal/report/modal.jsx
View file @
bc3a454f
This diff is collapsed.
Click to expand it.
src/components/modal/report/modal.scss
View file @
bc3a454f
...
@@ -13,15 +13,8 @@
...
@@ -13,15 +13,8 @@
.instructions
{
.instructions
{
line-height
:
1
.5rem
;
line-height
:
1
.5rem
;
}
.received
{
margin
:
0
auto
;
width
:
90%
;
text-align
:
center
;
line-height
:
1
.65rem
;
.
received
-header
{
.
instructions
-header
{
font-weight
:
bold
;
font-weight
:
bold
;
}
}
}
}
...
...
src/components/modal/report/report-options.js
0 → 100644
View file @
bc3a454f
const
PropTypes
=
require
(
'
prop-types
'
);
const
{
arrayOf
,
string
,
shape
}
=
PropTypes
;
/**
* Define both the PropType shape and default value for report options
* to ensure structure is validated by PropType checking going forward.
*/
const
messageShape
=
shape
({
id
:
string
.
isRequired
});
const
categoryShape
=
shape
({
value
:
string
.
isRequired
,
label
:
messageShape
.
isRequired
,
prompt
:
messageShape
.
isRequired
});
const
reportOptionsShape
=
arrayOf
(
categoryShape
);
const
REPORT_OPTIONS
=
[
{
value
:
''
,
label
:
{
id
:
'
report.reasonPlaceHolder
'
},
prompt
:
{
id
:
'
report.promptPlaceholder
'
}
},
{
value
:
'
0
'
,
label
:
{
id
:
'
report.reasonCopy
'
},
prompt
:
{
id
:
'
report.promptCopy
'
}
},
{
value
:
'
1
'
,
label
:
{
id
:
'
report.reasonUncredited
'
},
prompt
:
{
id
:
'
report.promptUncredited
'
}
},
{
value
:
'
2
'
,
label
:
{
id
:
'
report.reasonScary
'
},
prompt
:
{
id
:
'
report.promptScary
'
}
},
{
value
:
'
3
'
,
label
:
{
id
:
'
report.reasonLanguage
'
},
prompt
:
{
id
:
'
report.promptLanguage
'
}
},
{
value
:
'
4
'
,
label
:
{
id
:
'
report.reasonMusic
'
},
prompt
:
{
id
:
'
report.promptMusic
'
}
},
{
value
:
'
8
'
,
label
:
{
id
:
'
report.reasonImage
'
},
prompt
:
{
id
:
'
report.promptImage
'
}
},
{
value
:
'
5
'
,
label
:
{
id
:
'
report.reasonPersonal
'
},
prompt
:
{
id
:
'
report.promptPersonal
'
}
},
{
value
:
'
6
'
,
label
:
{
id
:
'
general.other
'
},
prompt
:
{
id
:
'
report.promptGuidelines
'
}
}
];
module
.
exports
=
{
reportOptionsShape
,
REPORT_OPTIONS
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment