We will be sunsetting Advisor during Jan, 2026 and will instead be providing information in Snyk Security DB.

You can begin to take advantage of Snyk Security DB today for a unified, package-centric experience.

How to use the @jenkins-cd/blueocean-core-js.capable function in @jenkins-cd/blueocean-core-js

To help you get started, we’ve selected a few @jenkins-cd/blueocean-core-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jenkinsci / blueocean-plugin / blueocean-personalization / src / main / js / components / PipelineCard.jsx View on Github external
render() {
        if (!this.props.runnable) {
            return null;
        }

        const { t, locale, runnable } = this.props;

        // Required props
        if (!t) {
            PipelineCard.logger.error('PipelineCard requires translate function as "t" prop.');
            return null;
        }

        const latestRun = runnable.latestRun;

        const isBranch = capable(runnable, BRANCH_CAPABILITY);
        const names = extractNames(runnable, isBranch);
        const organizationName = runnable.organization;
        const organizationDisplayName = organizationName === AppConfig.getOrganizationName() ? AppConfig.getOrganizationDisplayName() : organizationName;
        const fullDisplayName = isBranch
            ? runnable.fullDisplayName
                  .split('/')
                  .slice(0, -1)
                  .join('/')
            : runnable.fullDisplayName;

        let status;
        let startTime = null;
        let estimatedDuration = null;
        let commitId = null;

        if (latestRun) {
github jenkinsci / blueocean-plugin / blueocean-dashboard / src / main / js / components / Activity.jsx View on Github external
render() {
        const { pipeline, t, locale } = this.props;
        const { actionExtensionCount } = this.state;
        const actionsInRowCount = ActivityDetailsRow.actionItemsCount; // Non-extension actions

        if (!pipeline) {
            return null;
        }

        const runs = this.pager.data;
        const isLoading = this.pager.pending;
        const branch = this._branchFromProps(this.props);

        const isMultiBranchPipeline = capable(pipeline, MULTIBRANCH_PIPELINE);
        const hasBranches = pipeline.branchNames && !!pipeline.branchNames.length;

        const disableablePipeline = pipeline.disabled !== undefined && pipeline.disabled !== null ? true : false;

        const onNavigation = url => {
            this.context.location.pathname = url;
            this.context.router.push(this.context.location);
        };

        const onChangeDisableState = newDisableState => {
            this.setState({ pipelineDisabled: newDisableState });
        };

        const latestRun = runs && runs[0];

        // Only show the Run button for non multi-branch pipelines.
github jenkinsci / blueocean-plugin / blueocean-dashboard / src / main / js / components / PipelineTrends.jsx View on Github external
render() {
        const { pipeline } = this.props;
        const trends = this.trends.slice();

        let branchFilter = null;

        if (capable(pipeline, MULTIBRANCH_PIPELINE)) {
            const branchName = decodeURIComponent(this._selectedBranch(this.props, pipeline));

            branchFilter =  decodeURIComponent(b))} />;
        }

        return (
            <div>
                <div>{branchFilter}</div>

                <div>
                    {trends.map(trend =&gt; {
                        const CustomComponent = this.extensions[trend.id];
                        const rows = this.rowsMap[trend.id];

                        if (!rows || !rows.length) {
                            // forces a full re-render of the chart when branch is changed, for animations</div></div>
github jenkinsci / blueocean-plugin / blueocean-dashboard / src / main / js / components / MultiBranch.jsx View on Github external
render() {
        const { t, locale, pipeline } = this.props;
        const { actionExtensionCount } = this.state;
        const actionsInRowCount = BranchDetailsRow.actionItemsCount; // Non-extension actions

        if (!capable(pipeline, MULTIBRANCH_PIPELINE)) {
            const childProps = {
                title: t('pipelinedetail.placeholder.unsupported.branches.title'),
                message: t('pipelinedetail.placeholder.unsupported.branches.message'),
                linkText: t('pipelinedetail.placeholder.unsupported.branches.linktext'),
                linkHref: t('pipelinedetail.placeholder.unsupported.branches.linkhref'),
            };

            return ;
        }

        const branches = this.pager.data;

        if (!this.pager.pending &amp;&amp; !branches.length) {
            return ;
        }
github jenkinsci / blueocean-plugin / blueocean-dashboard / src / main / js / components / RunDetails.jsx View on Github external
_fetchRun(props) {
        this.isMultiBranch = capable(props.pipeline, MULTIBRANCH_PIPELINE);

        if (this.context.config && this.context.params) {
            this.href = RestPaths.run({
                organization: props.params.organization,
                pipeline: props.params.pipeline,
                branch: this.isMultiBranch && props.params.branch,
                runId: props.params.runId,
            });

            this.context.activityService.fetchActivity(this.href, { useCache: true }).then(run => {
                const testSummaryUrl = getTestSummaryUrl(run);
                return testSummaryUrl && this.context.activityService.fetchTestSummary(testSummaryUrl);
            });
        }
    }
github jenkinsci / blueocean-plugin / blueocean-dashboard / src / main / js / creation / github / api / GithubCreationApi.js View on Github external
_findExistingOrgFolderSuccess(orgFolder) {
        const isOrgFolder = capable(orgFolder, 'jenkins.branch.OrganizationFolder');

        return {
            isFound: true,
            isOrgFolder,
            orgFolder,
        };
    }
github jenkinsci / blueocean-plugin / blueocean-dashboard / src / main / js / components / MultiBranch.jsx View on Github external
componentWillMount() {
        if (this.props.pipeline && this.context.params && capable(this.props.pipeline, MULTIBRANCH_PIPELINE)) {
            const { organization, pipeline } = this.context.params;
            this.pager = this.context.pipelineService.branchPager(organization, pipeline);
        }
        this._countExtensions();
    }