frontend: apply ec6c2ed69 to link, publish, groups

This commit is contained in:
Fang 2020-03-19 00:00:02 +01:00
parent 143bae6190
commit cc1c28fdec
No known key found for this signature in database
GPG Key ID: EB035760C1BBA972
8 changed files with 113 additions and 72 deletions

View File

@ -73,6 +73,7 @@ export class AddScreen extends Component {
groups={props.groups}
contacts={props.contacts}
groupResults={false}
shipResults={true}
invites={this.state.invites}
setInvite={this.invChange}
/>

View File

@ -102,7 +102,9 @@ export class InviteSearch extends Component {
});
}
let shipMatches = this.state.peers.filter(e => {
let shipMatches = [];
if (this.props.shipResults) {
shipMatches = this.state.peers.filter(e => {
return e.includes(searchTerm) && !this.props.invites.ships.includes(e);
});
@ -118,10 +120,6 @@ export class InviteSearch extends Component {
}
}
this.setState({
searchResults: { groups: groupMatches, ships: shipMatches }
});
let isValid = true;
if (!urbitOb.isValidPatp("~" + searchTerm)) {
isValid = false;
@ -129,12 +127,14 @@ export class InviteSearch extends Component {
if (shipMatches.length === 0 && isValid) {
shipMatches.push(searchTerm);
}
}
this.setState({
searchResults: { groups: groupMatches, ships: shipMatches }
});
}
}
}
deleteGroup() {
let { ships } = this.props.invites;
@ -209,6 +209,18 @@ export class InviteSearch extends Component {
let participants = <div />;
let searchResults = <div />;
let placeholder = '';
if (props.shipResults) {
placeholder = 'ships';
}
if (props.groupResults) {
if (placeholder.length > 0) {
placeholder = placeholder + ' or ';
}
placeholder = placeholder + 'existing groups';
}
placeholder = 'Search for ' + placeholder;
let invErrElem = <span />;
if (state.inviteError) {
invErrElem = (
@ -372,7 +384,7 @@ export class InviteSearch extends Component {
"f7 ba b--gray3 b--gray2-d bg-gray0-d white-d pa3 w-100" +
" db focus-b--black focus-b--white-d"
}
placeholder="Search for ships or existing groups"
placeholder={placeholder}
disabled={searchDisabled}
rows={1}
spellCheck={false}

View File

@ -134,6 +134,7 @@ export class NewScreen extends Component {
groups={this.props.groups}
contacts={this.props.contacts}
groupResults={false}
shipResults={true}
invites={this.state.invites}
setInvite={this.invChange}
/>

View File

@ -57,6 +57,7 @@ export class InviteElement extends Component {
groups={{}}
contacts={props.contacts}
groupResults={false}
shipResults={true}
invites={{
groups: [],
ships: this.state.members

View File

@ -102,7 +102,9 @@ export class InviteSearch extends Component {
});
}
let shipMatches = this.state.peers.filter(e => {
let shipMatches = [];
if (this.props.shipResults) {
shipMatches = this.state.peers.filter(e => {
return e.includes(searchTerm) && !this.props.invites.ships.includes(e);
});
@ -118,10 +120,6 @@ export class InviteSearch extends Component {
}
}
this.setState({
searchResults: { groups: groupMatches, ships: shipMatches }
});
let isValid = true;
if (!urbitOb.isValidPatp("~" + searchTerm)) {
isValid = false;
@ -129,12 +127,14 @@ export class InviteSearch extends Component {
if (shipMatches.length === 0 && isValid) {
shipMatches.push(searchTerm);
}
}
this.setState({
searchResults: { groups: groupMatches, ships: shipMatches }
});
}
}
}
deleteGroup() {
let { ships } = this.props.invites;
@ -209,6 +209,18 @@ export class InviteSearch extends Component {
let participants = <div />;
let searchResults = <div />;
let placeholder = '';
if (props.shipResults) {
placeholder = 'ships';
}
if (props.groupResults) {
if (placeholder.length > 0) {
placeholder = placeholder + ' or ';
}
placeholder = placeholder + 'existing groups';
}
placeholder = 'Search for ' + placeholder;
let invErrElem = <span />;
if (state.inviteError) {
invErrElem = (
@ -372,7 +384,7 @@ export class InviteSearch extends Component {
"f7 ba b--gray3 b--gray2-d bg-gray0-d white-d pa3 w-100" +
" db focus-b--black focus-b--white-d"
}
placeholder="Search for ships or existing groups"
placeholder={placeholder}
disabled={searchDisabled}
rows={1}
spellCheck={false}

View File

@ -221,6 +221,7 @@ export class NewScreen extends Component {
groups={props.groups}
contacts={props.contacts}
groupResults={true}
shipResults={true}
invites={{
groups: state.groups,
ships: state.ships

View File

@ -102,7 +102,9 @@ export class InviteSearch extends Component {
});
}
let shipMatches = this.state.peers.filter(e => {
let shipMatches = [];
if (this.props.shipResults) {
shipMatches = this.state.peers.filter(e => {
return e.includes(searchTerm) && !this.props.invites.ships.includes(e);
});
@ -118,10 +120,6 @@ export class InviteSearch extends Component {
}
}
this.setState({
searchResults: { groups: groupMatches, ships: shipMatches }
});
let isValid = true;
if (!urbitOb.isValidPatp("~" + searchTerm)) {
isValid = false;
@ -129,12 +127,14 @@ export class InviteSearch extends Component {
if (shipMatches.length === 0 && isValid) {
shipMatches.push(searchTerm);
}
}
this.setState({
searchResults: { groups: groupMatches, ships: shipMatches }
});
}
}
}
deleteGroup() {
let { ships } = this.props.invites;
@ -209,6 +209,18 @@ export class InviteSearch extends Component {
let participants = <div />;
let searchResults = <div />;
let placeholder = '';
if (props.shipResults) {
placeholder = 'ships';
}
if (props.groupResults) {
if (placeholder.length > 0) {
placeholder = placeholder + ' or ';
}
placeholder = placeholder + 'existing groups';
}
placeholder = 'Search for ' + placeholder;
let invErrElem = <span />;
if (state.inviteError) {
invErrElem = (
@ -372,7 +384,7 @@ export class InviteSearch extends Component {
"f7 ba b--gray3 b--gray2-d bg-gray0-d white-d pa3 w-100" +
" db focus-b--black focus-b--white-d"
}
placeholder="Search for ships or existing groups"
placeholder={placeholder}
disabled={searchDisabled}
rows={1}
spellCheck={false}

View File

@ -189,6 +189,7 @@ export class NewScreen extends Component {
<InviteSearch
associations={this.props.associations}
groupResults={true}
shipResults={true}
groups={this.props.groups}
contacts={this.props.contacts}
invites={this.state.invites}