Skip to content

feat: Key-value pair view for environment[INS-4256]#8071

Merged
cwangsmv merged 17 commits intodevelopfrom
feat/env-config-table-view
Oct 28, 2024
Merged

feat: Key-value pair view for environment[INS-4256]#8071
cwangsmv merged 17 commits intodevelopfrom
feat/env-config-table-view

Conversation

@cwangsmv
Copy link
Copy Markdown
Contributor

@cwangsmv cwangsmv commented Oct 12, 2024

Highlight and Changes:

Add new KV-pair view for environment

  • Collection environment
Screenshot 2024-10-17 at 15 52 52
  • Global environment
Screenshot 2024-10-17 at 15 51 59
  • Folder environment
Screenshot 2024-10-17 at 11 26 25
  • UI Change:
    • New key-pair table for collection environment, global environment and folder environment UI
    • Prompt JSON editor modal
    • Add button to switch JSON view & kv pair view
    • Confirm naming and default view for environment
  • Models Change:
    • Add type and kv pair data attribute to environment and request-group data model
    • Ensure that newly add attributes won't add new attributes to old datas in git sync
  • Data transform
    • JSON and kv pair data transform logic

@cwangsmv cwangsmv marked this pull request as draft October 12, 2024 05:31
@cwangsmv cwangsmv force-pushed the feat/env-config-table-view branch 2 times, most recently from ee16325 to 7578f6c Compare October 17, 2024 07:42
@cwangsmv cwangsmv marked this pull request as ready for review October 17, 2024 07:56
@cwangsmv cwangsmv changed the title feat: Key-value pair view for environment feat: Key-value pair view for environment[INS-4256] Oct 17, 2024
@cwangsmv cwangsmv requested review from gatzjames and jackkav October 17, 2024 08:21
Copy link
Copy Markdown
Contributor

@ihexxa ihexxa left a comment

Choose a reason for hiding this comment

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

Had review as pass 1 and will do more checks later.

Comment thread packages/insomnia/src/ui/components/modals/workspace-environments-edit-modal.tsx Outdated
Comment thread packages/insomnia/src/ui/components/panes/request-group-pane.tsx Outdated
kvPair.push({
id: generateId('envPair'),
name: key,
value: isValObject ? JSON.stringify(val) : String(val),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

JSON.stringify may not work with nunjucks tags as values.

Copy link
Copy Markdown
Contributor Author

@cwangsmv cwangsmv Oct 22, 2024

Choose a reason for hiding this comment

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

Show a modal to block user from changing to table view when there's JSON error
Screenshot 2024-10-22 at 17 19 14

id: string;
name: string;
value: string;
type: EnvironmentKvPairDataType;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can we infer the data types for other primitives like number, boolean etc?
Currently if I add a number or boolean it is recognized as string in the table editor.
This might be difficult if we try to infer nunjucks templates that are not inside quotes but not quite sure about it.

},
];

const renderPairItem = (kvPair: EnvironmentKvPairData) => {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe we should turn this into a component in the module scope?

}, []);

return (
<div className="p-[--padding-sm] min-w-max h-full overflow-hidden flex flex-col">
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks like there is extra padding around the toolbar. If we want we could add padding in the key-value editor ListBox bellow

Suggested change
<div className="p-[--padding-sm] min-w-max h-full overflow-hidden flex flex-col">
<div className="min-w-max h-full overflow-hidden flex flex-col">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

OK, will remove the padding for toolbar

@cwangsmv cwangsmv force-pushed the feat/env-config-table-view branch from 7d5f4c6 to c239fbe Compare October 28, 2024 02:14
@cwangsmv cwangsmv enabled auto-merge (squash) October 28, 2024 02:15
@cwangsmv cwangsmv merged commit 0bae709 into develop Oct 28, 2024
@cwangsmv cwangsmv deleted the feat/env-config-table-view branch October 28, 2024 02:26
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