Example #1
0
const textBuilder = results => {
  const { failed, resolved, total } = results;

  const failedString = failed
    ? n__('%d failed test result', '%d failed test results', failed)
    : null;
  const resolvedString = resolved
    ? n__('%d fixed test result', '%d fixed test results', resolved)
    : null;
  const totalString = total ? n__('out of %d total test', 'out of %d total tests', total) : null;

  let resultsString = s__('Reports|no changed test results');

  if (failed) {
    if (resolved) {
      resultsString = sprintf(s__('Reports|%{failedString} and %{resolvedString}'), {
        failedString,
        resolvedString,
      });
    } else {
      resultsString = failedString;
    }
  } else if (resolved) {
    resultsString = resolvedString;
  }

  return `${resultsString} ${totalString}`;
};
Example #2
0
/**
 * Safari > 10 doesn't support `execCommand`, so instead we inform the user to copy manually.
 * See http://clipboardjs.com/#browser-support
 */
function genericError(e) {
  let key;
  if (/Mac/i.test(navigator.userAgent)) {
    key = '⌘'; // Command
  } else {
    key = 'Ctrl';
  }
  showTooltip(e.trigger, sprintf(__(`Press %{key}-C to copy`), { key }));
}
Example #3
0
 error: function(file, errorMessage) {
   const stripped = $('<div/>')
     .html(errorMessage)
     .text();
   $('.dropzone-alerts')
     .html(sprintf(__('Error uploading file: %{stripped}'), { stripped }))
     .show();
   this.removeFile(file);
 },
 ContributorsStatGraph.prototype.change_date_header = function() {
   const { x_domain } = ContributorsGraph.prototype;
   const formattedDateRange = sprintf(
     s__('ContributorsPage|%{startDate} – %{endDate}'),
     {
       startDate: this.dateFormat.format(new Date(x_domain[0])),
       endDate: this.dateFormat.format(new Date(x_domain[1])),
     },
   );
   return $('#date_header').text(formattedDateRange);
 };
Example #5
0
export const invalidProjectLabel = state => {
  if (state.selectedProject) {
    return sprintf(
      __('Project "%{name}" is no longer available. Select another project to continue.'),
      {
        name: state.selectedProject.name,
      },
    );
  }
  return '';
};
Example #6
0
 errorCallback: response => {
   let errorMessage = '';
   if (response && response.data && response.data.message) {
     errorMessage = response.data.message;
   }
   commit(types.SET_LOADING, false);
   createFlash(
     sprintf(__(`Failed to load errors from Sentry. Error message: %{errorMessage}`), {
       errorMessage,
     }),
   );
 },
Example #7
0
export const setLastCommitMessage = ({ rootState, commit }, data) => {
  const currentProject = rootState.projects[rootState.currentProjectId];
  const commitStats = data.stats
    ? sprintf(__('with %{additions} additions, %{deletions} deletions.'), {
        additions: data.stats.additions, // eslint-disable-line indent
        deletions: data.stats.deletions, // eslint-disable-line indent
      }) // eslint-disable-line indent
    : '';
  const commitMsg = sprintf(
    __('Your changes have been committed. Commit %{commitId} %{commitStats}'),
    {
      commitId: `<a href="${currentProject.web_url}/commit/${data.short_id}" class="commit-sha">${
        data.short_id
      }</a>`,
      commitStats,
    },
    false,
  );

  commit(rootTypes.SET_LAST_COMMIT_MSG, commitMsg, { root: true });
};
Example #8
0
export const setLastCommitMessage = ({ commit, rootGetters }, data) => {
  const { currentProject } = rootGetters;
  const commitStats = data.stats
    ? sprintf(__('with %{additions} additions, %{deletions} deletions.'), {
        additions: data.stats.additions,
        deletions: data.stats.deletions,
      })
    : '';
  const commitMsg = sprintf(
    __('Your changes have been committed. Commit %{commitId} %{commitStats}'),
    {
      commitId: `<a href="${currentProject.web_url}/commit/${data.short_id}" class="commit-sha">${
        data.short_id
      }</a>`,
      commitStats,
    },
    false,
  );

  commit(rootTypes.SET_LAST_COMMIT_MSG, commitMsg, { root: true });
};
Example #9
0
  populateActiveMetrics(metrics) {
    let totalMonitoredMetrics = 0;
    let totalMissingEnvVarMetrics = 0;
    let totalExporters = 0;

    metrics.forEach((metric) => {
      if (metric.active_metrics > 0) {
        totalExporters += 1;
        this.$monitoredMetricsList.append(`<li>${_.escape(metric.group)}<span class="badge">${_.escape(metric.active_metrics)}</span></li>`);
        totalMonitoredMetrics += metric.active_metrics;
        if (metric.metrics_missing_requirements > 0) {
          this.$missingEnvVarMetricsList.append(`<li>${_.escape(metric.group)}</li>`);
          totalMissingEnvVarMetrics += 1;
        }
      }
    });

    if (totalMonitoredMetrics === 0) {
      const emptyCommonMetricsText = sprintf(s__('PrometheusService|<p class="text-tertiary">No <a href="%{docsUrl}">common metrics</a> were found</p>'), {
        docsUrl: this.helpMetricsPath,
      }, false);
      this.$monitoredMetricsEmpty.empty();
      this.$monitoredMetricsEmpty.append(emptyCommonMetricsText);
      this.showMonitoringMetricsPanelState(PANEL_STATE.EMPTY);
    } else {
      const metricsCountText = sprintf(s__('PrometheusService|%{exporters} with %{metrics} were found'), {
        exporters: n__('%d exporter', '%d exporters', totalExporters),
        metrics: n__('%d metric', '%d metrics', totalMonitoredMetrics),
      });
      this.$monitoredMetricsCount.text(metricsCountText);
      this.showMonitoringMetricsPanelState(PANEL_STATE.LIST);

      if (totalMissingEnvVarMetrics > 0) {
        this.$missingEnvVarPanel.removeClass('hidden');
        this.$missingEnvVarMetricCount.text(totalMissingEnvVarMetrics);
      }
    }
  }
Example #10
0
export const showBranchNotFoundError = ({ dispatch }, branchId) => {
  dispatch('setErrorMessage', {
    text: sprintf(
      __("Branch %{branchName} was not found in this project's repository."),
      {
        branchName: `<strong>${_.escape(branchId)}</strong>`,
      },
      false,
    ),
    action: payload => dispatch('createNewBranchFromDefault', payload),
    actionText: __('Create branch'),
    actionPayload: branchId,
  });
};
Example #11
0
export const getQuickActionText = note => {
  let text = __('Applying command');
  const quickActions = AjaxCache.get(gl.GfmAutoComplete.dataSources.commands) || [];

  const executedCommands = quickActions.filter(command => {
    const commandRegex = new RegExp(`/${command.name}`);
    return commandRegex.test(note);
  });

  if (executedCommands && executedCommands.length) {
    if (executedCommands.length > 1) {
      text = __('Applying multiple commands');
    } else {
      const commandDescription = executedCommands[0].description.toLowerCase();
      text = sprintf(__('Applying command to %{commandDescription}', { commandDescription }));
    }
  }

  return text;
};
Example #12
0
   showSidebar() {
     return Object.keys(this.issue).length;
   },
   milestoneTitle() {
     return this.issue.milestone ? this.issue.milestone.title : __('No Milestone');
   },
   canRemove() {
     return !this.list.preset;
   },
   hasLabels() {
     return this.issue.labels && this.issue.labels.length;
   },
   labelDropdownTitle() {
     return this.hasLabels
       ? sprintf(__('%{firstLabel} +%{labelCount} more'), {
           firstLabel: this.issue.labels[0].title,
           labelCount: this.issue.labels.length - 1,
         })
       : __('Label');
   },
   selectedLabels() {
     return this.hasLabels ? this.issue.labels.map(l => l.title).join(',') : '';
   },
 },
 watch: {
   detail: {
     handler() {
       if (this.issue.id !== this.detail.issue.id) {
         $('.block.assignee')
           .find('input:not(.js-vue)[name="issue[assignee_ids][]"]')
           .each((i, el) => {
             $(el).remove();
Example #13
0
export const reportTextBuilder = (name = '', results = {}) => {
  const resultsString = textBuilder(results);
  return sprintf(__('%{name} found %{resultsString}'), { name, resultsString });
};
Example #14
0
export const summaryTextBuilder = (name = '', results = {}) => {
  const resultsString = textBuilder(results);
  return sprintf(__('%{name} contained %{resultsString}'), { name, resultsString });
};
Example #15
0
    return {
      discussions: CommentsStore.state,
      loading: false,
    };
  },
  computed: {
    discussion() {
      return this.discussions[this.discussionId];
    },
    note() {
      return this.discussion ? this.discussion.getNote(this.noteId) : {};
    },
    buttonText() {
      if (this.isResolved) {
        return sprintf(__('Resolved by %{resolvedByName}'), {
          resolvedByName: this.resolvedByName,
        });
      } else if (this.canResolve) {
        return __('Mark as resolved');
      }

      return __('Unable to resolve');
    },
    isResolved() {
      if (this.note) {
        return this.note.resolved;
      }

      return false;
    },
    resolvedByName() {