Unable to update node_modules in kibana(version 7.15.1) source code

I made some changes in the date picker provided by Elasticsearch EUI library inside kibana node_modules folder. Specifically to these path :-

  1. node_modules@elastic\eui\es\components\date_picker\super_date_picker\relativeOptions.js
  2. node_modules@elastic\eui\es\components\date_picker\super_date_picker\super_date_picker.js

But when I run it locally using the command "bin\Elasticsearch.bat", the changes are not reflected in the kibana GUI. Not able to find any useful resource, please help.

Hi @mridul.chandel

welcome to the Kibana community.

If you've found any bug or issue in the date picker I'd recommend to fill an issue on the EUI github repository.

As for the specific question, in the hypothesis you are testing a fix for kibana, the right folder to apply the fix is the lib folder rather than the es. Note that you'll lose everything in there on the first reinstall, so perhaps an fix/enhancement request issue on the EUI repo would be best.

Thanks @Marco_Liberati for the reply.

I tried making changes to the lib folder but in vain.

Let me explain my problem further and the steps I follow to make changes.

I downloaded the production build of Elasticsearch and Kibana (version 7.15.1), running them locally using the commands bin\Elasticsearch.bat and bin\kibana.bat respectively.

I want to make some customization to the Kibana date time filter(EUI Super Date Picker) according to the need of my company. The specific changes I made : -

  1. node_modules@elastic\eui\lib\components\date_picker\super_date_picker\relativeOptions.js
var relativeOptions = [{
  text: 'Seconds ago',
  value: 's'
}, {
  text: 'Minutes ago',
  value: 'm'
}, {
  text: 'Hours ago',
  value: 'h'
}, {
  text: 'Days ago',
  value: 'd'
}, {
  text: 'Weeks ago',
  value: 'w'
}, {
  text: 'Months ago',
  value: 'M'
},
// Commented this code
// {
//   text: 'Years ago',
//   value: 'y'
// },
{
  text: 'Seconds from now',
  value: 's+'
}, {
  text: 'Minutes from now',
  value: 'm+'
}, {
  text: 'Hours from now',
  value: 'h+'
}, {
  text: 'Days from now',
  value: 'd+'
}, {
  text: 'Weeks from now',
  value: 'w+'
}, {
  text: 'Months from now',
  value: 'M+'
},
// Commented this code
// {
//   text: 'Years from now',
//   value: 'y+'
// }
];
  1. node_modules@elastic\eui\lib\components\date_picker\super_date_picker\super_date_picker.js
function isRangeInvalid(start, end) {
  if (start === 'now' && end === 'now') {
    return true;
  }

  var startMoment = _datemath.default.parse(start);

  var endMoment = _datemath.default.parse(end, {
    roundUp: true
  });

  if (!startMoment || !endMoment || !startMoment.isValid() || !endMoment.isValid()) {
    return true;
  }
  
  if (startMoment.isAfter(endMoment)) {
    return true;
  }
  
  // Added this code
  if(endMoment.diff(startMoment, "days") > 365) {
    return true
  }

  return false;
}

After making these changes, I re-run Elasticsearch and Kibana but changes are not reflected in the Kibana GUI. I don't know whether I'm making some mistakes or missing some steps. Please help me out on this. Thanks in advance.

If you want to limit time range for kibana users, another option without changing the code could be to use a filtered alias .

@Marco_Liberati, the code changes that I had given in my previous comment are some of the many changes that I need to make in the node modules. Can you please suggest how can I make changes in the node modules and reflect them in the kibana GUI.

How did you install kibana?

@Marco_Liberati As told in one of my previous comment, I had downloaded the production build of Elasticsearch and Kibana and running them using bin\Elasticsearch.bat and bin\kibana.bat respectively. After making changes in the node_modules of kibana, I again run bin\kibana.bat but changes are not reflected.

If you didn't install it from source then all changes will be ignored I suspect.
Best approach here would be to make some enhancement requests on kibana for the requested changes, rather than change dependencies code locally.

@Marco_Liberati Can you please elaborate "installation from source". In my case I downloaded the zip of Elasticsearch and kibana from the official page and run it according to the instructions specified such as bin\Elasticsearch.bat and bin\kibana.bat.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.