-
Notifications
You must be signed in to change notification settings - Fork 0
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
CMDCT-4185: adding edit button to dashboard table rows so that user can edit report name #81
Conversation
…an edit report name
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.
I accidentally tapped the edit button thinking that's how I'd edit the title 😆
It works per the story's acceptance criteria but I'd heavily debate that design. So interesting to have an edit icon to the left and an edit button to the right. Maybe something more explicit Edit name vs Edit report. But I'm just rambling.
Yeah I actually agree with this, it is not great UX to have two edit buttons in the same row. I will bring this up with Megan after we get the logic in. I think there's a way to improve it but I'd like to leave it up to her. |
// pop off the edit button heading if the user is read only | ||
if (readOnlyUser) { | ||
tableContent.headRow.shift(); | ||
} |
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.
Incoming waffle alert.
On the one hand, I don't like throwing away functions' return values. So I'd prefer slice(1)
to shift()
here.
But then we have to turn this into an assignment instead: tc.hr = tc.hr.slice(1)
, which starts to feel awkward. Especially because we just declared the thing a second ago.
But maybe that's just revealing the underlying awkwardness of the whole situation, that we're creating something we might need to modify. So maybe we want to wrap the whole thing in a larger construct? Maybe along these lines???
const tableContent = {
caption: "QMR",
headRow: getHeadRow(readOnlyUser),
};
...
/** Return the dashboard table column headers, which differ for admin users */
const getHeadRow = (readOnlyUser: bool) => readOnlyUser
? ["Submission name", "Last edited", "Edited by", "Status", ""]
: ["", "Submission name", "Last edited", "Edited by", "Status", ""];
But that's an awful lot of redundancy to include/exclude a single empty string. And maybe it'll be worth it someday, when the column headers change more? For example, maybe admins get an extra column for locking/archiving - that's what's happened in our other apps.
But then again maybe not. And surely we can trust our successors to be able to introduce such constructs as they become necessary, rather than us preemptively introducing them in the hopes that they'll be (understood and) used (well) later.
And now both you and I have spent more time writing/reading about these 3 lines of code than anyone is ever likely to in the future. So, do what you want, and I'll approve it.
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.
I like this way better than my hard to read implementation! I went ahead with your solution you provided. Thanks Ben!
d59dca7
Code Climate has analyzed commit e9c205e and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 29.4% (90% is the threshold). This pull request will bring the total coverage in the repository to 93.6% (-0.4% change). View more on Code Climate. |
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.
Great re-factor
Description
Pretty simple PR to allow users to edit report name from the dashboard table. I went pretty simple here since there is just one field. I did not use any useForm magic so let me know if that is more appropriate here.
Related ticket(s)
CMDCT-4185
How to test
https://d2nvrsyhsh8gv1.cloudfront.net/
Test as state user:
Test as read only user: