Commit aa41d80d authored by Mike Greiling's avatar Mike Greiling

Merge branch 'leipert-object-spread' into 'master'

Use Object spread over Object.assign in app/assets

See merge request gitlab-org/gitlab!31354
parents 19f22930 57f74d46
...@@ -75,13 +75,11 @@ const Api = { ...@@ -75,13 +75,11 @@ const Api = {
const url = Api.buildUrl(Api.groupsPath); const url = Api.buildUrl(Api.groupsPath);
return axios return axios
.get(url, { .get(url, {
params: Object.assign( params: {
{ search: query,
search: query, per_page: DEFAULT_PER_PAGE,
per_page: DEFAULT_PER_PAGE, ...options,
}, },
options,
),
}) })
.then(({ data }) => { .then(({ data }) => {
callback(data); callback(data);
...@@ -282,7 +280,7 @@ const Api = { ...@@ -282,7 +280,7 @@ const Api = {
}; };
return axios return axios
.get(url, { .get(url, {
params: Object.assign({}, defaults, options), params: { ...defaults, ...options },
}) })
.then(({ data }) => callback(data)) .then(({ data }) => callback(data))
.catch(() => flash(__('Something went wrong while fetching projects'))); .catch(() => flash(__('Something went wrong while fetching projects')));
...@@ -365,13 +363,11 @@ const Api = { ...@@ -365,13 +363,11 @@ const Api = {
users(query, options) { users(query, options) {
const url = Api.buildUrl(this.usersPath); const url = Api.buildUrl(this.usersPath);
return axios.get(url, { return axios.get(url, {
params: Object.assign( params: {
{ search: query,
search: query, per_page: DEFAULT_PER_PAGE,
per_page: DEFAULT_PER_PAGE, ...options,
}, },
options,
),
}); });
}, },
...@@ -402,7 +398,7 @@ const Api = { ...@@ -402,7 +398,7 @@ const Api = {
}; };
return axios return axios
.get(url, { .get(url, {
params: Object.assign({}, defaults, options), params: { ...defaults, ...options },
}) })
.then(({ data }) => callback(data)) .then(({ data }) => callback(data))
.catch(() => flash(__('Something went wrong while fetching projects'))); .catch(() => flash(__('Something went wrong while fetching projects')));
......
...@@ -22,7 +22,7 @@ function eventHasModifierKeys(event) { ...@@ -22,7 +22,7 @@ function eventHasModifierKeys(event) {
export default class ShortcutsBlob extends Shortcuts { export default class ShortcutsBlob extends Shortcuts {
constructor(opts) { constructor(opts) {
const options = Object.assign({}, defaults, opts); const options = { ...defaults, ...opts };
super(options.skipResetBindings); super(options.skipResetBindings);
this.options = options; this.options = options;
......
...@@ -17,7 +17,7 @@ const defaults = { ...@@ -17,7 +17,7 @@ const defaults = {
class BlobForkSuggestion { class BlobForkSuggestion {
constructor(options) { constructor(options) {
this.elementMap = Object.assign({}, defaults, options); this.elementMap = { ...defaults, ...options };
this.onOpenButtonClick = this.onOpenButtonClick.bind(this); this.onOpenButtonClick = this.onOpenButtonClick.bind(this);
this.onCancelButtonClick = this.onCancelButtonClick.bind(this); this.onCancelButtonClick = this.onCancelButtonClick.bind(this);
} }
......
...@@ -19,14 +19,15 @@ export function getBoardSortableDefaultOptions(obj) { ...@@ -19,14 +19,15 @@ export function getBoardSortableDefaultOptions(obj) {
const touchEnabled = const touchEnabled =
'ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch); 'ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch);
const defaultSortOptions = Object.assign({}, sortableConfig, { const defaultSortOptions = {
...sortableConfig,
filter: '.no-drag', filter: '.no-drag',
delay: touchEnabled ? 100 : 0, delay: touchEnabled ? 100 : 0,
scrollSensitivity: touchEnabled ? 60 : 100, scrollSensitivity: touchEnabled ? 60 : 100,
scrollSpeed: 20, scrollSpeed: 20,
onStart: sortableStart, onStart: sortableStart,
onEnd: sortableEnd, onEnd: sortableEnd,
}); };
Object.keys(obj).forEach(key => { Object.keys(obj).forEach(key => {
defaultSortOptions[key] = obj[key]; defaultSortOptions[key] = obj[key];
......
...@@ -2,7 +2,7 @@ import DropLab from './droplab/drop_lab'; ...@@ -2,7 +2,7 @@ import DropLab from './droplab/drop_lab';
import ISetter from './droplab/plugins/input_setter'; import ISetter from './droplab/plugins/input_setter';
// Todo: Remove this when fixing issue in input_setter plugin // Todo: Remove this when fixing issue in input_setter plugin
const InputSetter = Object.assign({}, ISetter); const InputSetter = { ...ISetter };
class CloseReopenReportToggle { class CloseReopenReportToggle {
constructor(opts = {}) { constructor(opts = {}) {
......
...@@ -325,7 +325,7 @@ export default class Clusters { ...@@ -325,7 +325,7 @@ export default class Clusters {
handleClusterStatusSuccess(data) { handleClusterStatusSuccess(data) {
const prevStatus = this.store.state.status; const prevStatus = this.store.state.status;
const prevApplicationMap = Object.assign({}, this.store.state.applications); const prevApplicationMap = { ...this.store.state.applications };
this.store.updateStateFromServer(data.data); this.store.updateStateFromServer(data.data);
......
...@@ -2,7 +2,7 @@ import DropLab from './droplab/drop_lab'; ...@@ -2,7 +2,7 @@ import DropLab from './droplab/drop_lab';
import ISetter from './droplab/plugins/input_setter'; import ISetter from './droplab/plugins/input_setter';
// Todo: Remove this when fixing issue in input_setter plugin // Todo: Remove this when fixing issue in input_setter plugin
const InputSetter = Object.assign({}, ISetter); const InputSetter = { ...ISetter };
class CommentTypeToggle { class CommentTypeToggle {
constructor(opts = {}) { constructor(opts = {}) {
......
...@@ -13,7 +13,7 @@ import { ...@@ -13,7 +13,7 @@ import {
import confidentialMergeRequestState from './confidential_merge_request/state'; import confidentialMergeRequestState from './confidential_merge_request/state';
// Todo: Remove this when fixing issue in input_setter plugin // Todo: Remove this when fixing issue in input_setter plugin
const InputSetter = Object.assign({}, ISetter); const InputSetter = { ...ISetter };
const CREATE_MERGE_REQUEST = 'create-mr'; const CREATE_MERGE_REQUEST = 'create-mr';
const CREATE_BRANCH = 'create-branch'; const CREATE_BRANCH = 'create-branch';
......
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
events.forEach(item => { events.forEach(item => {
if (!item) return; if (!item) return;
const eventItem = Object.assign({}, DEFAULT_EVENT_OBJECTS[stage.slug], item); const eventItem = { ...DEFAULT_EVENT_OBJECTS[stage.slug], ...item };
eventItem.totalTime = eventItem.total_time; eventItem.totalTime = eventItem.total_time;
......
...@@ -28,9 +28,7 @@ export default { ...@@ -28,9 +28,7 @@ export default {
return this.label === null; return this.label === null;
}, },
pinStyle() { pinStyle() {
return this.repositioning return this.repositioning ? { ...this.position, cursor: 'move' } : this.position;
? Object.assign({}, this.position, { cursor: 'move' })
: this.position;
}, },
pinLabel() { pinLabel() {
return this.isNewNote return this.isNewNote
......
...@@ -233,7 +233,7 @@ export function trimFirstCharOfLineContent(line = {}) { ...@@ -233,7 +233,7 @@ export function trimFirstCharOfLineContent(line = {}) {
// eslint-disable-next-line no-param-reassign // eslint-disable-next-line no-param-reassign
delete line.text; delete line.text;
const parsedLine = Object.assign({}, line); const parsedLine = { ...line };
if (line.rich_text) { if (line.rich_text) {
const firstChar = parsedLine.rich_text.charAt(0); const firstChar = parsedLine.rich_text.charAt(0);
......
...@@ -58,13 +58,14 @@ export default class EnvironmentsStore { ...@@ -58,13 +58,14 @@ export default class EnvironmentsStore {
let filtered = {}; let filtered = {};
if (env.size > 1) { if (env.size > 1) {
filtered = Object.assign({}, env, { filtered = {
...env,
isFolder: true, isFolder: true,
isLoadingFolderContent: oldEnvironmentState.isLoading || false, isLoadingFolderContent: oldEnvironmentState.isLoading || false,
folderName: env.name, folderName: env.name,
isOpen: oldEnvironmentState.isOpen || false, isOpen: oldEnvironmentState.isOpen || false,
children: oldEnvironmentState.children || [], children: oldEnvironmentState.children || [],
}); };
} }
if (env.latest) { if (env.latest) {
...@@ -166,7 +167,7 @@ export default class EnvironmentsStore { ...@@ -166,7 +167,7 @@ export default class EnvironmentsStore {
let updated = env; let updated = env;
if (env.latest) { if (env.latest) {
updated = Object.assign({}, env, env.latest); updated = { ...env, ...env.latest };
delete updated.latest; delete updated.latest;
} else { } else {
updated = env; updated = env;
...@@ -192,7 +193,7 @@ export default class EnvironmentsStore { ...@@ -192,7 +193,7 @@ export default class EnvironmentsStore {
const { environments } = this.state; const { environments } = this.state;
const updatedEnvironments = environments.map(env => { const updatedEnvironments = environments.map(env => {
const updateEnv = Object.assign({}, env); const updateEnv = { ...env };
if (env.id === environment.id) { if (env.id === environment.id) {
updateEnv[prop] = newValue; updateEnv[prop] = newValue;
} }
......
...@@ -120,7 +120,7 @@ export default class FilteredSearchDropdownManager { ...@@ -120,7 +120,7 @@ export default class FilteredSearchDropdownManager {
filter: key, filter: key,
}; };
const extraArguments = mappingKey.extraArguments || {}; const extraArguments = mappingKey.extraArguments || {};
const glArguments = Object.assign({}, defaultArguments, extraArguments); const glArguments = { ...defaultArguments, ...extraArguments };
// Passing glArguments to `new glClass(<arguments>)` // Passing glArguments to `new glClass(<arguments>)`
mappingKey.reference = new (Function.prototype.bind.apply(glClass, [null, glArguments]))(); mappingKey.reference = new (Function.prototype.bind.apply(glClass, [null, glArguments]))();
......
...@@ -2,14 +2,12 @@ import { uniq } from 'lodash'; ...@@ -2,14 +2,12 @@ import { uniq } from 'lodash';
class RecentSearchesStore { class RecentSearchesStore {
constructor(initialState = {}, allowedKeys) { constructor(initialState = {}, allowedKeys) {
this.state = Object.assign( this.state = {
{ isLocalStorageAvailable: true,
isLocalStorageAvailable: true, recentSearches: [],
recentSearches: [], allowedKeys,
allowedKeys, ...initialState,
}, };
initialState,
);
} }
addRecentSearch(newSearch) { addRecentSearch(newSearch) {
......
...@@ -595,13 +595,14 @@ class GitLabDropdown { ...@@ -595,13 +595,14 @@ class GitLabDropdown {
return renderItem({ return renderItem({
instance: this, instance: this,
options: Object.assign({}, this.options, { options: {
...this.options,
icon: this.icon, icon: this.icon,
highlight: this.highlight, highlight: this.highlight,
highlightText: text => this.highlightTextMatches(text, this.filterInput.val()), highlightText: text => this.highlightTextMatches(text, this.filterInput.val()),
highlightTemplate: this.highlightTemplate.bind(this), highlightTemplate: this.highlightTemplate.bind(this),
parent, parent,
}), },
data, data,
group, group,
index, index,
......
...@@ -8,7 +8,7 @@ export default class GLForm { ...@@ -8,7 +8,7 @@ export default class GLForm {
constructor(form, enableGFM = {}) { constructor(form, enableGFM = {}) {
this.form = form; this.form = form;
this.textarea = this.form.find('textarea.js-gfm-input'); this.textarea = this.form.find('textarea.js-gfm-input');
this.enableGFM = Object.assign({}, defaultAutocompleteConfig, enableGFM); this.enableGFM = { ...defaultAutocompleteConfig, ...enableGFM };
// Disable autocomplete for keywords which do not have dataSources available // Disable autocomplete for keywords which do not have dataSources available
const dataSources = (gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources) || {}; const dataSources = (gl.GfmAutoComplete && gl.GfmAutoComplete.dataSources) || {};
Object.keys(this.enableGFM).forEach(item => { Object.keys(this.enableGFM).forEach(item => {
......
...@@ -2,7 +2,7 @@ import { visitUrl } from '../lib/utils/url_utility'; ...@@ -2,7 +2,7 @@ import { visitUrl } from '../lib/utils/url_utility';
import DropLab from '../droplab/drop_lab'; import DropLab from '../droplab/drop_lab';
import ISetter from '../droplab/plugins/input_setter'; import ISetter from '../droplab/plugins/input_setter';
const InputSetter = Object.assign({}, ISetter); const InputSetter = { ...ISetter };
const NEW_PROJECT = 'new-project'; const NEW_PROJECT = 'new-project';
const NEW_SUBGROUP = 'new-subgroup'; const NEW_SUBGROUP = 'new-subgroup';
......
...@@ -14,13 +14,12 @@ export const computeDiff = (originalContent, newContent) => { ...@@ -14,13 +14,12 @@ export const computeDiff = (originalContent, newContent) => {
endLineNumber: lineNumber + change.count - 1, endLineNumber: lineNumber + change.count - 1,
}); });
} else if ('added' in change || 'removed' in change) { } else if ('added' in change || 'removed' in change) {
acc.push( acc.push({
Object.assign({}, change, { ...change,
lineNumber, lineNumber,
modified: undefined, modified: undefined,
endLineNumber: lineNumber + change.count - 1, endLineNumber: lineNumber + change.count - 1,
}), });
);
} }
if (!change.removed) { if (!change.removed) {
......
...@@ -16,9 +16,7 @@ export default { ...@@ -16,9 +16,7 @@ export default {
}); });
Object.assign(state, { Object.assign(state, {
projects: Object.assign({}, state.projects, { projects: { ...state.projects, [projectPath]: project },
[projectPath]: project,
}),
}); });
}, },
[types.TOGGLE_EMPTY_STATE](state, { projectPath, value }) { [types.TOGGLE_EMPTY_STATE](state, { projectPath, value }) {
......
...@@ -14,12 +14,13 @@ export default { ...@@ -14,12 +14,13 @@ export default {
}, },
[types.CREATE_TREE](state, { treePath }) { [types.CREATE_TREE](state, { treePath }) {
Object.assign(state, { Object.assign(state, {
trees: Object.assign({}, state.trees, { trees: {
...state.trees,
[treePath]: { [treePath]: {
tree: [], tree: [],
loading: true, loading: true,
}, },
}), },
}); });
}, },
[types.SET_DIRECTORY_DATA](state, { data, treePath }) { [types.SET_DIRECTORY_DATA](state, { data, treePath }) {
......
...@@ -32,9 +32,7 @@ export function removeCommentIndicator(imageFrameEl) { ...@@ -32,9 +32,7 @@ export function removeCommentIndicator(imageFrameEl) {
commentIndicatorEl.remove(); commentIndicatorEl.remove();
} }
return Object.assign({}, meta, { return { ...meta, removed: willRemove };
removed: willRemove,
});
} }
export function showCommentIndicator(imageFrameEl, coordinate) { export function showCommentIndicator(imageFrameEl, coordinate) {
......
...@@ -4,12 +4,7 @@ export function setPositionDataAttribute(el, options) { ...@@ -4,12 +4,7 @@ export function setPositionDataAttribute(el, options) {
const { x, y, width, height } = options; const { x, y, width, height } = options;
const { position } = el.dataset; const { position } = el.dataset;
const positionObject = Object.assign({}, JSON.parse(position), { const positionObject = { ...JSON.parse(position), x, y, width, height };
x,
y,
width,
height,
});
el.setAttribute('data-position', JSON.stringify(positionObject)); el.setAttribute('data-position', JSON.stringify(positionObject));
} }
......
...@@ -75,9 +75,7 @@ export default class ImageDiff { ...@@ -75,9 +75,7 @@ export default class ImageDiff {
if (this.renderCommentBadge) { if (this.renderCommentBadge) {
imageDiffHelper.addImageCommentBadge(this.imageFrameEl, options); imageDiffHelper.addImageCommentBadge(this.imageFrameEl, options);
} else { } else {
const numberBadgeOptions = Object.assign({}, options, { const numberBadgeOptions = { ...options, badgeText: index + 1 };
badgeText: index + 1,
});
imageDiffHelper.addImageBadge(this.imageFrameEl, numberBadgeOptions); imageDiffHelper.addImageBadge(this.imageFrameEl, numberBadgeOptions);
} }
......
...@@ -220,7 +220,7 @@ export const fetchJobsForStage = ({ dispatch }, stage = {}) => { ...@@ -220,7 +220,7 @@ export const fetchJobsForStage = ({ dispatch }, stage = {}) => {
}, },
}) })
.then(({ data }) => { .then(({ data }) => {
const retriedJobs = data.retried.map(job => Object.assign({}, job, { retried: true })); const retriedJobs = data.retried.map(job => ({ ...job, retried: true }));
const jobs = data.latest_statuses.concat(retriedJobs); const jobs = data.latest_statuses.concat(retriedJobs);
dispatch('receiveJobsForStageSuccess', jobs); dispatch('receiveJobsForStageSuccess', jobs);
...@@ -236,7 +236,7 @@ export const receiveJobsForStageError = ({ commit }) => { ...@@ -236,7 +236,7 @@ export const receiveJobsForStageError = ({ commit }) => {
export const triggerManualJob = ({ state }, variables) => { export const triggerManualJob = ({ state }, variables) => {
const parsedVariables = variables.map(variable => { const parsedVariables = variables.map(variable => {
const copyVar = Object.assign({}, variable); const copyVar = { ...variable };
delete copyVar.id; delete copyVar.id;
return copyVar; return copyVar;
}); });
......
...@@ -230,10 +230,11 @@ export default { ...@@ -230,10 +230,11 @@ export default {
const defaultConfig = { path: this.getNotesDataByProp('discussionsPath') }; const defaultConfig = { path: this.getNotesDataByProp('discussionsPath') };
if (doesHashExistInUrl(constants.NOTE_UNDERSCORE)) { if (doesHashExistInUrl(constants.NOTE_UNDERSCORE)) {
return Object.assign({}, defaultConfig, { return {
...defaultConfig,
filter: constants.DISCUSSION_FILTERS_DEFAULT_VALUE, filter: constants.DISCUSSION_FILTERS_DEFAULT_VALUE,
persistFilter: false, persistFilter: false,
}); };
} }
return defaultConfig; return defaultConfig;
}, },
......
...@@ -248,7 +248,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => { ...@@ -248,7 +248,7 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
const hasQuickActions = utils.hasQuickActions(placeholderText); const hasQuickActions = utils.hasQuickActions(placeholderText);
const replyId = noteData.data.in_reply_to_discussion_id; const replyId = noteData.data.in_reply_to_discussion_id;
let methodToDispatch; let methodToDispatch;
const postData = Object.assign({}, noteData); const postData = { ...noteData };
if (postData.isDraft === true) { if (postData.isDraft === true) {
methodToDispatch = replyId methodToDispatch = replyId
? 'batchComments/addDraftToDiscussion' ? 'batchComments/addDraftToDiscussion'
......
...@@ -99,9 +99,10 @@ export default { ...@@ -99,9 +99,10 @@ export default {
// 3. If GitLab user does not have avatar, they might have a Gravatar // 3. If GitLab user does not have avatar, they might have a Gravatar
} else if (this.pipeline.commit.author_gravatar_url) { } else if (this.pipeline.commit.author_gravatar_url) {
commitAuthorInformation = Object.assign({}, this.pipeline.commit.author, { commitAuthorInformation = {
...this.pipeline.commit.author,
avatar_url: this.pipeline.commit.author_gravatar_url, avatar_url: this.pipeline.commit.author_gravatar_url,
}); };
} }
// 4. If committer is not a GitLab User, they can have a Gravatar // 4. If committer is not a GitLab User, they can have a Gravatar
} else { } else {
......
...@@ -15,7 +15,7 @@ export default class PipelineStore { ...@@ -15,7 +15,7 @@ export default class PipelineStore {
* @param {Object} pipeline * @param {Object} pipeline
*/ */
storePipeline(pipeline = {}) { storePipeline(pipeline = {}) {
const pipelineCopy = Object.assign({}, pipeline); const pipelineCopy = { ...pipeline };
if (pipelineCopy.triggered_by) { if (pipelineCopy.triggered_by) {
pipelineCopy.triggered_by = [pipelineCopy.triggered_by]; pipelineCopy.triggered_by = [pipelineCopy.triggered_by];
......
...@@ -21,7 +21,7 @@ export default { ...@@ -21,7 +21,7 @@ export default {
state.original = Object.freeze(settings); state.original = Object.freeze(settings);
}, },
[types.RESET_SETTINGS](state) { [types.RESET_SETTINGS](state) {
state.settings = Object.assign({}, state.original); state.settings = { ...state.original };
}, },
[types.TOGGLE_LOADING](state) { [types.TOGGLE_LOADING](state) {
state.isLoading = !state.isLoading; state.isLoading = !state.isLoading;
......
...@@ -13,14 +13,11 @@ Terminal.applyAddon(webLinks); ...@@ -13,14 +13,11 @@ Terminal.applyAddon(webLinks);
export default class GLTerminal { export default class GLTerminal {
constructor(element, options = {}) { constructor(element, options = {}) {
this.options = Object.assign( this.options = {
{}, cursorBlink: true,
{ screenKeys: true,
cursorBlink: true, ...options,
screenKeys: true, };
},
options,
);
this.container = element; this.container = element;
this.onDispose = []; this.onDispose = [];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment