  We use the IllustrisTNG50 cosmological hydrodynamical simulation,
complemented by a catalog of tagged globular clusters, to investigate the
properties and build up of two extended luminous components: the intra-cluster
light (ICL) and the intra-cluster globular clusters (ICGC). We select the 39
most massive groups and clusters in the box, spanning the range of virial
masses $5 \times 10^{12} < \rm M_{200}/\rm M_{\odot} < 2 \times 10^{14}$. We
find good agreement between predictions from the simulations and current
observational estimates of the fraction of mass in the ICL and its radial
extension. The stellar mass of the ICL is only $\sim10\%-20\%$ of the stellar
mass in the central galaxy but encodes useful information on the assembly
history of the group or cluster. About half the ICL in all our systems is
brought in by galaxies in a narrow stellar mass range, $M_*=10^{10}-10^{11}$
$\rm M_{\odot}$. However, the contribution of low-mass galaxies ($M_*<10^{10}$
$\rm M_{\odot}$) to the build-up of the ICL varies broadly from system to
system, $\sim 5\%-45\%$, a feature that might be recovered from the observable
properties of the ICL at $z=0$. At fixed virial mass, systems where the
accretion of dwarf galaxies plays an important role have shallower metallicity
profiles, less metal content and a lower stellar mass in the ICL than systems
where the main contributors are more massive galaxies. We show that
intra-cluster GCs are also good tracers of this history, representing a
valuable alternative when diffuse light is not detectable.
