Skip to content

Commit

Permalink
fix: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
SychO9 committed Dec 16, 2023
1 parent 02b414a commit 6d61c81
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ export default class AuthMethodModal<CustomAttrs extends IAuthMethodModalAttrs =
}

title(): Mithril.Children {
return app.translator.trans('flarum-package-manager.admin.auth_config.add_button_label');
const context = this.attrs.host ? 'edit' : 'add';
return app.translator.trans(`flarum-package-manager.admin.auth_config.${context}_label`);
}

content(): Mithril.Children {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default class ConfigureAuth extends ConfigureJson<IConfigureJson> {
})
}
>
{app.translator.trans('flarum-package-manager.admin.auth_config.add_button_label')}
{app.translator.trans('flarum-package-manager.admin.auth_config.add_label')}
</Button>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ export default class ConfigureComposer extends ConfigureJson<IConfigureJson> {
<label>{app.translator.trans('flarum-package-manager.admin.composer.repositories.label')}</label>
<div className="helpText">{app.translator.trans('flarum-package-manager.admin.composer.repositories.help')}</div>
<div className="ConfigureComposer-repositories">
{Object.keys(this.setting('repositories')() || {}).map((key) => {
const repository = this.setting('repositories')()[key] as Repository;
{Object.keys(this.setting('repositories')() || {}).map((name) => {
const repository = this.setting('repositories')()[name] as Repository;

return (
<div className="ButtonGroup ButtonGroup--full">
Expand All @@ -57,13 +57,13 @@ export default class ConfigureComposer extends ConfigureJson<IConfigureJson> {
}
onclick={() =>
app.modal.show(RepositoryModal, {
key,
name,
repository,
onsubmit: this.onchange.bind(this),
})
}
>
{key} ({repository.type})
{name} ({repository.type})
</Button>
<Button
className="Button Button--icon"
Expand All @@ -72,7 +72,7 @@ export default class ConfigureComposer extends ConfigureJson<IConfigureJson> {
onclick={() => {
if (confirm(extractText(app.translator.trans('flarum-package-manager.admin.composer.delete_repository_confirmation')))) {
const repositories = { ...this.setting('repositories')() };
delete repositories[key];
delete repositories[name];

this.setting('repositories')(repositories);
}
Expand All @@ -99,10 +99,10 @@ export default class ConfigureComposer extends ConfigureJson<IConfigureJson> {
return items;
}

onchange(repository: Repository, key: string) {
onchange(repository: Repository, name: string) {
this.setting('repositories')({
...this.setting('repositories')(),
[key]: repository,
[name]: repository,
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ import { type Repository } from './ConfigureComposer';

export interface IRepositoryModalAttrs extends IInternalModalAttrs {
onsubmit: (repository: Repository, key: string) => void;
key?: string;
name?: string;
repository?: Repository;
}

export default class RepositoryModal<CustomAttrs extends IRepositoryModalAttrs = IRepositoryModalAttrs> extends Modal<CustomAttrs> {
protected key!: Stream<string>;
protected name!: Stream<string>;
protected repository!: Stream<Repository>;

oninit(vnode: Mithril.Vnode<CustomAttrs, this>) {
super.oninit(vnode);

this.key = Stream(this.attrs.key || '');
this.name = Stream(this.attrs.name || '');
this.repository = Stream(this.attrs.repository || { type: 'composer', url: '' });
}

Expand All @@ -28,7 +28,8 @@ export default class RepositoryModal<CustomAttrs extends IRepositoryModalAttrs =
}

title(): Mithril.Children {
return app.translator.trans('flarum-package-manager.admin.composer.add_repository_label');
const context = this.attrs.repository ? 'edit' : 'add';
return app.translator.trans(`flarum-package-manager.admin.composer.${context}_repository_label`);
}

content(): Mithril.Children {
Expand All @@ -41,8 +42,8 @@ export default class RepositoryModal<CustomAttrs extends IRepositoryModalAttrs =
return (
<div className="Modal-body">
<div className="Form-group">
<label>{app.translator.trans('flarum-package-manager.admin.composer.repositories.add_modal.key_label')}</label>
<input className="FormControl" bidi={this.key} />
<label>{app.translator.trans('flarum-package-manager.admin.composer.repositories.add_modal.name_label')}</label>
<input className="FormControl" bidi={this.name} />
</div>
<div className="Form-group">
<label>{app.translator.trans('flarum-package-manager.admin.composer.repositories.add_modal.type_label')}</label>
Expand Down Expand Up @@ -70,7 +71,7 @@ export default class RepositoryModal<CustomAttrs extends IRepositoryModalAttrs =
}

submit() {
this.attrs.onsubmit(this.repository(), this.key());
this.attrs.onsubmit(this.repository(), this.name());
this.hide();
}
}
4 changes: 4 additions & 0 deletions extensions/package-manager/less/admin.less
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@
margin-bottom: 8px;
}
}

.flarum-package-manager-Page .SettingsGroups .Form {
max-height: unset;
}
6 changes: 4 additions & 2 deletions extensions/package-manager/locale/en.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
flarum-package-manager:
admin:
auth_config:
add_button_label: New authentication method
add_label: New authentication method
add_modal:
host_label: Host
host_placeholder: "example: extiverse.com"
Expand All @@ -11,6 +11,7 @@ flarum-package-manager:
unchanged_token_placeholder: "(unchanged)"
delete_confirmation: Are you sure you want to delete this authentication method?
delete_label: Delete authentication method
edit_label: Edit authentication method
fields:
host: Host
token: Token
Expand All @@ -26,6 +27,7 @@ flarum-package-manager:
add_repository_label: Add Repository
delete_repository_confirmation: Are you sure you want to delete this repository? All extensions installed from this repository will be removed.
delete_repository_label: Delete repository
edit_repository_label: Edit repository
title: Composer
minimum_stability:
label: Minimum Stability
Expand All @@ -45,7 +47,7 @@ flarum-package-manager:
vcs: vcs
path: path
add_modal:
key_label: Name
name_label: Name
type_label: Type
url: URL
submit_button: Submit
Expand Down

0 comments on commit 6d61c81

Please sign in to comment.