web/satellite: create access grant: bucket search feature

WHAT:
search for bucket names during creating access grant flow

WHY:
make user be able to search for needed buckets. Just in case if the number of buckets is too large.

Change-Id: I73bcaa160c7a1f433d8f0f7213999e7e40543bbc
This commit is contained in:
VitaliiShpital 2020-11-30 17:33:49 +02:00 committed by Vitalii Shpital
parent 494bd5db81
commit 7eccfccfda
2 changed files with 60 additions and 16 deletions

View File

@ -7,9 +7,17 @@
<p class="buckets-dropdown__container__all" @click.stop="selectAllBuckets"> <p class="buckets-dropdown__container__all" @click.stop="selectAllBuckets">
All All
</p> </p>
<label class="buckets-dropdown__container__search">
<input
class="buckets-dropdown__container__search__input"
placeholder="Search buckets"
type="text"
v-model="bucketSearch"
>
</label>
<div <div
class="buckets-dropdown__container__choices" class="buckets-dropdown__container__choices"
v-for="(name, index) in allBucketNames" v-for="(name, index) in bucketsList"
:key="index" :key="index"
> >
<div <div
@ -27,6 +35,9 @@
/> />
</div> </div>
</div> </div>
<p class="buckets-dropdown__container__no-buckets" v-if="!bucketsList.length">
No Buckets
</p>
</div> </div>
</div> </div>
</template> </template>
@ -46,6 +57,8 @@ import { ACCESS_GRANTS_ACTIONS } from '@/store/modules/accessGrants';
}, },
}) })
export default class BucketsDropdown extends Vue { export default class BucketsDropdown extends Vue {
public bucketSearch: string = '';
/** /**
* Clears selection of specific buckets and closes dropdown. * Clears selection of specific buckets and closes dropdown.
*/ */
@ -69,19 +82,24 @@ export default class BucketsDropdown extends Vue {
return this.selectedBucketNames.includes(name); return this.selectedBucketNames.includes(name);
} }
/**
* Returns stored bucket names list filtered by search string.
*/
public get bucketsList(): string[] {
const NON_EXIST_INDEX = -1;
const buckets: string[] = this.$store.state.bucketUsageModule.allBucketNames;
return buckets.filter((name: string) => {
return name.indexOf(this.bucketSearch.toLowerCase()) !== NON_EXIST_INDEX;
});
}
/** /**
* Returns stored selected bucket names. * Returns stored selected bucket names.
*/ */
public get selectedBucketNames(): string[] { public get selectedBucketNames(): string[] {
return this.$store.state.accessGrantsModule.selectedBucketNames; return this.$store.state.accessGrantsModule.selectedBucketNames;
} }
/**
* Returns all bucket names.
*/
public get allBucketNames(): string[] {
return this.$store.state.bucketUsageModule.allBucketNames;
}
} }
</script> </script>
@ -103,14 +121,14 @@ export default class BucketsDropdown extends Vue {
background-color: #fff; background-color: #fff;
border: 1px solid rgba(56, 75, 101, 0.4); border: 1px solid rgba(56, 75, 101, 0.4);
width: 100%; width: 100%;
padding-top: 10px; padding: 10px 0;
&__container { &__container {
overflow-y: scroll; overflow-y: scroll;
overflow-x: hidden; overflow-x: hidden;
height: auto; height: auto;
width: 100%; width: 100%;
max-height: 300px; max-height: 230px;
background-color: #fff; background-color: #fff;
border-radius: 6px; border-radius: 6px;
font-family: 'font_regular', sans-serif; font-family: 'font_regular', sans-serif;
@ -120,6 +138,19 @@ export default class BucketsDropdown extends Vue {
line-height: 21px; line-height: 21px;
color: #384b65; color: #384b65;
&__search {
padding: 5px 10px;
width: calc(100% - 20px);
&__input {
font-size: 14px;
line-height: 18px;
border-radius: 6px;
width: calc(100% - 30px);
padding: 5px;
}
}
&__all { &__all {
margin: 0; margin: 0;
cursor: pointer; cursor: pointer;
@ -132,6 +163,19 @@ export default class BucketsDropdown extends Vue {
} }
} }
&__no-buckets {
font-family: 'font_bold', sans-serif;
margin: 0;
font-size: 18px;
line-height: 24px;
cursor: default;
color: #000;
background-color: #fff;
width: 100%;
padding: 15px 0;
text-align: center;
}
&__choices { &__choices {
&__item__unselect-icon { &__item__unselect-icon {

View File

@ -12,12 +12,12 @@
class="buckets-selection__toggle-container__expand-icon" class="buckets-selection__toggle-container__expand-icon"
alt="Arrow down (expand)" alt="Arrow down (expand)"
/> />
<BucketsDropdown
v-show="isDropdownShown"
@close="closeDropdown"
v-click-outside="closeDropdown"
/>
</div> </div>
<BucketsDropdown
v-if="isDropdownShown"
@close="closeDropdown"
v-click-outside="closeDropdown"
/>
</div> </div>
</template> </template>
@ -82,9 +82,9 @@ export default class BucketsSelection extends Vue {
border: 1px solid rgba(56, 75, 101, 0.4); border: 1px solid rgba(56, 75, 101, 0.4);
font-family: 'font_regular', sans-serif; font-family: 'font_regular', sans-serif;
width: 235px; width: 235px;
position: relative;
&__toggle-container { &__toggle-container {
position: relative;
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: space-between; justify-content: space-between;