Skip to content

Commit

Permalink
Highlight preferred group if it's found in the "Where" list
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyrat committed Jul 1, 2020
1 parent 82d983c commit fc4becd
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
10 changes: 8 additions & 2 deletions popup/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@
@save-where-clicked="saveWhere"
@cancel-clicked="saveDiscard"
/>
<SaveWhere v-if="showSaveWhere" :display-reason="displayWhereReason" />
<SaveWhere
v-if="showSaveWhere"
:display-reason="displayWhereReason"
:preferred-group-uuid="preferredGroupUuid"
/>
</v-container>
</v-main>

Expand Down Expand Up @@ -191,6 +195,7 @@ export default {
saveLastActiveAt: null,
showSaveWhere: false,
displayWhereReason: null,
preferredGroupUuid: "",
// imported constants are only available in Vue if we assign them to data
tooltipDelay,
Expand Down Expand Up @@ -307,8 +312,9 @@ export default {
this.$store.dispatch("updateSaveState", updatedSaveState);
//this.saveLastActiveAt = updatedSaveState.lastActiveAt;
},
saveWhere: function (this: any, displayWhereReason: string) {
saveWhere: function (this: any, displayWhereReason: string, preferredGroupUuid: string) {
this.displayWhereReason = displayWhereReason;
this.preferredGroupUuid = preferredGroupUuid;
this.showSaveWhere = true;
},
showHelp: () => {
Expand Down
14 changes: 7 additions & 7 deletions popup/components/Save1stParty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,13 @@ export default {
},
async mounted(this: any) {
this.preferToSkipWhere = configManager.current.rememberMRUGroup;
const dbs = this.$store.state.KeePassDatabases as Database[];
const { preferredGroupUuid, preferredDb, primaryFound } = this.getPreferredGroup(
configManager.current.mruGroup,
dbs
);
this.preferredGroupUuid = preferredGroupUuid;
if (this.preferToSkipWhere) {
const dbs = this.$store.state.KeePassDatabases as Database[];
const { preferredGroupUuid, preferredDb, primaryFound } = this.getPreferredGroup(
configManager.current.mruGroup,
dbs
);
this.preferredGroupUuid = preferredGroupUuid;
this.preferredDb = preferredDb;
this.primaryFound = primaryFound;
Expand All @@ -203,7 +203,7 @@ export default {
this.$emit("cancel-clicked");
},
nextClicked: function (this: any) {
this.$emit("save-where-clicked", this.displayWhereReason);
this.$emit("save-where-clicked", this.displayWhereReason, this.preferredGroupUuid);
},
saveEntry: function (this: any) {
const updatedSaveState = Object.assign({}, this.$store.state.saveState) as SaveState;
Expand Down
19 changes: 13 additions & 6 deletions popup/components/SaveWhere.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
</v-sheet>
<v-card-text>
<v-treeview
:active="groupUuidArray"
:items="items"
:search="search"
selection-type="independent"
Expand Down Expand Up @@ -98,11 +99,12 @@ function findDatabaseByGroup(databases: Database[], group: Group) {
}
export default {
props: ["displayReason"],
props: ["preferredGroupUuid", "displayReason"],
data: () => ({
search: null,
saveEnabled: true,
skipInFuture: configManager.current.rememberMRUGroup
saveEnabled: false,
skipInFuture: configManager.current.rememberMRUGroup,
groupUuidArray: []
}),
computed: {
...mapGetters(["saveState", "KeePassDatabases", "ActiveKeePassDatabaseIndex"]),
Expand All @@ -123,23 +125,28 @@ export default {
}
}
},
mounted(this: any) {
this.groupUuidArray = [{ uuid: this.preferredGroupUuid }];
},
methods: {
saveEntry: function (this: any) {
Port.postMessage({ action: Action.CreateEntry } as AddonMessage);
window.close();
},
setGroup: function (this: any, value) {
const database = findDatabaseByGroup(this.KeePassDatabases, value[0]);
setGroup: function (this: any, values) {
if (!(values?.length > 0)) return;
const database = findDatabaseByGroup(this.KeePassDatabases, values[0]);
const updatedSaveState = Object.assign({}, this.$store.state.saveState) as SaveState;
updatedSaveState.newEntry = new Entry({
...updatedSaveState.newEntry,
parentGroup: value[0],
parentGroup: values[0],
database: new DatabaseSummary({
fileName: database.fileName,
root: new GroupSummary({ uuid: TemporaryIDString })
})
});
this.$store.dispatch("updateSaveState", updatedSaveState);
this.saveEnabled = true;
}
}
};
Expand Down

0 comments on commit fc4becd

Please sign in to comment.