fix(my-joy-beta): re-connect popover actions

This commit is contained in:
Sérgio Ramos 2017-12-22 03:28:36 +00:00
parent e9c833d1ea
commit 2d847da1d4
2 changed files with 23 additions and 14 deletions

View File

@ -114,7 +114,7 @@ export const Actions = ({
type="button" type="button"
onClick={onReboot} onClick={onReboot}
disabled={submitting || !allowedActions.reboot} disabled={submitting || !allowedActions.reboot}
loading={submitting && statuses.restarting} loading={submitting && statuses.rebooting}
secondary secondary
small small
icon icon
@ -127,7 +127,7 @@ export const Actions = ({
type="button" type="button"
onClick={onReboot} onClick={onReboot}
disabled={submitting || !allowedActions.reboot} disabled={submitting || !allowedActions.reboot}
loading={submitting && statuses.restarting} loading={submitting && statuses.rebooting}
secondary secondary
icon icon
> >
@ -220,7 +220,7 @@ export const Item = ({
<PopoverTarget box> <PopoverTarget box>
<ActionsIcon /> <ActionsIcon />
</PopoverTarget> </PopoverTarget>
<Popover placement="bottom"> <Popover placement="top">
<PopoverItem disabled={!allowedActions.start} onClick={onStart}> <PopoverItem disabled={!allowedActions.start} onClick={onStart}>
Start Start
</PopoverItem> </PopoverItem>

View File

@ -51,6 +51,7 @@ export const List = ({
sortOrder = 'desc', sortOrder = 'desc',
loading = false, loading = false,
error = null, error = null,
mutationError = null,
submitting, submitting,
handleAction, handleAction,
toggleSelectAll, toggleSelectAll,
@ -76,9 +77,16 @@ export const List = ({
</Message> </Message>
) : null; ) : null;
const _mutationError = mutationError && (
<Message error>
<MessageTitle>Ooops!</MessageTitle>
<MessageDescription>{mutationError}</MessageDescription>
</Message>
);
const handleStart = selected => handleAction({ name: 'start', selected }); const handleStart = selected => handleAction({ name: 'start', selected });
const handleStop = selected => handleAction({ name: 'stop', selected }); const handleStop = selected => handleAction({ name: 'stop', selected });
const handleReboot = selected => handleAction({ name: 'restart', selected }); const handleReboot = selected => handleAction({ name: 'reboot', selected });
const handleDelete = selected => handleAction({ name: 'delete', selected }); const handleDelete = selected => handleAction({ name: 'delete', selected });
const _table = !loading ? ( const _table = !loading ? (
@ -97,10 +105,10 @@ export const List = ({
key={id} key={id}
id={id} id={id}
{...rest} {...rest}
onStart={() => handleStart([id])} onStart={() => handleStart([{ id }])}
onStop={() => handleStop([id])} onStop={() => handleStop([{ id }])}
onReboot={() => handleReboot([id])} onReboot={() => handleReboot([{ id }])}
onDelete={() => handleDelete([id])} onDelete={() => handleDelete([{ id }])}
/> />
))} ))}
</InstanceList> </InstanceList>
@ -136,7 +144,8 @@ export const List = ({
/> />
)} )}
</ReduxForm> </ReduxForm>
{_error} {!_mutationError ? _error : null}
{_mutationError}
{_loading} {_loading}
{_table} {_table}
{_footer} {_footer}
@ -185,7 +194,7 @@ export default compose(
// check whether the main form is submitting // check whether the main form is submitting
const submitting = get(form, `${TABLE_FORM_NAME}.submitting`, false); const submitting = get(form, `${TABLE_FORM_NAME}.submitting`, false);
// check whether the main form has an error // check whether the main form has an error
const _error = get(form, `${TABLE_FORM_NAME}.error`, null); const mutationError = get(form, `${TABLE_FORM_NAME}.error`, null);
// get sort values // get sort values
const sortBy = get(values, 'instance-list-sort-by', 'name'); const sortBy = get(values, 'instance-list-sort-by', 'name');
const sortOrder = get(values, 'instance-list-sort-order', 'asc'); const sortOrder = get(values, 'instance-list-sort-order', 'asc');
@ -219,7 +228,7 @@ export default compose(
const statuses = { const statuses = {
starting: get(values, 'instance-list-starting', false), starting: get(values, 'instance-list-starting', false),
stopping: get(values, 'instance-list-stoping', false), stopping: get(values, 'instance-list-stoping', false),
restarting: get(values, 'instance-list-restarting', false), rebooting: get(values, 'instance-list-rebooting', false),
deleting: get(values, 'instance-list-deleteing', false) deleting: get(values, 'instance-list-deleteing', false)
}; };
@ -230,7 +239,7 @@ export default compose(
selected, selected,
statuses, statuses,
submitting, submitting,
error: _error || error, mutationError,
index, index,
sortOrder, sortOrder,
sortBy sortBy
@ -291,7 +300,7 @@ export default compose(
// flips submitting flag to true so that we can disable everything // flips submitting flag to true so that we can disable everything
const flipSubmitTrue = startSubmit(TABLE_FORM_NAME); const flipSubmitTrue = startSubmit(TABLE_FORM_NAME);
// sets (starting/restarting/etc) to true so that we can, for instance, // sets (starting/rebooting/etc) to true so that we can, for instance,
// have a spinner on the correct button // have a spinner on the correct button
const setIngTrue = set({ const setIngTrue = set({
name: `instance-list-${gerund}`, name: `instance-list-${gerund}`,
@ -324,7 +333,7 @@ export default compose(
// if no error, clears selected // if no error, clears selected
const clearSelected = !err && reset(TABLE_FORM_NAME); const clearSelected = !err && reset(TABLE_FORM_NAME);
// reverts (starting/restarting/etc) to false // reverts (starting/rebooting/etc) to false
const setIngFalse = set({ const setIngFalse = set({
name: `instance-list-${gerund}`, name: `instance-list-${gerund}`,
value: false value: false