Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}
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) {
status = latestRun.result === 'UNKNOWN' ? latestRun.state : latestRun.result;
startTime = latestRun.startTime;
estimatedDuration = latestRun.estimatedDurationInMillis;
constructor(fetch) {
this._fetch = fetch || Fetch.fetchJSON;
this.organization = AppConfig.getOrganizationName();
}
render() {
const pipeline = this.context.pipelineService.getPipeline(this.href);
const { setTitle } = this.props;
const { location = {} } = this.context;
const { organization, name, fullName, fullDisplayName } = pipeline || {};
const organizationName = organization || AppConfig.getOrganizationName();
const organizationDisplayName = organization === AppConfig.getOrganizationName() ? AppConfig.getOrganizationDisplayName() : organization;
const orgUrl = UrlBuilder.buildOrganizationUrl(organizationName);
const activityUrl = UrlBuilder.buildPipelineUrl(organizationName, fullName, 'activity');
const isReady = !!pipeline;
if (!pipeline && this.error) {
logger.log(`Error finding pipeline page for ${fullName}.`, this.error);
return ;
}
if (isReady) {
setTitle(`${organizationDisplayName} / ${name}`);
} else {
setTitle(translate('common.pager.loading', { defaultValue: 'Loading...' }));
}
render() {
const { organization } = this.context.params;
const { actionExtensionCount } = this.state;
const organizationName = organization || AppConfig.getOrganizationName();
const organizationDisplayName = organization === AppConfig.getOrganizationName() ? AppConfig.getOrganizationDisplayName() : organization;
const searchText = this.getSearchText();
this.pager = this.context.pipelineService.pipelinesPager(organizationName, searchText);
const pipelines = this.pager.data;
const orgLink = organizationName ? {organizationDisplayName} : '';
const showPipelineList = pipelines && pipelines.length > 0;
const showEmptyState = !this.pager.pending && !this.getSearchText() && (!pipelines || !pipelines.length);
const labelName = translate('home.pipelineslist.header.name', { defaultValue: 'Name' });
const labelHealth = translate('home.pipelineslist.header.health', { defaultValue: 'Health' });
const labelBranches = translate('home.pipelineslist.header.branches', { defaultValue: 'Branches' });
const labelPullReqs = translate('home.pipelineslist.header.pullrequests', { defaultValue: 'PR' });
constructor(fetch) {
this._fetch = fetch || Fetch.fetchJSON;
this.organization = AppConfig.getOrganizationName();
}
_navigateToPipelineEditor() {
const url = `/organizations/${AppConfig.getOrganizationName()}/pipeline-editor/${encodeURIComponent(this.pipelineName)}/`;
this.completeFlow({ url });
}
}
get favorites() {
if (!this._fetched) {
const user = User.current();
this._fetched = true;
if (user && !user.isAnonymous()) {
const baseUrl = UrlConfig.getBlueOceanAppURL();
const username = user.id;
const organization = AppConfig.getOrganizationName();
const url = cleanSlashes(`${baseUrl}/rest/organizations/${organization}/users/${username}/favorites/?start=0&limit=26`);
this.fetch(url).then(favorites => this._setFavorites(sortHelper.applyStandardSort(favorites)));
}
}
return this._favorites;
}
return (dispatch) => {
const baseUrl = UrlConfig.getBlueOceanAppURL();
const username = user.id;
const organization = AppConfig.getOrganizationName();
const url = cleanSlashes(`${baseUrl}/rest/organizations/${organization}/users/${username}/favorites/`);
if (fetchFlags[ACTION_TYPES.SET_FAVORITES]) {
return null;
}
fetchFlags[ACTION_TYPES.SET_FAVORITES] = true;
return dispatch(actions.generateData(
{ url },
ACTION_TYPES.SET_FAVORITES
));
};
},