Skip to content
This repository has been archived by the owner on Aug 1, 2022. It is now read-only.

feat(ui): check if project exists when searching #1030

Merged
merged 10 commits into from Oct 14, 2020
Merged

Conversation

xla
Copy link
Contributor

@xla xla commented Oct 13, 2020

Up until now we assumed the provided urn is not present in the monorepo.
This change alters the behaviour to first check if a project exists
locally - because locally sourced is best source. If it exists locally
the result box offers to navigate directly to it -- also possible with a
hit of enter. Should it not exist a track toggle is presented, which
when pressed will fire a request for the project and show a
notification.

  • check for project locally first
  • navigate to existing project
  • request urn from the network on track toggle
  • validate input to be a valid urn

Refs #984

@xla xla added feature Something that doesn't exist yet ui labels Oct 13, 2020
@xla xla self-assigned this Oct 13, 2020
@xla xla mentioned this pull request Oct 13, 2020
@cloudhead
Copy link
Contributor

Concept ACK

@xla xla mentioned this pull request Oct 14, 2020
8 tasks
Comment on lines -25 to +27
import Modal from "./Modal";
import ModalNewProject from "./Modal/NewProject.svelte";
import ModalSearch from "./Modal/Search.svelte";
import ModalShortcuts from "./Modal/Shortcuts.svelte";
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be better to separate such cosmetic changes into separates PRs. And I'd prefer to undo this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is not a cosmetic change, it's a structural one. Given the overhead of getting a change reviewed, approved and kept in sync with mainline, I made the call to include it here. As I touched the part of the codebase already. It does not distract or obfuscate the other changes and it should be fine to approve it along the rest.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for the wrong categorization on my side. In any case, still not fond of this change. What's the context and motivation 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.

It's the removal of the unnecessary bookkeeping in index.js plus dropping the superfluous Modal suffix.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I don't dislike dropping the bookkepping but the namespacing I do appreciate. The prefix is staying around as you see, though less elegant. Happy to talk about this another time.

@@ -1,6 +1,8 @@
<script lang="ts">
<script lang="typescript">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<script lang="typescript">
<script lang="ts">

Unless there's a good reason for the change, let's keep it consistent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah cool 👍

Comment on lines -15 to -19
enum TrackingEvent {
Track = "track",
Untrack = "untrack",
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Kind of unnecessary to move this to a new module with only this type when it is only used 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.

Consumers rely on the string value of these variants to catch the right events, but I didn't find a way to share that meaningfully. This was an attempt to do so.

Copy link
Contributor

Choose a reason for hiding this comment

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

fwiw: I'm all for small modules with specific data 👍 Just because it's only used here now doesn't mean the tests of time will not force it to be used elsewhere or be added to.

<script lang="ts">
import { createEventDispatcher } from "svelte";

<script lang="typescript">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<script lang="typescript">
<script lang="ts">

@@ -1,4 +1,4 @@
<script lang="ts">
<script lang="typescript">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<script lang="typescript">
<script lang="ts">

@@ -0,0 +1,171 @@
<script lang="typescript">
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<script lang="typescript">
<script lang="ts">

Comment on lines +22 to +23
let id: string;
let value: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

could you document what these are?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Could you expand on what kind of documentation you expect when stumbling upon these? Also would it help to rename them to not require documentation?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, renaming would probably be best. Expanding, I open this file and have no idea what id and value stand or are used for.

Copy link
Contributor

Choose a reason for hiding this comment

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

Looking at the code I'd probably call this rawUrn or unvalidatedUrn.

Also is the id above actually the urn? I find the name id hard to discern whether it's a PeerId or a RadUrn. WHERE ARE MY TYPES AS DOCUMENTATION /raises fist to sky

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Looking at the code I'd probably call this rawUrn or unvalidatedUrn.
It's validated.

It's the id part of of a RadUrn.

ui/src/search.ts Outdated Show resolved Hide resolved
ui/src/search.ts Outdated Show resolved Hide resolved
@@ -1,6 +1,8 @@
<script lang="ts">
<script lang="typescript">
Copy link
Member

Choose a reason for hiding this comment

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

Just out of curiosity, what's the difference? So far we've been using ts everywhere.
Official docs also mention ts: https://svelte.dev/blog/svelte-and-typescript#1_Compiling_TypeScript.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Somehow my editor stack doesn't pick it up unless it's the full language name.

Copy link
Member

Choose a reason for hiding this comment

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

Whirrd!

I think we should try to keep them consistent, so we should either fix your editor or update the rest of the codebase to use typescript.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment on lines +89 to +96
.container {
width: 26.5rem;
}

.search-bar {
margin-bottom: 1rem;
position: relative;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.container {
width: 26.5rem;
}
.search-bar {
margin-bottom: 1rem;
position: relative;
}
.container {
width: 50vw;
max-width: 800px;
min-width: 500px;
}
.search-bar {
margin-bottom: 1rem;
position: relative;
padding: var(--content-padding);
background-color: var(--color-background);
border-radius: 4px;
}

Now the validation error message is displaying in red on top of the overlay which is dark, looking no good, imo:

x

This suggestion does two things:

  1. Improves the responsiveness of the modal container, looking better in both small and large screens:

small
small

medium
medium

large
Screenshot from 2020-10-14 09-25-07

  1. Wraps the search bar with the appropriate background colour with nice padding:

Screenshot from 2020-10-14 09-32-38

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, @radicle-dev/product is aware of it and the work is tracked in #1031

Copy link
Contributor

Choose a reason for hiding this comment

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

Woudln't hurt to include this alrerady though as an temporary improvement.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can make these changes when polishing for the beta release. Don't see much value in doing changes until @radicle-dev/product has settled on something.

xla and others added 2 commits October 14, 2020 10:03
Co-authored-by: Nuno Alexandre <hi@nunoalexandre.com>
Co-authored-by: Nuno Alexandre <hi@nunoalexandre.com>
import { Icon, Input } from "../DesignSystem/Primitive";
import { Remote, TrackToggle } from "../DesignSystem/Component";

let id: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait, what's the id used for? I see that upon validation you set it as the Urn minus rad:git, but I can't see where that's used 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's shown next to the track button in the search resullt.


case Kind.RequestProject:
projectRequestStore.loading();
// FIXME(xla): This truly belongs in project.ts.
Copy link
Contributor

Choose a reason for hiding this comment

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

Or project/search.ts

@xla xla merged commit 646c50e into master Oct 14, 2020
@xla xla deleted the xla/984-check-project branch October 14, 2020 11:48
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature Something that doesn't exist yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants