Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.0.9 #8

Merged
merged 9 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ jobs:
- name: Install Dependencies
run: pnpm install

- name: Run lint
run: pnpm lint

- name: Build
run: pnpm run build

Expand Down
8 changes: 4 additions & 4 deletions addon/components/modals/group-details.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="grid grid-cols-3 gap-2 text-xs dark:text-gray-100">
<div class="col-span-3 mb-5">
<label class="block mb-2 font-bold">
Group Name
{{t "iam.components.modals.group-details.group-name"}}
</label>
<span class="block truncate">
{{n-a @options.group.name}}
Expand All @@ -12,7 +12,7 @@

<div class="mb-5">
<label class="block mb-2 font-bold">
Members
{{t "iam.common.member"}}
</label>
<span class="block truncate">
{{n-a @options.user.internal_id}}
Expand All @@ -21,7 +21,7 @@

<div class="mb-5">
<label class="block mb-2 font-bold">
Status
{{t "iam.common.status"}}
</label>
<Badge @status={{@options.vendor.status}} />
</div>
Expand All @@ -30,7 +30,7 @@

<div class="col-span-2 mb-5">
<label class="block mb-2 font-bold">
Address
{{t "iam.common.address"}}
</label>
<div>
{{n-a (html-safe @options.vendor.address)}}
Expand Down
14 changes: 7 additions & 7 deletions addon/components/modals/group-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
<div class="text-xs dark:text-gray-100">
<div class="input-group">
<label>
Group Name
{{t "iam.components.modals.group-form.group-name"}}
</label>
<Input @value={{@options.group.name}} @type="text" class="w-full form-input" placeholder="Group Name" />
<Input @value={{@options.group.name}} @type="text" class="w-full form-input" placeholder={{t "iam.components.modals.group-form.group-name"}} />
</div>
<div class="input-group">
<label>
Group Description
{{t "iam.components.modals.group-form.group-description"}}
</label>
<Textarea @value={{@options.group.description}} rows="5" class="w-full form-input" placeholder="Group Description" />
<Textarea @value={{@options.group.description}} rows="5" class="w-full form-input" placeholder={{t "iam.components.modals.group-form.group-description"}} />
</div>

<div class="input-group">
<div class="mb-4">
<InputLabel class="mb-2" @labelText="Select users to add to group" @helpText="Search and select users to add to this group." />
<InputLabel class="mb-2" @labelText={{t "iam.components.modals.group-form.select-users-add-group"}} @helpText={{t "iam.components.modals.group-form.search-select-users-add-group"}} />

<div class="flex items-start justify-between">
<ModelSelect @modelName="user" @selectedModel={{@options.lastSelectedUser}} @placeholder="Select user to add to group" class="w-64" @triggerClass="form-select form-input" @infiniteScroll={{false}} @renderInPlace={{true}} @onChange={{@options.addUser}} as |model|>
<ModelSelect @modelName="user" @selectedModel={{@options.lastSelectedUser}} @placeholder={{t "iam.components.modals.group-form.select-user-add-group"}} class="w-64" @triggerClass="form-select form-input" @infiniteScroll={{false}} @renderInPlace={{true}} @onChange={{@options.addUser}} as |model|>
{{model.name}}
</ModelSelect>
</div>
Expand All @@ -43,7 +43,7 @@
<div class="flex items-center justify-center h-full dark:text-gray-100">
<div class="flex flex-col items-center justify-center w-2/4 h-full my-8 text-center">
<div class="text-base font-semibold">
No users added to group
{{t "iam.components.modals.group-form.no-user-add-group"}}
</div>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions addon/components/modals/policy-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
<div class="modal-body-container" ...attributes>
<div class="input-group">
<label>
Policy Name
{{t "iam.components.modals.policy-form.policy-name"}}
</label>
<Input @value={{@options.policy.name}} @type="text" class="w-full form-input" placeholder="Enter a name for your policy" />
<Input @value={{@options.policy.name}} @type="text" class="w-full form-input" placeholder={{t "iam.components.modals.policy-form.enter-name-your-policy"}} />
</div>
<div class="input-group">
<label>
Policy Description
{{t "iam.components.modals.policy-form.policy-description"}}
</label>
<Input @value={{@options.policy.description}} @type="text" class="w-full form-input" placeholder="Enter a description for your policy" />
<Input @value={{@options.policy.description}} @type="text" class="w-full form-input" placeholder={{t "iam.components.modals.policy-form.enter-description-your-policy"}} />
</div>
<div class="input-group">
<label>
Select Permissions
{{t "iam.components.modals.policy-form.select-permissions"}}
</label>
<PermissionPicker @selected={{@options.policy.permissions}} @onChange={{fn (mut @options.policy.permissions)}} />
</div>
Expand Down
10 changes: 5 additions & 5 deletions addon/components/modals/role-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
<div class="modal-body-container" ...attributes>
<div class="input-group">
<label>
Role Name
{{t "iam.components.modals.role-form.role-name"}}
</label>
<Input @value={{@options.role.name}} @type="text" class="w-full form-input" placeholder="Enter a name for this role" />
<Input @value={{@options.role.name}} @type="text" class="w-full form-input" placeholder={{t "iam.components.modals.role-form.enter-name-for-this-role"}} />
</div>
<div class="input-group">
<label>
Role Description
{{t "iam.components.modals.role-form.role-description"}}
</label>
<Input @value={{@options.role.description}} @type="text" class="w-full form-input" placeholder="Enter a description for your role" />
<Input @value={{@options.role.description}} @type="text" class="w-full form-input" placeholder={{t "iam.components.modals.role-form.enter-description-your-role"}} />
</div>
<div class="input-group">
<label>
Select Permissions
{{t "iam.components.modals.role-form.select-permission"}}
</label>
<PermissionPicker @selected={{@options.role.permissionsArray}} @onChange={{@options.setPermissions}} />
</div>
Expand Down
16 changes: 8 additions & 8 deletions addon/components/modals/user-form.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@
<div class="flex">
<div class="w-32 mb-6 mr-6">
<Image src={{@options.user.avatar_url}} @fallbackSrc={{config "defaultValues.userImage"}} alt={{@options.user.name}} height="128" width="128" class="h-32 w-32 rounded-md" />
<UploadButton @name="photos" @accept="image/*" @onFileAdded={{@options.uploadNewPhoto}} class="w-32" />
<UploadButton @name={{t "iam.common.photo"}} @accept="image/*" @onFileAdded={{@options.uploadNewPhoto}} class="w-32" />
</div>
<div class="flex-1">
<div class="grid grid-cols-2 gap-3 text-xs dark:text-gray-100">
<div class="input-group">
<label>
Name
{{t "iam.common.name"}}
</label>
<Input @value={{@options.user.name}} @type="text" class="w-full form-input" placeholder="Name" />
<Input @value={{@options.user.name}} @type="text" class="w-full form-input" placeholder={{t "iam.common.name"}} />
</div>

<div class="input-group">
<label>
Email
{{t "iam.common.email"}}
</label>
<Input @value={{@options.user.email}} @type="text" class="w-full form-input" placeholder="Email" />
<Input @value={{@options.user.email}} @type="text" class="w-full form-input" placeholder={{t "iam.common.email"}} />
</div>

<div class="input-group">
<label>
Phone
{{t "iam.common.phone"}}
</label>
<PhoneInput @value={{@options.user.phone}} @onInput={{fn (mut @options.user.phone)}} class="form-input w-full" />
</div>

<div class="input-group">
<label>
Country
{{t "iam.common.country"}}
</label>
<CountrySelect class="w-full form-input form-select form-datalist" @value={{@options.user.country}} @onChange={{fn (mut @options.user.country)}} placeholder="Country" />
<CountrySelect class="w-full form-input form-select form-datalist" @value={{@options.user.country}} @onChange={{fn (mut @options.user.country)}} placeholder={{t "iam.common.country"}} />
</div>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions addon/components/permission-picker.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="mb-2 flex items-center justify-between">
<div class="flex items-center">
<div class="permission-picker-search">
<Input @type="text" {{on "input" (perform this.search)}} placeholder="Search permissions by keywords" class="w-64 form-input form-input-sm" />
<Input @type="text" {{on "input" (perform this.search)}} placeholder={{t "iam.components.permission-picker.search-permissions-keyword"}} class="w-64 form-input form-input-sm" />
</div>
<div>
{{#if this.isLoading}}
Expand All @@ -13,7 +13,7 @@
</div>
</div>
<div class="text-sm dark:text-gray-100">
Selected: {{this.selected.length}}
{{t "iam.components.permission-picker.selected"}} {{this.selected.length}}
</div>
</div>
<div class="bg-white border border-gray-200 rounded shadow-sm dark:bg-gray-700 dark:border-gray-900 text-xs">
Expand All @@ -22,8 +22,8 @@
<div class="flex items-center">
<Checkbox @value={{this.allSelected}} @onToggle={{this.selectAll}} @disabled={{not this.permissions}} />
</div>
<div class="col-span-5 flex items-center">Permission</div>
<div class="col-span-6 flex items-center">Description</div>
<div class="col-span-5 flex items-center">{{t "iam.common.permission"}}</div>
<div class="col-span-6 flex items-center">{{t "iam.common.description"}}</div>
</div>
</div>
<div class="h-48 overflow-y-scroll">
Expand All @@ -32,7 +32,7 @@
<div class="mr-2">
<Spinner @iconClass="text-sky-500" />
</div>
<span>Loading permissions...</span>
<span>{{t "iam.components.permission-picker.loading-permission"}}</span>
</div>
{{/unless}}
{{#each this.permissions as |permission|}}
Expand Down
2 changes: 1 addition & 1 deletion addon/components/table/cell/group-members.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</a>
</div>
{{else}}
<span>No Members</span>
<span>{{t "iam.components.table.group-members.no-member"}}</span>
{{/each}}
</div>
38 changes: 24 additions & 14 deletions addon/controllers/groups/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { action } from '@ember/object';
import { isBlank } from '@ember/utils';
import { timeout } from 'ember-concurrency';
import { task } from 'ember-concurrency-decorators';
import getWithDefault from '@fleetbase/ember-core/utils/get-with-default';

export default class GroupsIndexController extends Controller {
/**
Expand All @@ -21,6 +22,13 @@ export default class GroupsIndexController extends Controller {
*/
@service store;

/**
* Inject the `intl` service
*
* @var {Service}
*/
@service intl;

/**
* Inject the `notifications` service
*
Expand Down Expand Up @@ -105,21 +113,21 @@ export default class GroupsIndexController extends Controller {
*/
@tracked columns = [
{
label: 'Name',
label: this.intl.t('iam.common.name'),
valuePath: 'name',
cellComponent: 'table/cell/anchor',
onClick: this.editGroup,
width: '20%',
sortable: false,
},
{
label: 'Description',
label: this.intl.t('iam.common.description'),
valuePath: 'description',
sortable: false,
width: '25%',
},
{
label: 'Members',
label: this.intl.t('iam.common.member'),
valuePath: 'users',
cellComponent: 'table/cell/group-members',
onClick: (user) => {
Expand All @@ -129,7 +137,7 @@ export default class GroupsIndexController extends Controller {
width: '35%',
},
{
label: 'Created',
label: this.intl.t('iam.groups.index.created'),
valuePath: 'createdAt',
sortable: false,
width: '10%',
Expand All @@ -148,11 +156,11 @@ export default class GroupsIndexController extends Controller {
width: '10%',
actions: [
{
label: 'Edit group...',
label: this.intl.t('iam.groups.index.edit-group'),
fn: this.editGroup,
},
{
label: 'Delete group...',
label: this.intl.t('iam.groups.index.delete-group-label'),
fn: this.deleteGroup,
className: 'text-red-700 hover:text-red-800',
},
Expand Down Expand Up @@ -195,7 +203,7 @@ export default class GroupsIndexController extends Controller {

this.crud.bulkDelete(selected, {
modelNamePath: `name`,
acceptButtonText: 'Delete Groups',
acceptButtonText: this.intl.t('aim.groups.index.delete-group'),
onSuccess: () => {
return this.hostRouter.refresh();
},
Expand All @@ -220,12 +228,12 @@ export default class GroupsIndexController extends Controller {
const group = this.store.createRecord('group', { users: [] });

this.editGroup(group, {
title: 'New Group',
title: this.intl.t('iam.groups.index.new-group'),
group,
confirm: (modal) => {
modal.startLoading();
return group.save().then(() => {
this.notifications.success('New group created.');
this.notifications.success(this.intl.t('iam.groups.index.new-group-created'));
return this.hostRouter.refresh();
});
},
Expand All @@ -239,7 +247,7 @@ export default class GroupsIndexController extends Controller {
*/
@action editGroup(group, options = {}) {
this.modalsManager.show('modals/group-form', {
title: 'Edit Group',
title: this.intl.t('iam.groups.index.edit-group-title'),
group,
lastSelectedUser: null,
removeUser: (user) => {
Expand All @@ -252,7 +260,7 @@ export default class GroupsIndexController extends Controller {
confirm: (modal) => {
modal.startLoading();
return group.save().then(() => {
this.notifications.success('Changes to group saved.');
this.notifications.success(this.intl.t('iam.groups.index.changes-group-save'));
return this.hostRouter.refresh();
});
},
Expand All @@ -266,13 +274,15 @@ export default class GroupsIndexController extends Controller {
* @void
*/
@action deleteGroup(group) {
const groupName = getWithDefault(group, 'name', this.intl.t('iam.groups.index.untitled'));

this.modalsManager.confirm({
title: `Delete (${group.name || 'Untitled'}) group`,
body: 'Are you sure you want to delete this group? All data assosciated with this group will also be deleted. This action cannot be undone.',
title: this.intl.t('iam.groups.index.delete-group-title', { groupName }),
body: this.intl.t('iam.groups.index.data-assosciated-this-group-deleted'),
confirm: (modal) => {
modal.startLoading();
return group.destroyRecord().then((group) => {
this.notifications.success(`Group (${group.name}) deleted.`);
this.notifications.success(this.intl.t('iam.groups.index.delete-group-success-message', { name: group.name }));
this.hostRouter.refresh();
});
},
Expand Down
Loading
Loading