1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-02 23:48:47 +00:00

Fix select UI (#5780)

* fix repo api permission value

* fix transfer repo dialog select

* fix create repo dialog select template or storage

* fix data type check and text
This commit is contained in:
Michael An
2023-11-21 15:35:17 +08:00
committed by GitHub
parent 589b2ac208
commit eefbc643c6
5 changed files with 20 additions and 8 deletions

View File

@@ -25,6 +25,14 @@ class CreateRepoDialog extends React.Component {
library_template: libraryTemplates.length ? libraryTemplates[0] : '', library_template: libraryTemplates.length ? libraryTemplates[0] : '',
isSubmitBtnActive: false, isSubmitBtnActive: false,
}; };
this.templateOptions = [];
this.storageOptions = [];
if (Array.isArray(libraryTemplates) && libraryTemplates.length) {
this.templateOptions = libraryTemplates.map((item) => { return {value: item, label: item}; });
}
if (Array.isArray(storages) && storages.length) {
this.storageOptions = storages.map((item) => { return {value: item.id, label: item.name}; });
}
} }
handleRepoNameChange = (e) => { handleRepoNameChange = (e) => {
@@ -191,9 +199,10 @@ class CreateRepoDialog extends React.Component {
<FormGroup> <FormGroup>
<Label>{gettext('Template')}</Label> <Label>{gettext('Template')}</Label>
<SeahubSelect <SeahubSelect
defaultValue={{value: libraryTemplates[0], label: libraryTemplates[0]}} defaultValue={this.templateOptions[0]}
options={libraryTemplates.map((item, index) => { return {value: item, label: item}; })} options={this.templateOptions}
onChange={this.handlelibraryTemplatesInputChange} onChange={this.handlelibraryTemplatesInputChange}
value={this.templateOptions.find(opt => opt.value === this.state.library_template) || null}
/> />
</FormGroup> </FormGroup>
)} )}
@@ -202,9 +211,10 @@ class CreateRepoDialog extends React.Component {
<FormGroup> <FormGroup>
<Label>{gettext('Storage Backend')}</Label> <Label>{gettext('Storage Backend')}</Label>
<SeahubSelect <SeahubSelect
defaultValue={{value: storages[0].id, label: storages[0].name}} defaultValue={this.storageOptions[0]}
options={storages.map((item, index) => { return {value: item.id, label: item.name}; })} options={this.storageOptions}
onChange={this.handleStorageInputChange} onChange={this.handleStorageInputChange}
value={this.storageOptions.find(opt => opt.value === this.state.storage_id) || null}
/> />
</FormGroup> </FormGroup>
)} )}

View File

@@ -93,7 +93,7 @@ const propTypes = {
folderPath: PropTypes.string, folderPath: PropTypes.string,
}; };
class LibSubFolderSerGroupPermissionDialog extends React.Component { class LibSubFolderSetGroupPermissionDialog extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
@@ -363,6 +363,6 @@ class LibSubFolderSerGroupPermissionDialog extends React.Component {
} }
} }
LibSubFolderSerGroupPermissionDialog.propTypes = propTypes; LibSubFolderSetGroupPermissionDialog.propTypes = propTypes;
export default LibSubFolderSerGroupPermissionDialog; export default LibSubFolderSetGroupPermissionDialog;

View File

@@ -87,6 +87,7 @@ class TransferDialog extends React.Component {
placeholder={gettext('Select a department')} placeholder={gettext('Select a department')}
options={this.options} options={this.options}
onChange={this.handleSelectChange} onChange={this.handleSelectChange}
value={this.state.selectedOption}
/> />
} }
{isPro && canTransferToDept && {isPro && canTransferToDept &&

View File

@@ -70,6 +70,7 @@ class RepoAPITokenPermissionEditor extends React.Component {
placeholder={optionTranslation} placeholder={optionTranslation}
onChange={this.onPermissionChanged} onChange={this.onPermissionChanged}
captureMenuScroll={false} captureMenuScroll={false}
value={this.options.find(opt => opt.value === currentPermission) || null}
/> />
} }
</div> </div>

View File

@@ -14,7 +14,7 @@ const propTypes = {
onSelectChange: PropTypes.func.isRequired, onSelectChange: PropTypes.func.isRequired,
isMulti: PropTypes.bool.isRequired, isMulti: PropTypes.bool.isRequired,
className: PropTypes.string, className: PropTypes.string,
value: PropTypes.string, value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
}; };
class UserSelect extends React.Component { class UserSelect extends React.Component {