Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Source Course Option only to Current Course in Duplication Data #7298

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions app/controllers/course/courses_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ def index
end

def show
respond_to do |format|
format.json do
@currently_active_announcements = current_course.announcements.
currently_active.includes(:creator)
@activity_feeds = recent_activity_feeds.limit(20).preload(activity: [{ object: { topic: { actable: :forum } } },
:actor])
load_activity_course_users
load_todos
load_items_with_timeline
end
end
@currently_active_announcements = current_course.announcements.
currently_active.includes(:creator)
@activity_feeds = recent_activity_feeds.limit(20).preload(
activity: [
{ object: { topic: { actable: :forum } } },
:actor
]
)
load_activity_course_users
load_todos
load_items_with_timeline
end

def create
Expand Down
18 changes: 0 additions & 18 deletions app/controllers/course/object_duplications_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ class Course::ObjectDuplicationsController < Course::ComponentController
helper Course::Achievement::AchievementsHelper

def new
load_source_courses_data
load_destination_courses_data
load_items_data
load_destination_instances_data
Expand All @@ -17,11 +16,6 @@ def create
render partial: 'jobs/submitted', locals: { job: job }
end

# Duplication data for the current course
def data
load_items_data
end

protected

def authorize_duplication
Expand All @@ -30,18 +24,6 @@ def authorize_duplication

private

def load_source_courses_data
ActsAsTenant.without_tenant do
# Workaround to get Courses where current user is allowed to duplicate contents from
# without having to use accessible_by, which can take up to 5 minutes with includes
course_copiers = CourseUser.where(user: current_user).
where(role: CourseUser::MANAGER_ROLES.to_a) +
CourseUser.where(user: current_user).
where(role: :observer)
@source_courses = Course.includes(:instance).find(course_copiers.map(&:course_id))
end
end

def load_destination_courses_data
ActsAsTenant.without_tenant do
# Workaround to get Courses where current user plays one of manager roles
Expand Down
2 changes: 0 additions & 2 deletions app/views/course/object_duplications/data.json.jbuilder

This file was deleted.

5 changes: 0 additions & 5 deletions app/views/course/object_duplications/new.json.jbuilder
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
# frozen_string_literal: true
json.currentHost current_tenant.host

json.sourceCourses @source_courses do |course|
json.(course, :id, :title)
json.host course.instance.host
end

json.destinationCourses @destination_courses do |course|
json.(course, :id, :title)
json.path course_path(course)
Expand Down
22 changes: 0 additions & 22 deletions client/app/api/course/Duplication.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ export default class DuplicationAPI extends BaseCourseAPI {
* currentHost: string,
* destinationCourses: Array.<courseShape>,
* destinationInstances: Array.<instanceShape>,
* sourceCourses: courseListingShape,
* sourceCourse: sourceCourseShape,
* assessmentComponent: Array.<categoryShape>,
* surveyComponent: Array.<surveyShape>,
* achievementsComponent: Array.<achievementShape>,
Expand All @@ -24,26 +22,6 @@ export default class DuplicationAPI extends BaseCourseAPI {
return this.client.get(`${this.#urlPrefix}/new`);
}

/**
* Fetches a list of all duplicable objects for the given course.
*
* @param {string} courseId
* @return {Promise}
* success response: {
* sourceCourse: sourceCourseShape,
* assessmentComponent: Array.<categoryShape>,
* surveyComponent: Array.<surveyShape>,
* achievementsComponent: Array.<achievementShape>,
* materialsComponent: Array.<folderShape>,
* videosComponent: Array.<videoTabShape>,
* }
*
* See course/duplication/propTypes.js for custom propTypes.
*/
data(courseId) {
return this.client.get(`/courses/${courseId}/object_duplication/data`);
}

/**
* Duplicates selected items to the target course.
*
Expand Down
50 changes: 0 additions & 50 deletions client/app/bundles/course/duplication/components/BulkSelectors.jsx

This file was deleted.

42 changes: 42 additions & 0 deletions client/app/bundles/course/duplication/components/BulkSelectors.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { FC } from 'react';
import { defineMessages } from 'react-intl';

import Link from 'lib/components/core/Link';
import useTranslation from 'lib/hooks/useTranslation';

const translations = defineMessages({
selectAll: {
id: 'course.duplication.BulkSelectors.selectAll',
defaultMessage: 'Select All',
},
deselectAll: {
id: 'course.duplication.BulkSelectors.deselectAll',
defaultMessage: 'Deselect All',
},
});

interface Props {
callback: (value: boolean) => void;
selectLinkClassName?: string;
}

const BulkSelectors: FC<Props> = (props) => {
const { t } = useTranslation();
const { callback, selectLinkClassName } = props;

return (
<>
<Link
className={selectLinkClassName ?? 'ml-5 leading-6'}
onClick={() => callback(true)}
>
{t(translations.selectAll)}
</Link>
<Link className="ml-3 leading-6" onClick={() => callback(false)}>
{t(translations.deselectAll)}
</Link>
</>
);
};

export default BulkSelectors;

This file was deleted.

Loading