public void registerActions()

in Utils/azure-toolkit-ide-libs/azure-toolkit-ide-appservice-lib/src/main/java/com/microsoft/azure/toolkit/ide/appservice/AppServiceActionsContributor.java [48:149]


    public void registerActions(AzureActionManager am) {
        new Action<>(OPEN_IN_BROWSER)
            .withLabel("Open In Browser")
            .withIcon(AzureIcons.Action.PORTAL.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof AppServiceAppBase)
            .enableWhen(s -> s.getFormalStatus().isConnected())
            .withHandler((s, e) -> am.getAction(ResourceCommonActionsContributor.OPEN_URL).handle("https://" + s.getHostName(), e))
            .register(am);

        new Action<>(START_STREAM_LOG)
            .withLabel("Start Streaming Logs")
            .withIcon(AzureIcons.Action.LOG.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> false)
            .enableWhen(s -> s.getFormalStatus().isRunning())
            .register(am);

        new Action<>(STOP_STREAM_LOG)
            .withLabel("Stop Streaming Logs")
            .withIcon(AzureIcons.Action.LOG.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> false)
            .enableWhen(s -> s.getFormalStatus().isRunning())
            .register(am);

        new Action<>(PROFILE_FLIGHT_RECORD)
            .withLabel("Profile Flight Recorder")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> false)
            .enableWhen(s -> s.getFormalStatus().isRunning())
            .register(am);

        new Action<>(SSH_INTO_WEBAPP)
            .withLabel("SSH into Web App")
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> false)
            .enableWhen(s -> s.getFormalStatus().isRunning())
            .register(am);

        new Action<>(REFRESH_DEPLOYMENT_SLOTS)
            .withLabel("Refresh")
            .withIcon(AzureIcons.Action.REFRESH.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> s instanceof AppServiceAppBase)
            .withHandler(app -> AzureEventBus.emit("appservice.slot.refresh", app))
            .withShortcut(am.getIDEDefaultShortcuts().refresh())
            .register(am);

        new Action<>(OPEN_LOGS_IN_MONITOR)
            .withLabel("Open Logs with Azure Monitor")
            .withIcon(AzureIcons.Common.AZURE_MONITOR.getIconPath())
            .withIdParam(AzResource::getName)
            .visibleWhen(s -> false)
            .enableWhen(s -> s.getFormalStatus().isRunning() || (s instanceof FunctionApp function && StringUtils.isNotBlank(function.getEnvironmentId())))
            .register(am);

        new Action<>(COPY_FULL_APP_SETTINGS)
            .withLabel("Copy All")
            .withIdParam(AppServiceAppBase::getName)
            .withIcon(AzureIcons.Action.COPY.getIconPath())
            .withHandler((app, e) -> {
                final Map<String, String> variables = Optional.ofNullable(app.getAppSettings()).orElse(Collections.emptyMap());
                final String str = variables.entrySet().stream().map(v -> String.format("%s=%s", v.getKey(), v.getValue())).collect(Collectors.joining(System.lineSeparator()));
                AzureActionManager.getInstance().getAction(ResourceCommonActionsContributor.COPY_STRING).handle(str, e);
                AzureMessager.getMessager().success(AzureString.format("App settings of app (%s) has been copied into clipboard.", app.getName()));
            })
            .withAuthRequired(false)
            .register(am);

        new Action<>(UPDATE_IMAGE)
                .withLabel("Update Image")
                .withIdParam(AbstractAzResource::getName)
                .withIcon(AzureIcons.Action.UPLOAD.getIconPath())
                .withAuthRequired(true)
                .visibleWhen(s -> s instanceof AppServiceAppBase<?,?,?> app && !app.getFormalStatus().isReading() &&
                        Optional.ofNullable(app.getRuntime()).map(Runtime::isDocker).orElse(false))
                .enableWhen(s -> s.getFormalStatus().isConnected())
                .register(am);

        new Action<>(COPY_APP_SETTING)
                .withLabel("Copy")
                .withIcon(AzureIcons.Action.COPY.getIconPath())
                .withHandler((entry, e) -> {
                    final String str = String.format("%s=%s", entry.getKey(), entry.getValue());
                    AzureActionManager.getInstance().getAction(ResourceCommonActionsContributor.COPY_STRING).handle(str, e);
                    AzureMessager.getMessager().success(AzureString.format("App setting (%s) has been copied into clipboard.", entry.getKey()));
                })
                .withAuthRequired(false)
                .register(am);

        new Action<>(COPY_APP_SETTING_KEY)
                .withLabel("Copy Key")
                .withIdParam(Map.Entry::getKey)
                .withIcon(AzureIcons.Action.COPY.getIconPath())
                .withHandler((entry, e) -> {
                    AzureActionManager.getInstance().getAction(ResourceCommonActionsContributor.COPY_STRING).handle(entry.getKey(), e);
                    AzureMessager.getMessager().success(AzureString.format("App setting key (%s) been copied into clipboard.", entry.getKey()));
                })
                .withAuthRequired(false)
                .register(am);
    }