Skip to content

Commit

Permalink
Merge pull request #2102 from ucfopen/dev/32-pigeonite
Browse files Browse the repository at this point in the history
Dev/32 - Pigeonite
  • Loading branch information
FrenjaminBanklin authored Sep 21, 2023
2 parents 5693d59 + a785647 commit e8050b0
Show file tree
Hide file tree
Showing 134 changed files with 8,311 additions and 3,466 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [14.x]
node-version: [18.x]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand All @@ -19,10 +19,10 @@ jobs:
# should help to speed up yarn install and be safe
# across changes to the repo and platforms
- name: Cache Yarn Deps
uses: c-hive/gha-yarn-cache@v1
uses: c-hive/gha-yarn-cache@v1

- run: echo "github.ref = ${{ github.ref }}"

# frozen lockfile should make the cache more effective
# and our tests more predictable
- run: yarn install --frozen-lockfile
Expand All @@ -35,7 +35,7 @@ jobs:
# will fail the PRs that need prettier run on them
- name: Does Prettier Need to Be Run
run: git --no-pager diff --exit-code -- .

- run: yarn test:ci

build_docker_images:
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
- name: NPM - Test, Build, Deploy
uses: actions/setup-node@v1
with:
node-version: 14
node-version: 18
registry-url: https://registry.npmjs.org/

- name: Cache Yarn Deps
Expand Down
2 changes: 1 addition & 1 deletion docker/dockerfiles/obojobo-node-debian.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# =====================================================================================================
# Base stage used for build and final stages
# =====================================================================================================
FROM node:14.16.0-alpine AS base_stage
FROM node:18.16.0-alpine AS base_stage

# ======== PUT NEW NODE BIN DIR IN PATH
RUN npm config set prefix '/home/node/.npm-global'
Expand Down
2 changes: 1 addition & 1 deletion docker/obojobo-pm2-server-src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "obojobo-pm2-server-app",
"version": "16.0.1",
"version": "17.0.0",
"description": "Reference project for deploying and customizing an Obojobo Next server",
"main": "./index.js",
"private": true,
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"packages": [
"packages/**/*"
],
"version": "16.0.1",
"version": "17.0.0",
"command": {
"command": {
"run": {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "obojobo-next",
"version": "16.0.1",
"version": "17.0.0",
"repository": "https://github.com/ucfopen/Obojobo.git",
"homepage": "https://ucfopen.github.io/Obojobo-Docs/",
"license": "AGPL-3.0-only",
Expand Down Expand Up @@ -103,6 +103,6 @@
],
"engines": {
"yarn": "^1.15.2",
"node": "^14.16.0"
"node": "^18.16.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,33 @@ describe('EditorAPI', () => {
expect(res).toBe(mockJsonResult)
})

test('copyDraft fetches with the correct args', async () => {
test('copyDraft fetches with the correct args - allow default readOnly', async () => {
const res = await EditorAPI.copyDraft('draft-id', 'new-title')

expect(post).toHaveBeenCalledWith('/api/drafts/draft-id/copy', { title: 'new-title' })
expect(post).toHaveBeenCalledWith('/api/drafts/draft-id/copy', {
title: 'new-title',
readOnly: false
})
expect(res).toBe(mockJsonResult)
})

test('copyDraft fetches with the correct args - readOnly true', async () => {
const res = await EditorAPI.copyDraft('draft-id', 'new-title', true)

expect(post).toHaveBeenCalledWith('/api/drafts/draft-id/copy', {
title: 'new-title',
readOnly: true
})
expect(res).toBe(mockJsonResult)
})

test('copyDraft fetches with the correct args - readOnly false', async () => {
const res = await EditorAPI.copyDraft('draft-id', 'new-title', false)

expect(post).toHaveBeenCalledWith('/api/drafts/draft-id/copy', {
title: 'new-title',
readOnly: false
})
expect(res).toBe(mockJsonResult)
})

Expand Down Expand Up @@ -147,7 +170,10 @@ describe('EditorAPI', () => {
expect.hasAssertions()

return EditorAPI.copyDraft('mock-draft-id', 'new title').then(result => {
expect(post).toHaveBeenCalledWith('/api/drafts/mock-draft-id/copy', { title: 'new title' })
expect(post).toHaveBeenCalledWith('/api/drafts/mock-draft-id/copy', {
title: 'new title',
readOnly: false
})
expect(result).toEqual(mockJsonResult)
})
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

exports[`File Menu File Menu node 1`] = `
"<div class=\\"visual-editor--drop-down-menu\\"><div class=\\"dropdown is-not-open\\" tabindex=\\"-1\\"><button class=\\"menu-title\\">File</button><div class=\\"menu-items\\"><button>Save Module<span>
CTRL+S</span></button><button>New</button><button>Make a copy...</button><div class=\\"dropdown is-not-open\\" tabindex=\\"-1\\"><button class=\\"menu-title\\">Download</button><div class=\\"menu-items\\"><button>XML Document (.xml)</button><button>JSON Document (.json)</button></div></div><button>Import from file...</button><button disabled=\\"\\">Delete Module...</button><button>Copy LTI Link</button></div></div></div>"
CTRL+S</span></button><button>New</button><button>Make a copy...</button><button>Make a read-only copy...</button><div class=\\"dropdown is-not-open\\" tabindex=\\"-1\\"><button class=\\"menu-title\\">Download</button><div class=\\"menu-items\\"><button>XML Document (.xml)</button><button>JSON Document (.json)</button></div></div><button>Import from file...</button><button disabled=\\"\\">Delete Module...</button><button>Copy LTI Link</button></div></div></div>"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,20 @@ describe('File Menu', () => {
expect(ModalUtil.show).toHaveBeenCalled()
})

test('FileMenu calls Copy (Read-Only)', () => {
const model = {
title: 'mockTitle'
}

const component = mount(<FileMenu draftId="mockDraft" model={model} />)

component
.findWhere(n => n.type() === 'button' && n.html().includes('Make a read-only copy...'))
.simulate('click')

expect(ModalUtil.show).toHaveBeenCalled()
})

test('FileMenu calls Download', done => {
// setup
const model = {
Expand Down Expand Up @@ -243,7 +257,49 @@ describe('File Menu', () => {
.instance()
.copyModule('new title')
.then(() => {
expect(EditorAPI.copyDraft).toHaveBeenCalledWith('mockDraftId', 'new title')
expect(EditorAPI.copyDraft).toHaveBeenCalledWith('mockDraftId', 'new title', false)
})
})

test('copyModuleReadOnly calls copyDraft api', () => {
expect.hasAssertions()
const model = {
flatJSON: () => ({ children: [] }),
children: [
{
get: () => CONTENT_NODE,
flatJSON: () => ({ children: [] }),
children: { models: [{ get: () => 'mockValue' }] }
},
{
get: () => ASSESSMENT_NODE
}
]
}

const exportToJSON = jest.fn()

const component = mount(
<FileMenu
draftId="mockDraftId"
model={model}
exportToJSON={exportToJSON}
onSave={jest.fn()}
/>
)

EditorAPI.copyDraft.mockResolvedValueOnce({
status: 'ok',
value: {
draftId: 'new-copy-draft-id'
}
})

return component
.instance()
.copyModuleReadOnly('new title')
.then(() => {
expect(EditorAPI.copyDraft).toHaveBeenCalledWith('mockDraftId', 'new title', true)
})
})

Expand Down
4 changes: 2 additions & 2 deletions packages/app/obojobo-document-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "obojobo-document-engine",
"version": "16.0.1",
"version": "17.0.0",
"license": "AGPL-3.0-only",
"description": "",
"engines": {
"node": "^14.16.0"
"node": "^18.16.0"
},
"main": "index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
margin-bottom: 10rem;

span::selection {
background-color: highlight; /* stylelint-disable-line sh-waqar/declaration-use-variable */
color: inherit; /* stylelint-disable-line sh-waqar/declaration-use-variable */
background-color: highlight; /* stylelint-disable-line scale-unlimited/declaration-strict-value */
color: inherit; /* stylelint-disable-line scale-unlimited/declaration-strict-value */
}

.draft-toolbars {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@
cursor: pointer;
padding: 0;
margin: 0;
color: inherit; /* stylelint-disable-line sh-waqar/declaration-use-variable */
color: inherit; /* stylelint-disable-line scale-unlimited/declaration-strict-value */
font-weight: inherit;
text-align: left;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class FileMenu extends React.PureComponent {
constructor(props) {
super(props)
this.copyModule = this.copyModule.bind(this)
this.copyModuleReadOnly = this.copyModuleReadOnly.bind(this)
this.deleteModule = this.deleteModule.bind(this)
this.buildFileSelector = this.buildFileSelector.bind(this)
}
Expand All @@ -27,13 +28,37 @@ class FileMenu extends React.PureComponent {
})
}

copyModule(newTitle) {
copyModule(newTitle, readOnly = false) {
ModalUtil.hide()
return EditorAPI.copyDraft(this.props.draftId, newTitle).then(result => {
window.open(window.location.origin + '/editor/visual/' + result.value.draftId, '_blank')
return EditorAPI.copyDraft(this.props.draftId, newTitle, readOnly).then(result => {
if (readOnly) {
const buttons = [
{
value: 'OK',
onClick: ModalUtil.hide,
default: true
}
]
ModalUtil.show(
<Dialog buttons={buttons} title="Read-Only Copy Created">
A read-only copy of this module has been created.
<br />
Read-only copies can not be edited directly.
<br />
View the read-only copy in the dashboard to optionally synchronize any edits made to
this module.
</Dialog>
)
} else {
window.open(window.location.origin + '/editor/visual/' + result.value.draftId, '_blank')
}
})
}

copyModuleReadOnly(newTitle) {
return this.copyModule(newTitle, true)
}

processFileContent(id, content, type) {
EditorAPI.postDraft(
id,
Expand Down Expand Up @@ -101,6 +126,19 @@ class FileMenu extends React.PureComponent {
/>
)
},
{
name: 'Make a read-only copy...',
type: 'action',
action: () =>
ModalUtil.show(
<Prompt
title="Copy Module (Read-Only)"
message="Enter the title for the copied module:"
value={this.props.title + ' - Copy'}
onConfirm={this.copyModuleReadOnly}
/>
)
},
{
name: 'Download',
type: 'sub-menu',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@
cursor: pointer;
padding: 0;
margin: 0;
color: inherit; /* stylelint-disable-line sh-waqar/declaration-use-variable */
color: inherit; /* stylelint-disable-line scale-unlimited/declaration-strict-value */
font-weight: inherit;
text-align: left;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ const EditorAPI = {
return API.delete(`/api/drafts/${draftId}`).then(API.processJsonResults)
},

copyDraft(draftId, newTitle) {
return API.post(`/api/drafts/${draftId}/copy`, { title: newTitle }).then(API.processJsonResults)
copyDraft(draftId, newTitle, readOnly = false) {
return API.post(`/api/drafts/${draftId}/copy`, { title: newTitle, readOnly }).then(
API.processJsonResults
)
},

requestEditLock(draftId, contentId) {
Expand Down
6 changes: 3 additions & 3 deletions packages/app/obojobo-document-json-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"xml-formatter": "^2.4.0"
},
"peerDependencies": {
"obojobo-document-engine": "^16.0.1",
"obojobo-lib-utils": "^16.0.1"
"obojobo-document-engine": "^17.0.0",
"obojobo-lib-utils": "^17.0.0"
},
"name": "obojobo-document-json-parser",
"version": "16.0.1",
"version": "17.0.0",
"license": "AGPL-3.0-only",
"main": "",
"scripts": {
Expand Down
4 changes: 2 additions & 2 deletions packages/app/obojobo-document-xml-parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"xml-js": "^1.0.2"
},
"peerDependencies": {
"obojobo-lib-utils": "^16.0.1"
"obojobo-lib-utils": "^17.0.0"
},
"name": "obojobo-document-xml-parser",
"version": "16.0.1",
"version": "17.0.0",
"license": "AGPL-3.0-only",
"main": "xml2draft.js",
"scripts": {
Expand Down
Loading

0 comments on commit e8050b0

Please sign in to comment.