Skip to content
Snippets Groups Projects
Unverified Commit b709b696 authored by Lukas Eipert's avatar Lukas Eipert Committed by Mike Greiling
Browse files

Use Object spread over Object.assign in ee/

See https://gitlab.com/gitlab-org/gitlab/-/issues/202172

This is part of multiple merge requests in order to reduce the risk of
breaking master
parent 9955183f
No related branches found
No related tags found
No related merge requests found
Showing
with 47 additions and 51 deletions
Loading
Loading
@@ -58,7 +58,8 @@ export default {
},
mounted() {
if (this.allowCustomOrdering) {
const options = Object.assign({}, sortableDefaultOptions(), {
const options = {
...sortableDefaultOptions(),
onUpdate: event => {
const el = event.item;
 
Loading
Loading
@@ -70,7 +71,7 @@ export default {
 
this.$emit('reorderStage', { id, moveAfterId, moveBeforeId });
},
});
};
this.sortable = Sortable.create(this.$refs.list, options);
}
},
Loading
Loading
Loading
Loading
@@ -7,7 +7,8 @@ export default () => {
const touchEnabled =
'ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch);
 
return Object.assign({}, sortableConfig, {
return {
...sortableConfig,
fallbackOnBody: false,
group: {
name: 'stages',
Loading
Loading
@@ -22,5 +23,5 @@ export default () => {
onMove(e) {
return !e.related.classList.contains(NO_DRAG_CLASS);
},
});
};
};
Loading
Loading
@@ -2,7 +2,7 @@ import axios from '~/lib/utils/axios_utils';
 
export default {
createNewDraft(endpoint, data) {
const postData = Object.assign({}, data, { draft_note: data.note });
const postData = { ...data, draft_note: data.note };
delete postData.note;
 
return axios.post(endpoint, postData);
Loading
Loading
Loading
Loading
@@ -25,12 +25,10 @@ export default class EnvironmentsStore extends CeEnvironmentsStore {
const environments = this.state.environments.slice();
 
this.state.environments = environments.map(env => {
let updated = Object.assign({}, env);
let updated = { ...env };
 
if (env.id === environmentID) {
updated = Object.assign({}, updated, {
isDeployBoardVisible: !env.isDeployBoardVisible,
});
updated = { ...updated, isDeployBoardVisible: !env.isDeployBoardVisible };
}
return updated;
});
Loading
Loading
Loading
Loading
@@ -8,7 +8,8 @@
export const setDeployBoard = (oldEnvironmentState, environment) => {
let parsedEnvironment = environment;
if (environment.size === 1 && environment.rollout_status) {
parsedEnvironment = Object.assign({}, environment, {
parsedEnvironment = {
...environment,
hasDeployBoard: true,
isDeployBoardVisible:
oldEnvironmentState.isDeployBoardVisible === false
Loading
Loading
@@ -19,7 +20,7 @@ export const setDeployBoard = (oldEnvironmentState, environment) => {
isLoadingDeployBoard: environment.rollout_status.status === 'loading',
isEmptyDeployBoard: environment.rollout_status.status === 'not_found',
hasLegacyAppLabel: environment.rollout_status.has_legacy_app_label,
});
};
}
return parsedEnvironment;
};
Loading
Loading
@@ -96,7 +96,7 @@ export default class AccessDropdown {
}
 
const persistedItems = itemsToPreselect.map(item => {
const persistedItem = Object.assign({}, item);
const persistedItem = { ...item };
persistedItem.persisted = true;
return persistedItem;
});
Loading
Loading
@@ -361,7 +361,7 @@ export default class AccessDropdown {
usersResponse.forEach(response => {
// Add is it has not been added
if (map.indexOf(LEVEL_TYPES.USER + response.id) === -1) {
const user = Object.assign({}, response);
const user = { ...response };
user.type = LEVEL_TYPES.USER;
users.push(user);
}
Loading
Loading
Loading
Loading
@@ -55,13 +55,11 @@ export default {
},
mounted() {
if (this.canReorder) {
this.sortable = Sortable.create(
this.$refs.list,
Object.assign({}, sortableConfig, {
onStart: this.addDraggingCursor,
onEnd: this.reordered,
}),
);
this.sortable = Sortable.create(this.$refs.list, {
...sortableConfig,
onStart: this.addDraggingCursor,
onEnd: this.reordered,
});
}
},
methods: {
Loading
Loading
Loading
Loading
@@ -48,10 +48,7 @@ export const applySorts = array => array.sort(sortChildren).sort(sortByState);
* flags and properties to use while rendering tree.
* @param {Object} item
*/
export const formatChildItem = item =>
Object.assign({}, item, {
pathIdSeparator: PathIdSeparator[item.type],
});
export const formatChildItem = item => ({ ...item, pathIdSeparator: PathIdSeparator[item.type] });
 
/**
* Returns formatted array of Epics that doesn't contain
Loading
Loading
Loading
Loading
@@ -45,7 +45,7 @@ export default {
return this.isOpen ? 'angle-down' : 'angle-right';
},
statistics() {
const statisticsCopy = Object.assign({}, this.project.statistics);
const statisticsCopy = { ...this.project.statistics };
delete statisticsCopy.storageSize;
// eslint-disable-next-line no-underscore-dangle
delete statisticsCopy.__typename;
Loading
Loading
Loading
Loading
@@ -19,9 +19,12 @@ export const setSelectedEpic = ({ commit }, selectedEpic) =>
export const requestEpics = ({ commit }) => commit(types.REQUEST_EPICS);
export const receiveEpicsSuccess = ({ commit }, data) => {
const epics = data.map(rawEpic =>
convertObjectPropsToCamelCase(Object.assign({}, rawEpic, { url: rawEpic.web_edit_url }), {
dropKeys: ['web_edit_url'],
}),
convertObjectPropsToCamelCase(
{ ...rawEpic, url: rawEpic.web_edit_url },
{
dropKeys: ['web_edit_url'],
},
),
);
 
commit(types.RECEIVE_EPICS_SUCCESS, { epics });
Loading
Loading
const downloadPatchHelper = (patch, opts = {}) => {
const mergedOpts = Object.assign(
{
isEncoded: true,
},
opts,
);
const mergedOpts = {
isEncoded: true,
...opts,
};
 
const url = `data:text/plain;base64,${mergedOpts.isEncoded ? patch : btoa(patch)}`;
const link = document.createElement('a');
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ export default {
const index = this.notes.indexOf(comment);
 
if (index > -1) {
this.notes.splice(index, 1, Object.assign({}, comment, data));
this.notes.splice(index, 1, { ...comment, ...data });
}
},
removeComment(comment) {
Loading
Loading
Loading
Loading
@@ -33,7 +33,7 @@ describe('Api', () => {
beforeEach(() => {
mock = new MockAdapter(axios);
originalGon = window.gon;
window.gon = Object.assign({}, dummyGon);
window.gon = { ...dummyGon };
});
 
afterEach(() => {
Loading
Loading
Loading
Loading
@@ -13,10 +13,12 @@ export const mockEpicMeta = {
};
 
export const mockEpicData = convertObjectPropsToCamelCase(
Object.assign({}, getJSONFixture('epic/mock_data.json'), initial, {
{
...getJSONFixture('epic/mock_data.json'),
...initial,
endpoint: TEST_HOST,
sidebarCollapsed: false,
}),
},
{ deep: true },
);
 
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@ describe('Epic Store Actions', () => {
let state;
 
beforeEach(() => {
state = Object.assign({}, defaultState());
state = { ...defaultState() };
});
 
describe('setEpicMeta', () => {
Loading
Loading
Loading
Loading
@@ -54,13 +54,13 @@ describe('GeoNodeActionsComponent', () => {
 
describe('nodeToggleLabel', () => {
it('returns label for toggle button for a node', () => {
let mockNode = Object.assign({}, mockNodes[1]);
let mockNode = { ...mockNodes[1] };
let vmX = createComponent(mockNode);
 
expect(vmX.nodeToggleLabel).toBe('Pause replication');
vmX.$destroy();
 
mockNode = Object.assign({}, mockNodes[1], { enabled: false });
mockNode = { ...mockNodes[1], enabled: false };
vmX = createComponent(mockNode);
 
expect(vmX.nodeToggleLabel).toBe('Resume replication');
Loading
Loading
Loading
Loading
@@ -5,8 +5,8 @@ import mountComponent from 'helpers/vue_mount_component_helper';
import { mockNode, mockNodeDetails } from '../mock_data';
 
const createComponent = ({
node = Object.assign({}, mockNode),
nodeDetails = Object.assign({}, mockNodeDetails),
node = { ...mockNode },
nodeDetails = { ...mockNodeDetails },
nodeDetailsLoading = false,
nodeDetailsFailed = false,
}) => {
Loading
Loading
Loading
Loading
@@ -50,10 +50,7 @@ describe('GeoNodeItemComponent', () => {
describe('handleNodeDetails', () => {
describe('with matching ID', () => {
beforeEach(() => {
const mockNodeSecondary = Object.assign({}, mockNode, {
id: mockNodeDetails.id,
primary: false,
});
const mockNodeSecondary = { ...mockNode, id: mockNodeDetails.id, primary: false };
 
createComponent({ node: mockNodeSecondary });
});
Loading
Loading
Loading
Loading
@@ -7,8 +7,8 @@ import { mockNode, mockNodeDetails } from '../../mock_data';
const MOCK_VERSION_TEXT = `${mockNodeDetails.version} (${mockNodeDetails.revision})`;
 
const createComponent = ({
node = Object.assign({}, mockNode),
nodeDetails = Object.assign({}, mockNodeDetails),
node = { ...mockNode },
nodeDetails = { ...mockNodeDetails },
nodeActionsAllowed = true,
nodeEditAllowed = true,
nodeRemovalAllowed = true,
Loading
Loading
Loading
Loading
@@ -6,8 +6,8 @@ import { mockNode, mockNodeDetails } from '../../mock_data';
import { numberToHumanSize } from '~/lib/utils/number_utils';
 
const createComponent = (
node = Object.assign({}, mockNode),
nodeDetails = Object.assign({}, mockNodeDetails),
node = { ...mockNode },
nodeDetails = { ...mockNodeDetails },
nodeTypePrimary = false,
) => {
const Component = Vue.extend(NodeDetailsSectionOtherComponent);
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment