@ferosekhan :
You can add a new field in your dialog as runmode and you can input as publish.
Then in your sightly you an call as ,
<sly data-sly-use.runMode= "com.sourcedcode.core.models.utils.RunModeHelper ;">
<div data-sly-test="${runMode.getHasRunMode}">
// you can write your component logic here.
</div>
package com.sourcedcode.core.models.utils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.Default;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.RequestAttribute;
import org.apache.sling.settings.SlingSettingsService;
import javax.annotation.PostConstruct;
@Model(adaptables = SlingHttpServletRequest.class)
public class RunModeHelper {
@OSGiService
private SlingSettingsService slingSettingsService;
@RequestAttribute
@Default(values = "null")
private String runmode;
private boolean hasRunMode = false;
@PostConstruct
public void init() {
String runModes = slingSettingsService.getRunModes().toString();
hasRunMode = runModes.contains(runmode);
}
public boolean getHasRunMode() {
return hasRunMode;
}
}
source : https://sourcedcode.com/blog/aem/checking-run-mode-from-sightly-htl-in-aem
Thanks,
Siva