Skip to content

Commit

Permalink
(fix)As a user i want to embed items from ansa meta search to article…
Browse files Browse the repository at this point in the history
… body using drag and drop (sdansa 208) (#2663)

* Allow adding embed URLs by drag and dropping

* code style

* eslint autofix

* check if embeds are configured for content profile

* fix lint errors
  • Loading branch information
tomaskikutis authored and petrjasek committed Nov 20, 2018
1 parent 1695c12 commit 646019c
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 7 deletions.
6 changes: 2 additions & 4 deletions scripts/apps/search/MultiImageEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,8 @@ export function MultiImageEditController(
$scope.cancelHandler();
}
});
} else {
if (typeof $scope.cancelHandler === 'function') {
$scope.cancelHandler();
}
} else if (typeof $scope.cancelHandler === 'function') {
$scope.cancelHandler();
}
};

Expand Down
6 changes: 5 additions & 1 deletion scripts/apps/settings/settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ class SettingsComponent extends React.Component<IProps, IState> {
}

superdesk.getMenu(superdesk.MENU_SETTINGS).then((flatMenuItems) => {
this.setState({flatMenuItems: flatMenuItems, loading: false});
this.setState({
flatMenuItems: flatMenuItems.sort((a, b) =>
b.settings_menu_group.priority - a.settings_menu_group.priority),
loading: false,
});
});
}
render() {
Expand Down
38 changes: 38 additions & 0 deletions scripts/apps/vocabularies/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import {get} from 'lodash';
// Adding the following because planning webpack when compiled for test cases
// won't be aware of gettext.
const gettext = get(window, 'gettext', (text) => text);

export const MEDIA_TYPES = {
GALLERY: {
id: 'media',
label: gettext('Media gallery'),
},
RELATED_CONTENT: {
id: 'related_content',
label: gettext('Related items'),
},
};

export const MEDIA_TYPE_KEYS = Object.keys(MEDIA_TYPES).map((type) => MEDIA_TYPES[type].id);

export const VOCABULARY_SELECTION_TYPES = {
SINGLE_SELECTION: {
id: 'single selection',
label: gettext('Single selection'),
},
MULTIPLE_SELECTION: {
id: 'multi selection',
label: gettext('Multi selection'),
},
DO_NOT_SHOW: {
id: 'do not show',
label: gettext('Do not show'),
},
};

export const DEFAULT_SCHEMA = {
name: {},
qcode: {},
parent: {},
};
8 changes: 6 additions & 2 deletions scripts/core/editor3/components/BaseUnstyledComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,16 @@ class BaseUnstyledComponent extends React.Component<any, any> {
const blockKey = this.getDropBlockKey();
const link = event.originalEvent.dataTransfer.getData('URL');

if (typeof link === 'string' && link.startsWith('http')) {
if (
typeof link === 'string'
&& link.startsWith('http')
&& this.props.editorProps.editorFormat.includes('embed')
) {
getEmbedObject(link)
.then((oEmbed) => {
this.props.dispatch(embed(oEmbed, blockKey));
});
} else if (mediaType === 'text/html') {
} else if (mediaType === 'text/html' && this.props.editorProps.editorFormat.includes('embed')) {
this.props.dispatch(embed(event.originalEvent.dataTransfer.getData(mediaType), blockKey));
} else if (canDropMedia(event, this.props.editorProps)) { // Dropping new media
const {dataTransfer} = event.originalEvent;
Expand Down

0 comments on commit 646019c

Please sign in to comment.