-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Update to Superdesk v2.7 (#23)
* chore: Update to Superdesk v2.7 Fixing extension registration and code due to changes in extension API * fix unit test
- Loading branch information
1 parent
40729a9
commit 8225bcd
Showing
24 changed files
with
1,161 additions
and
918 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
client/extensions/tga-author-profile-fields/src/components/profileId/preview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import * as React from 'react'; | ||
|
||
import {ICommonFieldConfig, IPreviewComponentProps, IUser} from 'superdesk-api'; | ||
import {IProfileIdValue} from './editor'; | ||
import {superdesk} from '../../superdesk'; | ||
|
||
type IProps = IPreviewComponentProps<IProfileIdValue, ICommonFieldConfig>; | ||
|
||
interface IState { | ||
user?: IUser; | ||
} | ||
|
||
export class ProfileIdPreview extends React.PureComponent<IProps, IState> { | ||
constructor(props: IProps) { | ||
super(props); | ||
|
||
this.state = {user: undefined}; | ||
} | ||
|
||
componentDidMount() { | ||
if (this.props.value != null) { | ||
const {dataApi} = superdesk; | ||
|
||
dataApi.findOne<IUser>('users', this.props.value).then((user) => { | ||
this.setState({user: user}); | ||
}); | ||
} | ||
} | ||
|
||
render() { | ||
const {UserAvatar, Spacer} = superdesk.components; | ||
|
||
return this.props.value == null || this.state.user == null ? null : ( | ||
<div className="form__row"> | ||
{/*Mimics same layout as the SelectUser component's dropdown, taken from client-core*/} | ||
<Spacer h={true} gap="8" noWrap={true} justifyContent="start"> | ||
<div> | ||
<UserAvatar userId={this.props.value} /> | ||
</div> | ||
<Spacer v={true} gap="4" noWrap={true}> | ||
<div>{this.state.user.display_name}</div> | ||
<div style={{fontSize: '1.2rem'}}>@{this.state.user.username}</div> | ||
</Spacer> | ||
</Spacer> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
client/extensions/tga-author-profile-fields/src/components/profileText/interfaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import {IEditorComponentProps} from 'superdesk-api'; | ||
import {ICommonFieldConfig} from 'superdesk-api'; | ||
|
||
export interface IProfileTextFieldConfig { | ||
export interface IProfileTextFieldConfig extends ICommonFieldConfig { | ||
use_editor_3: boolean; | ||
exclude_from_content_api: boolean; | ||
} | ||
|
||
export type IProfileTextFieldProps = IEditorComponentProps<string | undefined, IProfileTextFieldConfig>; | ||
export type IProfileTextValue = string | undefined; |
9 changes: 6 additions & 3 deletions
9
client/extensions/tga-author-profile-fields/src/components/profileText/preview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 6 additions & 1 deletion
7
client/extensions/tga-author-profile-fields/src/components/vocab/interfaces.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
export interface IVocabularyFieldConfig { | ||
import {IVocabularyItem, ICommonFieldConfig} from 'superdesk-api'; | ||
|
||
export interface IVocabularyFieldConfig extends ICommonFieldConfig { | ||
vocabulary_name: string; | ||
allow_freetext: boolean; | ||
exclude_from_content_api: boolean; | ||
} | ||
|
||
export type IVocabularyFieldValue = IVocabularyItem | null | undefined; | ||
export type IVocabularyFieldArrayValue = Array<IVocabularyItem> | IVocabularyFieldValue; |
9 changes: 6 additions & 3 deletions
9
client/extensions/tga-author-profile-fields/src/components/vocab/preview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
client/extensions/tga-author-profile-fields/src/components/vocab/singleValuePreview.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import * as React from 'react'; | ||
|
||
import {IPreviewComponentProps} from 'superdesk-api'; | ||
import {IVocabularyFieldValue, IVocabularyFieldConfig} from './interfaces'; | ||
|
||
type IProps = IPreviewComponentProps<IVocabularyFieldValue, IVocabularyFieldConfig>; | ||
|
||
export class SingleVocabularyPreview extends React.PureComponent<IProps> { | ||
render() { | ||
return this.props.value == null || this.props.value.length === 0 ? null : ( | ||
<div className="form__row form__row--small-padding"> | ||
<p className="sd-text__normal"> | ||
{this.props.value.name} | ||
</p> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.