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

feat(app): support editor preference #18932

Merged
merged 32 commits into from
Nov 18, 2021
Merged

Conversation

lmiller1990
Copy link
Contributor

@lmiller1990 lmiller1990 commented Nov 16, 2021

  • allow configuring editor in settings page in app
  • refactor concept of "openerId" and "binary" to be the same
  • setting up data layer for device settings (eventually saved_state caching will all move to data-context layer, but it's too big to do right now)

All the data here is wired up to the server and working correctly:

image

@@ -8,11 +8,11 @@ import '../main.scss'
/* global cy, Cypress */
describe('FilePreference', () => {
const availableEditors = [
{ id: 'atom', name: 'Atom', isOther: false, openerId: 'atom' },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

openerId and binary are the same, but duplicated. Removing this is technical a breaking change, so now is the time to do it. Worst case scenario is the user will need to select their preferred editor again.

@cypress
Copy link

cypress bot commented Nov 16, 2021



Test summary

18648 1 216 7Flakiness 4


Run details

Project cypress
Status Failed
Commit 026aa34
Started Nov 18, 2021 3:19 AM
Ended Nov 18, 2021 3:30 AM
Duration 11:40 💡
OS Linux Debian - 10.9
Browser Multiple

View run in Cypress Dashboard ➡️


Failures

cypress/integration/commands/assertions_spec.js Failed
1 ... > rejects any element not in the document

Flakiness

commands/net_stubbing_spec.ts Flakiness
1 network stubbing > waiting and aliasing > can timeout waiting on a single request using "alias.request"
2 network stubbing > waiting and aliasing > can timeout waiting on a single request using "alias.request"
cypress/proxy-logging-spec.ts Flakiness
1 ... > works with forceNetworkError
e2e/redirects_spec.js Flakiness
1 redirection > meta > binds to the new page after a timeout

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

id: 'other',
name: 'Other',
openerId: '',
isOther: true,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed this option from here - it's only here for the purpose of having a placeholder on the front-end UI.

We still need that placeholder for now, so I append it here... https://github.com/cypress-io/cypress/pull/18932/files#diff-164ce6bedd1fe744fbd75f7b8526d850c94eb6fd43b9c22e60b18e976d9b21a8R376 will delete post 10.0.

@@ -67,37 +66,17 @@ describe('lib/util/editors', () => {
sinon.restore()
})

it('returns a list of editors on the user\'s system with an "On Computer" option prepended and an "Other" option appended', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No longer needed, we no long append this option in editors.ts, instead we do it elsewhere. I don't think this placeholder, which is here for the purpose of having a placeholder in the UI, should be the responsibility of this server module.

More info: https://github.com/cypress-io/cypress/pull/18932/files#r750277563

@lmiller1990 lmiller1990 requested review from ImCesar, tgriesser and a team November 17, 2021 09:01
@lmiller1990 lmiller1990 marked this pull request as ready for review November 17, 2021 09:01
@lmiller1990 lmiller1990 requested a review from a team as a code owner November 17, 2021 09:01
@lmiller1990 lmiller1990 requested review from jennifer-shehane and removed request for a team November 17, 2021 09:02
@lmiller1990 lmiller1990 removed the request for review from jennifer-shehane November 17, 2021 09:02
tgriesser
tgriesser previously approved these changes Nov 17, 2021
},
})

t.liveMutation('setWatchForSpecChange', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't matter for this PR, but just wanted to mention I think it might be better if we start moving away from the liveMutation everywhere, now that we have patterns for state management nailed down in our urql cache, linting on ensuring id exists, etc. Changing a config setting probably doesn't need to refetch everything on the page if we know it's updating a single field.

Was going to introduce that in #18906 and document in the general architecture guide, but don't worry about making that change here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, lets's get rid of live mutation in one single PR - sounds good

@@ -300,6 +300,54 @@ export const mutation = mutationType({
},
})

t.liveMutation('setAutoScrollingEnabled', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be simpler to have a single mutation for this like updateSettings($input: UpdateSettingsInput). We can change that later though

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah just realized this, I want to redo the entire cache layer (for appData) and probably add this refactor then (as well as typing the rest of the appData layer etc...)

Copy link
Contributor

@ZachJW34 ZachJW34 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few comments, nothing blocking.

Would it be good to have an empty state here, like a -.
Screen Shot 2021-11-17 at 9 46 05 AM

cy.mount(() => <ExternalEditorSettings class="p-12" />)
cy.mountFragment(ExternalEditorSettingsFragmentDoc, {
onResult: (ctx) => {
ctx.localSettings.availableEditors = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be stubbed in packages/frontend-shared/cypress/support/mock-graphql/stubgql-*?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gql`
mutation SetPreferredEditorBinary ($value: String!) {
setPreferredEditorBinary (value: $value)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove newline

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return props.gql.localSettings.availableEditors.find((x) => x.binary === props.gql.localSettings.preferences.preferredEditorBinary)
})

const updateEditor = async (editor: ExternalEditorSettingsFragment['localSettings']['availableEditors'][number]) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any reason to use async here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

export class LocalSettingsActions {
constructor (private ctx: DataContext) {}

async setDevicePreference<K extends keyof DevicePreferences> (key: K, value: DevicePreferences[K]) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need async?

@@ -0,0 +1,5 @@
import type { DataContext } from '..'

export class LocalSettingsSource {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? And if we do, it should be named LocalSettingsDataSource.

@lmiller1990 lmiller1990 merged commit e983f90 into 10.0-release Nov 18, 2021
@lmiller1990 lmiller1990 deleted the lmiller1990/editors branch November 18, 2021 03:40
tgriesser added a commit that referenced this pull request Nov 21, 2021
* 10.0-release:
  feat: use fuzzy search (#18966)
  fix: onUnmounted warning in topnav (#18988)
  fix: CYPRESS_INTERNAL_VITE_DEV for development
  feat: Create default config file (#18943)
  feat(app): support editor preference (#18932)
tgriesser added a commit that referenced this pull request Nov 21, 2021
…e-data-clean-refactor

* tgriesser/chore/e2e-data-clean: (76 commits)
  chore: post-merge cleanup
  feat: use hoisted yarn install in binary build (#17285)
  fix: fix spec list header, "Create specs" prompt, add workspace recommended apollo extension (#18993)
  feat(unify): reporter settings (#18946)
  feat: add devServer to config file (#18962)
  fix: compile npm packages for node 12 (#18989)
  fix: show call count even if `cy.stub().log(false)`. (#18907)
  chore: Update TypeScript to 4.4.4 (#18930)
  feat: use fuzzy search (#18966)
  fix: onUnmounted warning in topnav (#18988)
  fix: wrap playground selectors in double quotes if not included (#18442)
  fix: flaky settings_spec test (#18979)
  fix: CYPRESS_INTERNAL_VITE_DEV for development
  feat: Create default config file (#18943)
  feat(app): support editor preference (#18932)
  chore: Update Chrome (stable) to 96.0.4664.45 (#18931)
  fix: Loading of specs with % in the filename (#18877)
  feat: improve vite DX (#18937)
  chore: refactor `create` into class `$Cy` (#18715)
  feat: Use plugins on config files (#18798)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants