- 
                Notifications
    
You must be signed in to change notification settings  - Fork 172
 
Configure share link expiration date required (frontend part) #3187
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
base: master
Are you sure you want to change the base?
Configure share link expiration date required (frontend part) #3187
Conversation
| 
           sorry for my non-conventional commit message. I will think about it next time!  | 
    
4621e0e    to
    096adaa      
    Compare
  
    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.
the logic looks good to me, i just have a few minor suggestions about consistency and intentionality 🙂
| value='{{ permissions | tojson }}'> | ||
| {%- endif %} | ||
| 
               | 
          ||
| <span id="deposit-share-btn-require-link-expiration" | 
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.
| <span id="deposit-share-btn-require-link-expiration" | |
| <input type="hidden" id="deposits-share-btn-require-link-expiration" | 
i'd keep the indentation consistent with other elements – in my experience, inconsistent indenting makes HTML very hard to read very quickly.
the change from <span> to <input> + ID change (deposit- -> deposits-) is also mostly for consistency with the other config data elements on the deposit form.
| 
               | 
          ||
| 
               | 
          ||
| {%- block page_body %} | ||
| <span id="detail-share-btn-require-link-expiration" | 
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.
| <span id="detail-share-btn-require-link-expiration" | |
| <span id="detail-share-btn-require-link-expiration" | 
note: in contrast to the deposit form, i couldn't quickly identify a trend on the landing page regarding type and ID of config elements
| } | ||
| checkIfIsAccessLinksExpirationRequired = () => { | ||
| return ( | ||
| document.getElementById("deposit-share-btn-require-link-expiration")?.dataset | 
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.
| document.getElementById("deposit-share-btn-require-link-expiration")?.dataset | |
| document.getElementById("deposits-share-btn-require-link-expiration")?.dataset | 
| render() { | ||
| const { results, record, onItemAddedOrDeleted, onPermissionChanged } = this.props; | ||
| const { loading, error } = this.state; | ||
| const isLinkExpirationDateError = this.checkIfLinkExpirationError(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.
| const isLinkExpirationDateError = this.checkIfLinkExpirationError(error); | |
| const hasLinkExpirationDateError = this.checkIfLinkExpirationError(error); | 
| 
               | 
          ||
| <Table color="green"> | ||
| <CreateAccessLink | ||
| hasError={isLinkExpirationDateError} | 
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.
| hasError={isLinkExpirationDateError} | |
| hasError={hasLinkExpirationDateError} | 
| }; | ||
| 
               | 
          ||
| CreateAccessLink.defaultProps = { | ||
| hasError: false, | 
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 feel there's a slight discrepancy between the naming and actual use of the property here:
the naming suggests the presence/absence of any generic error, but the use is limited only to the expiration date
i'd prefer an alternative, like the following suggestions:
- rename the variable to something more narrow like 
hasExpirationDateError, or - change the nature of the variable, e.g. into a list named 
errorsthat contains the names of all fields with validation errors... or a dictionary of the shape{fieldName: errorMessage, ...} 
the second option is a bit more flexible but probably overkill, the first one is simpler but a bit more limited.
note that these two are just the first ideas that came to my mind, i'm fine with other alternatives as long as they make the intentionality a bit clearer!
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.
the logic looks good to me, i just have a few minor suggestions about consistency and intentionality 🙂
096adaa    to
    ab0e4dc      
    Compare
  
    | 
           I just remembered that there is another spot that needs to know about required expiration dates for secret links:  | 
    
ab0e4dc    to
    4ab69ec      
    Compare
  
    4ab69ec    to
    2186821      
    Compare
  
    | 
           So, to get the config variable to the   | 
    
264c363    to
    bb007ea      
    Compare
  
    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.
thanks a lot for the update, and sorry for the long wait!
from my perspective, just one more comment about an else if – other than that, I'm setting up a new my-site to quickly sanity check, and will get back after
        
          
                ...semantic-ui/js/invenio_app_rdm/landing_page/ShareOptions/AccessRequests/AccessRequestsTab.js
              
                Outdated
          
            Show resolved
            Hide resolved
        
      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.
LGTM, thanks for all the work!
| } | ||
| else if (settings["secret_link_expiration"] === 0 && isAccessLinksExpirationRequired) { | 
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.
| } | |
| else if (settings["secret_link_expiration"] === 0 && isAccessLinksExpirationRequired) { | |
| } else if (settings["secret_link_expiration"] === 0 && isAccessLinksExpirationRequired) { | 
looks like the linter wants it to be on the same line
2baad3e    to
    cabae40      
    Compare
  
    * the new configuration variable RDM_RECORDS_REQUIRE_SECRET_LINKS_EXPIRATION adds the option to make the expiration date required * added error messages improve the user experience.
cabae40    to
    df90a74      
    Compare
  
    
❤️ Thank you for your contribution!
Description
This is the frontend part of this PR.
It changes the help text depending on the configuration and adds error styles if the expiration date is required.
This PR has to be merged AFTER inveniosoftware/invenio-rdm-records#2169
Checklist
Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:
Frontend
Reminder
By using GitHub, you have already agreed to the GitHub’s Terms of Service including that: