Commit e08e0edb authored by David Kim's avatar David Kim

Merge branch 'ph/removeParticipantsFromSidebarEntity' into 'master'

Removes participants and subscriptions from sidebar entity

See merge request gitlab-org/gitlab!68032
parents 7422f8dc 007e8b8e
...@@ -22,7 +22,6 @@ export default class SidebarService { ...@@ -22,7 +22,6 @@ export default class SidebarService {
constructor(endpointMap) { constructor(endpointMap) {
if (!SidebarService.singleton) { if (!SidebarService.singleton) {
this.endpoint = endpointMap.endpoint; this.endpoint = endpointMap.endpoint;
this.toggleSubscriptionEndpoint = endpointMap.toggleSubscriptionEndpoint;
this.moveIssueEndpoint = endpointMap.moveIssueEndpoint; this.moveIssueEndpoint = endpointMap.moveIssueEndpoint;
this.projectsAutocompleteEndpoint = endpointMap.projectsAutocompleteEndpoint; this.projectsAutocompleteEndpoint = endpointMap.projectsAutocompleteEndpoint;
this.fullPath = endpointMap.fullPath; this.fullPath = endpointMap.fullPath;
...@@ -75,10 +74,6 @@ export default class SidebarService { ...@@ -75,10 +74,6 @@ export default class SidebarService {
}); });
} }
toggleSubscription() {
return axios.post(this.toggleSubscriptionEndpoint);
}
moveIssue(moveToProjectId) { moveIssue(moveToProjectId) {
return axios.post(this.moveIssueEndpoint, { return axios.post(this.moveIssueEndpoint, {
move_to_project_id: moveToProjectId, move_to_project_id: moveToProjectId,
......
...@@ -17,7 +17,6 @@ export default class SidebarMediator { ...@@ -17,7 +17,6 @@ export default class SidebarMediator {
this.store = new Store(options); this.store = new Store(options);
this.service = new Service({ this.service = new Service({
endpoint: options.endpoint, endpoint: options.endpoint,
toggleSubscriptionEndpoint: options.toggleSubscriptionEndpoint,
moveIssueEndpoint: options.moveIssueEndpoint, moveIssueEndpoint: options.moveIssueEndpoint,
projectsAutocompleteEndpoint: options.projectsAutocompleteEndpoint, projectsAutocompleteEndpoint: options.projectsAutocompleteEndpoint,
fullPath: options.fullPath, fullPath: options.fullPath,
...@@ -85,22 +84,6 @@ export default class SidebarMediator { ...@@ -85,22 +84,6 @@ export default class SidebarMediator {
this.store.setAssigneeData(data); this.store.setAssigneeData(data);
this.store.setReviewerData(data); this.store.setReviewerData(data);
this.store.setTimeTrackingData(data); this.store.setTimeTrackingData(data);
this.store.setParticipantsData(data);
this.store.setSubscriptionsData(data);
}
toggleSubscription() {
this.store.setFetchingState('subscriptions', true);
return this.service
.toggleSubscription()
.then(() => {
this.store.setSubscribedState(!this.store.subscribed);
this.store.setFetchingState('subscriptions', false);
})
.catch((err) => {
this.store.setFetchingState('subscriptions', false);
throw err;
});
} }
fetchAutocompleteProjects(searchTerm) { fetchAutocompleteProjects(searchTerm) {
......
...@@ -22,8 +22,6 @@ export default class SidebarStore { ...@@ -22,8 +22,6 @@ export default class SidebarStore {
this.isFetching = { this.isFetching = {
assignees: true, assignees: true,
reviewers: true, reviewers: true,
participants: true,
subscriptions: true,
}; };
this.isLoading = {}; this.isLoading = {};
this.autocompleteProjects = []; this.autocompleteProjects = [];
...@@ -63,18 +61,6 @@ export default class SidebarStore { ...@@ -63,18 +61,6 @@ export default class SidebarStore {
this.humanTotalTimeSpent = data.human_total_time_spent; this.humanTotalTimeSpent = data.human_total_time_spent;
} }
setParticipantsData(data) {
this.isFetching.participants = false;
this.participants = data.participants || [];
}
setSubscriptionsData(data) {
this.projectEmailsDisabled = data.project_emails_disabled || false;
this.subscribeDisabledDescription = data.subscribe_disabled_description;
this.isFetching.subscriptions = false;
this.subscribed = data.subscribed || false;
}
setFetchingState(key, value) { setFetchingState(key, value) {
this.isFetching[key] = value; this.isFetching[key] = value;
} }
......
...@@ -3,23 +3,6 @@ ...@@ -3,23 +3,6 @@
class IssuableSidebarExtrasEntity < Grape::Entity class IssuableSidebarExtrasEntity < Grape::Entity
include RequestAwareEntity include RequestAwareEntity
include TimeTrackableEntity include TimeTrackableEntity
include NotificationsHelper
expose :participants, using: ::API::Entities::UserBasic do |issuable|
issuable.participants(request.current_user)
end
expose :project_emails_disabled do |issuable|
issuable.project.emails_disabled?
end
expose :subscribe_disabled_description do |issuable|
notification_description(:owner_disabled)
end
expose :subscribed do |issuable|
issuable.subscribed?(request.current_user, issuable.project)
end
expose :assignees, using: ::API::Entities::UserBasic expose :assignees, using: ::API::Entities::UserBasic
end end
...@@ -63,8 +63,6 @@ describe('Sidebar mediator', () => { ...@@ -63,8 +63,6 @@ describe('Sidebar mediator', () => {
expect(mediator.store.assignees).toEqual(mockData.assignees); expect(mediator.store.assignees).toEqual(mockData.assignees);
expect(mediator.store.humanTimeEstimate).toEqual(mockData.human_time_estimate); expect(mediator.store.humanTimeEstimate).toEqual(mockData.human_time_estimate);
expect(mediator.store.humanTotalTimeSpent).toEqual(mockData.human_total_time_spent); expect(mediator.store.humanTotalTimeSpent).toEqual(mockData.human_total_time_spent);
expect(mediator.store.participants).toEqual(mockData.participants);
expect(mediator.store.subscribed).toEqual(mockData.subscribed);
expect(mediator.store.timeEstimate).toEqual(mockData.time_estimate); expect(mediator.store.timeEstimate).toEqual(mockData.time_estimate);
expect(mediator.store.totalTimeSpent).toEqual(mockData.total_time_spent); expect(mediator.store.totalTimeSpent).toEqual(mockData.total_time_spent);
}); });
...@@ -117,19 +115,4 @@ describe('Sidebar mediator', () => { ...@@ -117,19 +115,4 @@ describe('Sidebar mediator', () => {
urlSpy.mockRestore(); urlSpy.mockRestore();
}); });
}); });
it('toggle subscription', () => {
mediator.store.setSubscribedState(false);
mock.onPost(mediatorMockData.toggleSubscriptionEndpoint).reply(200, {});
const spy = jest
.spyOn(mediator.service, 'toggleSubscription')
.mockReturnValue(Promise.resolve());
return mediator.toggleSubscription().then(() => {
expect(spy).toHaveBeenCalled();
expect(mediator.store.subscribed).toEqual(true);
spy.mockRestore();
});
});
}); });
...@@ -16,17 +16,6 @@ const ANOTHER_ASSINEE = { ...@@ -16,17 +16,6 @@ const ANOTHER_ASSINEE = {
avatar_url: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon', avatar_url: 'https://www.gravatar.com/avatar/e64c7d89f26bd1972efa854d13d7dd61?s=80&d=identicon',
}; };
const PARTICIPANT = {
id: 1,
state: 'active',
username: 'marcene',
name: 'Allie Will',
web_url: 'foo.com',
avatar_url: 'gravatar.com/avatar/xxx',
};
const PARTICIPANT_LIST = [PARTICIPANT, { ...PARTICIPANT, id: 2 }, { ...PARTICIPANT, id: 3 }];
describe('Sidebar store', () => { describe('Sidebar store', () => {
let testContext; let testContext;
...@@ -113,28 +102,6 @@ describe('Sidebar store', () => { ...@@ -113,28 +102,6 @@ describe('Sidebar store', () => {
expect(testContext.store.changing).toBe(true); expect(testContext.store.changing).toBe(true);
}); });
it('sets participants data', () => {
expect(testContext.store.participants.length).toEqual(0);
testContext.store.setParticipantsData({
participants: PARTICIPANT_LIST,
});
expect(testContext.store.isFetching.participants).toEqual(false);
expect(testContext.store.participants.length).toEqual(PARTICIPANT_LIST.length);
});
it('sets subcriptions data', () => {
expect(testContext.store.subscribed).toEqual(null);
testContext.store.setSubscriptionsData({
subscribed: true,
});
expect(testContext.store.isFetching.subscriptions).toEqual(false);
expect(testContext.store.subscribed).toEqual(true);
});
it('set assigned data', () => { it('set assigned data', () => {
const users = { const users = {
assignees: UsersMockHelper.createNumberRandomUsers(3), assignees: UsersMockHelper.createNumberRandomUsers(3),
...@@ -147,11 +114,11 @@ describe('Sidebar store', () => { ...@@ -147,11 +114,11 @@ describe('Sidebar store', () => {
}); });
it('sets fetching state', () => { it('sets fetching state', () => {
expect(testContext.store.isFetching.participants).toEqual(true); expect(testContext.store.isFetching.assignees).toEqual(true);
testContext.store.setFetchingState('participants', false); testContext.store.setFetchingState('assignees', false);
expect(testContext.store.isFetching.participants).toEqual(false); expect(testContext.store.isFetching.assignees).toEqual(false);
}); });
it('sets loading state', () => { it('sets loading state', () => {
......
...@@ -10,11 +10,7 @@ RSpec.describe IssuableSidebarExtrasEntity do ...@@ -10,11 +10,7 @@ RSpec.describe IssuableSidebarExtrasEntity do
subject { described_class.new(resource, request: request).as_json } subject { described_class.new(resource, request: request).as_json }
it 'have subscribe attributes' do it 'have assignee attribute' do
expect(subject).to include(:participants, expect(subject).to include(:assignees)
:project_emails_disabled,
:subscribe_disabled_description,
:subscribed,
:assignees)
end end
end end
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