Not showing local if there are no federated instances.
This commit is contained in:
parent
ea7ad04e9b
commit
3d70609228
3 changed files with 26 additions and 14 deletions
32
ui/src/components/listing-type-select.tsx
vendored
32
ui/src/components/listing-type-select.tsx
vendored
|
@ -6,6 +6,7 @@ import { i18n } from '../i18next';
|
||||||
|
|
||||||
interface ListingTypeSelectProps {
|
interface ListingTypeSelectProps {
|
||||||
type_: ListingType;
|
type_: ListingType;
|
||||||
|
showLocal?: boolean;
|
||||||
onChange?(val: ListingType): any;
|
onChange?(val: ListingType): any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,6 +32,7 @@ export class ListingTypeSelect extends Component<
|
||||||
static getDerivedStateFromProps(props: any): ListingTypeSelectProps {
|
static getDerivedStateFromProps(props: any): ListingTypeSelectProps {
|
||||||
return {
|
return {
|
||||||
type_: props.type_,
|
type_: props.type_,
|
||||||
|
showLocal: props.showLocal,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +55,22 @@ export class ListingTypeSelect extends Component<
|
||||||
/>
|
/>
|
||||||
{i18n.t('subscribed')}
|
{i18n.t('subscribed')}
|
||||||
</label>
|
</label>
|
||||||
|
{this.props.showLocal && (
|
||||||
|
<label
|
||||||
|
className={`pointer btn btn-outline-secondary ${
|
||||||
|
this.state.type_ == ListingType.Local && 'active'
|
||||||
|
}`}
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
id={`${this.id}-local`}
|
||||||
|
type="radio"
|
||||||
|
value={ListingType.Local}
|
||||||
|
checked={this.state.type_ == ListingType.Local}
|
||||||
|
onChange={linkEvent(this, this.handleTypeChange)}
|
||||||
|
/>
|
||||||
|
{i18n.t('local')}
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
<label
|
<label
|
||||||
className={`pointer btn btn-outline-secondary ${
|
className={`pointer btn btn-outline-secondary ${
|
||||||
this.state.type_ == ListingType.All && 'active'
|
this.state.type_ == ListingType.All && 'active'
|
||||||
|
@ -67,20 +85,6 @@ export class ListingTypeSelect extends Component<
|
||||||
/>
|
/>
|
||||||
{i18n.t('all')}
|
{i18n.t('all')}
|
||||||
</label>
|
</label>
|
||||||
<label
|
|
||||||
className={`pointer btn btn-outline-secondary ${
|
|
||||||
this.state.type_ == ListingType.Local && 'active'
|
|
||||||
}`}
|
|
||||||
>
|
|
||||||
<input
|
|
||||||
id={`${this.id}-all`}
|
|
||||||
type="radio"
|
|
||||||
value={ListingType.Local}
|
|
||||||
checked={this.state.type_ == ListingType.Local}
|
|
||||||
onChange={linkEvent(this, this.handleTypeChange)}
|
|
||||||
/>
|
|
||||||
{i18n.t('local')}
|
|
||||||
</label>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
4
ui/src/components/main.tsx
vendored
4
ui/src/components/main.tsx
vendored
|
@ -537,6 +537,10 @@ export class Main extends Component<any, MainState> {
|
||||||
<span class="mr-3">
|
<span class="mr-3">
|
||||||
<ListingTypeSelect
|
<ListingTypeSelect
|
||||||
type_={this.state.listingType}
|
type_={this.state.listingType}
|
||||||
|
showLocal={
|
||||||
|
this.state.siteRes.federated_instances &&
|
||||||
|
this.state.siteRes.federated_instances.length > 0
|
||||||
|
}
|
||||||
onChange={this.handleListingTypeChange}
|
onChange={this.handleListingTypeChange}
|
||||||
/>
|
/>
|
||||||
</span>
|
</span>
|
||||||
|
|
4
ui/src/components/user.tsx
vendored
4
ui/src/components/user.tsx
vendored
|
@ -539,6 +539,10 @@ export class User extends Component<any, UserState> {
|
||||||
this.state.userSettingsForm.default_listing_type
|
this.state.userSettingsForm.default_listing_type
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
showLocal={
|
||||||
|
this.state.siteRes.federated_instances &&
|
||||||
|
this.state.siteRes.federated_instances.length > 0
|
||||||
|
}
|
||||||
onChange={this.handleUserSettingsListingTypeChange}
|
onChange={this.handleUserSettingsListingTypeChange}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue