Skip to content

Commit

Permalink
Merge branch 'learningequality:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Aypak authored Oct 14, 2024
2 parents 26402f9 + 1011ace commit 6f33576
Show file tree
Hide file tree
Showing 28 changed files with 425 additions and 215 deletions.
89 changes: 44 additions & 45 deletions .github/workflows/add_contributor.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,64 @@
name: Add new contributor to AUTHORS.md

on:
pull_request:
types: [opened]
pull_request_target:
types:
- closed

jobs:
check_contributor_exists:
update-authors:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

outputs:
is_contributor_in_file: ${{ steps.check_contributor_step.outputs.exists }}

steps:
- name: Checkout repository
- name: Checkout develop branch
uses: actions/checkout@v4
with:
sparse-checkout: .
ref: 'develop'
fetch-depth: 0
persist-credentials: false

- name: Check if contributor already exists
id: check_contributor_step
- name: Check if author is in AUTHORS.md
id: check-author
run: |
exists=$(grep -c -F "${{ github.event.pull_request.user.login }}" AUTHORS.md || true)
if [[ $exists -gt 0 ]]; then
echo "exists=true" >> "$GITHUB_OUTPUT"
GH_USER="${{ github.event.pull_request.user.login }}"
# AUTHORS.md file already exist in repo, so can skip the conditional logic to create one if not exists
if ! grep -q "| ${GH_USER} |" AUTHORS.md; then
echo "new_author=true" >> $GITHUB_ENV
else
echo "exists=false" >> "$GITHUB_OUTPUT"
echo "new_author=false" >> $GITHUB_ENV
fi
add_contributor:
runs-on: ubuntu-latest
needs: check_contributor_exists

if: needs.check_contributor_exists.outputs.is_contributor_in_file == 'false'

permissions:
contents: write

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Set up Git and checkout PR's branch
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git fetch origin refs/pull/${{ github.event.number }}/head:pr
git checkout pr
- name: Get contributor's full name and append to AUTHORS.md file
- name: Add author to AUTHORS.md if not present
if: env.new_author == 'true'
run: |
username=${{ github.event.pull_request.user.login }}
full_name=$(curl -s -H "Authorization: token $GITHUB_TOKEN" "https://api.github.com/users/$username" | jq -r '.name')
if [[ "$full_name" == "" || "$full_name" == "null" ]]; then
full_name='-'
GH_USER="${{ github.event.pull_request.user.login }}"
AUTHOR_NAME=$(curl -s https://api.github.com/users/${GH_USER} | jq -r '.name')
if [ -z "$AUTHOR_NAME" ]; then
AUTHOR_NAME="-"
fi
echo "| $full_name | $username |" >> AUTHORS.md
echo "| $AUTHOR_NAME | $GH_USER |" >> AUTHORS.md
- name: Commit and push changes to the contributor's PR branch
- name: Commit updated AUTHORS.md
if: env.new_author == 'true'
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add AUTHORS.md
git commit -m "Add ${{ github.event.pull_request.user.login }} to AUTHORS.md"
git push origin pr:${{ github.event.pull_request.head.ref }}
- name: GitHub App token
if: env.new_author == 'true'
uses: tibdex/github-app-token@v2
id: generate-token
with:
app_id: ${{ secrets.LE_BOT_APP_ID }}
private_key: ${{ secrets.LE_BOT_PRIVATE_KEY }}

- name: Push changes to develop
if: env.new_author == 'true'
uses: ad-m/github-push-action@v0.8.0
with:
github_token: ${{ steps.generate-token.outputs.token }}
branch: 'develop'
1 change: 1 addition & 0 deletions AUTHORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,4 @@ If you have contributed to Kolibri, feel free to add your name and Github accoun
| Mazen Oweiss | moweiss |
| Eshaan Aggarwal | EshaanAgg |
| Nikhil Sharma | ThEditor |
| - | BabyElias |
2 changes: 2 additions & 0 deletions kolibri/core/assets/src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,5 @@ export const Presets = Object.freeze({
export const MAX_QUESTIONS_PER_QUIZ_SECTION = 25;

export const DisconnectionErrorCodes = [0, 502, 504, 511];

export const RENDERER_SUFFIX = '_renderer';
2 changes: 1 addition & 1 deletion kolibri/core/assets/src/core-app/pluginMediator.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Vue from 'vue';
import scriptLoader from 'kolibri-common//utils/scriptLoader';
import { RENDERER_SUFFIX } from '../views/ContentRenderer/constants';
import { RENDERER_SUFFIX } from 'kolibri.coreVue.vuex.constants';
import contentRendererMixin from '../views/ContentRenderer/mixin';
import ContentRendererLoading from '../views/ContentRenderer/ContentRendererLoading';
import ContentRendererError from '../views/ContentRenderer/ContentRendererError';
Expand Down
3 changes: 3 additions & 0 deletions kolibri/core/assets/src/heartbeat.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,9 @@ export class HeartBeat {
'MSPointerMove',
];
}
setReloadOnReconnect(reloadOnReconnect) {
set(this._connection.reloadOnReconnect, reloadOnReconnect);
}
}

const heartbeat = new HeartBeat();
Expand Down
1 change: 0 additions & 1 deletion kolibri/core/assets/src/kolibri_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export default class KolibriApp extends KolibriModule {
ready() {
this.setupVue();
return heartbeat.startPolling().then(() => {
this.store.dispatch('getNotifications');
return Promise.all([
// Invoke each of the state setters before initializing the app.
...this.stateSetters.map(setter => setter(this.store)),
Expand Down
5 changes: 5 additions & 0 deletions kolibri/core/assets/src/mixins/commonCoreStrings.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ export const coreStrings = createTranslator('CommonCoreStrings', {
context:
'Button to cancel an action and return to the previous page. Usually this is the opposite of the save button which saves some piece of information.',
},
learnMoreAction: {
message: 'Learn more',
context:
'Button for link which will show the user information providing more information about the relevant context',
},
cannotUndoActionWarning: {
message: 'This action cannot be undone',
context:
Expand Down
48 changes: 2 additions & 46 deletions kolibri/core/assets/src/state/modules/core/actions.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
import debounce from 'lodash/debounce';
import pick from 'lodash/pick';
import client from 'kolibri.client';
import heartbeat from 'kolibri.heartbeat';
import logger from 'kolibri.lib.logging';
import {
FacilityResource,
FacilityDatasetResource,
UserSyncStatusResource,
PingbackNotificationResource,
PingbackNotificationDismissedResource,
} from 'kolibri.resources';
import { setServerTime } from 'kolibri.utils.serverClock';
import urls from 'kolibri.urls';
import redirectBrowser from 'kolibri.utils.redirectBrowser';
import CatchErrors from 'kolibri.utils.CatchErrors';
import Vue from 'kolibri.lib.vue';
import Lockr from 'lockr';
import { set, get } from '@vueuse/core';
import useUser from 'kolibri.coreVue.composables.useUser';
import {
DisconnectionErrorCodes,
LoginErrors,
Expand All @@ -25,7 +22,6 @@ import {
} from 'kolibri.coreVue.vuex.constants';
import { baseSessionState } from '../session';
import { browser, os } from '../../../utils/browserInfo';
import useConnection from '../../../composables/useConnection';

const logging = logger.getLogger(__filename);

Expand All @@ -36,16 +32,6 @@ const logging = logger.getLogger(__filename);
* the API to state in the Vuex store
*/

function _notificationListState(data) {
return data.map(notification => ({
id: notification.id,
version_range: notification.version_range,
timestamp: notification.timestamp,
link_url: notification.link_url,
i18n: notification.i18n,
}));
}

/**
* Actions
*
Expand All @@ -70,7 +56,7 @@ export function handleApiError(store, { error, reloadOnReconnect = false } = {})
if (DisconnectionErrorCodes.includes(error.response.status)) {
// Do not log errors for disconnections, as it disrupts the user experience
// and should already be being handled by our disconnection overlay.
set(useConnection().reloadOnReconnect, reloadOnReconnect);
heartbeat.setReloadOnReconnect(reloadOnReconnect);
return;
}
// Reassign object properties here as Axios error objects have built in
Expand Down Expand Up @@ -179,36 +165,6 @@ export function setPageVisibility(store) {
_setPageVisibility(store, document.visibilityState === 'visible');
}

export function getNotifications(store) {
const { isAdmin, isSuperuser } = useUser();
if (get(isAdmin) || get(isSuperuser)) {
return PingbackNotificationResource.fetchCollection()
.then(notifications => {
logging.info('Notifications set.');
store.commit('CORE_SET_NOTIFICATIONS', _notificationListState(notifications));
})
.catch(error => {
store.dispatch('handleApiError', { error });
});
}
return Promise.resolve();
}

export function saveDismissedNotification(store, notification_id) {
const { user_id } = useUser();
const dismissedNotificationData = {
user: get(user_id),
notification: notification_id,
};
return PingbackNotificationDismissedResource.saveModel({ data: dismissedNotificationData })
.then(() => {
store.commit('CORE_REMOVE_NOTIFICATION', notification_id);
})
.catch(error => {
store.dispatch('handleApiError', { error });
});
}

export function getFacilities(store) {
return FacilityResource.fetchCollection({ force: true }).then(facilities => {
store.commit('CORE_SET_FACILITIES', [...facilities]);
Expand Down
19 changes: 0 additions & 19 deletions kolibri/core/assets/src/utils/contentNodeUtils.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Vue from 'vue';
import { render, screen } from '@testing-library/vue';
import useUser, { useUserMock } from 'kolibri.coreVue.composables.useUser';
import { RENDERER_SUFFIX } from 'kolibri.coreVue.vuex.constants';
import DownloadButton from '../DownloadButton.vue';
import { RENDERER_SUFFIX } from '../constants';

jest.mock('kolibri.coreVue.composables.useUser');

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Vue from 'vue';
import { RENDERER_SUFFIX } from 'kolibri.coreVue.vuex.constants';
import { canRenderContent, getRenderableFiles, getDefaultFile, getFilePreset } from '../utils';
import { RENDERER_SUFFIX } from '../constants';

// Add a component to the Vue instance that can be used to test the utility functions
const addRegisterableComponents = (...presets) => {
Expand Down
1 change: 0 additions & 1 deletion kolibri/core/assets/src/views/ContentRenderer/constants.js

This file was deleted.

2 changes: 1 addition & 1 deletion kolibri/core/assets/src/views/ContentRenderer/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RENDERER_SUFFIX } from './constants';
import { RENDERER_SUFFIX } from 'kolibri.coreVue.vuex.constants';
import ContentRendererError from './ContentRendererError';
import { canRenderContent, getRenderableFiles, getDefaultFile, getFilePreset } from './utils';

Expand Down
2 changes: 1 addition & 1 deletion kolibri/core/assets/src/views/ContentRenderer/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Vue from 'vue';
import { RENDERER_SUFFIX } from './constants';
import { RENDERER_SUFFIX } from 'kolibri.coreVue.vuex.constants';

export const canRenderContent = preset => Boolean(Vue.options.components[preset + RENDERER_SUFFIX]);

Expand Down
2 changes: 1 addition & 1 deletion kolibri/core/assets/src/views/ExamReport/utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import has from 'lodash/has';
import logger from 'kolibri.lib.logging';
import { masteryModelValidator } from '../../utils/contentNodeUtils';
import { masteryModelValidator } from 'kolibri-common/utils/contentNode';

export const logging = logger.getLogger(__filename);

Expand Down
2 changes: 1 addition & 1 deletion kolibri/core/assets/src/views/MasteryModel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<script>
import { MasteryModelTypes } from 'kolibri.coreVue.vuex.constants';
import { masteryModelValidator } from '../utils/contentNodeUtils';
import { masteryModelValidator } from 'kolibri-common/utils/contentNode';
export default {
name: 'MasteryModel',
Expand Down
Loading

0 comments on commit 6f33576

Please sign in to comment.