Skip to content

Commit

Permalink
Merge branch 'authoring-react' into broadcasting
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaskikutis committed Sep 28, 2023
2 parents b3f054b + 3ba1154 commit da35e70
Show file tree
Hide file tree
Showing 11 changed files with 552 additions and 374 deletions.
854 changes: 512 additions & 342 deletions po/superdesk.pot

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions scripts/apps/users/directives/UserPreferencesDirective.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import {gettext} from 'core/utils';
import {appConfig, getUserInterfaceLanguage} from 'appConfig';
import {applyDefault} from 'core/helpers/typescript-helpers';

const THEME_LIGHT = 'light-ui';

/**
* @ngdoc directive
* @module superdesk.apps.users
Expand Down Expand Up @@ -44,8 +46,13 @@ export function UserPreferencesDirective(
const body = angular.element('body');

scope.activeNavigation = null;

scope.activeTheme = localStorage.getItem('theme');

if (scope.activeTheme === '') {
scope.activeTheme = THEME_LIGHT;
}

scope.$watch('activeTheme', (val) => {
if (!val) {
return;
Expand Down
12 changes: 6 additions & 6 deletions scripts/apps/users/views/edit-form.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,17 @@ <h5>{{ user.username}}</h5>
</div>
</div>

<h3 id="user-password" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3 sd-margin-b--0-5">Password</h3>
<h3 id="user-password" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3 sd-margin-b--0-5" translate>Password</h3>
<div class="sd-container sd-container--flex sd-container--gap-none sd-container--direction-column sd-radius--medium sd-panel-bg--000 sd-shadow--z2 sd-padding--3 sd-state--focus sd-margin-b--3">
<div sd-info-item class="password button-group button-group--center button-group--comfort" ng-if="features.reset_user_password && user._id && !profile && user.is_enabled && _active" id="password-reset-trigger">
<span class="change-btn btn btn--hollow btn--primary" ng-click="show.reset_password = !show.reset_password" ng-show="!show.reset_password">reset password</span>
<span class="change-btn btn btn--hollow btn--primary" ng-click="show.reset_password = !show.reset_password" ng-show="!show.reset_password" translate>reset password</span>
</div>
<div sd-info-item class="password button-group button-group--center button-group--comfort" ng-if="features.reset_user_password && user._id && profile" id="password-change-trigger">
<span class="change-btn btn btn--hollow btn--primary" ng-click="show.change_password = !show.change_password" ng-show="!show.change_password">change password</span>
<span class="change-btn btn btn--hollow btn--primary" ng-click="show.change_password = !show.change_password" ng-show="!show.change_password" translate>change password</span>
</div>
</div>

<h3 id="user-desk" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3 sd-margin-b--0-5">Default desk</h3>
<h3 id="user-desk" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3 sd-margin-b--0-5" translate>Default desk</h3>
<div class="sd-container sd-container--flex sd-container--gap-none sd-container--direction-column sd-radius--medium sd-panel-bg--000 sd-shadow--z2 sd-padding--3 sd-state--focus sd-margin-b--3">
<div sd-info-item class="form__group form__group--default form__group--mb-0 form__group--inline-label" ng-if="userDesks && userDesks.length > 0">
<div class="form__item">
Expand All @@ -223,7 +223,7 @@ <h3 id="user-desk" class="sd-heading sd-text-align--left sd-text--sans sd-headi
</div>
</div>

<h3 id="user-language" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3 sd-margin-b--0-5">Language</h3>
<h3 id="user-language" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3 sd-margin-b--0-5" translate>Language</h3>
<div class="sd-container sd-container--flex sd-container--gap-none sd-container--direction-column sd-radius--medium sd-panel-bg--000 sd-shadow--z2 sd-padding--3 sd-state--focus sd-margin-b--3">
<div sd-info-item class="field__language form__group form__group--default form__group--mb-0 form__group--inline-label">
<div class="form__item">
Expand All @@ -243,7 +243,7 @@ <h3 id="user-language" class="sd-heading sd-text-align--left sd-text--sans sd-he

<!-- Author content -->
<div class="details-info" ng-show="user.is_author" id="authorDetails">
<h3 class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3 sd-margin-b--0-5">Author info</h3>
<h3 class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3 sd-margin-b--0-5" translate>Author info</h3>
<div class="sd-container sd-container--flex sd-container--gap-none sd-container--direction-column sd-radius--medium sd-panel-bg--000 sd-shadow--z2 sd-padding--3 sd-state--focus sd-margin-b--4">
<div class="field__email form__group form__group--default form__group--mb-3" sd-info-item ng-if="!hideSignOff">
<div class="form__item">
Expand Down
4 changes: 2 additions & 2 deletions scripts/apps/users/views/user-preferences.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div class="preferences__content">
<ul class="simple-list simple-list--comfortable simple-list--fixedW-large simple-list--users">
<li class="simple-list__item simple-list__item--stacked simple-list__item--justify-flex-start">
<h3 id="feature-preview" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3">Feature preview</h3>
<h3 id="feature-preview" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3" translate>Feature preview</h3>
<div class="sd-container sd-container--flex sd-container--gap-none sd-container--direction-column sd-radius--medium sd-panel-bg--000 sd-shadow--z2 sd-padding--3 sd-state--focus sd-margin-b--1">
<ul class="simple-list simple-list--comfortable simple-list--dotted simple-list--no-border-b simple-list--no-border-t sd-padding--2">
<li class="simple-list__item simple-list__item--stacked">
Expand All @@ -40,7 +40,7 @@ <h3 id="feature-preview" class="sd-heading sd-text-align--left sd-text--sans sd-
</li>

<li class="simple-list__item simple-list__item--stacked simple-list__item--justify-flex-start">
<h3 id="view-formats" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3">View formats</h3>
<h3 id="view-formats" class="sd-heading sd-text-align--left sd-text--sans sd-heading--h3" translate>View formats</h3>
<div class="sd-container sd-container--flex sd-container--gap-none sd-container--direction-column sd-radius--medium sd-panel-bg--000 sd-shadow--z2 sd-padding--3 sd-state--focus sd-margin-b--1">
<p class="sd-text sd-text--normal sd-text-align--left sd-text--sans sd-text-color--light">Select the prefered default view format for specific areas of Superdesks interface. The sections
will always open in the selected view format, but can be always changed using the view option dropdown in each section.</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class FormattingOptionsTreeSelect extends React.Component<IProps> {
label={gettext('Formatting options')}
labelHidden
inlineLabel
zIndex={1051}
/>
);
}
Expand Down
1 change: 1 addition & 0 deletions scripts/core/editor3/components/Editor3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const mapStateToProps = (state) => ({
const mapDispatchToProps = (dispatch) => ({
onChange: (editorState: EditorState) => dispatch(actions.changeEditorState(editorState)),
onTab: (e) => dispatch(actions.handleEditorTab(e)),
showPopup: (type, data) => dispatch(actions.showPopup(type, data)),
dragDrop: (transfer, mediaType) => dispatch(actions.dragDrop(transfer, mediaType)),
unlock: () => dispatch(actions.setLocked(false)),
dispatch: (x) => dispatch(x),
Expand Down
22 changes: 16 additions & 6 deletions scripts/core/editor3/components/Editor3Component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import UnstyledBlock from './UnstyledBlock';
import UnstyledWrapper from './UnstyledWrapper';
import * as Suggestions from '../helpers/suggestions';
import {getCurrentAuthor} from '../helpers/author';
import {setSpellcheckerProgress, applySpellcheck} from '../actions';
import {setSpellcheckerProgress, applySpellcheck, PopupTypes} from '../actions';
import {noop} from 'lodash';
import {getSpellcheckWarningsByBlock} from './spellchecker/SpellcheckerDecorator';
import {getSpellchecker} from './spellchecker/default-spellcheckers';
Expand Down Expand Up @@ -136,6 +136,7 @@ interface IProps {
onTab?(event): void;
dragDrop?(): void;
dispatch?(action: any): void;
showPopup?(type: any, data: any): void;
}

interface IState {
Expand Down Expand Up @@ -272,7 +273,19 @@ export class Editor3Component extends React.Component<IProps, IState> {
}

keyBindingFn(e) {
const {key, shiftKey} = e;
const {key, shiftKey, ctrlKey} = e;
const selectionState = this.props.editorState.getSelection();

if (
key === 'k'
&& ctrlKey
&& this.props.editorFormat.includes('link')
&& selectionState.isCollapsed() !== true
) {
this.props.showPopup(PopupTypes.Link, selectionState);
e.preventDefault();
return '';
}

if (key === 'ArrowDown' || key === 'ArrowUp') {
const autocompleteEl = document.querySelector(`.${editor3AutocompleteClassName}`) as HTMLElement | null;
Expand All @@ -295,10 +308,7 @@ export class Editor3Component extends React.Component<IProps, IState> {

// ctrl + X
if (key === 'x' && KeyBindingUtil.hasCommandModifier(e)) {
const {editorState} = this.props;
const selection = editorState.getSelection();

if (!selection.isCollapsed()) {
if (!selectionState.isCollapsed()) {
document.execCommand('copy'); // add selected text to clipboard
return 'delete';
}
Expand Down
2 changes: 1 addition & 1 deletion scripts/core/editor3/components/toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class ToolbarComponent extends React.Component<IProps, IState> {
<SelectionButton
onClick={showPopup(PopupTypes.Link)}
iconName="link"
tooltip={gettext('Link')}
tooltip={gettext('Link (Ctrl+K)')}
/>
)}
{has('embed') && (
Expand Down
9 changes: 0 additions & 9 deletions scripts/core/menu/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,6 @@ angular.module('superdesk.core.menu', [
});
}

scope.toggleTheme = function() {
scope.theme = scope.theme === 'dark-ui' ? '' : 'dark-ui';
localStorage.setItem('theme', scope.theme);

scope.theme ?
body.attr('data-theme', scope.theme) :
body.removeAttr('data-theme');
};

scope.toggleMenu = function() {
ctrl.flags.menu = !ctrl.flags.menu;
};
Expand Down
4 changes: 0 additions & 4 deletions scripts/core/menu/views/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ <h1 class="sd-top-menu__header" ng-if="currentRoute.category === 'superdesk.core
<sd-global-menu-horizontal></sd-global-menu-horizontal>
</div>

<button class="navbtn" ng-click="toggleTheme()">
<i class="icon-adjust" style="color: white"></i>
</button>

<button class="navbtn dropdown__toggle" ng-click="toggleNotifications()"
aria-label="{{ 'View notifications' | translate }}">
<span id="unread-count" class="badge badge--primary" ng-show="notifications.unread">{{
Expand Down
10 changes: 6 additions & 4 deletions scripts/core/superdesk-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1144,12 +1144,14 @@ declare module 'superdesk-api' {
archive_item: IArticle;
}

export interface IUserPrivileges {
[privilege: string]: 1 | 0;
}

export interface IUserRole extends IBaseRestApiResponse {
_id: string;
name: string;
privileges?: {
[privilege: string]: 1 | 0;
};
privileges?: IUserPrivileges;
author_role: string;
editor_role: string;
}
Expand Down Expand Up @@ -1224,7 +1226,7 @@ declare module 'superdesk-api' {
avatar: string;
avatar_renditions: {};
role?: IUserRole['_id'];
privileges: {};
privileges: IUserPrivileges;
user_type: 'user' | 'administrator';
is_support: boolean;
is_author: boolean;
Expand Down

0 comments on commit da35e70

Please sign in to comment.