Skip to content

Commit

Permalink
#131, #111, #53, #128, #54: Add missing dialogs data save feature, ad…
Browse files Browse the repository at this point in the history
…d workaround for broken SDK in 2022.3
  • Loading branch information
seclerp committed Dec 8, 2022
1 parent dac0d3b commit 1efb0e0
Show file tree
Hide file tree
Showing 18 changed files with 332 additions and 50 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,14 @@
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
## [223.1.0] - 2022-12-07
### Added
- Most common values in dialogs are saved between instances
- Ability to run commands in terminal-like tool window
- Support for a stable Rider 2022.3

### Fixed
- DbContext class not showing up (#105)

## [223.0.0] - 2022-09-30
### Added
Expand Down Expand Up @@ -114,6 +121,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Deleting used database

[Unreleased]: https://github.com/seclerp/rider-efcore/compare/v223.0.0...HEAD
[223.1.0]: https://github.com/seclerp/rider-efcore/compare/v223.0.0...HEAD
[223.0.0]: https://github.com/seclerp/rider-efcore/compare/v222.2.0...v223.0.0
[222.2.0]: https://github.com/seclerp/rider-efcore/compare/v222.1.1...v222.2.0
[222.1.1]: https://github.com/seclerp/rider-efcore/compare/v222.1.0...v222.1.1
Expand Down
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import java.text.SimpleDateFormat
plugins {
id 'java'
id 'org.jetbrains.kotlin.jvm' version '1.6.21'
id 'org.jetbrains.intellij' version '1.9.0' // https://github.com/JetBrains/gradle-intellij-plugin/releases
id 'com.jetbrains.rdgen' version '2022.3.2' // https://www.myget.org/feed/rd-snapshots/package/maven/com.jetbrains.rd/rd-gen
id 'org.jetbrains.changelog' version '1.3.1'
id 'org.jetbrains.intellij' version '1.10.0' // https://github.com/JetBrains/gradle-intellij-plugin/releases
id 'com.jetbrains.rdgen' version '2022.3.4' // https://www.myget.org/feed/rd-snapshots/package/maven/com.jetbrains.rd/rd-gen
id 'org.jetbrains.changelog' version '2.0.0'
}

ext {
Expand Down
63 changes: 63 additions & 0 deletions docs/values-saved-between-dialogs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
## Which values are saved between dialogs?

> **Note**: To save selected values between dialogs the
> `Settings` | `Tools` | `EF Core UI` | `Use previously selected options in dialogs` option should be **enabled**.

### Common
- **Startup project**: Yes _(determined by previously selected pair with Migrations project)_
- **Migrations project**: Yes _(determined by previously selected pair with Startup project)_
- **DbContext value**: Yes _(per Migrations project)_
- **Build configuration**: No _(reason: default value equals to current solution configuration)_
- **SKip project build process**: Yes
- **Target framework**: Yes _(per Startup project)_
- **Additional arguments**: Yes _(when "Store sensitive data in a secure store" option is enabled)_


### Add Migration
- **Migration name**: No
- **Migrations folder**: Yes


### Remove Last Migration
Nothing to save.


### Generate SQL Script
- **From migration**: No
- **To migration**: No
- **Output file**: Yes
- **Make script idempotent**: Yes
- **No transactions**: Yes


### Update Database
- **Target migration**: No
- **Use default connection of startup project**: Yes
- **Connection**: Yes _(when "Store sensitive data in a secure store" option is enabled)_


### Drop Database
Nothing to save.


### Scaffold DbContext

#### Main
- **Connection**: Yes _(when "Store sensitive data in a secure store" option is enabled)_
- **Provider**: Yes
- **Output folder**: Yes
- **Use attributes to generate the model**: Yes
- **Use database names**: Yes
- **Generate OnConfiguring method**: Yes
- **Use the pluralizer**: Yes

#### DbContext
- **Generated DbContext name**: Yes
- **Generated DbContext folder**: Yes

#### Tables
- **Scaffold all schemas**: No

#### Schemas
- **Scaffold all schemas**: No
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ javaVersion=17
DotnetPluginId=Rider.Plugins.EfCore
DotnetSolution=Rider.Plugins.EfCore.sln
RiderPluginId=me.seclerp.rider.plugins.efcore
PluginVersion=223.0.0
PluginVersion=223.1.0

BuildConfiguration=Debug

Expand All @@ -15,12 +15,12 @@ PublishChannel=default
# Possible values:
# Release: 2021.2.0
# EAP: 2022.2.0-eap04
RiderSdkVersion=2022.3.0-eap01
RiderSdkVersion=2022.3.0
# Possible values (minor is omitted):
# Release: 2020.2
# Nightly: 2020.3-SNAPSHOT
# EAP: 2020.3-EAP2-SNAPSHOT
ProductVersion=2022.3-EAP1-SNAPSHOT
ProductVersion=2022.3-SNAPSHOT

# Kotlin 1.4 will bundle the stdlib dependency by default, causing problems with the version bundled with the IDE
# https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-rc-released/#stdlib-default
Expand Down
2 changes: 1 addition & 1 deletion src/dotnet/Plugin.props
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project>

<PropertyGroup>
<SdkVersion Condition=" '$(SdkVersion)' == '' ">2022.3.0-eap01</SdkVersion>
<SdkVersion Condition=" '$(SdkVersion)' == '' ">2022.3.0</SdkVersion>

<Title>Entity Framework Core</Title>
<Description>JetBrains Rider plugin for Entity Framework Core</Description>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package me.seclerp.rider.plugins.efcore.cli.execution

import com.intellij.openapi.components.Service
import com.intellij.openapi.components.service
import com.intellij.openapi.project.Project
import me.seclerp.rider.plugins.efcore.settings.EfCoreUiSettingsStateService

@Service
class PreferredCommandExecutorProvider(private val intellijProject: Project) {
private val settingsStateService = service<EfCoreUiSettingsStateService>()
private val settingsStateService = EfCoreUiSettingsStateService.getInstance()

fun getExecutor(): CliCommandExecutor =
when (settingsStateService.useTerminalExecution) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import me.seclerp.observables.bind
import me.seclerp.observables.observable
import me.seclerp.rider.plugins.efcore.features.shared.ObservableMigrations
import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDataContext
import me.seclerp.rider.plugins.efcore.state.DialogsStateService

class UpdateDatabaseDataContext(intellijProject: Project): CommonDataContext(intellijProject, true) {
val availableMigrations = ObservableMigrations(intellijProject, migrationsProject, dbContext)
Expand All @@ -25,4 +26,33 @@ class UpdateDatabaseDataContext(intellijProject: Project): CommonDataContext(int
""
}
}

override fun loadState(commonDialogState: DialogsStateService.SpecificDialogState) {
super.loadState(commonDialogState)

commonDialogState.getBool(KnownStateKeys.USE_DEFAULT_CONNECTION)?.apply {
useDefaultConnection.value = this
}

if (pluginSettings.storeSensitiveData && !useDefaultConnection.value) {
commonDialogState.getSensitive(KnownStateKeys.CONNECTION)?.apply {
connection.value = this
}
}
}

override fun saveState(commonDialogState: DialogsStateService.SpecificDialogState) {
super.saveState(commonDialogState)

commonDialogState.set(KnownStateKeys.USE_DEFAULT_CONNECTION, useDefaultConnection.value)

if (pluginSettings.storeSensitiveData && !useDefaultConnection.value) {
commonDialogState.setSensitive(KnownStateKeys.CONNECTION, connection.value)
}
}

object KnownStateKeys {
const val USE_DEFAULT_CONNECTION = "useDefaultConnection"
const val CONNECTION = "connection"
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package me.seclerp.rider.plugins.efcore.features.dbcontext.scaffold

import com.intellij.openapi.project.Project
import me.seclerp.observables.ObservableCollection
import me.seclerp.observables.observable
import me.seclerp.observables.observableList
import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDataContext
import me.seclerp.rider.plugins.efcore.state.DialogsStateService
import me.seclerp.rider.plugins.efcore.ui.items.SimpleItem

class ScaffoldDbContextDataContext(intellijProject: Project) : CommonDataContext(intellijProject, false) {
Expand All @@ -25,4 +25,75 @@ class ScaffoldDbContextDataContext(intellijProject: Project) : CommonDataContext

val scaffoldAllTables = observable(true)
val scaffoldAllSchemas = observable(true)

override fun loadState(commonDialogState: DialogsStateService.SpecificDialogState) {
super.loadState(commonDialogState)

if (pluginSettings.storeSensitiveData) {
commonDialogState.getSensitive(KnownStateKeys.CONNECTION)?.apply {
connection.value = this
}
}

commonDialogState.get(KnownStateKeys.PROVIDER)?.apply {
provider.value = this
}

commonDialogState.get(KnownStateKeys.OUTPUT_FOLDER)?.apply {
outputFolder.value = this
}

commonDialogState.getBool(KnownStateKeys.USE_ATTRIBUTES)?.apply {
useAttributes.value = this
}

commonDialogState.getBool(KnownStateKeys.USE_DATABASE_NAMES)?.apply {
useDatabaseNames.value = this
}

commonDialogState.getBool(KnownStateKeys.GENERATE_ON_CONFIGURING)?.apply {
generateOnConfiguring.value = this
}

commonDialogState.getBool(KnownStateKeys.USE_PLURALIZER)?.apply {
usePluralizer.value = this
}

commonDialogState.get(KnownStateKeys.DB_CONTEXT_NAME)?.apply {
dbContextName.value = this
}

commonDialogState.get(KnownStateKeys.DB_CONTEXT_FOLDER)?.apply {
dbContextFolder.value = this
}
}

override fun saveState(commonDialogState: DialogsStateService.SpecificDialogState) {
super.saveState(commonDialogState)

if (pluginSettings.storeSensitiveData) {
commonDialogState.setSensitive(KnownStateKeys.CONNECTION, connection.value)
}

commonDialogState.set(KnownStateKeys.PROVIDER, provider.value)
commonDialogState.set(KnownStateKeys.OUTPUT_FOLDER, outputFolder.value)
commonDialogState.set(KnownStateKeys.USE_ATTRIBUTES, useAttributes.value)
commonDialogState.set(KnownStateKeys.USE_DATABASE_NAMES, useDatabaseNames.value)
commonDialogState.set(KnownStateKeys.GENERATE_ON_CONFIGURING, generateOnConfiguring.value)
commonDialogState.set(KnownStateKeys.USE_PLURALIZER, usePluralizer.value)
commonDialogState.set(KnownStateKeys.DB_CONTEXT_NAME, dbContextName.value)
commonDialogState.set(KnownStateKeys.DB_CONTEXT_FOLDER, dbContextFolder.value)
}

object KnownStateKeys {
const val CONNECTION = "connection"
const val PROVIDER = "provider"
const val OUTPUT_FOLDER = "outputFolder"
const val USE_ATTRIBUTES = "useAttributes"
const val USE_DATABASE_NAMES = "useDatabaseNames"
const val GENERATE_ON_CONFIGURING = "generateOnConfiguring"
const val USE_PLURALIZER = "usePluralizer"
const val DB_CONTEXT_NAME = "dbContextName"
const val DB_CONTEXT_FOLDER = "dbContextFolder"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.intellij.openapi.project.Project
import me.seclerp.observables.*
import me.seclerp.rider.plugins.efcore.features.shared.ObservableMigrations
import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDataContext
import me.seclerp.rider.plugins.efcore.state.DialogsStateService

class AddMigrationDataContext(
intellijProject: Project
Expand All @@ -24,4 +25,22 @@ class AddMigrationDataContext(
migrationName.value
}
}

override fun loadState(commonDialogState: DialogsStateService.SpecificDialogState) {
super.loadState(commonDialogState)

commonDialogState.get(KnownStateKeys.OUTPUT_FOLDER)?.apply {
migrationsOutputFolder.value = this
}
}

override fun saveState(commonDialogState: DialogsStateService.SpecificDialogState) {
super.saveState(commonDialogState)

commonDialogState.set(KnownStateKeys.OUTPUT_FOLDER, migrationsOutputFolder.value)
}

object KnownStateKeys {
const val OUTPUT_FOLDER = "outputFolder"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.intellij.openapi.project.Project
import me.seclerp.observables.*
import me.seclerp.rider.plugins.efcore.features.shared.ObservableMigrations
import me.seclerp.rider.plugins.efcore.features.shared.dialog.CommonDataContext
import me.seclerp.rider.plugins.efcore.state.DialogsStateService

class GenerateScriptDataContext(
intellijProject: Project
Expand Down Expand Up @@ -44,4 +45,34 @@ class GenerateScriptDataContext(
}
}
}

override fun loadState(commonDialogState: DialogsStateService.SpecificDialogState) {
super.loadState(commonDialogState)

commonDialogState.get(KnownStateKeys.OUTPUT_FILE)?.apply {
outputFilePath.value = this
}

commonDialogState.getBool(KnownStateKeys.IDEMPOTENT)?.apply {
idempotent.value = this
}

commonDialogState.getBool(KnownStateKeys.NO_TRANSACTIONS)?.apply {
noTransactions.value = this
}
}

override fun saveState(commonDialogState: DialogsStateService.SpecificDialogState) {
super.saveState(commonDialogState)

commonDialogState.set(KnownStateKeys.OUTPUT_FILE, outputFilePath.value)
commonDialogState.set(KnownStateKeys.IDEMPOTENT, idempotent.value)
commonDialogState.set(KnownStateKeys.NO_TRANSACTIONS, noTransactions.value)
}

object KnownStateKeys {
const val OUTPUT_FILE = "outputFilePath"
const val IDEMPOTENT = "idempotent"
const val NO_TRANSACTIONS = "noTransactions"
}
}
Loading

0 comments on commit 1efb0e0

Please sign in to comment.