metacatui icon indicating copy to clipboard operation
metacatui copied to clipboard

Move repeated method to Utilities module

Open robyngit opened this issue 1 year ago • 0 comments

The bytesToSize method is repeated in multiple files. This method should be moved to the Utilities module so that it can be used in multiple places without repeating the code, making it easier to maintain and update.

This will also help reduce the size of some of our larger files and make it easier to continue implementation of the file hierarchy table.

  • [x] Add bytesToSize function to src/js/common/Utilities.js
    • constants like kibibyte = 1024 should be defined as const at the top of the file, after the define statement and before const Utilities = {}. See for example, see how we're starting to define CLASS_NAMES in views.
  • [x] Import the Utilities module in the files where the function is used, and use it instead of repeating the function in each file.
    • src/js/models/DataONEObject.js
    • src/js/models/PackageModel.js
    • src/js/models/SolrResult.js
    • src/js/views/StatsView.js

robyngit avatar Jul 18 '24 15:07 robyngit