Skip to content

Commit

Permalink
Merge branch 'develop' into uat
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLark86 committed Aug 16, 2023
2 parents b3fc55a + 92c7452 commit bf562a2
Show file tree
Hide file tree
Showing 35 changed files with 638 additions and 14,523 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- run: pip install black
- run: pip install black~=23.0
- run: black --diff .

flake8:
Expand Down
6 changes: 2 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ jobs:
python -m pip install --upgrade pip wheel setuptools
pip install -r dev-requirements.txt
- name: nosetests
run: nosetests tests
- name: pytest
run: pytest --log-level=ERROR --disable-warnings

- name: initialize data
run: python manage.py app:initialize_data
Expand All @@ -53,8 +53,6 @@ jobs:
- uses: actions/setup-node@v3
with:
node-version: 14.x
cache: 'npm'
cache-dependency-path: client/package-lock.json

- run: git config --global url."https://git@".insteadOf git://

Expand Down
2 changes: 1 addition & 1 deletion client/.npmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
package-lock=true
package-lock=false
6 changes: 4 additions & 2 deletions client/extensions/tga-author-profile-fields/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
},
"devDependencies": {
"superdesk-code-style": "1.5.0",
"typescript": "3.9.7",
"superdesk-ui-framework": "2.4.17"
"typescript": "~4.9.5"
},
"peerDependencies": {
"superdesk-ui-framework": "3.0.9"
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import * as React from 'react';

import {IEditorComponentProps, IUser} from 'superdesk-api';
import {IUser} from 'superdesk-api';
import {superdesk} from '../../superdesk';
import {IProfileTextFieldConfig} from './interfaces';
import {IProfileTextFieldProps} from './interfaces';
import {Input} from 'superdesk-ui-framework/react'

type IProps = IEditorComponentProps<string, IProfileTextFieldConfig>;

export class ProfileTextField extends React.PureComponent<IProps> {
constructor(props: IProps) {
export class ProfileTextField extends React.PureComponent<IProfileTextFieldProps> {
constructor(props: IProfileTextFieldProps) {
super(props);

this.onProfileIDChanged = this.onProfileIDChanged.bind(this);
Expand Down Expand Up @@ -47,14 +45,15 @@ export class ProfileTextField extends React.PureComponent<IProps> {
return this.props.config?.use_editor_3 ? (
<Editor3Html
key={this.props.item.extra?.profile_id}
value={this.props.value}
value={this.props.value ?? ''}
onChange={this.props.setValue}
readOnly={this.props.readOnly}
/>
) : (
<Input
key={this.props.item.extra?.profile_id}
value={this.props.value}
type="text"
disabled={this.props.readOnly}
onChange={this.props.setValue}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';

import {IPreviewComponentProps} from 'superdesk-api';

export class ProfileTextPreview extends React.PureComponent<IPreviewComponentProps> {
export class ProfileTextPreview extends React.PureComponent<IPreviewComponentProps<string>> {
render() {
return (
<div className="form__row form__row--small-padding">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,33 @@
import * as React from 'react';

import {ILiveResourcesProps, IRestApiResponse, IVocabulary} from 'superdesk-api';
import {ILiveResourcesProps, IRestApiResponse, IVocabulary, IVocabularyItem, IEditorComponentProps} from 'superdesk-api';
import {superdesk} from '../../superdesk';
import {IVocabularyFieldProps} from './interfaces';
import {IVocabularyFieldConfig} from './interfaces';

import {Select, Option} from "superdesk-ui-framework/react";
import {Select, Option, MultiSelect, Label} from 'superdesk-ui-framework/react';

type IVocabularyFieldValue = IVocabularyItem | Array<IVocabularyItem> | null | undefined;
type IVocabularyFieldProps = IEditorComponentProps<IVocabularyFieldValue, IVocabularyFieldConfig>

function getValueAsArray(value: IVocabularyFieldValue): Array<IVocabularyItem> {
if (value == null) {
return [];
} else if (!Array.isArray(value)) {
return [value];
}

return value;
}

function getValueAsDictionary(value: IVocabularyFieldValue): IVocabularyItem | null {
if (value == null) {
return null;
} else if (Array.isArray(value)) {
return value[0];
}

return value;
}


export class VocabularyField extends React.PureComponent<IVocabularyFieldProps> {
Expand All @@ -22,15 +45,46 @@ export class VocabularyField extends React.PureComponent<IVocabularyFieldProps>
<WithLiveResources resources={resources}>
{(resourcesResponse) => {
const vocab = resourcesResponse[0] as IRestApiResponse<IVocabulary>;
const isMultiSelect = vocab._items[0].selection_type === 'multi selection';
const items = vocab._items[0].items;

return (
return isMultiSelect ? (
<MultiSelect
value={getValueAsArray(this.props.value)}
options={items}
placeholder={'Select an item'}
optionLabel={(item) => item?.name || ''}
onChange={(newValues) => {
this.props.setValue(newValues);
}}
filter={true}
labelHidden={true}
label={'CV Items'}
inlineLabel={true}
itemTemplate={(item) => (
<div
className="sd-container sd-container--gap-medium"
style={{maxWidth: '600px'}} // Define max-width, so SDGs will fit in screen
>
<Label
text={item.qcode}
style="translucent"
/>
<span className="sd-text__normal sd-whitespace--normal">
{item.name}
</span>
</div>
)}
/>
) : (
<Select
onChange={(qcode) => {
this.props.setValue(items.find((item) => item.qcode === qcode));
}}
value={this.props.value?.qcode}
value={getValueAsDictionary(this.props.value)?.qcode}
inlineLabel={true}
label={'CV Item'}
labelHidden={true}
disabled={this.props.readOnly}
>
<Option />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import {IEditorComponentProps, IVocabularyItem} from 'superdesk-api';

export interface IVocabularyFieldConfig {
vocabulary_name: string;
allow_freetext: boolean;
exclude_from_content_api: boolean;
}

export type IVocabularyFieldProps = IEditorComponentProps<IVocabularyItem | null | undefined, IVocabularyFieldConfig>;
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
import * as React from 'react';

import {IPreviewComponentProps, IVocabularyItem,} from 'superdesk-api';
import {IPreviewComponentProps, IVocabularyItem} from 'superdesk-api';
import {SimpleList, SimpleListItem, Label} from 'superdesk-ui-framework/react';

export class VocabularyPreview extends React.PureComponent<IPreviewComponentProps> {
export class VocabularyPreview extends React.PureComponent<IPreviewComponentProps<IVocabularyItem | Array<IVocabularyItem>>> {
render() {
const item: IVocabularyItem = this.props.value;

return (
<div className="form__row form__row--small-padding">
<p className="sd-text__normal">
{item.name}
</p>
{!Array.isArray(this.props.value) ? (
<p className="sd-text__normal">
{this.props.value.name}
</p>
) : (
<SimpleList>
{this.props.value.map((value) => (
<SimpleListItem>
{value.qcode == null ? null : (
<Label
text={value.qcode}
style="translucent"
/>
)}
<p className="sd-text__normal sd-whitespace--normal">
{value.name}
</p>

</SimpleListItem>
))}
</SimpleList>
)}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import * as React from 'react';

import {ILiveResourcesProps, IRestApiResponse, IVocabulary, IVocabularyItem} from 'superdesk-api';
import {ILiveResourcesProps, IRestApiResponse, IVocabulary, IVocabularyItem, IEditorComponentProps} from 'superdesk-api';
import {superdesk} from '../../superdesk';
import {IVocabularyFieldProps} from './interfaces';

import {Autocomplete} from "superdesk-ui-framework/react";
import {Autocomplete} from 'superdesk-ui-framework/react';
import {IVocabularyFieldConfig} from "./interfaces";


type IVocabularyFieldValue = IVocabularyItem | null | undefined;
type IVocabularyFieldProps = IEditorComponentProps<IVocabularyFieldValue, IVocabularyFieldConfig>
const NEW_ITEM_PREFIX = '_new:';

export class VocabularyTypeaheadField extends React.PureComponent<IVocabularyFieldProps> {
Expand Down
6 changes: 4 additions & 2 deletions client/extensions/tga-sign-off/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
},
"devDependencies": {
"superdesk-code-style": "1.5.0",
"typescript": "3.9.7",
"superdesk-ui-framework": "2.4.17"
"typescript": "~4.9.5"
},
"peerDependencies": {
"superdesk-ui-framework": "3.0.9"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class UserSignOffField extends React.Component<IEditorProps, IState> {
disabled={this.props.readOnly}
/>
) : (
<ButtonGroup align="right">
<ButtonGroup align="end">
{this.props.readOnly ? null : (
<Button
type="default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import {hasUserSignedOff} from '../../utils';
import {IconLabel, ToggleBox} from 'superdesk-ui-framework/react';
import {SignOffDetails} from '../details';

interface IProps extends IPreviewComponentProps {
value: IUserSignOff | null;
}
type IProps = IPreviewComponentProps<IUserSignOff | null>;

export class UserSignOffPreview extends React.PureComponent<IProps> {
render() {
Expand Down
4 changes: 3 additions & 1 deletion client/extensions/tga-sign-off/src/components/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export function getUserSignOffModal(fieldProps: IEditorProps, currentUser: IUser
</p>
<Input
value={this.state.signOff.funding_source ?? ''}
type="text"
disabled={disabled}
onChange={(value) => {
this.updateField('funding_source', value);
Expand All @@ -116,6 +117,7 @@ export function getUserSignOffModal(fieldProps: IEditorProps, currentUser: IUser
</span>
<Input
value={this.state.signOff.affiliation ?? ''}
type="text"
disabled={disabled}
onChange={(value) => {
this.updateField('affiliation', value);
Expand Down Expand Up @@ -197,7 +199,7 @@ export function getUserSignOffModal(fieldProps: IEditorProps, currentUser: IUser
</ModalBody>
<ModalFooter>
<div className="sd-d-flex">
<ButtonGroup align="right">
<ButtonGroup align="end">
<Button
text={showSave ? gettext('Cancel') : gettext('Close')}
onClick={this.props.closeModal}
Expand Down
Loading

0 comments on commit bf562a2

Please sign in to comment.