Skip to content
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## [Unreleased]
### Removed
- Ability to create new components when moving files.

## [0.14.0] - 2018-02-07
### Added
Expand Down
59 changes: 11 additions & 48 deletions addon/components/file-browser/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ export default Ember.Component.extend(Analytics, {
selectedFile: null,
node: null,
nodeTitle: null,
newNodeType: null,
newProject: false,
projectSelectState: 'main',
willCreateComponent: false,
willMoveToNode: false,
isInputInvalid: true,
nodeLink: Ember.computed.alias('node.links.html'),
isMoving: false,

init() {
this._super(...arguments);
Expand Down Expand Up @@ -384,8 +383,6 @@ export default Ember.Component.extend(Analytics, {
closeModal() {
if (this.get('modalOpen') == 'move') {
this.set('projectSelectState', 'main');
this.set('willCreateComponent', false);
this.set('willMoveToNode', false);
}
this.set('modalOpen', false);
},
Expand All @@ -406,59 +403,32 @@ export default Ember.Component.extend(Analytics, {
},
checkNodeTitleKeypress(value) {
this.set('nodeTitle', value);
if (this.get('nodeTitle')) {
this.set('isInputInvalid', false);
} else {
this.set('isInputInvalid', true);
}
this.set('isInputInvalid', Ember.isBlank(value));
},
changeProjectSelectState(state) {
this.set('projectSelectState', state);
this.set('willCreateComponent', false);
this.set('willMoveToNode', false);
if (!this.get('isInputInvalid')) {
this.set('isInputInvalid', true);
}
},
updateCreateOrMoveNode(state) {
if (state == 'create') {
this.set('willCreateComponent', true);
this.set('willMoveToNode', false);
this.set('isInputInvalid', true);
} else {
this.set('willCreateComponent', false);
this.set('willMoveToNode', true);
this.set('isInputInvalid', false);
}
this.set('isInputInvalid', true);
},
setSelectedNode(node, isChild) {
this.set('node', node);
this.set('isChildNode', isChild);
this.set('isInputInvalid', false);
},
setMoveFile() {
this.set('isMoving', true);
let selectedItem = this.get('selectedItems.firstObject');
let title = this.get('nodeTitle');

if (this.get('projectSelectState') == 'newProject') {
this.set('newNodeType', 'project');
this.set('newProject', true);
this._createProject(title).then(project => {
this.set('node', project);
this._addNewNodeToList(this.get('user'), project);
this._moveFile(selectedItem, project);
});
} else if (this.get('projectSelectState') == 'existingProject') {
if (this.get('willCreateComponent')) {
this.set('newNodeType', 'component');
this._createComponent(title).then(component => {
this.set('node', component);
this._addNewNodeToList(this.get('user'), component);
this._moveFile(selectedItem, component);
});
} else if (this.get('willMoveToNode')) {
this._moveFile(selectedItem, this.get('node'));

this.set('newNodeType', null);
}
this._moveFile(selectedItem, this.get('node'));
this.set('newProject', false);
}
},
},
Expand All @@ -472,13 +442,6 @@ export default Ember.Component.extend(Analytics, {
this.get('i18n').t('eosf.components.moveToProject.couldNotCreateProject')
));
},
_createComponent(title) {
return this.get('node')
.addChild(title, null, '', true)
.catch(() => this.get('toast').error(
this.get('i18n').t('eosf.components.moveToProject.couldNotCreateComponent')
));
},
_moveFile(item, node) {
item.move(node)
.then(() => {
Expand All @@ -490,11 +453,11 @@ export default Ember.Component.extend(Analytics, {
this.set('modalOpen', 'successMove');
this.set('projectSelectState', 'main');
this.set('willCreateComponent', false);
this.set('willMoveToNode', false);
this.send('track', 'move', 'track', 'Quick Files - Move to project');
})
.catch(() => this.get('toast').error(
this.get('i18n').t('eosf.components.moveToProject.couldNotMoveFile')
));
))
.then(() => this.set('isMoving', false));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to refactor this component to use ember-concurrency tasks instead of chained promises, but that can be another time.

},
});
15 changes: 4 additions & 11 deletions addon/components/file-browser/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,7 @@
<button {{action 'viewItem'}} class='btn text-primary'>{{fa-icon "file-o"}} View</button>
{{/if}}
{{#if (if-filter 'move-button' display)}}
{{!-- temporarily disable move button
<button {{action 'openModal' 'move'}} class='btn text-primary'>{{fa-icon "level-up"}} Move</button>
--}}
{{/if}}
{{#if (and edit (if-filter 'delete-button' display))}}
<button {{action 'openModal' 'delete'}} class='btn text-danger'>{{fa-icon "trash"}} Delete</button>
Expand Down Expand Up @@ -173,20 +171,17 @@
isLoadingProjects=isLoadingProjects
file=selectedItems.firstObject
projectSelectState=projectSelectState
willCreateComponent=willCreateComponent
willMoveToNode=willMoveToNode
showErrorMessage=showErrorMessage
setSelectedNode=(action 'setSelectedNode')
changeProjectSelectState=(action 'changeProjectSelectState')
updateCreateOrMoveNode=(action 'updateCreateOrMoveNode')
checkNodeTitleKeypress=(action 'checkNodeTitleKeypress')
}}
{{/modal.body}}
{{#modal.footer}}
{{#bs-button onClick=(action 'closeModal') type='default'}}Cancel{{/bs-button}}
{{#bs-button disabled=isMoving onClick=(action 'closeModal') type='default'}}Cancel{{/bs-button}}
{{#if (not-eq projectSelectState 'main')}}
{{#bs-button onClick=(action 'changeProjectSelectState' 'main') type='default'}}Back{{/bs-button}}
{{#bs-button disabled=isInputInvalid onClick=(action 'setMoveFile') type='primary'}}Move file{{/bs-button}}
{{#bs-button disabled=isMoving onClick=(action 'changeProjectSelectState' 'main') type='default'}}Back{{/bs-button}}
{{#bs-button disabled=(or isInputInvalid isMoving) onClick=(action 'setMoveFile') type='primary'}}Move file{{/bs-button}}
{{/if}}
{{/modal.footer}}
{{/bs-modal}}
Expand All @@ -197,10 +192,8 @@
{{#modal.footer}}
{{#bs-button type='default' onClick=(action 'closeModal')}}{{t "eosf.components.moveToProject.keepWorkingHere"}}{{/bs-button}}
<a class="btn btn-success" href="{{nodeLink}}">
{{#if (eq newNodeType 'project')}}
{{#if newProject}}
{{t "eosf.components.moveToProject.goToNewProject"}}
{{else if (eq newNodeType 'component')}}
{{t "eosf.components.moveToProject.goToNewComponent"}}
{{else if isChildNode}}
{{t "eosf.components.moveToProject.goToComponent"}}
{{else}}
Expand Down
9 changes: 1 addition & 8 deletions addon/components/project-selector/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@ import layout from './template';
* user=user
* file=file
* projectSelectState=projectSelectState
* willCreateComponent=willCreateComponent
* willMoveToNode=willMoveToNode
* setSelectedNode=(action 'setSelectedNode')
* changeProjectSelectState=(action 'changeProjectSelectState')
* updateCreateOrMoveNode=(action 'updateCreateOrMoveNode')
* checkNodeTitleKeypress=(action 'checkNodeTitleKeypress')}
* ```
* @class project-selector
Expand All @@ -36,8 +33,6 @@ export default Ember.Component.extend({
projectSelectState: 'main',
selectedProject: null,
isLoadingProjects: true,
willCreateComponent: false,
willMoveToNode: false,
showErrorMessage: null,
projectList: Ember.A(),
isProjectPublic: Ember.computed.alias('selectedProject.public'),
Expand All @@ -51,11 +46,9 @@ export default Ember.Component.extend({

actions: {
changeState(state) {
this.set('selectedProject', null);
this.changeProjectSelectState(state);
},
updateCreateOrMoveNode(state) {
this.updateCreateOrMoveNode(state);
},
checkNodeTitleKeypress(value) {
this.checkNodeTitleKeypress(value);
},
Expand Down
59 changes: 12 additions & 47 deletions addon/components/project-selector/template.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -50,56 +50,21 @@
</p>
{{/if}}
{{#if selectedProject}}
<div>
<h5>{{t "eosf.components.moveToProject.organizeProject"}}</h5>
<p class="text-muted text-smaller m-t-xs">
{{if isChildNode (t "eosf.components.moveToProject.organizeChildNode") (t "eosf.components.moveToProject.organizeParentNode")}}
</p>
<div class="row text-center m-v-md">
<div class="toggle-button">
<input id="create" onchange={{action 'updateCreateOrMoveNode' 'create'}} type="radio" name="createComponentDecision" checked={{willCreateComponent}}>
<label class="wide-text-only" for="create">
{{fa-icon "plus-circle"}} {{t "eosf.components.moveToProject.createComponent"}}
</label>

<input id="moveToNode" onchange={{action 'updateCreateOrMoveNode' 'move'}} type="radio" name="createComponentDecision" checked={{willMoveToNode}}>
<label class="wide-text-only" for="moveToNode">
{{fa-icon "cube"}}
{{#if isChildNode}}
{{t "eosf.components.moveToProject.useCurrentComponent"}}
{{else}}
{{t "eosf.components.moveToProject.useCurrentProject"}}
{{/if}}
</label>
</div>
</div>
</div>
{{#if willCreateComponent}}
{{input
type='text'
placeholder=(t "eosf.components.moveToProject.enterComponentTitle")
class="form-control"
name='nodeTitle'
id='projectTitle'
key-up='checkNodeTitleKeypress'}}
{{/if}}
{{#if (or willCreateComponent willMoveToNode)}}
<p class="m-t-lg">
<p class="m-t-lg">
{{#if isChildNode}}
{{t "eosf.components.moveToProject.convertOrCopyMessage.component"}}
{{else}}
{{t "eosf.components.moveToProject.convertOrCopyMessage.project"}}
{{/if}}
</p>
{{#unless isProjectPublic}}
<p class="text-danger m-t-sm">
{{#if isChildNode}}
{{t "eosf.components.moveToProject.convertOrCopyMessage.component"}}
{{t "eosf.components.moveToProject.noLongerPublicWarning.component"}}
{{else}}
{{t "eosf.components.moveToProject.convertOrCopyMessage.project"}}
{{t "eosf.components.moveToProject.noLongerPublicWarning.project"}}
{{/if}}
</p>
{{#unless isProjectPublic}}
<p class="text-danger m-t-sm">
{{#if isChildNode}}
{{t "eosf.components.moveToProject.noLongerPublicWarning.component"}}
{{else}}
{{t "eosf.components.moveToProject.noLongerPublicWarning.project"}}
{{/if}}
</p>
{{/unless}}
{{/if}}
{{/unless}}
{{/if}}
{{/if}}
9 changes: 0 additions & 9 deletions addon/locales/en/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,19 +220,11 @@ export default {
createNewProject: 'Create new project',
connectToExisting: 'Connect file to existing OSF project',
enterProjectTitle: 'Enter project title',
enterComponentTitle: 'Enter component title',
newProjectMessage: 'You have selected to create a new public project for your file. Users will still have access to your file unless the project becomes private.',
chooseProject: 'Choose project',
projectSelectMessage: 'The list of projects appearing are projects and components for which you have write access. Registrations are not included here.',
noProjectsExistError: 'You have no available projects. Go back to create a new project.',
organizeProject: 'Organize',
organizeParentNode: 'You can organize your file by storing it in the project or its own component.',
organizeChildNode: 'You can organize your file by storing it in the component or its own component.',
createComponent: 'Create component',
couldNotCreateComponent: 'Could not create component. Please try again.',
couldNotCreateProject: 'Could not create project. Please try again.',
useCurrentComponent: 'Use current component',
useCurrentProject: 'Use current project',
convertOrCopyMessage: {
project: 'Clicking "Move file" will immediately make changes to your OSF project and move your file.',
component: 'Clicking "Move file" will immediately make changes to your OSF component and move your file.',
Expand All @@ -245,7 +237,6 @@ export default {
couldNotMoveFile: 'Could not move file. Please try again',
keepWorkingHere: 'Keep working here',
goToNewProject: 'Go to new project',
goToNewComponent: 'Go to new component',
goToComponent: 'Go to component',
goToProject: 'Go to project',
},
Expand Down