This part is the same as in feature tree component. Maybe we can push that into the preview service directly. Should I attempt a PR for this?