-
Notifications
You must be signed in to change notification settings - Fork 310
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
General Settings view for Devices #624
Conversation
pkg/webui/locales/xx.json
Outdated
"console.views.device-add.messages.abp": "Xxxxxxxxxx Xx Xxxxxxxxxxxxxxx (XXX)", | ||
"console.views.device-add.messages.resetWarning": "Xxxxxxxx xx xxxxxxxx xxx xxxxx xxxx xxxxxx xxxxxxxxxxx xxx xxxxxx xxxxxxx", | ||
"console.views.device-add.messages.couldNotRetrieveFrequencyPlans": "Xxxxx xxx xxxxxxxx xxx xxxx xx xxxxxxxxx xxxxxxxxx xxxxx", | ||
"console.views.device-general-settings.index.updateSuccess": "Xxxxxxxxxxxx xxxxxxx xxx xxxxxx", | ||
"console.views.device-overview.index.hardware": "Xxxxxxxx", | ||
"console.views.device-overview.index.brand": "Xxxxx", | ||
"console.views.device-overview.index.model": "Xxxxx", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please move these to shared-messages.js
. The gateway model has them as well, see https://github.com/TheThingsNetwork/lorawan-stack/blob/master/api/gateway.proto#L48-L53
async handleSubmit (values, { setSubmitting, resetForm }) { | ||
const { device } = this.props | ||
const { application_id } = device.ids.application_ids | ||
const updatedDevice = Object.assign({}, values) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const updatedDevice = Object.assign({}, values) | |
const updatedDevice = {...values} |
|
||
async handleSubmit (values, { setSubmitting, resetForm }) { | ||
const { device } = this.props | ||
const { application_id } = device.ids.application_ids |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can selector here, see https://github.com/TheThingsNetwork/lorawan-stack/blob/master/pkg/webui/lib/selectors/id.js#L17-L20
updatedDevice.ids.dev_addr = updatedDevice.session.dev_addr | ||
} | ||
} | ||
delete updatedDevice.activation_mode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const { activation_mode, ...updatedDevice } = values
and you can remove this + simplifies check on L51
export default class DeviceGeneralSettings extends React.Component { | ||
|
||
state = { | ||
error: undefined, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error: undefined, | |
error: '', |
max={16} | ||
placeholder={m.leaveBlankPlaceholder} | ||
description={m.nwkKeyDescription} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
} | ||
|
||
DeviceDataForm.propTypes = { | ||
onSubmit: PropTypes.func, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not required?
|
||
DeviceDataForm.propTypes = { | ||
onSubmit: PropTypes.func, | ||
error: PropTypes.error, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add default value
DeviceDataForm.propTypes = { | ||
onSubmit: PropTypes.func, | ||
error: PropTypes.error, | ||
update: PropTypes.bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add default value
@@ -101,6 +101,7 @@ export default { | |||
list: ttnClient.Applications.Devices.getAll.bind(ttnClient.Applications.Devices), | |||
get: ttnClient.Applications.Devices.getById.bind(ttnClient.Applications.Devices), | |||
create: ttnClient.Applications.Devices.create.bind(ttnClient.Applications.Devices), | |||
update: ttnClient.Applications.Devices.updateById.bind(ttnClient.Applications.Devices), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please see how the applications
and application
definitions are structured. lets be consistent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please check the <Tabs />
storybook, changing tabs doesnot work anymore
@@ -16,7 +16,7 @@ import getByPath from '../get-by-path' | |||
|
|||
export const getApplicationId = function (application = {}) { | |||
return getByPath(application, 'application_id') | |||
|| getByPath(application, 'application_ids.application_id') | |||
|| getByPath(application, 'ids.application_id') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this breaks the events component.
my suggestion would be to add an additional case:
|| getByPath(application, 'ids.application_id') | |
|| (getByPath(application, 'application_ids.application_id') | |
|| (getByPath(application, ''ids.application_id')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This also causes the issue we discussed in slack:
checkPropTypes.js:19 Warning: Failed prop type: The prop `emitter` is marked as required in `Event`, but its value is `undefined`.
in Event (created by DefaultEvent)
in DefaultEvent (created by List)
in li (created by ListItem)
in ListItem (created by List)
in ol (created by List)
in div (created by List)
in List (created by EventsWidget)
in aside (created by EventsWidget)
in EventsWidget (created by EventsSubscription)
in EventsSubscription (created by Connect(EventsSubscription))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh indeed. Was looking whether it was used elsewhere, but couldn't find it. Will add a case then.
const changed = diff(device, updatedDevice) | ||
await api.device.update(appId, device_id, changed) | ||
|
||
resetForm({ ...values }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resetForm({ ...values }) | |
resetForm(values) |
should work as well
db7b48f
to
dddc699
Compare
1d7013e
to
474ea80
Compare
Summary
Closes #584
Changes
<Tab />
's as nav elementsNotes for Reviewers
I have added the link prop to the
<Tabs />
which will render the tab element as<NavLink />
, as such also handling active state by itself. I decided to not make it a dedicated component, as the functionality could quite easily be added and it saves us some redundancy. Hope that's ok with you.Release Notes
cc @htdvisser