GitLab snippet Web Intents - autofill from text query parameter
<!--IssueSummary start--> <details> <summary> Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards. </summary> - [Label this issue](https://contributors.gitlab.com/manage-issue?action=label&projectId=278964&issueIid=199402) - [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=199402) </details> <!--IssueSummary end--> ### Problem to solve Currently, there isn't a programmatic way to populate the snippet text area. ### Intended users <!-- Who will use this feature? If known, include any of the following: types of users (e.g. Developer), personas, or specific company roles (e.g. Release Manager). It's okay to write "Unknown" and fill this field in later. * [Rachel (Release Manager)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#rachel-release-manager) * [Parker (Product Manager)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#parker-product-manager) * [Delaney (Development Team Lead)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#delaney-development-team-lead) * [Sasha (Software Developer)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#sasha-software-developer) * [Presley (Product Designer)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#presley-product-designer) * [Devon (DevOps Engineer)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#devon-devops-engineer) * [Sidney (Systems Administrator)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#sidney-systems-administrator) * [Sam (Security Analyst)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#sam-security-analyst) * [Dana (Data Analyst)](https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/#dana-data-analyst) Personas are described at https://about.gitlab.com/handbook/marketing/product-marketing/roles-personas/ --> Intended for Gitter users. We will translate code blocks written in markdown into a GitLab snippet, see https://gitlab.com/gitlab-org/gitter/webapp/issues/2415 ### Further details <!-- Include use cases, benefits, and/or goals (contributes to our vision?) --> For a related issue/feature, we have a way to preselect the issue template via query parameter, https://gitlab.com/gitlab-org/gitlab-foss/issues/26595 --- There is something similar for Twitter which they call Web Intents, https://developer.twitter.com/en/docs/twitter-for-websites/tweet-button/guides/web-intent For example, when you visit https://twitter.com/intent/tweet?text=myspecialtweet, it will start a draft tweet with `myspecialtweet` in place ### Proposal <!-- How are we going to solve the problem? Try to include the user journey! https://about.gitlab.com/handbook/journeys/#user-journey --> Add `?text=mynewsnippet` query parameter to the new snippet endpoint that will autofill the file text. This doesn't create the snippet, just autofill the text area. ``` https://gitlab.com/snippets/new?text=mynewsnippet ``` There is a max length of about 2000 characters for URL's in browsers so we can't support unlimited length snippets but should be sufficient for many cases. ### Permissions and Security <!-- What permissions are required to perform the described actions? Are they consistent with the existing permissions as documented for users, groups, and projects as appropriate? Is the proposed behavior consistent between the UI, API, and other access methods (e.g. email replies)?--> You need to be signed in to create a snippet. Currently when you link the new snippet page, it will ask you to sign in first before viewing it. We need to ensure the redirect back keeps the `?text=` parameter and autofills ### Documentation <!-- See the Feature Change Documentation Workflow https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html Add all known Documentation Requirements here, per https://docs.gitlab.com/ee/development/documentation/feature-change-workflow.html#documentation-requirements If this feature requires changing permissions, this document https://docs.gitlab.com/ee/user/permissions.html must be updated accordingly. --> Add documentation to https://docs.gitlab.com/ee/api/snippets.html ### Availability & Testing <!-- What risks does this change pose to our availability? How might it affect the quality of the product? What additional test coverage or changes to tests will be needed? Will it require cross-browser testing? Please list the test areas (unit, integration and end-to-end) that needs to be added or updated to ensure that this feature will work as intended. Please use the list below as guidance. * Unit test changes * Integration test changes * End-to-end test change See the test engineering planning process and reach out to your counterpart Software Engineer in Test for assistance: https://about.gitlab.com/handbook/engineering/quality/test-engineering/#test-planning --> * Integration test changes ### What does success look like, and how can we measure that? <!-- Define both the success metrics and acceptance criteria. Note that success metrics indicate the desired business outcomes, while acceptance criteria indicate when the solution is working correctly. If there is no way to measure success, link to an issue that will implement a way to measure this. --> Visit https://gitlab.com/snippets/new?text=mynewsnippet and see the snippet textarea filled will `mynewsnippet` --- cc @viktomas @jramsay @ericschurter @timzallmann
issue