mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-01-18 07:52:23 +01:00
(bug) should not change group of subscriber
This commit is contained in:
parent
a8623487fd
commit
35656229ad
@ -39,10 +39,9 @@ type selectGroupOption = { value: number, label: string };
|
||||
*/
|
||||
export const ChangeRoleModal: React.FC<ChangeRoleModalProps> = ({ isOpen, toggleModal, user, onSuccess, onError }) => {
|
||||
const { t } = useTranslation('admin');
|
||||
const { control, handleSubmit } = useForm<RoleFormData>({ defaultValues: { groupId: user.group_id } });
|
||||
const { control, handleSubmit } = useForm<RoleFormData>({ defaultValues: { role: user.role, groupId: user.group_id } });
|
||||
|
||||
const [groups, setGroups] = useState<Array<Group>>([]);
|
||||
const [selectedRole, setSelectedRole] = useState<UserRole>(user.role);
|
||||
|
||||
useEffect(() => {
|
||||
GroupAPI.index({ disabled: false }).then(setGroups).catch(onError);
|
||||
@ -64,10 +63,10 @@ export const ChangeRoleModal: React.FC<ChangeRoleModalProps> = ({ isOpen, toggle
|
||||
};
|
||||
|
||||
/**
|
||||
* Callback triggered when the user changes the selected role in the dropdown selection list
|
||||
* Check if we can change the group of the user
|
||||
*/
|
||||
const onRoleSelect = (data: UserRole) => {
|
||||
setSelectedRole(data);
|
||||
const canChangeGroup = (): boolean => {
|
||||
return !user.subscription;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -104,15 +103,14 @@ export const ChangeRoleModal: React.FC<ChangeRoleModalProps> = ({ isOpen, toggle
|
||||
control={control}
|
||||
id="role"
|
||||
label={t('app.admin.change_role_modal.new_role')}
|
||||
rules={{ required: true }}
|
||||
onChange={onRoleSelect} />
|
||||
{selectedRole !== 'admin' &&
|
||||
<FormSelect options={buildGroupsOptions()}
|
||||
control={control}
|
||||
id="groupId"
|
||||
label={t('app.admin.change_role_modal.new_group')}
|
||||
tooltip={t('app.admin.change_role_modal.new_group_help')}
|
||||
rules={{ required: true }} />}
|
||||
rules={{ required: true }} />
|
||||
<FormSelect options={buildGroupsOptions()}
|
||||
control={control}
|
||||
disabled={!canChangeGroup()}
|
||||
id="groupId"
|
||||
label={t('app.admin.change_role_modal.new_group')}
|
||||
tooltip={t('app.admin.change_role_modal.new_group_help')}
|
||||
rules={{ required: true }} />
|
||||
</form>
|
||||
</FabModal>
|
||||
);
|
||||
|
@ -999,13 +999,13 @@ en:
|
||||
refuse_documents_info: "After verification, you may notify the member that the evidence submitted is not acceptable. You can specify the reasons for your refusal and indicate the actions to be taken. The member will be notified by e-mail."
|
||||
change_role_modal:
|
||||
change_role: "Change role"
|
||||
warning_role_change: "<p><strong>Warning:</strong> changing the role of a user is not a harmless operation.</p><ul><li><strong>Members</strong> can only book reservations for themselves, paying by card or wallet.</li><li><strong>Managers</strong> can book reservations for themselves, paying by card or wallet, and for other members and managers, by collecting payments at the checkout.</li><li><strong>Administrators</strong> can only book reservations for members and managers, by collecting payments at the checkout. Moreover, they can change every settings of the application.</li></ul>"
|
||||
warning_role_change: "<p><strong>Warning:</strong> changing the role of a user is not a harmless operation.</p><ul><li><strong>Members</strong> can only book reservations for themselves, paying by card or wallet.</li><li><strong>Managers</strong> can book reservations for themselves, paying by card or wallet, and for other members and managers, by collecting payments at the checkout.</li><li><strong>Administrators</strong> as managers, they can book reservations for themselves and for others. Moreover, they can change every settings of the application.</li></ul>"
|
||||
new_role: "New role"
|
||||
admin: "Administrator"
|
||||
manager: "Manager"
|
||||
member: "Member"
|
||||
new_group: "New group"
|
||||
new_group_help: "Members and managers must be placed in a group."
|
||||
new_group_help: "Users with a running subscription cannot be changed from their current group."
|
||||
confirm: "Change role"
|
||||
role_changed: "Role successfully changed from {OLD} to {NEW}."
|
||||
error_while_changing_role: "An error occurred while changing the role. Please try again later."
|
||||
|
@ -18,18 +18,19 @@ Use the following commands to dump the PostgreSQL database to an archive file
|
||||
cd /apps/fabmanager/
|
||||
docker-compose exec postgres bash
|
||||
cd /var/lib/postgresql/data/
|
||||
pg_dump -U postgres fabmanager_production > fabmanager_production_$(date -I).sql
|
||||
tar cvzf fabmanager_production_$(date -I).tar.gz fabmanager_production_$(date -I).sql
|
||||
DB=$(psql -U postgres -c \\l | grep production | awk '{print $1}')
|
||||
pg_dump -U postgres "$DB" > "$DB_$(date -I).sql"
|
||||
tar cvzf "fabmanager_database_dump_$(date -I).tar.gz" "$DB_$(date -I).sql"
|
||||
```
|
||||
|
||||
If you're connected to your server thought SSH, you can download the resulting dump file using the following:
|
||||
```bash
|
||||
scp root@remote.server.fab:/apps/fabmanager/postgresql/fabmanager_production_$(date -I).tar.gz .
|
||||
scp root@remote.server.fab:/apps/fabmanager/postgresql/fabmanager_database_dump_$(date -I).tar.gz .
|
||||
```
|
||||
|
||||
Restore the dump with the following:
|
||||
```bash
|
||||
tar xvf fabmanager_production_$(date -I).tar.gz
|
||||
tar xvf fabmanager_database_dump_$(date -I).tar.gz
|
||||
sudo cp fabmanager_production_$(date -I).sql /apps/fabmanager/postgresql/
|
||||
cd /apps/fabmanager/
|
||||
docker-compose down
|
||||
@ -76,7 +77,7 @@ This is currently not supported, because of some PostgreSQL specific instruction
|
||||
- `db/migrate/20200511075933_fix_accounting_periods.rb` is using `CREATE RULE` and `DROP RULE`;
|
||||
- `app/models/project.rb` is using the `pg_search` gem.
|
||||
- `db/migrate/20200622135401_add_pg_search_dmetaphone_support_functions.rb` is using [fuzzystrmatch](http://www.postgresql.org/docs/current/static/fuzzystrmatch.html) module and defines a PL/pgSQL function (`pg_search_dmetaphone()`);
|
||||
- `db/migrate/20200623134900_add_search_vector_to_project.rb` is using [tsvector](https://www.postgresql.org/docs/10/datatype-textsearch.html), a PostgreSQL datatype and [GIN (Generalized Inverted Index)](https://www.postgresql.org/docs/9.1/textsearch-indexes.html) a PostgreSQL index type;
|
||||
- `db/migrate/20200623134900_add_search_vector_to_project.rb` is using [tsvector](https://www.postgresql.org/docs/10/datatype-textsearch.html), a PostgreSQL datatype and [GIN (Generalized Inverted Index)](https://www.postgresql.org/docs/9.1/textsearch-indexes.html) a PostgreSQL index type;
|
||||
- `db/migrate/20200623141305_update_search_vector_of_projects.rb` defines a PL/pgSQL function (`fill_search_vector_for_project()`) and create an SQL trigger for this function;
|
||||
- `db/migrate/20200629123011_update_pg_trgm.rb` is using [ALTER EXTENSION](https://www.postgresql.org/docs/10/sql-alterextension.html);
|
||||
- `db/migrate/20201027101809_create_payment_schedule_items.rb` is using [jsonb](https://www.postgresql.org/docs/9.4/static/datatype-json.html);
|
||||
|
Loading…
x
Reference in New Issue
Block a user